| 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/drm/ozone_platform_gbm.h" | 5 #include "ui/ozone/platform/drm/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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::BGRA_8888, size, | 82 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::BGRA_8888, size, |
| 83 true); | 83 true); |
| 84 } | 84 } |
| 85 | 85 |
| 86 protected: | 86 protected: |
| 87 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); | 87 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class GbmDeviceGenerator : public DrmDeviceGenerator { | 90 class GbmDeviceGenerator : public DrmDeviceGenerator { |
| 91 public: | 91 public: |
| 92 GbmDeviceGenerator() {} | 92 GbmDeviceGenerator(bool use_atomic) : use_atomic_(use_atomic) {} |
| 93 ~GbmDeviceGenerator() override {} | 93 ~GbmDeviceGenerator() override {} |
| 94 | 94 |
| 95 // DrmDeviceGenerator: | 95 // DrmDeviceGenerator: |
| 96 scoped_refptr<DrmDevice> CreateDevice(const base::FilePath& path, | 96 scoped_refptr<DrmDevice> CreateDevice(const base::FilePath& path, |
| 97 base::File file) override { | 97 base::File file) override { |
| 98 scoped_refptr<DrmDevice> drm = new GbmDevice(path, file.Pass()); | 98 scoped_refptr<DrmDevice> drm = new GbmDevice(path, file.Pass()); |
| 99 if (drm->Initialize()) | 99 if (drm->Initialize(use_atomic_)) |
| 100 return drm; | 100 return drm; |
| 101 | 101 |
| 102 return nullptr; | 102 return nullptr; |
| 103 } | 103 } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 bool use_atomic_; |
| 107 |
| 106 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); | 108 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); |
| 107 }; | 109 }; |
| 108 | 110 |
| 109 class OzonePlatformGbm : public OzonePlatform { | 111 class OzonePlatformGbm : public OzonePlatform { |
| 110 public: | 112 public: |
| 111 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {} | 113 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {} |
| 112 ~OzonePlatformGbm() override {} | 114 ~OzonePlatformGbm() override {} |
| 113 | 115 |
| 114 // OzonePlatform: | 116 // OzonePlatform: |
| 115 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 117 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 #else | 165 #else |
| 164 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | 166 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
| 165 make_scoped_ptr(new StubKeyboardLayoutEngine())); | 167 make_scoped_ptr(new StubKeyboardLayoutEngine())); |
| 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 { |
| 175 bool use_atomic = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 176 switches::kOzoneUseAtomicDrm); |
| 173 #if defined(OS_CHROMEOS) | 177 #if defined(OS_CHROMEOS) |
| 174 gpu_lock_.reset(new GpuLock()); | 178 gpu_lock_.reset(new GpuLock()); |
| 175 #endif | 179 #endif |
| 176 gl_api_loader_.reset(new GlApiLoader()); | 180 gl_api_loader_.reset(new GlApiLoader()); |
| 177 drm_device_manager_.reset(new DrmDeviceManager( | 181 drm_device_manager_.reset(new DrmDeviceManager( |
| 178 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator()))); | 182 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator(use_atomic)))); |
| 179 buffer_generator_.reset(new GbmBufferGenerator()); | 183 buffer_generator_.reset(new GbmBufferGenerator()); |
| 180 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); | 184 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); |
| 181 if (!surface_factory_ozone_) | 185 if (!surface_factory_ozone_) |
| 182 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 186 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
| 183 | 187 |
| 184 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), | 188 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), |
| 185 screen_manager_.get()); | 189 screen_manager_.get()); |
| 186 scoped_ptr<DrmGpuDisplayManager> ndd(new DrmGpuDisplayManager( | 190 scoped_ptr<DrmGpuDisplayManager> ndd(new DrmGpuDisplayManager( |
| 187 screen_manager_.get(), drm_device_manager_.get())); | 191 screen_manager_.get(), drm_device_manager_.get())); |
| 188 gpu_platform_support_.reset(new DrmGpuPlatformSupport( | 192 gpu_platform_support_.reset(new DrmGpuPlatformSupport( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 OzonePlatform* CreateOzonePlatformGbm() { | 227 OzonePlatform* CreateOzonePlatformGbm() { |
| 224 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 228 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 225 #if defined(USE_MESA_PLATFORM_NULL) | 229 #if defined(USE_MESA_PLATFORM_NULL) |
| 226 // Only works with surfaceless. | 230 // Only works with surfaceless. |
| 227 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); | 231 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); |
| 228 #endif | 232 #endif |
| 229 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 233 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
| 230 } | 234 } |
| 231 | 235 |
| 232 } // namespace ui | 236 } // namespace ui |
| OLD | NEW |