Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 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/caca/ozone_platform_caca.h" | 5 #include "ui/ozone/platform/x11/ozone_platform_x11.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include <utility> |
| 8 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 8 |
| 9 #include "ui/events/ozone/layout/no/no_keyboard_layout_engine.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/bind.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | |
| 10 #include "ui/ozone/common/native_display_delegate_ozone.h" | 13 #include "ui/ozone/common/native_display_delegate_ozone.h" |
| 11 #include "ui/ozone/common/stub_overlay_manager.h" | 14 #include "ui/ozone/common/stub_overlay_manager.h" |
| 12 #include "ui/ozone/platform/caca/caca_event_source.h" | 15 #include "ui/ozone/platform/x11/x11_event_factory.h" |
| 13 #include "ui/ozone/platform/caca/caca_window.h" | 16 #include "ui/ozone/platform/x11/x11_surface_factory.h" |
| 14 #include "ui/ozone/platform/caca/caca_window_manager.h" | 17 #include "ui/ozone/platform/x11/x11_window_host.h" |
| 15 #include "ui/ozone/public/cursor_factory_ozone.h" | 18 #include "ui/ozone/platform/x11/x11_window_host_manager.h" |
| 16 #include "ui/ozone/public/gpu_platform_support.h" | 19 #include "ui/ozone/public/gpu_platform_support.h" |
| 17 #include "ui/ozone/public/gpu_platform_support_host.h" | 20 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 18 #include "ui/ozone/public/input_controller.h" | 21 #include "ui/ozone/public/input_controller.h" |
| 19 #include "ui/ozone/public/ozone_platform.h" // nogncheck | 22 #include "ui/ozone/public/ozone_platform.h" |
|
spang
2016/01/20 19:53:31
Keep the "// nogncheck" or "gn check" will complai
kylechar
2016/01/20 21:46:16
Done.
| |
| 20 #include "ui/ozone/public/system_input_injector.h" | 23 #include "ui/ozone/public/system_input_injector.h" |
| 21 | 24 |
| 22 namespace ui { | 25 namespace ui { |
| 23 | 26 |
| 24 namespace { | 27 namespace { |
| 25 | 28 |
| 26 class OzonePlatformCaca : public OzonePlatform { | 29 // Singleton OzonePlatform implementation for Linux X11 platform. |
| 30 class OzonePlatformX11 : public OzonePlatform { | |
| 27 public: | 31 public: |
| 28 OzonePlatformCaca() {} | 32 OzonePlatformX11() {} |
| 29 ~OzonePlatformCaca() override {} | 33 ~OzonePlatformX11() override {} |
| 30 | 34 |
| 31 // OzonePlatform: | 35 // OzonePlatform: |
| 32 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 36 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
| 33 return window_manager_.get(); | 37 return surface_factory_ozone_.get(); |
| 34 } | 38 } |
| 35 OverlayManagerOzone* GetOverlayManager() override { | 39 |
| 40 ui::OverlayManagerOzone* GetOverlayManager() override { | |
| 36 return overlay_manager_.get(); | 41 return overlay_manager_.get(); |
| 37 } | 42 } |
| 43 | |
| 38 CursorFactoryOzone* GetCursorFactoryOzone() override { | 44 CursorFactoryOzone* GetCursorFactoryOzone() override { |
| 39 return cursor_factory_ozone_.get(); | 45 return cursor_factory_ozone_.get(); |
| 40 } | 46 } |
| 47 | |
| 48 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { | |
| 49 NOTREACHED(); | |
| 50 return nullptr; | |
| 51 } | |
| 52 | |
| 41 InputController* GetInputController() override { | 53 InputController* GetInputController() override { |
| 42 return input_controller_.get(); | 54 return input_controller_.get(); |
| 43 } | 55 } |
| 56 | |
| 44 GpuPlatformSupport* GetGpuPlatformSupport() override { | 57 GpuPlatformSupport* GetGpuPlatformSupport() override { |
| 45 return gpu_platform_support_.get(); | 58 return gpu_platform_support_.get(); |
| 46 } | 59 } |
| 60 | |
| 47 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | 61 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
| 48 return gpu_platform_support_host_.get(); | 62 return gpu_platform_support_host_.get(); |
| 49 } | 63 } |
| 50 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { | 64 |
| 51 return nullptr; // no input injection support. | |
| 52 } | |
| 53 scoped_ptr<PlatformWindow> CreatePlatformWindow( | 65 scoped_ptr<PlatformWindow> CreatePlatformWindow( |
| 54 PlatformWindowDelegate* delegate, | 66 PlatformWindowDelegate* delegate, |
| 55 const gfx::Rect& bounds) override { | 67 const gfx::Rect& bounds) override { |
| 56 scoped_ptr<CacaWindow> caca_window(new CacaWindow( | 68 scoped_ptr<X11WindowHost> window = |
| 57 delegate, window_manager_.get(), event_source_.get(), bounds)); | 69 window_manager_->CreatePlatformWindow(delegate); |
| 58 if (!caca_window->Initialize()) | 70 window->SetBounds(bounds); |
| 59 return nullptr; | 71 window->Create(); |
| 60 return caca_window; | 72 return std::move(window); |
|
spang
2016/01/20 19:53:30
Return statements should ever have a std::move() b
kylechar
2016/01/20 21:46:16
scoped_ptr<X11WindowHost> isn't converted to scope
spang
2016/01/20 22:32:53
Ah I missed the type change. It's correct as-is th
| |
| 61 } | 73 } |
| 74 | |
| 62 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 75 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
| 63 return make_scoped_ptr(new NativeDisplayDelegateOzone()); | 76 return make_scoped_ptr(new NativeDisplayDelegateOzone()); |
| 64 } | 77 } |
| 78 | |
| 65 base::ScopedFD OpenClientNativePixmapDevice() const override { | 79 base::ScopedFD OpenClientNativePixmapDevice() const override { |
| 66 return base::ScopedFD(); | 80 return base::ScopedFD(); |
| 67 } | 81 } |
| 68 | 82 |
| 69 void InitializeUI() override { | 83 void InitializeUI() override { |
| 70 window_manager_.reset(new CacaWindowManager); | 84 window_manager_ = new X11WindowHostManager(); |
| 85 surface_factory_ozone_.reset(new X11SurfaceFactory(window_manager_)); | |
| 71 overlay_manager_.reset(new StubOverlayManager()); | 86 overlay_manager_.reset(new StubOverlayManager()); |
| 72 event_source_.reset(new CacaEventSource()); | 87 input_controller_ = CreateStubInputController(); |
| 73 cursor_factory_ozone_.reset(new CursorFactoryOzone()); | 88 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 89 event_factory_ozone_.reset( | |
| 90 new X11EventFactory(gfx::GetXDisplay(), window_manager_)); | |
| 74 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 91 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
| 75 input_controller_ = CreateStubInputController(); | |
| 76 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | |
| 77 make_scoped_ptr(new NoKeyboardLayoutEngine())); | |
| 78 } | 92 } |
| 79 | 93 |
| 80 void InitializeGPU() override { | 94 void InitializeGPU() override { |
| 95 surface_factory_ozone_.reset(new X11SurfaceFactory(nullptr)); | |
| 81 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); | 96 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
| 82 } | 97 } |
| 83 | 98 |
| 84 private: | 99 private: |
| 85 scoped_ptr<CacaWindowManager> window_manager_; | 100 // Objects in the Browser process. |
| 86 scoped_ptr<CacaEventSource> event_source_; | 101 scoped_refptr<X11WindowHostManager> window_manager_; |
| 87 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; | 102 scoped_ptr<OverlayManagerOzone> overlay_manager_; |
| 103 scoped_ptr<InputController> input_controller_; | |
| 104 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; | |
| 105 scoped_ptr<X11EventFactory> event_factory_ozone_; | |
| 106 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | |
| 107 | |
| 108 // Objects in the GPU process. | |
| 88 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; | 109 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; |
| 89 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | |
| 90 scoped_ptr<InputController> input_controller_; | |
| 91 scoped_ptr<OverlayManagerOzone> overlay_manager_; | |
| 92 | 110 |
| 93 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCaca); | 111 // Objects in both Browser and GPU process. |
| 112 scoped_ptr<X11SurfaceFactory> surface_factory_ozone_; | |
| 113 | |
| 114 DISALLOW_COPY_AND_ASSIGN(OzonePlatformX11); | |
| 94 }; | 115 }; |
| 95 | 116 |
| 96 } // namespace | 117 } // namespace |
| 97 | 118 |
| 98 OzonePlatform* CreateOzonePlatformCaca() { | 119 OzonePlatform* CreateOzonePlatformX11() { |
| 99 return new OzonePlatformCaca; | 120 return new OzonePlatformX11; |
| 100 } | 121 } |
| 101 | 122 |
| 102 } // namespace ui | 123 } // namespace ui |
| OLD | NEW |