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

Side by Side Diff: ui/gl/init/gl_factory_ozone.cc

Issue 2190353003: Delete old Ozone surface creation API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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/gl/init/BUILD.gn ('k') | ui/gl/init/gl_init.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/gl/init/gl_factory.h" 5 #include "ui/gl/init/gl_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "ui/gl/gl_context.h" 9 #include "ui/gl/gl_context.h"
10 #include "ui/gl/gl_context_egl.h" 10 #include "ui/gl/gl_context_egl.h"
11 #include "ui/gl/gl_context_osmesa.h" 11 #include "ui/gl/gl_context_osmesa.h"
12 #include "ui/gl/gl_context_stub.h" 12 #include "ui/gl/gl_context_stub.h"
13 #include "ui/gl/gl_egl_api_implementation.h" 13 #include "ui/gl/gl_egl_api_implementation.h"
14 #include "ui/gl/gl_implementation.h" 14 #include "ui/gl/gl_implementation.h"
15 #include "ui/gl/gl_share_group.h" 15 #include "ui/gl/gl_share_group.h"
16 #include "ui/gl/gl_surface.h" 16 #include "ui/gl/gl_surface.h"
17 #include "ui/gl/gl_surface_egl.h" 17 #include "ui/gl/gl_surface_egl.h"
18 #include "ui/gl/gl_surface_osmesa.h" 18 #include "ui/gl/gl_surface_osmesa.h"
19 #include "ui/gl/gl_surface_stub.h" 19 #include "ui/gl/gl_surface_stub.h"
20 #include "ui/gl/init/gl_surface_ozone.h"
21 #include "ui/ozone/public/ozone_platform.h" 20 #include "ui/ozone/public/ozone_platform.h"
22 #include "ui/ozone/public/surface_factory_ozone.h" 21 #include "ui/ozone/public/surface_factory_ozone.h"
23 #include "ui/ozone/public/surface_ozone_egl.h"
24 22
25 namespace gl { 23 namespace gl {
26 namespace init { 24 namespace init {
27 25
28 namespace { 26 namespace {
29 27
30 ui::SurfaceFactoryOzone* GetSurfaceFactory() { 28 ui::SurfaceFactoryOzone* GetSurfaceFactory() {
31 return ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); 29 return ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
32 } 30 }
33 31
(...skipping 21 matching lines...) Expand all
55 return InitializeGLSurface( 53 return InitializeGLSurface(
56 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_BGRA, size)); 54 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_BGRA, size));
57 case kGLImplementationMockGL: 55 case kGLImplementationMockGL:
58 return InitializeGLSurface(new GLSurfaceStub); 56 return InitializeGLSurface(new GLSurfaceStub);
59 default: 57 default:
60 NOTREACHED(); 58 NOTREACHED();
61 } 59 }
62 return nullptr; 60 return nullptr;
63 } 61 }
64 62
65 // TODO(kylechar): Remove when all implementations are switched over.
66 scoped_refptr<GLSurface> CreateViewGLSurfaceOld(gfx::AcceleratedWidget window) {
67 switch (GetGLImplementation()) {
68 case kGLImplementationEGLGLES2:
69 DCHECK_NE(window, gfx::kNullAcceleratedWidget);
70 return CreateViewGLSurfaceOzone(window);
71 default:
72 NOTREACHED();
73 }
74 return nullptr;
75 }
76
77 // TODO(kylechar): Remove when all implementations are switched over.
78 scoped_refptr<GLSurface> CreateOffscreenGLSurfaceOld(const gfx::Size& size) {
79 switch (GetGLImplementation()) {
80 case kGLImplementationEGLGLES2:
81 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
82 (size.width() == 0 && size.height() == 0)) {
83 return InitializeGLSurface(new SurfacelessEGL(size));
84 } else {
85 return InitializeGLSurface(new PbufferGLSurfaceEGL(size));
86 }
87 default:
88 NOTREACHED();
89 }
90 return nullptr;
91 }
92
93 } // namespace 63 } // namespace
94 64
95 std::vector<GLImplementation> GetAllowedGLImplementations() { 65 std::vector<GLImplementation> GetAllowedGLImplementations() {
96 std::vector<GLImplementation> impls; 66 std::vector<GLImplementation> impls;
97 impls.push_back(kGLImplementationEGLGLES2); 67 impls.push_back(kGLImplementationEGLGLES2);
98 impls.push_back(kGLImplementationOSMesaGL); 68 impls.push_back(kGLImplementationOSMesaGL);
99 return impls; 69 return impls;
100 } 70 }
101 71
102 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { 72 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
(...skipping 11 matching lines...) Expand all
114 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); 84 TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
115 switch (GetGLImplementation()) { 85 switch (GetGLImplementation()) {
116 case kGLImplementationMockGL: 86 case kGLImplementationMockGL:
117 return scoped_refptr<GLContext>(new GLContextStub(share_group)); 87 return scoped_refptr<GLContext>(new GLContextStub(share_group));
118 case kGLImplementationOSMesaGL: 88 case kGLImplementationOSMesaGL:
119 return InitializeGLContext(new GLContextOSMesa(share_group), 89 return InitializeGLContext(new GLContextOSMesa(share_group),
120 compatible_surface, gpu_preference); 90 compatible_surface, gpu_preference);
121 case kGLImplementationEGLGLES2: 91 case kGLImplementationEGLGLES2:
122 return InitializeGLContext(new GLContextEGL(share_group), 92 return InitializeGLContext(new GLContextEGL(share_group),
123 compatible_surface, gpu_preference); 93 compatible_surface, gpu_preference);
124
125 default: 94 default:
126 NOTREACHED(); 95 NOTREACHED();
127 return nullptr;
128 } 96 }
97 return nullptr;
129 } 98 }
130 99
131 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { 100 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
132 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); 101 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
133 102
134 if (HasDefaultImplementation(GetGLImplementation())) 103 if (HasDefaultImplementation(GetGLImplementation()))
135 return CreateDefaultViewGLSurface(window); 104 return CreateDefaultViewGLSurface(window);
136 105
137 // TODO(kylechar): This is deprecated, remove when possible.
138 if (!GetSurfaceFactory()->UseNewSurfaceAPI())
139 return CreateViewGLSurfaceOld(window);
140
141 return GetSurfaceFactory()->CreateViewGLSurface(GetGLImplementation(), 106 return GetSurfaceFactory()->CreateViewGLSurface(GetGLImplementation(),
142 window); 107 window);
143 } 108 }
144 109
145 scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( 110 scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface(
146 gfx::AcceleratedWidget window) { 111 gfx::AcceleratedWidget window) {
147 TRACE_EVENT0("gpu", "gl::init::CreateSurfacelessViewGLSurface"); 112 TRACE_EVENT0("gpu", "gl::init::CreateSurfacelessViewGLSurface");
148 113
149 return GetSurfaceFactory()->CreateSurfacelessViewGLSurface( 114 return GetSurfaceFactory()->CreateSurfacelessViewGLSurface(
150 GetGLImplementation(), window); 115 GetGLImplementation(), window);
151 } 116 }
152 117
153 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) { 118 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) {
154 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); 119 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
155 120
156 if (HasDefaultImplementation(GetGLImplementation())) 121 if (HasDefaultImplementation(GetGLImplementation()))
157 return CreateDefaultOffscreenGLSurface(size); 122 return CreateDefaultOffscreenGLSurface(size);
158 123
159 // TODO(kylechar): This is deprecated, remove when possible.
160 if (!GetSurfaceFactory()->UseNewSurfaceAPI())
161 return CreateOffscreenGLSurfaceOld(size);
162
163 return GetSurfaceFactory()->CreateOffscreenGLSurface(GetGLImplementation(), 124 return GetSurfaceFactory()->CreateOffscreenGLSurface(GetGLImplementation(),
164 size); 125 size);
165 } 126 }
166 127
167 } // namespace init 128 } // namespace init
168 } // namespace gl 129 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/BUILD.gn ('k') | ui/gl/init/gl_init.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698