Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: ui/ozone/platform/drm/ozone_platform_drm.cc

Issue 1311043016: Switch DRM platform to using a separate thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mv-drm-calls-on-thread2
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/drm/ozone_platform_drm.h" 5 #include "ui/ozone/platform/drm/ozone_platform_drm.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" 9 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
10 #include "ui/events/ozone/device/device_manager.h" 10 #include "ui/events/ozone/device/device_manager.h"
11 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" 11 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
12 #include "ui/events/ozone/evdev/event_factory_evdev.h" 12 #include "ui/events/ozone/evdev/event_factory_evdev.h"
13 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" 13 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
14 #include "ui/ozone/platform/drm/common/drm_util.h" 14 #include "ui/ozone/platform/drm/common/drm_util.h"
15 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" 15 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.h"
16 #include "ui/ozone/platform/drm/gpu/drm_device.h"
17 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
18 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
19 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
20 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h"
21 #include "ui/ozone/platform/drm/gpu/drm_surface_factory.h" 16 #include "ui/ozone/platform/drm/gpu/drm_surface_factory.h"
22 #include "ui/ozone/platform/drm/gpu/drm_window.h" 17 #include "ui/ozone/platform/drm/gpu/drm_thread.h"
23 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 18 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
24 #include "ui/ozone/platform/drm/host/drm_cursor.h" 19 #include "ui/ozone/platform/drm/host/drm_cursor.h"
25 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" 20 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
26 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" 21 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
27 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" 22 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h"
28 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" 23 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h"
29 #include "ui/ozone/platform/drm/host/drm_window_host.h" 24 #include "ui/ozone/platform/drm/host/drm_window_host.h"
30 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" 25 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
31 #include "ui/ozone/public/ozone_gpu_test_helper.h" 26 #include "ui/ozone/public/ozone_gpu_test_helper.h"
32 #include "ui/ozone/public/ozone_platform.h" 27 #include "ui/ozone/public/ozone_platform.h"
33 28
34 #if defined(USE_XKBCOMMON) 29 #if defined(USE_XKBCOMMON)
35 #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h" 30 #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h"
36 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" 31 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h"
37 #else 32 #else
38 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" 33 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
39 #endif 34 #endif
40 35
41 namespace ui { 36 namespace ui {
42 37
43 namespace { 38 namespace {
44 39
45 // OzonePlatform for Linux DRM (Direct Rendering Manager) 40 // OzonePlatform for Linux DRM (Direct Rendering Manager)
46 // 41 //
47 // This platform is Linux without any display server (no X, wayland, or 42 // This platform is Linux without any display server (no X, wayland, or
48 // anything). This means chrome alone owns the display and input devices. 43 // anything). This means chrome alone owns the display and input devices.
49 class OzonePlatformDrm : public OzonePlatform { 44 class OzonePlatformDrm : public OzonePlatform {
50 public: 45 public:
51 OzonePlatformDrm() 46 OzonePlatformDrm() : device_manager_(CreateDeviceManager()) {}
52 : buffer_generator_(new DrmBufferGenerator()),
53 screen_manager_(new ScreenManager(buffer_generator_.get())),
54 device_manager_(CreateDeviceManager()) {}
55 ~OzonePlatformDrm() override {} 47 ~OzonePlatformDrm() override {}
56 48
57 // OzonePlatform: 49 // OzonePlatform:
58 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { 50 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
59 return surface_factory_ozone_.get(); 51 return surface_factory_.get();
60 } 52 }
61 OverlayManagerOzone* GetOverlayManager() override { 53 OverlayManagerOzone* GetOverlayManager() override {
62 return overlay_manager_.get(); 54 return overlay_manager_.get();
63 } 55 }
64 CursorFactoryOzone* GetCursorFactoryOzone() override { 56 CursorFactoryOzone* GetCursorFactoryOzone() override {
65 return cursor_factory_ozone_.get(); 57 return cursor_factory_ozone_.get();
66 } 58 }
67 InputController* GetInputController() override { 59 InputController* GetInputController() override {
68 return event_factory_ozone_->input_controller(); 60 return event_factory_ozone_->input_controller();
69 } 61 }
(...skipping 17 matching lines...) Expand all
87 return platform_window.Pass(); 79 return platform_window.Pass();
88 } 80 }
89 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { 81 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override {
90 return make_scoped_ptr( 82 return make_scoped_ptr(
91 new DrmNativeDisplayDelegate(display_manager_.get())); 83 new DrmNativeDisplayDelegate(display_manager_.get()));
92 } 84 }
93 base::ScopedFD OpenClientNativePixmapDevice() const override { 85 base::ScopedFD OpenClientNativePixmapDevice() const override {
94 return base::ScopedFD(); 86 return base::ScopedFD();
95 } 87 }
96 void InitializeUI() override { 88 void InitializeUI() override {
97 drm_device_manager_.reset(new DrmDeviceManager(
98 scoped_ptr<DrmDeviceGenerator>(new DrmDeviceGenerator())));
99 window_manager_.reset(new DrmWindowHostManager()); 89 window_manager_.reset(new DrmWindowHostManager());
100 cursor_.reset(new DrmCursor(window_manager_.get())); 90 cursor_.reset(new DrmCursor(window_manager_.get()));
101 #if defined(USE_XKBCOMMON) 91 #if defined(USE_XKBCOMMON)
102 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(make_scoped_ptr( 92 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(make_scoped_ptr(
103 new XkbKeyboardLayoutEngine(xkb_evdev_code_converter_))); 93 new XkbKeyboardLayoutEngine(xkb_evdev_code_converter_)));
104 #else 94 #else
105 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( 95 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
106 make_scoped_ptr(new StubKeyboardLayoutEngine())); 96 make_scoped_ptr(new StubKeyboardLayoutEngine()));
107 #endif 97 #endif
108 event_factory_ozone_.reset(new EventFactoryEvdev( 98 event_factory_ozone_.reset(new EventFactoryEvdev(
109 cursor_.get(), device_manager_.get(), 99 cursor_.get(), device_manager_.get(),
110 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); 100 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()));
111 overlay_manager_.reset(new DrmOverlayManager(false, nullptr)); 101 overlay_manager_.reset(new DrmOverlayManager(false, nullptr));
112 surface_factory_ozone_.reset(new DrmSurfaceFactory(screen_manager_.get()));
113 scoped_ptr<DrmGpuDisplayManager> display_manager(new DrmGpuDisplayManager(
114 screen_manager_.get(), drm_device_manager_.get()));
115 gpu_platform_support_.reset(new DrmGpuPlatformSupport(
116 drm_device_manager_.get(), screen_manager_.get(),
117 buffer_generator_.get(), display_manager.Pass()));
118 gpu_platform_support_host_.reset( 102 gpu_platform_support_host_.reset(
119 new DrmGpuPlatformSupportHost(cursor_.get())); 103 new DrmGpuPlatformSupportHost(cursor_.get()));
120 display_manager_.reset(new DrmDisplayHostManager( 104 display_manager_.reset(new DrmDisplayHostManager(
121 gpu_platform_support_host_.get(), device_manager_.get(), 105 gpu_platform_support_host_.get(), device_manager_.get(),
122 event_factory_ozone_->input_controller())); 106 event_factory_ozone_->input_controller()));
123 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); 107 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone);
124 108
109 drm_thread_.reset(new DrmThread());
110 drm_thread_->Start();
111
112 surface_factory_.reset(new DrmSurfaceFactory(drm_thread_.get()));
113 gpu_platform_support_ = drm_thread_->CreateGpuPlatformSupportProxy();
114
125 if (!gpu_helper_.Initialize(base::ThreadTaskRunnerHandle::Get(), 115 if (!gpu_helper_.Initialize(base::ThreadTaskRunnerHandle::Get(),
126 base::ThreadTaskRunnerHandle::Get())) 116 base::ThreadTaskRunnerHandle::Get()))
127 LOG(FATAL) << "Failed to initialize dummy channel."; 117 LOG(FATAL) << "Failed to initialize dummy channel.";
128 } 118 }
129 119
130 void InitializeGPU() override {} 120 void InitializeGPU() override {}
131 121
132 private: 122 private:
133 // Objects in the "GPU" process. 123 // Objects in the "GPU" process.
134 scoped_ptr<DrmDeviceManager> drm_device_manager_; 124 scoped_ptr<DrmThread> drm_thread_;
135 scoped_ptr<DrmBufferGenerator> buffer_generator_; 125 scoped_ptr<DrmSurfaceFactory> surface_factory_;
136 scoped_ptr<ScreenManager> screen_manager_; 126 scoped_ptr<DrmGpuPlatformSupportProxy> gpu_platform_support_;
137 scoped_ptr<DrmGpuPlatformSupport> gpu_platform_support_;
138 127
139 // Objects in the "Browser" process. 128 // Objects in the "Browser" process.
140 scoped_ptr<OverlayManagerOzone> overlay_manager_; 129 scoped_ptr<OverlayManagerOzone> overlay_manager_;
141 scoped_ptr<DeviceManager> device_manager_; 130 scoped_ptr<DeviceManager> device_manager_;
142 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; 131 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_;
143 scoped_ptr<DrmWindowHostManager> window_manager_; 132 scoped_ptr<DrmWindowHostManager> window_manager_;
144 scoped_ptr<DrmCursor> cursor_; 133 scoped_ptr<DrmCursor> cursor_;
145 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; 134 scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
146 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_; 135 scoped_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_;
147 scoped_ptr<DrmDisplayHostManager> display_manager_; 136 scoped_ptr<DrmDisplayHostManager> display_manager_;
148 137
149 #if defined(USE_XKBCOMMON) 138 #if defined(USE_XKBCOMMON)
150 XkbEvdevCodes xkb_evdev_code_converter_; 139 XkbEvdevCodes xkb_evdev_code_converter_;
151 #endif 140 #endif
152 141
153 // Objects on both processes. 142 // Objects on both processes.
154 scoped_ptr<DrmSurfaceFactory> surface_factory_ozone_;
155
156 OzoneGpuTestHelper gpu_helper_; 143 OzoneGpuTestHelper gpu_helper_;
157 144
158 DISALLOW_COPY_AND_ASSIGN(OzonePlatformDrm); 145 DISALLOW_COPY_AND_ASSIGN(OzonePlatformDrm);
159 }; 146 };
160 147
161 } // namespace 148 } // namespace
162 149
163 OzonePlatform* CreateOzonePlatformDri() { 150 OzonePlatform* CreateOzonePlatformDri() {
164 return new OzonePlatformDrm; 151 return new OzonePlatformDrm;
165 } 152 }
166 153
167 OzonePlatform* CreateOzonePlatformDrm() { 154 OzonePlatform* CreateOzonePlatformDrm() {
168 return new OzonePlatformDrm; 155 return new OzonePlatformDrm;
169 } 156 }
170 157
171 } // namespace ui 158 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698