OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/ozone/platform/x11/ozone_platform_x11.h" |
| 6 |
| 7 #include "base/at_exit.h" |
| 8 #include "base/bind.h" |
| 9 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 10 #include "ui/ozone/common/native_display_delegate_ozone.h" |
| 11 #include "ui/ozone/platform/x11/x11_input_controller.h" |
| 12 #include "ui/ozone/platform/x11/x11_surface_factory.h" |
| 13 #include "ui/ozone/public/gpu_platform_support.h" |
| 14 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 15 #include "ui/ozone/public/ozone_platform.h" |
| 16 #include "ui/ozone/public/system_input_injector.h" |
| 17 #include "ui/ozone/public/ui_thread_gpu.h" |
| 18 #include "ui/platform_window/x11/x11_window.h" |
| 19 |
| 20 namespace ui { |
| 21 namespace { |
| 22 |
| 23 // OzonePlatform for Linux X11 |
| 24 class OzonePlatformX11 : public OzonePlatform { |
| 25 public: |
| 26 OzonePlatformX11() { |
| 27 base::AtExitManager::RegisterTask( |
| 28 base::Bind(&base::DeletePointer<OzonePlatformX11>, this)); |
| 29 } |
| 30 virtual ~OzonePlatformX11() {} |
| 31 |
| 32 // OzonePlatform: |
| 33 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
| 34 return surface_factory_ozone_.get(); |
| 35 } |
| 36 CursorFactoryOzone* GetCursorFactoryOzone() override { |
| 37 return cursor_factory_ozone_.get(); |
| 38 } |
| 39 GpuPlatformSupport* GetGpuPlatformSupport() override { |
| 40 return gpu_platform_support_.get(); |
| 41 } |
| 42 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
| 43 return gpu_platform_support_host_.get(); |
| 44 } |
| 45 scoped_ptr<PlatformWindow> CreatePlatformWindow( |
| 46 PlatformWindowDelegate* delegate, |
| 47 const gfx::Rect& bounds) override { |
| 48 scoped_ptr<X11Window> window = |
| 49 window_manager_->CreatePlatformWindow(delegate).Pass(); |
| 50 window->SetBounds(bounds); |
| 51 window->Create(); |
| 52 return window.Pass(); |
| 53 } |
| 54 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
| 55 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); |
| 56 } |
| 57 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { |
| 58 NOTREACHED(); |
| 59 return scoped_ptr<SystemInputInjector>(); |
| 60 } |
| 61 InputController* GetInputController() override { |
| 62 return input_controller_.get(); |
| 63 } |
| 64 void InitializeUI() override { |
| 65 if (!input_controller_) |
| 66 input_controller_.reset(new X11InputController()); |
| 67 if (!window_manager_) |
| 68 window_manager_ = new X11WindowManager(); |
| 69 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
| 70 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 71 surface_factory_ozone_.reset(new X11SurfaceFactory(window_manager_)); |
| 72 } |
| 73 |
| 74 void InitializeGPU() override { |
| 75 if (!input_controller_) |
| 76 input_controller_.reset(new X11InputController()); |
| 77 if (!window_manager_) |
| 78 window_manager_ = new X11WindowManager(); |
| 79 if (!surface_factory_ozone_) |
| 80 surface_factory_ozone_.reset(new X11SurfaceFactory(window_manager_)); |
| 81 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
| 82 } |
| 83 |
| 84 private: |
| 85 scoped_ptr<X11InputController> input_controller_; |
| 86 scoped_ptr<X11SurfaceFactory> surface_factory_ozone_; |
| 87 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
| 88 |
| 89 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; |
| 90 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
| 91 |
| 92 scoped_refptr<X11WindowManager> window_manager_; |
| 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(OzonePlatformX11); |
| 95 }; |
| 96 |
| 97 } // namespace |
| 98 |
| 99 OzonePlatform* CreateOzonePlatformX11() { |
| 100 return new OzonePlatformX11; |
| 101 } |
| 102 |
| 103 } // namespace ui |
OLD | NEW |