| 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 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h" | 42 #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h" |
| 43 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" | 43 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" |
| 44 #else | 44 #else |
| 45 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" | 45 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 namespace ui { | 48 namespace ui { |
| 49 | 49 |
| 50 namespace { | 50 namespace { |
| 51 | 51 |
| 52 const char kDefaultGraphicsCardPath[] = "/dev/dri/card0"; | |
| 53 | |
| 54 class GlApiLoader { | 52 class GlApiLoader { |
| 55 public: | 53 public: |
| 56 GlApiLoader() | 54 GlApiLoader() |
| 57 : glapi_lib_(dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL)) {} | 55 : glapi_lib_(dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL)) {} |
| 58 | 56 |
| 59 ~GlApiLoader() { | 57 ~GlApiLoader() { |
| 60 if (glapi_lib_) | 58 if (glapi_lib_) |
| 61 dlclose(glapi_lib_); | 59 dlclose(glapi_lib_); |
| 62 } | 60 } |
| 63 | 61 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 make_scoped_ptr(new StubKeyboardLayoutEngine())); | 146 make_scoped_ptr(new StubKeyboardLayoutEngine())); |
| 149 #endif | 147 #endif |
| 150 event_factory_ozone_.reset(new EventFactoryEvdev( | 148 event_factory_ozone_.reset(new EventFactoryEvdev( |
| 151 cursor_.get(), device_manager_.get(), | 149 cursor_.get(), device_manager_.get(), |
| 152 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); | 150 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); |
| 153 } | 151 } |
| 154 | 152 |
| 155 void InitializeGPU() override { | 153 void InitializeGPU() override { |
| 156 gl_api_loader_.reset(new GlApiLoader()); | 154 gl_api_loader_.reset(new GlApiLoader()); |
| 157 // Async page flips are supported only on surfaceless mode. | 155 // Async page flips are supported only on surfaceless mode. |
| 158 gbm_ = new GbmWrapper(base::FilePath(kDefaultGraphicsCardPath)); | 156 gbm_ = new GbmWrapper(GetFirstDisplayCardPath()); |
| 159 gbm_->Initialize(); | 157 gbm_->Initialize(); |
| 160 drm_device_manager_.reset(new DrmDeviceManager(gbm_)); | 158 drm_device_manager_.reset(new DrmDeviceManager(gbm_)); |
| 161 buffer_generator_.reset(new GbmBufferGenerator()); | 159 buffer_generator_.reset(new GbmBufferGenerator()); |
| 162 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); | 160 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); |
| 163 // This makes sure that simple targets that do not handle display | 161 // This makes sure that simple targets that do not handle display |
| 164 // configuration can still use the primary display. | 162 // configuration can still use the primary display. |
| 165 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); | 163 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); |
| 166 | 164 |
| 167 window_delegate_manager_.reset(new DriWindowDelegateManager()); | 165 window_delegate_manager_.reset(new DriWindowDelegateManager()); |
| 168 if (!surface_factory_ozone_) | 166 if (!surface_factory_ozone_) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 OzonePlatform* CreateOzonePlatformGbm() { | 209 OzonePlatform* CreateOzonePlatformGbm() { |
| 212 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 210 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 213 #if defined(USE_MESA_PLATFORM_NULL) | 211 #if defined(USE_MESA_PLATFORM_NULL) |
| 214 // Only works with surfaceless. | 212 // Only works with surfaceless. |
| 215 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); | 213 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); |
| 216 #endif | 214 #endif |
| 217 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 215 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
| 218 } | 216 } |
| 219 | 217 |
| 220 } // namespace ui | 218 } // namespace ui |
| OLD | NEW |