| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 const char kDefaultGraphicsCardPath[] = "/dev/dri/card0"; | 46 const char kDefaultGraphicsCardPath[] = "/dev/dri/card0"; |
| 47 | 47 |
| 48 class GbmBufferGenerator : public ScanoutBufferGenerator { | 48 class GbmBufferGenerator : public ScanoutBufferGenerator { |
| 49 public: | 49 public: |
| 50 GbmBufferGenerator(DriWrapper* dri) | 50 GbmBufferGenerator(DriWrapper* dri) |
| 51 : dri_(dri), | 51 : dri_(dri), |
| 52 glapi_lib_(dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL)), | 52 glapi_lib_(dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL)), |
| 53 device_(gbm_create_device(dri_->get_fd())) {} | 53 device_(gbm_create_device(dri_->get_fd())) { |
| 54 if (!device_) |
| 55 LOG(FATAL) << "Unable to initialize gbm for " << kDefaultGraphicsCardPath; |
| 56 } |
| 54 virtual ~GbmBufferGenerator() { | 57 virtual ~GbmBufferGenerator() { |
| 55 gbm_device_destroy(device_); | 58 gbm_device_destroy(device_); |
| 56 if (glapi_lib_) | 59 if (glapi_lib_) |
| 57 dlclose(glapi_lib_); | 60 dlclose(glapi_lib_); |
| 58 } | 61 } |
| 59 | 62 |
| 60 gbm_device* device() const { return device_; } | 63 gbm_device* device() const { return device_; } |
| 61 | 64 |
| 62 virtual scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) OVERRIDE { | 65 virtual scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) OVERRIDE { |
| 63 return GbmBuffer::CreateBuffer( | 66 return GbmBuffer::CreateBuffer( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 device_manager_ = CreateDeviceManager(); | 134 device_manager_ = CreateDeviceManager(); |
| 132 gpu_platform_support_host_.reset(new GpuPlatformSupportHostGbm()); | 135 gpu_platform_support_host_.reset(new GpuPlatformSupportHostGbm()); |
| 133 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | 136 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 134 cursor_.reset(new DriCursor(gpu_platform_support_host_.get())); | 137 cursor_.reset(new DriCursor(gpu_platform_support_host_.get())); |
| 135 event_factory_ozone_.reset( | 138 event_factory_ozone_.reset( |
| 136 new EventFactoryEvdev(cursor_.get(), device_manager_.get())); | 139 new EventFactoryEvdev(cursor_.get(), device_manager_.get())); |
| 137 } | 140 } |
| 138 | 141 |
| 139 virtual void InitializeGPU() OVERRIDE { | 142 virtual void InitializeGPU() OVERRIDE { |
| 140 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); | 143 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); |
| 144 dri_->Initialize(); |
| 141 buffer_generator_.reset(new GbmBufferGenerator(dri_.get())); | 145 buffer_generator_.reset(new GbmBufferGenerator(dri_.get())); |
| 142 screen_manager_.reset(new ScreenManager(dri_.get(), | 146 screen_manager_.reset(new ScreenManager(dri_.get(), |
| 143 buffer_generator_.get())); | 147 buffer_generator_.get())); |
| 144 if (!surface_factory_ozone_) | 148 if (!surface_factory_ozone_) |
| 145 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 149 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
| 146 | 150 |
| 147 surface_factory_ozone_->InitializeGpu(dri_.get(), | 151 surface_factory_ozone_->InitializeGpu(dri_.get(), |
| 148 buffer_generator_->device(), | 152 buffer_generator_->device(), |
| 149 screen_manager_.get(), | 153 screen_manager_.get(), |
| 150 &gpu_window_manager_); | 154 &gpu_window_manager_); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 }; | 192 }; |
| 189 | 193 |
| 190 } // namespace | 194 } // namespace |
| 191 | 195 |
| 192 OzonePlatform* CreateOzonePlatformGbm() { | 196 OzonePlatform* CreateOzonePlatformGbm() { |
| 193 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 197 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 194 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 198 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
| 195 } | 199 } |
| 196 | 200 |
| 197 } // namespace ui | 201 } // namespace ui |
| OLD | NEW |