Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: ui/ozone/platform/dri/ozone_platform_gbm.cc

Issue 371813004: ozone: gbm: Add overlay support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "ui/events/ozone/device/device_manager.h" 12 #include "ui/events/ozone/device/device_manager.h"
13 #include "ui/events/ozone/evdev/event_factory_evdev.h" 13 #include "ui/events/ozone/evdev/event_factory_evdev.h"
14 #include "ui/ozone/ozone_platform.h" 14 #include "ui/ozone/ozone_platform.h"
15 #include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h" 15 #include "ui/ozone/platform/dri/cursor_factory_evdev_dri.h"
16 #include "ui/ozone/platform/dri/dri_wrapper.h" 16 #include "ui/ozone/platform/dri/dri_wrapper.h"
17 #include "ui/ozone/platform/dri/gbm_buffer.h"
17 #include "ui/ozone/platform/dri/gbm_surface.h" 18 #include "ui/ozone/platform/dri/gbm_surface.h"
18 #include "ui/ozone/platform/dri/gbm_surface_factory.h" 19 #include "ui/ozone/platform/dri/gbm_surface_factory.h"
19 #include "ui/ozone/platform/dri/gpu_platform_support_gbm.h" 20 #include "ui/ozone/platform/dri/gpu_platform_support_gbm.h"
20 #include "ui/ozone/platform/dri/gpu_platform_support_host_gbm.h" 21 #include "ui/ozone/platform/dri/gpu_platform_support_host_gbm.h"
21 #include "ui/ozone/platform/dri/scanout_surface.h" 22 #include "ui/ozone/platform/dri/scanout_surface.h"
22 #include "ui/ozone/platform/dri/screen_manager.h" 23 #include "ui/ozone/platform/dri/screen_manager.h"
23 #include "ui/ozone/platform/dri/virtual_terminal_manager.h" 24 #include "ui/ozone/platform/dri/virtual_terminal_manager.h"
24 #include "ui/ozone/public/cursor_factory_ozone.h" 25 #include "ui/ozone/public/cursor_factory_ozone.h"
25 #include "ui/ozone/public/gpu_platform_support.h" 26 #include "ui/ozone/public/gpu_platform_support.h"
26 #include "ui/ozone/public/gpu_platform_support_host.h" 27 #include "ui/ozone/public/gpu_platform_support_host.h"
(...skipping 20 matching lines...) Expand all
47 if (glapi_lib_) 48 if (glapi_lib_)
48 dlclose(glapi_lib_); 49 dlclose(glapi_lib_);
49 } 50 }
50 51
51 gbm_device* device() const { return device_; } 52 gbm_device* device() const { return device_; }
52 53
53 virtual ScanoutSurface* Create(const gfx::Size& size) OVERRIDE { 54 virtual ScanoutSurface* Create(const gfx::Size& size) OVERRIDE {
54 return new GbmSurface(device_, dri_, size); 55 return new GbmSurface(device_, dri_, size);
55 } 56 }
56 57
57 private: 58 protected:
58 DriWrapper* dri_; // Not owned. 59 DriWrapper* dri_; // Not owned.
59 60
60 // HACK: gbm drivers have broken linkage 61 // HACK: gbm drivers have broken linkage
61 void *glapi_lib_; 62 void *glapi_lib_;
62 63
63 gbm_device* device_; 64 gbm_device* device_;
64 65
65 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceGenerator); 66 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceGenerator);
66 }; 67 };
67 68
69 class GbmEglImageSurfaceGenerator : public GbmSurfaceGenerator {
70 public:
71 GbmEglImageSurfaceGenerator(DriWrapper* dri) : GbmSurfaceGenerator(dri) {}
72 virtual ~GbmEglImageSurfaceGenerator() {}
73
74 virtual ScanoutSurface* Create(const gfx::Size& size) OVERRIDE {
75 GbmBuffer* buffer = new GbmBuffer(device_, dri_, size);
76 if (!buffer->InitializeBuffer(SurfaceFactoryOzone::RGBA_8888, true)) {
77 ScanoutSurface* surf = buffer;
alexst (slow to review) 2014/07/08 17:22:32 Why the temp assignment here?
achaulk 2014/07/08 18:16:37 GbmBuffer is non-deletable because of the refcount
alexst (slow to review) 2014/07/08 21:28:37 I see. It's subtle, though, can we make something
achaulk 2014/07/08 21:36:12 I suppose that works just as well. We already have
achaulk 2014/07/08 21:38:52 I spoke too soon. Compiler says no ../../base/mac
78 delete surf;
79 return NULL;
80 }
81 return buffer;
82 }
83 };
84
68 class OzonePlatformGbm : public OzonePlatform { 85 class OzonePlatformGbm : public OzonePlatform {
69 public: 86 public:
70 OzonePlatformGbm() { 87 OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {
71 base::AtExitManager::RegisterTask( 88 base::AtExitManager::RegisterTask(
72 base::Bind(&base::DeletePointer<OzonePlatformGbm>, this)); 89 base::Bind(&base::DeletePointer<OzonePlatformGbm>, this));
73 } 90 }
74 virtual ~OzonePlatformGbm() {} 91 virtual ~OzonePlatformGbm() {}
75 92
76 // OzonePlatform: 93 // OzonePlatform:
77 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { 94 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE {
78 return surface_factory_ozone_.get(); 95 return surface_factory_ozone_.get();
79 } 96 }
80 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { 97 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE {
(...skipping 16 matching lines...) Expand all
97 virtual scoped_ptr<TouchscreenDeviceManager> 114 virtual scoped_ptr<TouchscreenDeviceManager>
98 CreateTouchscreenDeviceManager() OVERRIDE { 115 CreateTouchscreenDeviceManager() OVERRIDE {
99 return scoped_ptr<TouchscreenDeviceManager>( 116 return scoped_ptr<TouchscreenDeviceManager>(
100 new TouchscreenDeviceManagerOzone()); 117 new TouchscreenDeviceManagerOzone());
101 } 118 }
102 #endif 119 #endif
103 virtual void InitializeUI() OVERRIDE { 120 virtual void InitializeUI() OVERRIDE {
104 vt_manager_.reset(new VirtualTerminalManager()); 121 vt_manager_.reset(new VirtualTerminalManager());
105 // Needed since the browser process creates the accelerated widgets and that 122 // Needed since the browser process creates the accelerated widgets and that
106 // happens through SFO. 123 // happens through SFO.
107 surface_factory_ozone_.reset(new GbmSurfaceFactory()); 124 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_));
108 125
109 device_manager_ = CreateDeviceManager(); 126 device_manager_ = CreateDeviceManager();
110 gpu_platform_support_host_.reset(new GpuPlatformSupportHostGbm()); 127 gpu_platform_support_host_.reset(new GpuPlatformSupportHostGbm());
111 cursor_factory_ozone_.reset( 128 cursor_factory_ozone_.reset(
112 new CursorFactoryEvdevDri(gpu_platform_support_host_.get())); 129 new CursorFactoryEvdevDri(gpu_platform_support_host_.get()));
113 event_factory_ozone_.reset(new EventFactoryEvdev( 130 event_factory_ozone_.reset(new EventFactoryEvdev(
114 cursor_factory_ozone_.get(), device_manager_.get())); 131 cursor_factory_ozone_.get(), device_manager_.get()));
115 } 132 }
116 133
117 virtual void InitializeGPU() OVERRIDE { 134 virtual void InitializeGPU() OVERRIDE {
118 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath)); 135 dri_.reset(new DriWrapper(kDefaultGraphicsCardPath));
119 surface_generator_.reset(new GbmSurfaceGenerator(dri_.get())); 136 if (use_surfaceless_)
137 surface_generator_.reset(new GbmEglImageSurfaceGenerator(dri_.get()));
138 else
139 surface_generator_.reset(new GbmSurfaceGenerator(dri_.get()));
120 screen_manager_.reset(new ScreenManager(dri_.get(), 140 screen_manager_.reset(new ScreenManager(dri_.get(),
121 surface_generator_.get())); 141 surface_generator_.get()));
122 if (!surface_factory_ozone_) 142 if (!surface_factory_ozone_)
123 surface_factory_ozone_.reset(new GbmSurfaceFactory()); 143 surface_factory_ozone_.reset(new GbmSurfaceFactory(use_surfaceless_));
124 144
125 surface_factory_ozone_->InitializeGpu(dri_.get(), 145 surface_factory_ozone_->InitializeGpu(dri_.get(),
126 surface_generator_->device(), 146 surface_generator_->device(),
127 screen_manager_.get()); 147 screen_manager_.get());
128 148
129 gpu_platform_support_.reset( 149 gpu_platform_support_.reset(
130 new GpuPlatformSupportGbm(surface_factory_ozone_.get())); 150 new GpuPlatformSupportGbm(surface_factory_ozone_.get()));
131 } 151 }
132 152
133 private: 153 private:
154 bool use_surfaceless_;
134 scoped_ptr<VirtualTerminalManager> vt_manager_; 155 scoped_ptr<VirtualTerminalManager> vt_manager_;
135 scoped_ptr<DriWrapper> dri_; 156 scoped_ptr<DriWrapper> dri_;
136 scoped_ptr<GbmSurfaceGenerator> surface_generator_; 157 scoped_ptr<GbmSurfaceGenerator> surface_generator_;
137 scoped_ptr<ScreenManager> screen_manager_; 158 scoped_ptr<ScreenManager> screen_manager_;
138 scoped_ptr<DeviceManager> device_manager_; 159 scoped_ptr<DeviceManager> device_manager_;
139 160
140 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_; 161 scoped_ptr<GbmSurfaceFactory> surface_factory_ozone_;
141 scoped_ptr<CursorFactoryEvdevDri> cursor_factory_ozone_; 162 scoped_ptr<CursorFactoryEvdevDri> cursor_factory_ozone_;
142 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; 163 scoped_ptr<EventFactoryEvdev> event_factory_ozone_;
143 164
144 scoped_ptr<GpuPlatformSupportGbm> gpu_platform_support_; 165 scoped_ptr<GpuPlatformSupportGbm> gpu_platform_support_;
145 scoped_ptr<GpuPlatformSupportHostGbm> gpu_platform_support_host_; 166 scoped_ptr<GpuPlatformSupportHostGbm> gpu_platform_support_host_;
146 167
147 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm); 168 DISALLOW_COPY_AND_ASSIGN(OzonePlatformGbm);
148 }; 169 };
149 170
150 } // namespace 171 } // namespace
151 172
152 OzonePlatform* CreateOzonePlatformGbm() { return new OzonePlatformGbm; } 173 OzonePlatform* CreateOzonePlatformGbm() {
174 return new OzonePlatformGbm(false);
175 }
176 OzonePlatform* CreateOzonePlatformGbmEglImage() {
177 return new OzonePlatformGbm(true);
178 }
153 179
154 } // namespace ui 180 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698