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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 class GbmDeviceGenerator : public DrmDeviceGenerator { | 90 class GbmDeviceGenerator : public DrmDeviceGenerator { |
91 public: | 91 public: |
92 GbmDeviceGenerator() {} | 92 GbmDeviceGenerator() {} |
93 ~GbmDeviceGenerator() override {} | 93 ~GbmDeviceGenerator() override {} |
94 | 94 |
95 // DrmDeviceGenerator: | 95 // DrmDeviceGenerator: |
96 scoped_refptr<DriWrapper> CreateDevice(const base::FilePath& path, | 96 scoped_refptr<DriWrapper> CreateDevice(const base::FilePath& path, |
97 base::File file) override { | 97 base::File file) override { |
98 scoped_refptr<DriWrapper> drm = new GbmWrapper(path, file.Pass()); | 98 scoped_refptr<DriWrapper> drm = new GbmWrapper(path, file.Pass()); |
99 drm->Initialize(); | 99 if (drm->Initialize()) |
100 return drm; | 100 return drm; |
| 101 |
| 102 return nullptr; |
101 } | 103 } |
102 | 104 |
103 private: | 105 private: |
104 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); | 106 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); |
105 }; | 107 }; |
106 | 108 |
107 class OzonePlatformGbm : public OzonePlatform { | 109 class OzonePlatformGbm : public OzonePlatform { |
108 public: | 110 public: |
109 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { | 111 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { |
110 } | 112 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 #endif | 168 #endif |
167 event_factory_ozone_.reset(new EventFactoryEvdev( | 169 event_factory_ozone_.reset(new EventFactoryEvdev( |
168 cursor_.get(), device_manager_.get(), | 170 cursor_.get(), device_manager_.get(), |
169 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); | 171 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); |
170 } | 172 } |
171 | 173 |
172 void InitializeGPU() override { | 174 void InitializeGPU() override { |
173 gl_api_loader_.reset(new GlApiLoader()); | 175 gl_api_loader_.reset(new GlApiLoader()); |
174 // Async page flips are supported only on surfaceless mode. | 176 // Async page flips are supported only on surfaceless mode. |
175 gbm_ = new GbmWrapper(GetFirstDisplayCardPath()); | 177 gbm_ = new GbmWrapper(GetFirstDisplayCardPath()); |
176 gbm_->Initialize(); | 178 if (!gbm_->Initialize()) |
| 179 LOG(FATAL) << "Failed to initialize primary DRM device"; |
| 180 |
177 drm_device_manager_.reset(new DrmDeviceManager(gbm_)); | 181 drm_device_manager_.reset(new DrmDeviceManager(gbm_)); |
178 buffer_generator_.reset(new GbmBufferGenerator()); | 182 buffer_generator_.reset(new GbmBufferGenerator()); |
179 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); | 183 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); |
180 // This makes sure that simple targets that do not handle display | 184 // This makes sure that simple targets that do not handle display |
181 // configuration can still use the primary display. | 185 // configuration can still use the primary display. |
182 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); | 186 ForceInitializationOfPrimaryDisplay(gbm_, screen_manager_.get()); |
183 | 187 |
184 window_delegate_manager_.reset(new DriWindowDelegateManager()); | 188 window_delegate_manager_.reset(new DriWindowDelegateManager()); |
185 if (!surface_factory_ozone_) | 189 if (!surface_factory_ozone_) |
186 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 190 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 OzonePlatform* CreateOzonePlatformGbm() { | 233 OzonePlatform* CreateOzonePlatformGbm() { |
230 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 234 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
231 #if defined(USE_MESA_PLATFORM_NULL) | 235 #if defined(USE_MESA_PLATFORM_NULL) |
232 // Only works with surfaceless. | 236 // Only works with surfaceless. |
233 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); | 237 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); |
234 #endif | 238 #endif |
235 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 239 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
236 } | 240 } |
237 | 241 |
238 } // namespace ui | 242 } // namespace ui |
OLD | NEW |