| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "ui/ozone/platform/wayland/ozone_platform_wayland.h" | 5 #include "ui/ozone/platform/wayland/ozone_platform_wayland.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/ozone/common/native_display_delegate_ozone.h" | 8 #include "ui/ozone/common/native_display_delegate_ozone.h" |
| 9 #include "ui/ozone/common/stub_overlay_manager.h" | 9 #include "ui/ozone/common/stub_overlay_manager.h" |
| 10 #include "ui/ozone/platform/wayland/wayland_connection.h" | 10 #include "ui/ozone/platform/wayland/wayland_connection.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return nullptr; | 59 return nullptr; |
| 60 return std::move(window); | 60 return std::move(window); |
| 61 } | 61 } |
| 62 | 62 |
| 63 std::unique_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() | 63 std::unique_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() |
| 64 override { | 64 override { |
| 65 return base::WrapUnique(new NativeDisplayDelegateOzone); | 65 return base::WrapUnique(new NativeDisplayDelegateOzone); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void InitializeUI() override { | 68 void InitializeUI() override { |
| 69 InitParams default_params; |
| 70 InitializeUI(default_params); |
| 71 } |
| 72 |
| 73 void InitializeUI(const InitParams& args) override { |
| 69 connection_.reset(new WaylandConnection); | 74 connection_.reset(new WaylandConnection); |
| 70 if (!connection_->Initialize()) | 75 if (!connection_->Initialize()) |
| 71 LOG(FATAL) << "Failed to initialize Wayland platform"; | 76 LOG(FATAL) << "Failed to initialize Wayland platform"; |
| 72 | 77 |
| 73 cursor_factory_.reset(new CursorFactoryOzone); | 78 cursor_factory_.reset(new CursorFactoryOzone); |
| 74 overlay_manager_.reset(new StubOverlayManager); | 79 overlay_manager_.reset(new StubOverlayManager); |
| 75 input_controller_ = CreateStubInputController(); | 80 input_controller_ = CreateStubInputController(); |
| 76 surface_factory_.reset(new WaylandSurfaceFactory(connection_.get())); | 81 surface_factory_.reset(new WaylandSurfaceFactory(connection_.get())); |
| 77 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 82 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
| 78 } | 83 } |
| 79 | 84 |
| 80 void InitializeGPU() override { | 85 void InitializeGPU() override { |
| 81 // Don't reinitialize the surface factory in case InitializeUI was called | 86 InitParams default_params; |
| 82 // previously in the same process. | 87 InitializeGPU(default_params); |
| 83 if (!surface_factory_) | 88 } |
| 89 |
| 90 void InitializeGPU(const InitParams& args) override { |
| 91 // TODO(fwang): args.single_process parameter should be checked here; make |
| 92 // sure callers pass in the proper value. Once it happens, the check whether |
| 93 // surface factory was set in the same process by a previous InitializeUI |
| 94 // call becomes unneeded. |
| 95 if (!surface_factory_) { |
| 96 // TODO(fwang): Separate processes can not share a Wayland connection |
| 97 // and so the current implementations of GLOzoneEGLWayland and |
| 98 // WaylandCanvasSurface may only work when UI and GPU live in the same |
| 99 // process. GetSurfaceFactoryOzone() must be non-null so a dummy instance |
| 100 // of WaylandSurfaceFactory is needed to make the GPU initialization |
| 101 // gracefully fail. |
| 84 surface_factory_.reset(new WaylandSurfaceFactory(nullptr)); | 102 surface_factory_.reset(new WaylandSurfaceFactory(nullptr)); |
| 103 } |
| 85 } | 104 } |
| 86 | 105 |
| 87 private: | 106 private: |
| 88 std::unique_ptr<WaylandConnection> connection_; | 107 std::unique_ptr<WaylandConnection> connection_; |
| 89 std::unique_ptr<WaylandSurfaceFactory> surface_factory_; | 108 std::unique_ptr<WaylandSurfaceFactory> surface_factory_; |
| 90 std::unique_ptr<CursorFactoryOzone> cursor_factory_; | 109 std::unique_ptr<CursorFactoryOzone> cursor_factory_; |
| 91 std::unique_ptr<StubOverlayManager> overlay_manager_; | 110 std::unique_ptr<StubOverlayManager> overlay_manager_; |
| 92 std::unique_ptr<InputController> input_controller_; | 111 std::unique_ptr<InputController> input_controller_; |
| 93 std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | 112 std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
| 94 | 113 |
| 95 DISALLOW_COPY_AND_ASSIGN(OzonePlatformWayland); | 114 DISALLOW_COPY_AND_ASSIGN(OzonePlatformWayland); |
| 96 }; | 115 }; |
| 97 | 116 |
| 98 } // namespace | 117 } // namespace |
| 99 | 118 |
| 100 OzonePlatform* CreateOzonePlatformWayland() { | 119 OzonePlatform* CreateOzonePlatformWayland() { |
| 101 return new OzonePlatformWayland; | 120 return new OzonePlatformWayland; |
| 102 } | 121 } |
| 103 | 122 |
| 104 } // namespace ui | 123 } // namespace ui |
| OLD | NEW |