| 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/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 13 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 14 #include "ui/events/ozone/device/device_manager.h" | 14 #include "ui/events/ozone/device/device_manager.h" |
| 15 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 15 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 16 #include "ui/events/ozone/layout/stub/stub_keyboard_layouts.h" |
| 16 #include "ui/ozone/platform/dri/display_manager.h" | 17 #include "ui/ozone/platform/dri/display_manager.h" |
| 17 #include "ui/ozone/platform/dri/dri_cursor.h" | 18 #include "ui/ozone/platform/dri/dri_cursor.h" |
| 18 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" | 19 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" |
| 19 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" | 20 #include "ui/ozone/platform/dri/dri_gpu_platform_support_host.h" |
| 20 #include "ui/ozone/platform/dri/dri_window.h" | 21 #include "ui/ozone/platform/dri/dri_window.h" |
| 21 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" | 22 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" |
| 22 #include "ui/ozone/platform/dri/dri_window_manager.h" | 23 #include "ui/ozone/platform/dri/dri_window_manager.h" |
| 23 #include "ui/ozone/platform/dri/dri_wrapper.h" | 24 #include "ui/ozone/platform/dri/dri_wrapper.h" |
| 24 #include "ui/ozone/platform/dri/gbm_buffer.h" | 25 #include "ui/ozone/platform/dri/gbm_buffer.h" |
| 25 #include "ui/ozone/platform/dri/gbm_surface.h" | 26 #include "ui/ozone/platform/dri/gbm_surface.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 88 } |
| 88 CursorFactoryOzone* GetCursorFactoryOzone() override { | 89 CursorFactoryOzone* GetCursorFactoryOzone() override { |
| 89 return cursor_factory_ozone_.get(); | 90 return cursor_factory_ozone_.get(); |
| 90 } | 91 } |
| 91 GpuPlatformSupport* GetGpuPlatformSupport() override { | 92 GpuPlatformSupport* GetGpuPlatformSupport() override { |
| 92 return gpu_platform_support_.get(); | 93 return gpu_platform_support_.get(); |
| 93 } | 94 } |
| 94 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | 95 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
| 95 return gpu_platform_support_host_.get(); | 96 return gpu_platform_support_host_.get(); |
| 96 } | 97 } |
| 98 KeyboardLayoutsOzone* GetKeyboardLayouts() override { |
| 99 return keyboard_layouts_ozone_.get(); |
| 100 } |
| 97 scoped_ptr<PlatformWindow> CreatePlatformWindow( | 101 scoped_ptr<PlatformWindow> CreatePlatformWindow( |
| 98 PlatformWindowDelegate* delegate, | 102 PlatformWindowDelegate* delegate, |
| 99 const gfx::Rect& bounds) override { | 103 const gfx::Rect& bounds) override { |
| 100 scoped_ptr<DriWindow> platform_window( | 104 scoped_ptr<DriWindow> platform_window( |
| 101 new DriWindow(delegate, bounds, gpu_platform_support_host_.get(), | 105 new DriWindow(delegate, bounds, gpu_platform_support_host_.get(), |
| 102 event_factory_ozone_.get(), window_manager_.get(), | 106 event_factory_ozone_.get(), window_manager_.get(), |
| 103 display_manager_.get())); | 107 display_manager_.get())); |
| 104 platform_window->Initialize(); | 108 platform_window->Initialize(); |
| 105 return platform_window.Pass(); | 109 return platform_window.Pass(); |
| 106 } | 110 } |
| 107 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 111 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
| 108 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateProxy( | 112 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateProxy( |
| 109 gpu_platform_support_host_.get(), device_manager_.get(), | 113 gpu_platform_support_host_.get(), device_manager_.get(), |
| 110 display_manager_.get())); | 114 display_manager_.get())); |
| 111 } | 115 } |
| 112 void InitializeUI() override { | 116 void InitializeUI() override { |
| 113 display_manager_.reset(new DisplayManager()); | 117 display_manager_.reset(new DisplayManager()); |
| 114 // Needed since the browser process creates the accelerated widgets and that | 118 // Needed since the browser process creates the accelerated widgets and that |
| 115 // happens through SFO. | 119 // happens through SFO. |
| 116 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 120 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
| 117 device_manager_ = CreateDeviceManager(); | 121 device_manager_ = CreateDeviceManager(); |
| 118 gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost()); | 122 gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost()); |
| 119 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | 123 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 120 window_manager_.reset( | 124 window_manager_.reset( |
| 121 new DriWindowManager(gpu_platform_support_host_.get())); | 125 new DriWindowManager(gpu_platform_support_host_.get())); |
| 122 event_factory_ozone_.reset(new EventFactoryEvdev(window_manager_->cursor(), | 126 event_factory_ozone_.reset(new EventFactoryEvdev(window_manager_->cursor(), |
| 123 device_manager_.get())); | 127 device_manager_.get())); |
| 128 keyboard_layouts_ozone_.reset(new StubKeyboardLayouts()); |
| 124 } | 129 } |
| 125 | 130 |
| 126 void InitializeGPU() override { | 131 void InitializeGPU() override { |
| 127 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); | 132 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); |
| 128 dri_->Initialize(); | 133 dri_->Initialize(); |
| 129 buffer_generator_.reset(new GbmBufferGenerator(dri_.get())); | 134 buffer_generator_.reset(new GbmBufferGenerator(dri_.get())); |
| 130 screen_manager_.reset(new ScreenManager(dri_.get(), | 135 screen_manager_.reset(new ScreenManager(dri_.get(), |
| 131 buffer_generator_.get())); | 136 buffer_generator_.get())); |
| 132 window_delegate_manager_.reset(new DriWindowDelegateManager()); | 137 window_delegate_manager_.reset(new DriWindowDelegateManager()); |
| 133 if (!surface_factory_ozone_) | 138 if (!surface_factory_ozone_) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 149 private: | 154 private: |
| 150 bool use_surfaceless_; | 155 bool use_surfaceless_; |
| 151 scoped_ptr<DriWrapper> dri_; | 156 scoped_ptr<DriWrapper> dri_; |
| 152 scoped_ptr<GbmBufferGenerator> buffer_generator_; | 157 scoped_ptr<GbmBufferGenerator> buffer_generator_; |
| 153 scoped_ptr<ScreenManager> screen_manager_; | 158 scoped_ptr<ScreenManager> screen_manager_; |
| 154 scoped_ptr<DeviceManager> device_manager_; | 159 scoped_ptr<DeviceManager> device_manager_; |
| 155 | 160 |
| 156 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; | 161 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; |
| 157 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; | 162 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
| 158 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 163 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
| 164 scoped_ptr<KeyboardLayoutsOzone> keyboard_layouts_ozone_; |
| 159 | 165 |
| 160 scoped_ptr<DriGpuPlatformSupport> gpu_platform_support_; | 166 scoped_ptr<DriGpuPlatformSupport> gpu_platform_support_; |
| 161 scoped_ptr<DriGpuPlatformSupportHost> gpu_platform_support_host_; | 167 scoped_ptr<DriGpuPlatformSupportHost> gpu_platform_support_host_; |
| 162 | 168 |
| 163 scoped_ptr<DriWindowDelegateManager> window_delegate_manager_; | 169 scoped_ptr<DriWindowDelegateManager> window_delegate_manager_; |
| 164 // Browser side object only. | 170 // Browser side object only. |
| 165 scoped_ptr<DriWindowManager> window_manager_; | 171 scoped_ptr<DriWindowManager> window_manager_; |
| 166 scoped_ptr<DisplayManager> display_manager_; | 172 scoped_ptr<DisplayManager> display_manager_; |
| 167 | 173 |
| 168 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); | 174 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); |
| 169 }; | 175 }; |
| 170 | 176 |
| 171 } // namespace | 177 } // namespace |
| 172 | 178 |
| 173 OzonePlatform* CreateOzonePlatformGbm() { | 179 OzonePlatform* CreateOzonePlatformGbm() { |
| 174 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 180 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 175 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 181 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
| 176 } | 182 } |
| 177 | 183 |
| 178 } // namespace ui | 184 } // namespace ui |
| OLD | NEW |