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/caca/ozone_platform_caca.h" | |
6 | |
7 #include "base/macros.h" | |
8 #include "base/memory/ptr_util.h" | |
9 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | |
10 #include "ui/events/ozone/layout/no/no_keyboard_layout_engine.h" | |
11 #include "ui/ozone/common/native_display_delegate_ozone.h" | |
12 #include "ui/ozone/common/stub_overlay_manager.h" | |
13 #include "ui/ozone/platform/caca/caca_event_source.h" | |
14 #include "ui/ozone/platform/caca/caca_window.h" | |
15 #include "ui/ozone/platform/caca/caca_window_manager.h" | |
16 #include "ui/ozone/public/cursor_factory_ozone.h" | |
17 #include "ui/ozone/public/gpu_platform_support_host.h" | |
18 #include "ui/ozone/public/input_controller.h" | |
19 #include "ui/ozone/public/ozone_platform.h" | |
20 #include "ui/ozone/public/system_input_injector.h" | |
21 | |
22 namespace ui { | |
23 | |
24 namespace { | |
25 | |
26 class OzonePlatformCaca : public OzonePlatform { | |
27 public: | |
28 OzonePlatformCaca() {} | |
29 ~OzonePlatformCaca() override {} | |
30 | |
31 // OzonePlatform: | |
32 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | |
33 return window_manager_.get(); | |
34 } | |
35 OverlayManagerOzone* GetOverlayManager() override { | |
36 return overlay_manager_.get(); | |
37 } | |
38 CursorFactoryOzone* GetCursorFactoryOzone() override { | |
39 return cursor_factory_ozone_.get(); | |
40 } | |
41 InputController* GetInputController() override { | |
42 return input_controller_.get(); | |
43 } | |
44 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | |
45 return gpu_platform_support_host_.get(); | |
46 } | |
47 std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override { | |
48 return nullptr; // no input injection support. | |
49 } | |
50 std::unique_ptr<PlatformWindow> CreatePlatformWindow( | |
51 PlatformWindowDelegate* delegate, | |
52 const gfx::Rect& bounds) override { | |
53 std::unique_ptr<CacaWindow> caca_window(new CacaWindow( | |
54 delegate, window_manager_.get(), event_source_.get(), bounds)); | |
55 if (!caca_window->Initialize()) | |
56 return nullptr; | |
57 return std::move(caca_window); | |
58 } | |
59 std::unique_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() | |
60 override { | |
61 return base::MakeUnique<NativeDisplayDelegateOzone>(); | |
62 } | |
63 | |
64 void InitializeUI() override { | |
65 window_manager_.reset(new CacaWindowManager); | |
66 overlay_manager_.reset(new StubOverlayManager()); | |
67 event_source_.reset(new CacaEventSource()); | |
68 cursor_factory_ozone_.reset(new CursorFactoryOzone()); | |
69 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | |
70 input_controller_ = CreateStubInputController(); | |
71 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | |
72 base::MakeUnique<NoKeyboardLayoutEngine>()); | |
73 } | |
74 | |
75 void InitializeGPU() override { | |
76 if (!window_manager_) { | |
77 // The return value of GetSurfaceFactoryOzone() must be non-null so a | |
78 // dummy instance of CacaWindowManager is needed to make the GPU | |
79 // initialization gracefully fail. | |
80 window_manager_.reset(new CacaWindowManager); | |
81 } | |
82 } | |
83 | |
84 private: | |
85 std::unique_ptr<CacaWindowManager> window_manager_; | |
86 std::unique_ptr<CacaEventSource> event_source_; | |
87 std::unique_ptr<CursorFactoryOzone> cursor_factory_ozone_; | |
88 std::unique_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | |
89 std::unique_ptr<InputController> input_controller_; | |
90 std::unique_ptr<OverlayManagerOzone> overlay_manager_; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCaca); | |
93 }; | |
94 | |
95 } // namespace | |
96 | |
97 OzonePlatform* CreateOzonePlatformCaca() { | |
98 return new OzonePlatformCaca; | |
99 } | |
100 | |
101 } // namespace ui | |
OLD | NEW |