OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/dri/ozone_platform_gbm.h" | 5 #include "ui/ozone/platform/dri/ozone_platform_gbm.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <gbm.h> | 8 #include <gbm.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 14 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
15 #include "ui/events/ozone/device/device_manager.h" | 15 #include "ui/events/ozone/device/device_manager.h" |
16 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 16 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 17 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 18 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" |
17 #include "ui/ozone/platform/dri/display_manager.h" | 19 #include "ui/ozone/platform/dri/display_manager.h" |
18 #include "ui/ozone/platform/dri/dri_cursor.h" | 20 #include "ui/ozone/platform/dri/dri_cursor.h" |
19 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" | 21 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" |
20 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" | 22 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" |
21 #include "ui/ozone/platform/dri/dri_window.h" | 23 #include "ui/ozone/platform/dri/dri_window.h" |
22 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" | 24 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" |
23 #include "ui/ozone/platform/dri/dri_window_manager.h" | 25 #include "ui/ozone/platform/dri/dri_window_manager.h" |
24 #include "ui/ozone/platform/dri/dri_wrapper.h" | 26 #include "ui/ozone/platform/dri/dri_wrapper.h" |
25 #include "ui/ozone/platform/dri/gbm_buffer.h" | 27 #include "ui/ozone/platform/dri/gbm_buffer.h" |
26 #include "ui/ozone/platform/dri/gbm_surface.h" | 28 #include "ui/ozone/platform/dri/gbm_surface.h" |
(...skipping 25 matching lines...) Expand all Loading... |
52 } | 54 } |
53 virtual ~GbmBufferGenerator() { | 55 virtual ~GbmBufferGenerator() { |
54 gbm_device_destroy(device_); | 56 gbm_device_destroy(device_); |
55 if (glapi_lib_) | 57 if (glapi_lib_) |
56 dlclose(glapi_lib_); | 58 dlclose(glapi_lib_); |
57 } | 59 } |
58 | 60 |
59 gbm_device* device() const { return device_; } | 61 gbm_device* device() const { return device_; } |
60 | 62 |
61 scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) override { | 63 scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) override { |
62 return GbmBuffer::CreateBuffer( | 64 return GbmBuffer::CreateBuffer(dri_, device_, |
63 dri_, device_, SurfaceFactoryOzone::RGBA_8888, size, true); | 65 SurfaceFactoryOzone::RGBA_8888, size, true); |
64 } | 66 } |
65 | 67 |
66 protected: | 68 protected: |
67 DriWrapper* dri_; // Not owned. | 69 DriWrapper* dri_; // Not owned. |
68 | 70 |
69 // HACK: gbm drivers have broken linkage | 71 // HACK: gbm drivers have broken linkage |
70 void *glapi_lib_; | 72 void* glapi_lib_; |
71 | 73 |
72 gbm_device* device_; | 74 gbm_device* device_; |
73 | 75 |
74 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); | 76 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); |
75 }; | 77 }; |
76 | 78 |
77 class OzonePlatformGbm : public OzonePlatform { | 79 class OzonePlatformGbm : public OzonePlatform { |
78 public: | 80 public: |
79 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { | 81 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { |
80 base::AtExitManager::RegisterTask( | 82 base::AtExitManager::RegisterTask( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void InitializeUI() override { | 121 void InitializeUI() override { |
120 display_manager_.reset(new DisplayManager()); | 122 display_manager_.reset(new DisplayManager()); |
121 // Needed since the browser process creates the accelerated widgets and that | 123 // Needed since the browser process creates the accelerated widgets and that |
122 // happens through SFO. | 124 // happens through SFO. |
123 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 125 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
124 device_manager_ = CreateDeviceManager(); | 126 device_manager_ = CreateDeviceManager(); |
125 gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost()); | 127 gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost()); |
126 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | 128 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
127 window_manager_.reset( | 129 window_manager_.reset( |
128 new DriWindowManager(gpu_platform_support_host_.get())); | 130 new DriWindowManager(gpu_platform_support_host_.get())); |
129 event_factory_ozone_.reset(new EventFactoryEvdev(window_manager_->cursor(), | 131 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
130 device_manager_.get())); | 132 make_scoped_ptr(new StubKeyboardLayoutEngine())); |
| 133 event_factory_ozone_.reset(new EventFactoryEvdev( |
| 134 window_manager_->cursor(), device_manager_.get(), |
| 135 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); |
131 } | 136 } |
132 | 137 |
133 void InitializeGPU() override { | 138 void InitializeGPU() override { |
134 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); | 139 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); |
135 dri_->Initialize(); | 140 dri_->Initialize(); |
136 buffer_generator_.reset(new GbmBufferGenerator(dri_.get())); | 141 buffer_generator_.reset(new GbmBufferGenerator(dri_.get())); |
137 screen_manager_.reset(new ScreenManager(dri_.get(), | 142 screen_manager_.reset( |
138 buffer_generator_.get())); | 143 new ScreenManager(dri_.get(), buffer_generator_.get())); |
139 window_delegate_manager_.reset(new DriWindowDelegateManager()); | 144 window_delegate_manager_.reset(new DriWindowDelegateManager()); |
140 if (!surface_factory_ozone_) | 145 if (!surface_factory_ozone_) |
141 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 146 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
142 | 147 |
143 surface_factory_ozone_->InitializeGpu( | 148 surface_factory_ozone_->InitializeGpu( |
144 dri_.get(), buffer_generator_->device(), screen_manager_.get(), | 149 dri_.get(), buffer_generator_->device(), screen_manager_.get(), |
145 window_delegate_manager_.get()); | 150 window_delegate_manager_.get()); |
146 scoped_ptr<NativeDisplayDelegateDri> ndd( | 151 scoped_ptr<NativeDisplayDelegateDri> ndd( |
147 new NativeDisplayDelegateDri(dri_.get(), screen_manager_.get())); | 152 new NativeDisplayDelegateDri(dri_.get(), screen_manager_.get())); |
148 ndd->Initialize(); | 153 ndd->Initialize(); |
(...skipping 25 matching lines...) Expand all Loading... |
174 }; | 179 }; |
175 | 180 |
176 } // namespace | 181 } // namespace |
177 | 182 |
178 OzonePlatform* CreateOzonePlatformGbm() { | 183 OzonePlatform* CreateOzonePlatformGbm() { |
179 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 184 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
180 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 185 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
181 } | 186 } |
182 | 187 |
183 } // namespace ui | 188 } // namespace ui |
OLD | NEW |