Index: ui/ozone/platform/x11/ozone_platform_x11.cc |
diff --git a/ui/ozone/platform/x11/ozone_platform_x11.cc b/ui/ozone/platform/x11/ozone_platform_x11.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f31786d39ca02982fb84b6f2b7a297c19237d850 |
--- /dev/null |
+++ b/ui/ozone/platform/x11/ozone_platform_x11.cc |
@@ -0,0 +1,97 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/ozone/platform/x11/ozone_platform_x11.h" |
+ |
+#include "base/at_exit.h" |
+#include "base/bind.h" |
+#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
+#include "ui/ozone/common/native_display_delegate_ozone.h" |
+#include "ui/ozone/platform/x11/x11_input_controller.h" |
+#include "ui/ozone/platform/x11/x11_surface_factory.h" |
+#include "ui/ozone/public/gpu_platform_support.h" |
+#include "ui/ozone/public/gpu_platform_support_host.h" |
+#include "ui/ozone/public/ozone_platform.h" |
+#include "ui/ozone/public/system_input_injector.h" |
+#include "ui/ozone/public/ui_thread_gpu.h" |
+#include "ui/platform_window/x11/x11_window.h" |
+ |
+namespace ui { |
+namespace { |
+ |
+// OzonePlatform for Linux X11 |
+class OzonePlatformX11 : public OzonePlatform { |
+ public: |
+ OzonePlatformX11() { |
+ base::AtExitManager::RegisterTask( |
+ base::Bind(&base::DeletePointer<OzonePlatformX11>, this)); |
+ } |
+ virtual ~OzonePlatformX11() {} |
+ |
+ // OzonePlatform: |
+ ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
+ return surface_factory_ozone_.get(); |
+ } |
+ CursorFactoryOzone* GetCursorFactoryOzone() override { |
+ return cursor_factory_ozone_.get(); |
+ } |
+ GpuPlatformSupport* GetGpuPlatformSupport() override { |
+ return gpu_platform_support_.get(); |
+ } |
+ GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
+ return gpu_platform_support_host_.get(); |
+ } |
+ scoped_ptr<PlatformWindow> CreatePlatformWindow( |
+ PlatformWindowDelegate* delegate, |
+ const gfx::Rect& bounds) override { |
+ scoped_ptr<X11Window> window = |
+ window_manager_->CreatePlatformWindow(delegate).Pass(); |
spang
2014/12/06 00:31:23
I don't think you need the .Pass() here.
|
+ window->SetBounds(bounds); |
+ window->Create(); |
+ return window.Pass(); |
+ } |
+ scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
+ return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); |
+ } |
+ scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { |
+ NOTREACHED(); |
+ return scoped_ptr<SystemInputInjector>(); |
+ } |
+ InputController* GetInputController() override { return &input_controller_; } |
+ void InitializeUI() override { |
+ if (!window_manager_) |
+ window_manager_ = new X11WindowManager(); |
+ gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
+ cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
+ surface_factory_ozone_.reset(new X11SurfaceFactory(window_manager_)); |
+ } |
+ |
+ void InitializeGPU() override { |
+ if (!window_manager_) |
+ window_manager_ = new X11WindowManager(); |
+ if (!surface_factory_ozone_) |
+ surface_factory_ozone_.reset(new X11SurfaceFactory(window_manager_)); |
+ gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
+ } |
+ |
+ private: |
+ X11InputController input_controller_; |
spang
2014/12/06 00:31:23
I don't think it makes sense to have an input cont
achaulk
2014/12/08 16:44:41
It's just a stub for now. If it really is as simpl
spang
2014/12/09 19:47:33
Would still prefer you put it in the scoped_ptr<>
|
+ scoped_ptr<X11SurfaceFactory> surface_factory_ozone_; |
+ scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
+ |
+ scoped_ptr<GpuPlatformSupport> gpu_platform_support_; |
+ scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
+ |
+ scoped_refptr<X11WindowManager> window_manager_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(OzonePlatformX11); |
+}; |
+ |
+} // namespace |
+ |
+OzonePlatform* CreateOzonePlatformX11() { |
+ return new OzonePlatformX11; |
+} |
+ |
+} // namespace ui |