Commit 3c7f51e9 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Ozone, Fuchsia] Add OzonePlatform::GetPlatformProperties()

Scenic Ozone platform requires view_owner_request field to be set in
PlatformWindowInitProperties when creating a window. Previously
there was no mechanism for upper layers to discover that the current
Ozone platform expects that field. To solve this problem this CL adds
GetPlatformProperties() method in OzonePlatform. The returned
PlatformProperties struct contains just one field, but in future it
can be extended as needed for other platforms.

Bug: 829980
Change-Id: Idcd8c1b645cdeca36975c7feb5a1cf720fd592dd
Reviewed-on: https://chromium-review.googlesource.com/1110877
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569706}
parent f9daa687
...@@ -29,6 +29,10 @@ namespace ui { ...@@ -29,6 +29,10 @@ namespace ui {
namespace { namespace {
constexpr OzonePlatform::PlatformProperties kScenicPlatformProperties = {
/*needs_view_owner_request=*/true,
};
class ScenicPlatformEventSource : public ui::PlatformEventSource { class ScenicPlatformEventSource : public ui::PlatformEventSource {
public: public:
ScenicPlatformEventSource() = default; ScenicPlatformEventSource() = default;
...@@ -83,6 +87,10 @@ class OzonePlatformScenic : public OzonePlatform { ...@@ -83,6 +87,10 @@ class OzonePlatformScenic : public OzonePlatform {
&window_manager_, delegate, std::move(properties.view_owner_request)); &window_manager_, delegate, std::move(properties.view_owner_request));
} }
const PlatformProperties& GetPlatformProperties() override {
return kScenicPlatformProperties;
}
std::unique_ptr<display::NativeDisplayDelegate> CreateNativeDisplayDelegate() std::unique_ptr<display::NativeDisplayDelegate> CreateNativeDisplayDelegate()
override { override {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
......
...@@ -20,6 +20,10 @@ bool g_platform_initialized_gpu = false; ...@@ -20,6 +20,10 @@ bool g_platform_initialized_gpu = false;
base::LazyInstance<base::OnceCallback<void(OzonePlatform*)>>::Leaky base::LazyInstance<base::OnceCallback<void(OzonePlatform*)>>::Leaky
instance_callback = LAZY_INSTANCE_INITIALIZER; instance_callback = LAZY_INSTANCE_INITIALIZER;
constexpr OzonePlatform::PlatformProperties kDefaultPlatformProperties = {
/*needs_view_owner_request=*/false,
};
base::Lock& GetOzoneInstanceLock() { base::Lock& GetOzoneInstanceLock() {
static base::Lock lock; static base::Lock lock;
return lock; return lock;
...@@ -117,6 +121,11 @@ IPC::MessageFilter* OzonePlatform::GetGpuMessageFilter() { ...@@ -117,6 +121,11 @@ IPC::MessageFilter* OzonePlatform::GetGpuMessageFilter() {
return nullptr; return nullptr;
} }
const OzonePlatform::PlatformProperties&
OzonePlatform::GetPlatformProperties() {
return kDefaultPlatformProperties;
}
base::MessageLoop::Type OzonePlatform::GetMessageLoopTypeForGpu() { base::MessageLoop::Type OzonePlatform::GetMessageLoopTypeForGpu() {
return base::MessageLoop::TYPE_DEFAULT; return base::MessageLoop::TYPE_DEFAULT;
} }
......
...@@ -81,6 +81,14 @@ class OZONE_EXPORT OzonePlatform { ...@@ -81,6 +81,14 @@ class OZONE_EXPORT OzonePlatform {
bool using_mojo = false; bool using_mojo = false;
}; };
// Struct used to indicate platform properties.
struct PlatformProperties {
// Fuchsia only: set to true when the platforms requires
// |view_owner_request| field in PlatformWindowInitProperties when creating
// a window.
bool needs_view_owner_request;
};
// Ensures the OzonePlatform instance without doing any initialization. // Ensures the OzonePlatform instance without doing any initialization.
// No-op in case the instance is already created. // No-op in case the instance is already created.
// This is useful in order call virtual methods that depend on the ozone // This is useful in order call virtual methods that depend on the ozone
...@@ -128,6 +136,10 @@ class OZONE_EXPORT OzonePlatform { ...@@ -128,6 +136,10 @@ class OZONE_EXPORT OzonePlatform {
virtual std::unique_ptr<display::NativeDisplayDelegate> virtual std::unique_ptr<display::NativeDisplayDelegate>
CreateNativeDisplayDelegate() = 0; CreateNativeDisplayDelegate() = 0;
// Returns a struct that contains configuration and requirements for the
// current platform implementation.
virtual const PlatformProperties& GetPlatformProperties();
// Returns the message loop type required for OzonePlatform instance that // Returns the message loop type required for OzonePlatform instance that
// will be initialized for the GPU process. // will be initialized for the GPU process.
virtual base::MessageLoop::Type GetMessageLoopTypeForGpu(); virtual base::MessageLoop::Type GetMessageLoopTypeForGpu();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment