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

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

Issue 2327813002: Convert Ozone GBM to use GLOzone. (Closed)
Patch Set: Typo. Created 4 years, 3 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
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "third_party/khronos/EGL/egl.h" 14 #include "third_party/khronos/EGL/egl.h"
15 #include "ui/gfx/buffer_format_util.h" 15 #include "ui/gfx/buffer_format_util.h"
16 #include "ui/gl/gl_surface_egl.h" 16 #include "ui/gl/gl_surface_egl.h"
17 #include "ui/ozone/common/egl_util.h" 17 #include "ui/ozone/common/egl_util.h"
18 #include "ui/ozone/common/gl_ozone_egl.h"
18 #include "ui/ozone/platform/drm/common/drm_util.h" 19 #include "ui/ozone/platform/drm/common/drm_util.h"
19 #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h" 20 #include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h"
20 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" 21 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
21 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" 22 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
22 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" 23 #include "ui/ozone/platform/drm/gpu/gbm_surface.h"
23 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" 24 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h"
24 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" 25 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
25 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 26 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
26 #include "ui/ozone/public/native_pixmap.h" 27 #include "ui/ozone/public/native_pixmap.h"
27 #include "ui/ozone/public/surface_ozone_canvas.h" 28 #include "ui/ozone/public/surface_ozone_canvas.h"
28 29
29 namespace ui { 30 namespace ui {
30 31
32 namespace {
33
34 class GLOzoneEGLGbm : public GLOzoneEGL {
35 public:
36 GLOzoneEGLGbm(GbmSurfaceFactory* surface_factory, DrmThreadProxy* drm_thread)
37 : surface_factory_(surface_factory), drm_thread_(drm_thread) {}
38 ~GLOzoneEGLGbm() override {}
39
40 scoped_refptr<gl::GLSurface> CreateViewGLSurface(
41 gfx::AcceleratedWidget window) override {
42 return gl::InitializeGLSurface(new GbmSurface(
43 surface_factory_, drm_thread_->CreateDrmWindowProxy(window), window));
44 }
45
46 scoped_refptr<gl::GLSurface> CreateSurfacelessViewGLSurface(
47 gfx::AcceleratedWidget window) override {
48 return gl::InitializeGLSurface(new GbmSurfaceless(
49 surface_factory_, drm_thread_->CreateDrmWindowProxy(window), window));
50 }
51
52 scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(
53 const gfx::Size& size) override {
54 DCHECK_EQ(size.width(), 0);
55 DCHECK_EQ(size.height(), 0);
56 return gl::InitializeGLSurface(new gl::SurfacelessEGL(size));
57 }
58
59 protected:
60 intptr_t GetNativeDisplay() override { return EGL_DEFAULT_DISPLAY; }
61
62 bool LoadGLES2Bindings() override { return LoadDefaultEGLGLES2Bindings(); }
63
64 private:
65 GbmSurfaceFactory* surface_factory_;
66 DrmThreadProxy* drm_thread_;
67
68 DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLGbm);
69 };
70
71 } // namespace
72
31 GbmSurfaceFactory::GbmSurfaceFactory(DrmThreadProxy* drm_thread) 73 GbmSurfaceFactory::GbmSurfaceFactory(DrmThreadProxy* drm_thread)
32 : drm_thread_(drm_thread) {} 74 : egl_implementation_(new GLOzoneEGLGbm(this, drm_thread)),
75 drm_thread_(drm_thread) {}
33 76
34 GbmSurfaceFactory::~GbmSurfaceFactory() { 77 GbmSurfaceFactory::~GbmSurfaceFactory() {
35 DCHECK(thread_checker_.CalledOnValidThread()); 78 DCHECK(thread_checker_.CalledOnValidThread());
36 } 79 }
37 80
38 void GbmSurfaceFactory::RegisterSurface(gfx::AcceleratedWidget widget, 81 void GbmSurfaceFactory::RegisterSurface(gfx::AcceleratedWidget widget,
39 GbmSurfaceless* surface) { 82 GbmSurfaceless* surface) {
40 DCHECK(thread_checker_.CalledOnValidThread()); 83 DCHECK(thread_checker_.CalledOnValidThread());
41 widget_to_surface_map_.insert(std::make_pair(widget, surface)); 84 widget_to_surface_map_.insert(std::make_pair(widget, surface));
42 } 85 }
43 86
44 void GbmSurfaceFactory::UnregisterSurface(gfx::AcceleratedWidget widget) { 87 void GbmSurfaceFactory::UnregisterSurface(gfx::AcceleratedWidget widget) {
45 DCHECK(thread_checker_.CalledOnValidThread()); 88 DCHECK(thread_checker_.CalledOnValidThread());
46 widget_to_surface_map_.erase(widget); 89 widget_to_surface_map_.erase(widget);
47 } 90 }
48 91
49 GbmSurfaceless* GbmSurfaceFactory::GetSurface( 92 GbmSurfaceless* GbmSurfaceFactory::GetSurface(
50 gfx::AcceleratedWidget widget) const { 93 gfx::AcceleratedWidget widget) const {
51 DCHECK(thread_checker_.CalledOnValidThread()); 94 DCHECK(thread_checker_.CalledOnValidThread());
52 auto it = widget_to_surface_map_.find(widget); 95 auto it = widget_to_surface_map_.find(widget);
53 DCHECK(it != widget_to_surface_map_.end()); 96 DCHECK(it != widget_to_surface_map_.end());
54 return it->second; 97 return it->second;
55 } 98 }
56 99
57 scoped_refptr<gl::GLSurface> GbmSurfaceFactory::CreateViewGLSurface( 100 std::vector<gl::GLImplementation>
58 gl::GLImplementation implementation, 101 GbmSurfaceFactory::GetAllowedGLImplementations() {
59 gfx::AcceleratedWidget widget) {
60 DCHECK(thread_checker_.CalledOnValidThread()); 102 DCHECK(thread_checker_.CalledOnValidThread());
61 103 std::vector<gl::GLImplementation> impls;
62 if (implementation != gl::kGLImplementationEGLGLES2) { 104 impls.push_back(gl::kGLImplementationEGLGLES2);
63 NOTREACHED(); 105 impls.push_back(gl::kGLImplementationOSMesaGL);
64 return nullptr; 106 return impls;
65 }
66
67 return gl::InitializeGLSurface(
68 new GbmSurface(this, drm_thread_->CreateDrmWindowProxy(widget), widget));
69 } 107 }
70 108
71 scoped_refptr<gl::GLSurface> GbmSurfaceFactory::CreateSurfacelessViewGLSurface( 109 GLOzone* GbmSurfaceFactory::GetGLOzone(gl::GLImplementation implementation) {
72 gl::GLImplementation implementation,
73 gfx::AcceleratedWidget widget) {
74 DCHECK(thread_checker_.CalledOnValidThread()); 110 DCHECK(thread_checker_.CalledOnValidThread());
75 111 switch (implementation) {
76 if (implementation != gl::kGLImplementationEGLGLES2) { 112 case gl::kGLImplementationEGLGLES2:
77 NOTREACHED(); 113 return egl_implementation_.get();
78 return nullptr; 114 default:
115 return nullptr;
79 } 116 }
80
81 return gl::InitializeGLSurface(new GbmSurfaceless(
82 this, drm_thread_->CreateDrmWindowProxy(widget), widget));
83 }
84
85 scoped_refptr<gl::GLSurface> GbmSurfaceFactory::CreateOffscreenGLSurface(
86 gl::GLImplementation implementation,
87 const gfx::Size& size) {
88 DCHECK(thread_checker_.CalledOnValidThread());
89
90 if (implementation != gl::kGLImplementationEGLGLES2) {
91 NOTREACHED();
92 return nullptr;
93 }
94
95 DCHECK_EQ(size.width(), 0);
96 DCHECK_EQ(size.height(), 0);
97
98 return gl::InitializeGLSurface(new gl::SurfacelessEGL(size));
99 }
100
101 intptr_t GbmSurfaceFactory::GetNativeDisplay() {
102 DCHECK(thread_checker_.CalledOnValidThread());
103 return EGL_DEFAULT_DISPLAY;
104 }
105
106 bool GbmSurfaceFactory::LoadEGLGLES2Bindings() {
107 DCHECK(thread_checker_.CalledOnValidThread());
108 return LoadDefaultEGLGLES2Bindings();
109 } 117 }
110 118
111 std::unique_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget( 119 std::unique_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget(
112 gfx::AcceleratedWidget widget) { 120 gfx::AcceleratedWidget widget) {
113 DCHECK(thread_checker_.CalledOnValidThread()); 121 DCHECK(thread_checker_.CalledOnValidThread());
114 LOG(ERROR) << "Software rendering mode is not supported with GBM platform"; 122 LOG(ERROR) << "Software rendering mode is not supported with GBM platform";
115 return nullptr; 123 return nullptr;
116 } 124 }
117 125
118 std::vector<gfx::BufferFormat> GbmSurfaceFactory::GetScanoutFormats( 126 std::vector<gfx::BufferFormat> GbmSurfaceFactory::GetScanoutFormats(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 171 }
164 172
165 scoped_refptr<GbmBuffer> buffer = drm_thread_->CreateBufferFromFds( 173 scoped_refptr<GbmBuffer> buffer = drm_thread_->CreateBufferFromFds(
166 widget, size, format, std::move(scoped_fds), planes); 174 widget, size, format, std::move(scoped_fds), planes);
167 if (!buffer) 175 if (!buffer)
168 return nullptr; 176 return nullptr;
169 return make_scoped_refptr(new GbmPixmap(this, buffer)); 177 return make_scoped_refptr(new GbmPixmap(this, buffer));
170 } 178 }
171 179
172 } // namespace ui 180 } // 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