| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ | 5 #ifndef UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ |
| 6 #define UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ | 6 #define UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "ui/ozone/ozone_export.h" | 11 #include "ui/ozone/ozone_export.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 class Rect; | 14 class Rect; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace shell { |
| 18 class Connector; |
| 19 class Connection; |
| 20 } |
| 21 |
| 17 namespace ui { | 22 namespace ui { |
| 18 | 23 |
| 19 class CursorFactoryOzone; | 24 class CursorFactoryOzone; |
| 20 class InputController; | 25 class InputController; |
| 21 class GpuPlatformSupport; | 26 class GpuPlatformSupport; |
| 22 class GpuPlatformSupportHost; | 27 class GpuPlatformSupportHost; |
| 23 class NativeDisplayDelegate; | 28 class NativeDisplayDelegate; |
| 24 class OverlayManagerOzone; | 29 class OverlayManagerOzone; |
| 25 class PlatformWindow; | 30 class PlatformWindow; |
| 26 class PlatformWindowDelegate; | 31 class PlatformWindowDelegate; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 // | 44 // |
| 40 // A platform is free to use different implementations of each | 45 // A platform is free to use different implementations of each |
| 41 // interface depending on the context. You can, for example, create | 46 // interface depending on the context. You can, for example, create |
| 42 // different objects depending on the underlying hardware, command | 47 // different objects depending on the underlying hardware, command |
| 43 // line flags, or whatever is appropriate for the platform. | 48 // line flags, or whatever is appropriate for the platform. |
| 44 class OZONE_EXPORT OzonePlatform { | 49 class OZONE_EXPORT OzonePlatform { |
| 45 public: | 50 public: |
| 46 OzonePlatform(); | 51 OzonePlatform(); |
| 47 virtual ~OzonePlatform(); | 52 virtual ~OzonePlatform(); |
| 48 | 53 |
| 54 // Additional initalization params for the platform. Platforms must not retain |
| 55 // a reference to this structure. |
| 56 struct InitParams { |
| 57 // Ozone may retain this pointer for later use. An Ozone platform embedder |
| 58 // must set this parameter in order for the Ozone platform implementation to |
| 59 // be able to use Mojo. |
| 60 shell::Connector* connector = nullptr; |
| 61 |
| 62 // Setting this to true indicates that the platform implementation should |
| 63 // operate as a single process for platforms (i.e. drm) that are usually |
| 64 // split between a main and gpu specific portion. |
| 65 bool single_process = false; |
| 66 }; |
| 67 |
| 49 // Initializes the subsystems/resources necessary for the UI process (e.g. | 68 // Initializes the subsystems/resources necessary for the UI process (e.g. |
| 50 // events, surface, etc.) | 69 // events, etc.) |
| 70 // TODO(rjkroege): Remove deprecated entry point (http://crbug.com/620934) |
| 51 static void InitializeForUI(); | 71 static void InitializeForUI(); |
| 52 | 72 |
| 53 // Initializes the subsystems/resources necessary for the GPU process. | 73 // Initializes the subsystems/resources necessary for the UI process (e.g. |
| 74 // events) with additional properties to customize the ozone platform |
| 75 // implementation. Ozone will not retain InitParams after returning from |
| 76 // InitalizeForUI. |
| 77 static void InitializeForUI(const InitParams& args); |
| 78 |
| 79 // Initializes the subsystems/resources necessary for rendering (i.e. GPU). |
| 80 // TODO(rjkroege): Remove deprecated entry point (http://crbug.com/620934) |
| 54 static void InitializeForGPU(); | 81 static void InitializeForGPU(); |
| 55 | 82 |
| 83 // Initializes the subsystems for rendering but with additional properties |
| 84 // provided by |args| as with InitalizeForUI. |
| 85 static void InitializeForGPU(const InitParams& args); |
| 86 |
| 56 static OzonePlatform* GetInstance(); | 87 static OzonePlatform* GetInstance(); |
| 57 | 88 |
| 58 // Factory getters to override in subclasses. The returned objects will be | 89 // Factory getters to override in subclasses. The returned objects will be |
| 59 // injected into the appropriate layer at startup. Subclasses should not | 90 // injected into the appropriate layer at startup. Subclasses should not |
| 60 // inject these objects themselves. Ownership is retained by OzonePlatform. | 91 // inject these objects themselves. Ownership is retained by OzonePlatform. |
| 61 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() = 0; | 92 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() = 0; |
| 62 virtual ui::OverlayManagerOzone* GetOverlayManager() = 0; | 93 virtual ui::OverlayManagerOzone* GetOverlayManager() = 0; |
| 63 virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() = 0; | 94 virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() = 0; |
| 64 virtual ui::InputController* GetInputController() = 0; | 95 virtual ui::InputController* GetInputController() = 0; |
| 65 virtual ui::GpuPlatformSupport* GetGpuPlatformSupport() = 0; | 96 virtual ui::GpuPlatformSupport* GetGpuPlatformSupport() = 0; |
| 66 virtual ui::GpuPlatformSupportHost* GetGpuPlatformSupportHost() = 0; | 97 virtual ui::GpuPlatformSupportHost* GetGpuPlatformSupportHost() = 0; |
| 67 virtual std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() = 0; | 98 virtual std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() = 0; |
| 68 virtual std::unique_ptr<PlatformWindow> CreatePlatformWindow( | 99 virtual std::unique_ptr<PlatformWindow> CreatePlatformWindow( |
| 69 PlatformWindowDelegate* delegate, | 100 PlatformWindowDelegate* delegate, |
| 70 const gfx::Rect& bounds) = 0; | 101 const gfx::Rect& bounds) = 0; |
| 71 virtual std::unique_ptr<ui::NativeDisplayDelegate> | 102 virtual std::unique_ptr<ui::NativeDisplayDelegate> |
| 72 CreateNativeDisplayDelegate() = 0; | 103 CreateNativeDisplayDelegate() = 0; |
| 73 | 104 |
| 105 // Ozone platform implementations may also choose to expose mojo interfaces to |
| 106 // internal functionality. Embedders wishing to take advantage of ozone mojo |
| 107 // implementations must invoke AddInterfaces with a valid shell::Connection* |
| 108 // pointer to export all Mojo interfaces defined within Ozone. |
| 109 // |
| 110 // A default do-nothing implementation is provided to permit platform |
| 111 // implementations to opt out of implementing any Mojo interfaces. |
| 112 virtual void AddInterfaces(shell::Connection* connection); |
| 113 |
| 74 private: | 114 private: |
| 75 virtual void InitializeUI() = 0; | 115 virtual void InitializeUI() = 0; |
| 76 virtual void InitializeGPU() = 0; | 116 virtual void InitializeGPU() = 0; |
| 117 virtual void InitializeUI(const InitParams& args); |
| 118 virtual void InitializeGPU(const InitParams& args); |
| 77 | 119 |
| 78 static void CreateInstance(); | 120 static void CreateInstance(); |
| 79 | 121 |
| 80 static OzonePlatform* instance_; | 122 static OzonePlatform* instance_; |
| 81 | 123 |
| 82 DISALLOW_COPY_AND_ASSIGN(OzonePlatform); | 124 DISALLOW_COPY_AND_ASSIGN(OzonePlatform); |
| 83 }; | 125 }; |
| 84 | 126 |
| 85 } // namespace ui | 127 } // namespace ui |
| 86 | 128 |
| 87 #endif // UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ | 129 #endif // UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ |
| OLD | NEW |