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

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

Issue 2047283003: Move GLSurface creation from //ui/gl to //ui/gl/init. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gl_context
Patch Set: Fix Ozone CreateViewGLSurface logic. Created 4 years, 6 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/gl_factory.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"
11 #include "ui/gl/gl_context_egl.h" 11 #include "ui/gl/gl_context_egl.h"
12 #include "ui/gl/gl_context_osmesa.h" 12 #include "ui/gl/gl_context_osmesa.h"
13 #include "ui/gl/gl_context_stub.h" 13 #include "ui/gl/gl_context_stub.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"
18 #include "ui/gl/gl_surface_osmesa.h"
19 #include "ui/gl/gl_surface_stub.h"
17 20
18 namespace gl { 21 namespace gl {
19 namespace init { 22 namespace init {
20 23
21 namespace { 24 namespace {
22 25
23 // Used to render into an already current context+surface, 26 // Used to render into an already current context+surface,
24 // that we do not have ownership of (draw callback). 27 // that we do not have ownership of (draw callback).
25 // TODO(boliu): Make this inherit from GLContextEGL. 28 // TODO(boliu): Make this inherit from GLContextEGL.
26 class GLNonOwnedContext : public GLContextReal { 29 class GLNonOwnedContext : public GLContextReal {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 65 }
63 66
64 std::string GLNonOwnedContext::GetExtensions() { 67 std::string GLNonOwnedContext::GetExtensions() {
65 const char* extensions = eglQueryString(display_, EGL_EXTENSIONS); 68 const char* extensions = eglQueryString(display_, EGL_EXTENSIONS);
66 if (!extensions) 69 if (!extensions)
67 return GLContext::GetExtensions(); 70 return GLContext::GetExtensions();
68 71
69 return GLContext::GetExtensions() + " " + extensions; 72 return GLContext::GetExtensions() + " " + extensions;
70 } 73 }
71 74
72 } // anonymous namespace 75 } // namespace
73 76
74 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, 77 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
75 GLSurface* compatible_surface, 78 GLSurface* compatible_surface,
76 GpuPreference gpu_preference) { 79 GpuPreference gpu_preference) {
77 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); 80 TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
78 switch (GetGLImplementation()) { 81 switch (GetGLImplementation()) {
79 case kGLImplementationMockGL: 82 case kGLImplementationMockGL:
80 return scoped_refptr<GLContext>(new GLContextStub(share_group)); 83 return scoped_refptr<GLContext>(new GLContextStub(share_group));
81 case kGLImplementationOSMesaGL: 84 case kGLImplementationOSMesaGL:
82 return InitializeGLContext(new GLContextOSMesa(share_group), 85 return InitializeGLContext(new GLContextOSMesa(share_group),
83 compatible_surface, gpu_preference); 86 compatible_surface, gpu_preference);
84 default: 87 default:
85 if (compatible_surface->GetHandle()) { 88 if (compatible_surface->GetHandle()) {
86 return InitializeGLContext(new GLContextEGL(share_group), 89 return InitializeGLContext(new GLContextEGL(share_group),
87 compatible_surface, gpu_preference); 90 compatible_surface, gpu_preference);
88 } else { 91 } else {
89 return InitializeGLContext(new GLNonOwnedContext(share_group), 92 return InitializeGLContext(new GLNonOwnedContext(share_group),
90 compatible_surface, gpu_preference); 93 compatible_surface, gpu_preference);
91 } 94 }
92 } 95 }
93 } 96 }
94 97
98 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
99 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
100 CHECK_NE(kGLImplementationNone, GetGLImplementation());
101 switch (GetGLImplementation()) {
102 case kGLImplementationOSMesaGL:
103 return InitializeGLSurface(new GLSurfaceOSMesaHeadless());
104 case kGLImplementationEGLGLES2:
105 if (window != gfx::kNullAcceleratedWidget) {
106 return InitializeGLSurface(new NativeViewGLSurfaceEGL(window));
107 } else {
108 return InitializeGLSurface(new GLSurfaceStub());
109 }
110 default:
111 NOTREACHED();
112 return nullptr;
113 }
114 }
115
116 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) {
117 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
118 CHECK_NE(kGLImplementationNone, GetGLImplementation());
119 switch (GetGLImplementation()) {
120 case kGLImplementationOSMesaGL: {
121 return InitializeGLSurface(
122 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_BGRA, size));
123 }
124 case kGLImplementationEGLGLES2: {
125 scoped_refptr<GLSurface> surface;
126 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
127 (size.width() == 0 && size.height() == 0)) {
128 return InitializeGLSurface(new SurfacelessEGL(size));
129 } else {
130 return InitializeGLSurface(new PbufferGLSurfaceEGL(size));
131 }
132 }
133 case kGLImplementationMockGL:
134 return new GLSurfaceStub;
135 default:
136 NOTREACHED();
137 return nullptr;
138 }
139 }
140
95 } // namespace init 141 } // namespace init
96 } // namespace gl 142 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/gl_factory.cc ('k') | ui/gl/init/gl_factory_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698