| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::BGRA_8888, size, | 81 return GbmBuffer::CreateBuffer(gbm, SurfaceFactoryOzone::BGRA_8888, size, |
| 82 true); | 82 true); |
| 83 } | 83 } |
| 84 | 84 |
| 85 protected: | 85 protected: |
| 86 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); | 86 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 class GbmDeviceGenerator : public DrmDeviceGenerator { | 89 class GbmDeviceGenerator : public DrmDeviceGenerator { |
| 90 public: | 90 public: |
| 91 GbmDeviceGenerator() {} | 91 GbmDeviceGenerator(bool use_atomic) : use_atomic_(use_atomic) {} |
| 92 ~GbmDeviceGenerator() override {} | 92 ~GbmDeviceGenerator() override {} |
| 93 | 93 |
| 94 // DrmDeviceGenerator: | 94 // DrmDeviceGenerator: |
| 95 scoped_refptr<DrmDevice> CreateDevice(const base::FilePath& path, | 95 scoped_refptr<DrmDevice> CreateDevice(const base::FilePath& path, |
| 96 base::File file) override { | 96 base::File file) override { |
| 97 scoped_refptr<DrmDevice> drm = new GbmDevice(path, file.Pass()); | 97 scoped_refptr<DrmDevice> drm = new GbmDevice(path, file.Pass()); |
| 98 if (drm->Initialize()) | 98 if (drm->Initialize(use_atomic_)) |
| 99 return drm; | 99 return drm; |
| 100 | 100 |
| 101 return nullptr; | 101 return nullptr; |
| 102 } | 102 } |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 bool use_atomic_; |
| 106 |
| 105 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); | 107 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); |
| 106 }; | 108 }; |
| 107 | 109 |
| 108 class OzonePlatformGbm : public OzonePlatform { | 110 class OzonePlatformGbm : public OzonePlatform { |
| 109 public: | 111 public: |
| 110 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {} | 112 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {} |
| 111 ~OzonePlatformGbm() override {} | 113 ~OzonePlatformGbm() override {} |
| 112 | 114 |
| 113 // OzonePlatform: | 115 // OzonePlatform: |
| 114 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 116 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 #else | 164 #else |
| 163 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | 165 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
| 164 make_scoped_ptr(new StubKeyboardLayoutEngine())); | 166 make_scoped_ptr(new StubKeyboardLayoutEngine())); |
| 165 #endif | 167 #endif |
| 166 event_factory_ozone_.reset(new EventFactoryEvdev( | 168 event_factory_ozone_.reset(new EventFactoryEvdev( |
| 167 cursor_.get(), device_manager_.get(), | 169 cursor_.get(), device_manager_.get(), |
| 168 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); | 170 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine())); |
| 169 } | 171 } |
| 170 | 172 |
| 171 void InitializeGPU() override { | 173 void InitializeGPU() override { |
| 174 bool use_atomic = false; |
| 172 gl_api_loader_.reset(new GlApiLoader()); | 175 gl_api_loader_.reset(new GlApiLoader()); |
| 173 drm_device_manager_.reset(new DrmDeviceManager( | 176 drm_device_manager_.reset(new DrmDeviceManager( |
| 174 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator()))); | 177 scoped_ptr<DrmDeviceGenerator>(new GbmDeviceGenerator(use_atomic)))); |
| 175 buffer_generator_.reset(new GbmBufferGenerator()); | 178 buffer_generator_.reset(new GbmBufferGenerator()); |
| 176 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); | 179 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); |
| 177 if (!surface_factory_ozone_) | 180 if (!surface_factory_ozone_) |
| 178 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 181 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
| 179 | 182 |
| 180 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), | 183 surface_factory_ozone_->InitializeGpu(drm_device_manager_.get(), |
| 181 screen_manager_.get()); | 184 screen_manager_.get()); |
| 182 scoped_ptr<DrmGpuDisplayManager> ndd(new DrmGpuDisplayManager( | 185 scoped_ptr<DrmGpuDisplayManager> ndd(new DrmGpuDisplayManager( |
| 183 screen_manager_.get(), drm_device_manager_.get())); | 186 screen_manager_.get(), drm_device_manager_.get())); |
| 184 gpu_platform_support_.reset(new DrmGpuPlatformSupport( | 187 gpu_platform_support_.reset(new DrmGpuPlatformSupport( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 OzonePlatform* CreateOzonePlatformGbm() { | 221 OzonePlatform* CreateOzonePlatformGbm() { |
| 219 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 222 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 220 #if defined(USE_MESA_PLATFORM_NULL) | 223 #if defined(USE_MESA_PLATFORM_NULL) |
| 221 // Only works with surfaceless. | 224 // Only works with surfaceless. |
| 222 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); | 225 cmd->AppendSwitch(switches::kOzoneUseSurfaceless); |
| 223 #endif | 226 #endif |
| 224 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 227 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
| 225 } | 228 } |
| 226 | 229 |
| 227 } // namespace ui | 230 } // namespace ui |
| OLD | NEW |