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

Side by Side Diff: ui/ozone/platform/drm/gpu/gbm_surface_factory.cc

Issue 2393913002: Rename GbmSurfaceFactory::drm_thread_ to GbmSurfaceFactory::drm_thread_proxy_ (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_surface_factory.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/drm/gpu/gbm_surface_factory.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
6 6
7 #include <gbm.h> 7 #include <gbm.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 15 matching lines...) Expand all
26 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 26 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
27 #include "ui/ozone/public/native_pixmap.h" 27 #include "ui/ozone/public/native_pixmap.h"
28 #include "ui/ozone/public/surface_ozone_canvas.h" 28 #include "ui/ozone/public/surface_ozone_canvas.h"
29 29
30 namespace ui { 30 namespace ui {
31 31
32 namespace { 32 namespace {
33 33
34 class GLOzoneEGLGbm : public GLOzoneEGL { 34 class GLOzoneEGLGbm : public GLOzoneEGL {
35 public: 35 public:
36 GLOzoneEGLGbm(GbmSurfaceFactory* surface_factory, DrmThreadProxy* drm_thread) 36 GLOzoneEGLGbm(GbmSurfaceFactory* surface_factory,
37 : surface_factory_(surface_factory), drm_thread_(drm_thread) {} 37 DrmThreadProxy* drm_thread_proxy)
38 : surface_factory_(surface_factory),
39 drm_thread_proxy_(drm_thread_proxy) {}
38 ~GLOzoneEGLGbm() override {} 40 ~GLOzoneEGLGbm() override {}
39 41
40 scoped_refptr<gl::GLSurface> CreateViewGLSurface( 42 scoped_refptr<gl::GLSurface> CreateViewGLSurface(
41 gfx::AcceleratedWidget window) override { 43 gfx::AcceleratedWidget window) override {
42 return gl::InitializeGLSurface(new GbmSurface( 44 return gl::InitializeGLSurface(new GbmSurface(
43 surface_factory_, drm_thread_->CreateDrmWindowProxy(window), window)); 45 surface_factory_, drm_thread_proxy_->CreateDrmWindowProxy(window),
46 window));
44 } 47 }
45 48
46 scoped_refptr<gl::GLSurface> CreateSurfacelessViewGLSurface( 49 scoped_refptr<gl::GLSurface> CreateSurfacelessViewGLSurface(
47 gfx::AcceleratedWidget window) override { 50 gfx::AcceleratedWidget window) override {
48 return gl::InitializeGLSurface(new GbmSurfaceless( 51 return gl::InitializeGLSurface(new GbmSurfaceless(
49 surface_factory_, drm_thread_->CreateDrmWindowProxy(window), window)); 52 surface_factory_, drm_thread_proxy_->CreateDrmWindowProxy(window),
53 window));
50 } 54 }
51 55
52 scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface( 56 scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(
53 const gfx::Size& size) override { 57 const gfx::Size& size) override {
54 DCHECK_EQ(size.width(), 0); 58 DCHECK_EQ(size.width(), 0);
55 DCHECK_EQ(size.height(), 0); 59 DCHECK_EQ(size.height(), 0);
56 return gl::InitializeGLSurface(new gl::SurfacelessEGL(size)); 60 return gl::InitializeGLSurface(new gl::SurfacelessEGL(size));
57 } 61 }
58 62
59 protected: 63 protected:
60 intptr_t GetNativeDisplay() override { return EGL_DEFAULT_DISPLAY; } 64 intptr_t GetNativeDisplay() override { return EGL_DEFAULT_DISPLAY; }
61 65
62 bool LoadGLES2Bindings() override { return LoadDefaultEGLGLES2Bindings(); } 66 bool LoadGLES2Bindings() override { return LoadDefaultEGLGLES2Bindings(); }
63 67
64 private: 68 private:
65 GbmSurfaceFactory* surface_factory_; 69 GbmSurfaceFactory* surface_factory_;
66 DrmThreadProxy* drm_thread_; 70 DrmThreadProxy* drm_thread_proxy_;
67 71
68 DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLGbm); 72 DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLGbm);
69 }; 73 };
70 74
71 } // namespace 75 } // namespace
72 76
73 GbmSurfaceFactory::GbmSurfaceFactory(DrmThreadProxy* drm_thread) 77 GbmSurfaceFactory::GbmSurfaceFactory(DrmThreadProxy* drm_thread_proxy)
74 : egl_implementation_(new GLOzoneEGLGbm(this, drm_thread)), 78 : egl_implementation_(new GLOzoneEGLGbm(this, drm_thread_proxy)),
75 drm_thread_(drm_thread) {} 79 drm_thread_proxy_(drm_thread_proxy) {}
76 80
77 GbmSurfaceFactory::~GbmSurfaceFactory() { 81 GbmSurfaceFactory::~GbmSurfaceFactory() {
78 DCHECK(thread_checker_.CalledOnValidThread()); 82 DCHECK(thread_checker_.CalledOnValidThread());
79 } 83 }
80 84
81 void GbmSurfaceFactory::RegisterSurface(gfx::AcceleratedWidget widget, 85 void GbmSurfaceFactory::RegisterSurface(gfx::AcceleratedWidget widget,
82 GbmSurfaceless* surface) { 86 GbmSurfaceless* surface) {
83 DCHECK(thread_checker_.CalledOnValidThread()); 87 DCHECK(thread_checker_.CalledOnValidThread());
84 widget_to_surface_map_.insert(std::make_pair(widget, surface)); 88 widget_to_surface_map_.insert(std::make_pair(widget, surface));
85 } 89 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 std::unique_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget( 123 std::unique_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget(
120 gfx::AcceleratedWidget widget) { 124 gfx::AcceleratedWidget widget) {
121 DCHECK(thread_checker_.CalledOnValidThread()); 125 DCHECK(thread_checker_.CalledOnValidThread());
122 LOG(ERROR) << "Software rendering mode is not supported with GBM platform"; 126 LOG(ERROR) << "Software rendering mode is not supported with GBM platform";
123 return nullptr; 127 return nullptr;
124 } 128 }
125 129
126 std::vector<gfx::BufferFormat> GbmSurfaceFactory::GetScanoutFormats( 130 std::vector<gfx::BufferFormat> GbmSurfaceFactory::GetScanoutFormats(
127 gfx::AcceleratedWidget widget) { 131 gfx::AcceleratedWidget widget) {
128 std::vector<gfx::BufferFormat> scanout_formats; 132 std::vector<gfx::BufferFormat> scanout_formats;
129 drm_thread_->GetScanoutFormats(widget, &scanout_formats); 133 drm_thread_proxy_->GetScanoutFormats(widget, &scanout_formats);
130 return scanout_formats; 134 return scanout_formats;
131 } 135 }
132 136
133 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( 137 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
134 gfx::AcceleratedWidget widget, 138 gfx::AcceleratedWidget widget,
135 gfx::Size size, 139 gfx::Size size,
136 gfx::BufferFormat format, 140 gfx::BufferFormat format,
137 gfx::BufferUsage usage) { 141 gfx::BufferUsage usage) {
138 #if !defined(OS_CHROMEOS) 142 #if !defined(OS_CHROMEOS)
139 // Support for memory mapping accelerated buffers requires some 143 // Support for memory mapping accelerated buffers requires some
140 // CrOS-specific patches (using dma-buf mmap API). 144 // CrOS-specific patches (using dma-buf mmap API).
141 DCHECK(gfx::BufferUsage::SCANOUT == usage); 145 DCHECK(gfx::BufferUsage::SCANOUT == usage);
142 #endif 146 #endif
143 147
144 scoped_refptr<GbmBuffer> buffer = 148 scoped_refptr<GbmBuffer> buffer =
145 drm_thread_->CreateBuffer(widget, size, format, usage); 149 drm_thread_proxy_->CreateBuffer(widget, size, format, usage);
146 if (!buffer.get()) 150 if (!buffer.get())
147 return nullptr; 151 return nullptr;
148 152
149 return make_scoped_refptr(new GbmPixmap(this, buffer)); 153 return make_scoped_refptr(new GbmPixmap(this, buffer));
150 } 154 }
151 155
152 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle( 156 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmapFromHandle(
153 gfx::AcceleratedWidget widget, 157 gfx::AcceleratedWidget widget,
154 gfx::Size size, 158 gfx::Size size,
155 gfx::BufferFormat format, 159 gfx::BufferFormat format,
156 const gfx::NativePixmapHandle& handle) { 160 const gfx::NativePixmapHandle& handle) {
157 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format); 161 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format);
158 if (handle.planes.size() != num_planes || 162 if (handle.planes.size() != num_planes ||
159 (handle.fds.size() != 1 && handle.fds.size() != num_planes)) { 163 (handle.fds.size() != 1 && handle.fds.size() != num_planes)) {
160 return nullptr; 164 return nullptr;
161 } 165 }
162 std::vector<base::ScopedFD> scoped_fds; 166 std::vector<base::ScopedFD> scoped_fds;
163 for (auto& fd : handle.fds) { 167 for (auto& fd : handle.fds) {
164 scoped_fds.emplace_back(fd.fd); 168 scoped_fds.emplace_back(fd.fd);
165 } 169 }
166 170
167 std::vector<gfx::NativePixmapPlane> planes; 171 std::vector<gfx::NativePixmapPlane> planes;
168 172
169 for (const auto& plane : handle.planes) { 173 for (const auto& plane : handle.planes) {
170 planes.push_back(plane); 174 planes.push_back(plane);
171 } 175 }
172 176
173 scoped_refptr<GbmBuffer> buffer = drm_thread_->CreateBufferFromFds( 177 scoped_refptr<GbmBuffer> buffer = drm_thread_proxy_->CreateBufferFromFds(
174 widget, size, format, std::move(scoped_fds), planes); 178 widget, size, format, std::move(scoped_fds), planes);
175 if (!buffer) 179 if (!buffer)
176 return nullptr; 180 return nullptr;
177 return make_scoped_refptr(new GbmPixmap(this, buffer)); 181 return make_scoped_refptr(new GbmPixmap(this, buffer));
178 } 182 }
179 183
180 } // namespace ui 184 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_surface_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698