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

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

Issue 2629633003: Refactor GL bindings so there is no global GLApi or DriverGL. (Closed)
Patch Set: rebase Created 3 years, 10 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/gpu_timing_unittest.cc ('k') | ui/gl/init/gl_factory_mac.cc » ('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_bindings.h" 9 #include "ui/gl/gl_bindings.h"
10 #include "ui/gl/gl_context.h" 10 #include "ui/gl/gl_context.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 GLNonOwnedContext::GLNonOwnedContext(GLShareGroup* share_group) 53 GLNonOwnedContext::GLNonOwnedContext(GLShareGroup* share_group)
54 : GLContextReal(share_group), display_(nullptr) {} 54 : GLContextReal(share_group), display_(nullptr) {}
55 55
56 bool GLNonOwnedContext::Initialize(GLSurface* compatible_surface, 56 bool GLNonOwnedContext::Initialize(GLSurface* compatible_surface,
57 const GLContextAttribs& attribs) { 57 const GLContextAttribs& attribs) {
58 display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); 58 display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
59 return true; 59 return true;
60 } 60 }
61 61
62 bool GLNonOwnedContext::MakeCurrent(GLSurface* surface) { 62 bool GLNonOwnedContext::MakeCurrent(GLSurface* surface) {
63 SetRealGLApi(); 63 BindGLApi();
64 SetCurrent(surface); 64 SetCurrent(surface);
65 InitializeDynamicBindings(); 65 InitializeDynamicBindings();
66 return true; 66 return true;
67 } 67 }
68 68
69 std::string GLNonOwnedContext::GetExtensions() { 69 std::string GLNonOwnedContext::GetExtensions() {
70 const char* extensions = eglQueryString(display_, EGL_EXTENSIONS); 70 const char* extensions = eglQueryString(display_, EGL_EXTENSIONS);
71 if (!extensions) 71 if (!extensions)
72 return GLContext::GetExtensions(); 72 return GLContext::GetExtensions();
73 73
(...skipping 18 matching lines...) Expand all
92 } 92 }
93 } 93 }
94 94
95 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, 95 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
96 GLSurface* compatible_surface, 96 GLSurface* compatible_surface,
97 const GLContextAttribs& attribs) { 97 const GLContextAttribs& attribs) {
98 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); 98 TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
99 switch (GetGLImplementation()) { 99 switch (GetGLImplementation()) {
100 case kGLImplementationMockGL: 100 case kGLImplementationMockGL:
101 return scoped_refptr<GLContext>(new GLContextStub(share_group)); 101 return scoped_refptr<GLContext>(new GLContextStub(share_group));
102 case kGLImplementationStubGL: {
103 scoped_refptr<GLContextStub> stub_context =
104 new GLContextStub(share_group);
105 stub_context->SetUseStubApi(true);
106 return stub_context;
107 }
102 case kGLImplementationOSMesaGL: 108 case kGLImplementationOSMesaGL:
103 return InitializeGLContext(new GLContextOSMesa(share_group), 109 return InitializeGLContext(new GLContextOSMesa(share_group),
104 compatible_surface, attribs); 110 compatible_surface, attribs);
105 default: 111 default:
106 if (compatible_surface->GetHandle()) { 112 if (compatible_surface->GetHandle()) {
107 return InitializeGLContext(new GLContextEGL(share_group), 113 return InitializeGLContext(new GLContextEGL(share_group),
108 compatible_surface, attribs); 114 compatible_surface, attribs);
109 } else { 115 } else {
110 return InitializeGLContext(new GLNonOwnedContext(share_group), 116 return InitializeGLContext(new GLNonOwnedContext(share_group),
111 compatible_surface, attribs); 117 compatible_surface, attribs);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() && 151 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
146 (size.width() == 0 && size.height() == 0)) { 152 (size.width() == 0 && size.height() == 0)) {
147 return InitializeGLSurfaceWithFormat( 153 return InitializeGLSurfaceWithFormat(
148 new SurfacelessEGL(size), format); 154 new SurfacelessEGL(size), format);
149 } else { 155 } else {
150 return InitializeGLSurfaceWithFormat( 156 return InitializeGLSurfaceWithFormat(
151 new PbufferGLSurfaceEGL(size), format); 157 new PbufferGLSurfaceEGL(size), format);
152 } 158 }
153 } 159 }
154 case kGLImplementationMockGL: 160 case kGLImplementationMockGL:
161 case kGLImplementationStubGL:
155 return new GLSurfaceStub; 162 return new GLSurfaceStub;
156 default: 163 default:
157 NOTREACHED(); 164 NOTREACHED();
158 return nullptr; 165 return nullptr;
159 } 166 }
160 } 167 }
161 168
162 } // namespace init 169 } // namespace init
163 } // namespace gl 170 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gpu_timing_unittest.cc ('k') | ui/gl/init/gl_factory_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698