| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 LOG(FATAL) << "Unable to initialize gbm for " << kDefaultGraphicsCardPath; | 50 LOG(FATAL) << "Unable to initialize gbm for " << kDefaultGraphicsCardPath; |
| 51 } | 51 } |
| 52 virtual ~GbmBufferGenerator() { | 52 virtual ~GbmBufferGenerator() { |
| 53 gbm_device_destroy(device_); | 53 gbm_device_destroy(device_); |
| 54 if (glapi_lib_) | 54 if (glapi_lib_) |
| 55 dlclose(glapi_lib_); | 55 dlclose(glapi_lib_); |
| 56 } | 56 } |
| 57 | 57 |
| 58 gbm_device* device() const { return device_; } | 58 gbm_device* device() const { return device_; } |
| 59 | 59 |
| 60 virtual scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) OVERRIDE { | 60 virtual scoped_refptr<ScanoutBuffer> Create(const gfx::Size& size) override { |
| 61 return GbmBuffer::CreateBuffer( | 61 return GbmBuffer::CreateBuffer( |
| 62 dri_, device_, SurfaceFactoryOzone::RGBA_8888, size, true); | 62 dri_, device_, SurfaceFactoryOzone::RGBA_8888, size, true); |
| 63 } | 63 } |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 DriWrapper* dri_; // Not owned. | 66 DriWrapper* dri_; // Not owned. |
| 67 | 67 |
| 68 // HACK: gbm drivers have broken linkage | 68 // HACK: gbm drivers have broken linkage |
| 69 void *glapi_lib_; | 69 void *glapi_lib_; |
| 70 | 70 |
| 71 gbm_device* device_; | 71 gbm_device* device_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); | 73 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 class OzonePlatformGbm : public OzonePlatform { | 76 class OzonePlatformGbm : public OzonePlatform { |
| 77 public: | 77 public: |
| 78 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { | 78 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) { |
| 79 base::AtExitManager::RegisterTask( | 79 base::AtExitManager::RegisterTask( |
| 80 base::Bind(&base::DeletePointer<OzonePlatformGbm>, this)); | 80 base::Bind(&base::DeletePointer<OzonePlatformGbm>, this)); |
| 81 } | 81 } |
| 82 virtual ~OzonePlatformGbm() {} | 82 virtual ~OzonePlatformGbm() {} |
| 83 | 83 |
| 84 // OzonePlatform: | 84 // OzonePlatform: |
| 85 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { | 85 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
| 86 return surface_factory_ozone_.get(); | 86 return surface_factory_ozone_.get(); |
| 87 } | 87 } |
| 88 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { | 88 virtual CursorFactoryOzone* GetCursorFactoryOzone() override { |
| 89 return cursor_factory_ozone_.get(); | 89 return cursor_factory_ozone_.get(); |
| 90 } | 90 } |
| 91 virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE { | 91 virtual GpuPlatformSupport* GetGpuPlatformSupport() override { |
| 92 return gpu_platform_support_.get(); | 92 return gpu_platform_support_.get(); |
| 93 } | 93 } |
| 94 virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE { | 94 virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
| 95 return gpu_platform_support_host_.get(); | 95 return gpu_platform_support_host_.get(); |
| 96 } | 96 } |
| 97 virtual scoped_ptr<PlatformWindow> CreatePlatformWindow( | 97 virtual scoped_ptr<PlatformWindow> CreatePlatformWindow( |
| 98 PlatformWindowDelegate* delegate, | 98 PlatformWindowDelegate* delegate, |
| 99 const gfx::Rect& bounds) OVERRIDE { | 99 const gfx::Rect& bounds) override { |
| 100 scoped_ptr<DriWindow> platform_window( | 100 scoped_ptr<DriWindow> platform_window( |
| 101 new DriWindow(delegate, | 101 new DriWindow(delegate, |
| 102 bounds, | 102 bounds, |
| 103 gpu_platform_support_host_.get(), | 103 gpu_platform_support_host_.get(), |
| 104 event_factory_ozone_.get(), | 104 event_factory_ozone_.get(), |
| 105 window_manager_.get())); | 105 window_manager_.get())); |
| 106 platform_window->Initialize(); | 106 platform_window->Initialize(); |
| 107 return platform_window.PassAs<PlatformWindow>(); | 107 return platform_window.PassAs<PlatformWindow>(); |
| 108 } | 108 } |
| 109 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() | 109 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() |
| 110 OVERRIDE { | 110 override { |
| 111 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateProxy( | 111 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateProxy( |
| 112 gpu_platform_support_host_.get(), device_manager_.get())); | 112 gpu_platform_support_host_.get(), device_manager_.get())); |
| 113 } | 113 } |
| 114 virtual void InitializeUI() OVERRIDE { | 114 virtual void InitializeUI() override { |
| 115 vt_manager_.reset(new VirtualTerminalManager()); | 115 vt_manager_.reset(new VirtualTerminalManager()); |
| 116 // Needed since the browser process creates the accelerated widgets and that | 116 // Needed since the browser process creates the accelerated widgets and that |
| 117 // happens through SFO. | 117 // happens through SFO. |
| 118 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 118 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
| 119 device_manager_ = CreateDeviceManager(); | 119 device_manager_ = CreateDeviceManager(); |
| 120 gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost()); | 120 gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost()); |
| 121 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | 121 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 122 window_manager_.reset( | 122 window_manager_.reset( |
| 123 new DriWindowManager(gpu_platform_support_host_.get())); | 123 new DriWindowManager(gpu_platform_support_host_.get())); |
| 124 event_factory_ozone_.reset(new EventFactoryEvdev(window_manager_->cursor(), | 124 event_factory_ozone_.reset(new EventFactoryEvdev(window_manager_->cursor(), |
| 125 device_manager_.get())); | 125 device_manager_.get())); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual void InitializeGPU() OVERRIDE { | 128 virtual void InitializeGPU() override { |
| 129 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); | 129 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); |
| 130 dri_->Initialize(); | 130 dri_->Initialize(); |
| 131 buffer_generator_.reset(new GbmBufferGenerator(dri_.get())); | 131 buffer_generator_.reset(new GbmBufferGenerator(dri_.get())); |
| 132 screen_manager_.reset(new ScreenManager(dri_.get(), | 132 screen_manager_.reset(new ScreenManager(dri_.get(), |
| 133 buffer_generator_.get())); | 133 buffer_generator_.get())); |
| 134 window_delegate_manager_.reset(new DriWindowDelegateManager()); | 134 window_delegate_manager_.reset(new DriWindowDelegateManager()); |
| 135 if (!surface_factory_ozone_) | 135 if (!surface_factory_ozone_) |
| 136 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); | 136 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_)); |
| 137 | 137 |
| 138 surface_factory_ozone_->InitializeGpu(dri_.get(), | 138 surface_factory_ozone_->InitializeGpu(dri_.get(), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 } // namespace | 175 } // namespace |
| 176 | 176 |
| 177 OzonePlatform* CreateOzonePlatformGbm() { | 177 OzonePlatform* CreateOzonePlatformGbm() { |
| 178 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 178 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 179 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); | 179 return new OzonePlatformGbm(cmd->HasSwitch(switches::kOzoneUseSurfaceless)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace ui | 182 } // namespace ui |
| OLD | NEW |