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/gl_gl_api_implementation.cc

Issue 139013008: Implement support for rendering to 32-bit float textures on ES3 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Restore compatibility with clients using unsized formats Created 6 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/gl_context_stub.cc ('k') | ui/gl/gl_version_info.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gl_gl_api_implementation.h" 5 #include "ui/gl/gl_gl_api_implementation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "ui/gl/gl_context.h" 12 #include "ui/gl/gl_context.h"
13 #include "ui/gl/gl_implementation.h" 13 #include "ui/gl/gl_implementation.h"
14 #include "ui/gl/gl_state_restorer.h" 14 #include "ui/gl/gl_state_restorer.h"
15 #include "ui/gl/gl_surface.h" 15 #include "ui/gl/gl_surface.h"
16 #include "ui/gl/gl_switches.h" 16 #include "ui/gl/gl_switches.h"
17 #include "ui/gl/gl_version_info.h"
17 18
18 namespace gfx { 19 namespace gfx {
19 20
20 // The GL Api being used. This could be g_real_gl or gl_trace_gl 21 // The GL Api being used. This could be g_real_gl or gl_trace_gl
21 static GLApi* g_gl; 22 static GLApi* g_gl;
22 // A GL Api that calls directly into the driver. 23 // A GL Api that calls directly into the driver.
23 static RealGLApi* g_real_gl; 24 static RealGLApi* g_real_gl;
24 // A GL Api that calls TRACE and then calls another GL api. 25 // A GL Api that calls TRACE and then calls another GL api.
25 static TraceGLApi* g_trace_gl; 26 static TraceGLApi* g_trace_gl;
27 // GL version used when initializing dynamic bindings.
28 static GLVersionInfo* g_version_info = NULL;
26 29
27 namespace { 30 namespace {
28 31
29 static inline GLenum GetInternalFormat(GLenum internal_format) { 32 static inline GLenum GetInternalFormat(GLenum internal_format) {
30 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 33 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
31 if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT) 34 if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT)
32 return GL_RGBA8; 35 return GL_RGBA8;
33 } 36 }
34 return internal_format; 37 return internal_format;
35 } 38 }
36 39
37 // TODO(epenner): Could the above function be merged into this and removed? 40 // TODO(epenner): Could the above function be merged into this and removed?
38 static inline GLenum GetTexInternalFormat(GLenum internal_format, 41 static inline GLenum GetTexInternalFormat(GLenum internal_format,
39 GLenum format, 42 GLenum format,
40 GLenum type) { 43 GLenum type) {
41 GLenum gl_internal_format = GetInternalFormat(internal_format); 44 GLenum gl_internal_format = GetInternalFormat(internal_format);
42 45
43 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) 46 // g_version_info must be initialized when this function is bound.
47 DCHECK(gfx::g_version_info);
48 if (type == GL_FLOAT && gfx::g_version_info->is_angle &&
49 gfx::g_version_info->is_es2) {
50 // It's possible that the texture is using a sized internal format, and
51 // ANGLE exposing GLES2 API doesn't support those.
piman 2014/02/12 21:04:08 nit: file a bug and reference here, so that we can
52 switch (format) {
53 case GL_RGBA:
54 gl_internal_format = GL_RGBA;
55 break;
56 case GL_RGB:
57 gl_internal_format = GL_RGB;
58 break;
59 default:
60 break;
61 }
62 }
63
64 if (gfx::g_version_info->is_es)
44 return gl_internal_format; 65 return gl_internal_format;
45 66
46 if (type == GL_FLOAT) { 67 if (type == GL_FLOAT) {
47 switch (format) { 68 switch (format) {
48 case GL_RGBA: 69 case GL_RGBA:
49 gl_internal_format = GL_RGBA32F_ARB; 70 gl_internal_format = GL_RGBA32F_ARB;
50 break; 71 break;
51 case GL_RGB: 72 case GL_RGB:
52 gl_internal_format = GL_RGB32F_ARB; 73 gl_internal_format = GL_RGB32F_ARB;
53 break; 74 break;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void SetGLApi(GLApi* api) { 222 void SetGLApi(GLApi* api) {
202 g_current_gl_context_tls->Set(api); 223 g_current_gl_context_tls->Set(api);
203 } 224 }
204 225
205 void SetGLToRealGLApi() { 226 void SetGLToRealGLApi() {
206 SetGLApi(g_gl); 227 SetGLApi(g_gl);
207 } 228 }
208 229
209 void InitializeDynamicGLBindingsGL(GLContext* context) { 230 void InitializeDynamicGLBindingsGL(GLContext* context) {
210 g_driver_gl.InitializeCustomDynamicBindings(context); 231 g_driver_gl.InitializeCustomDynamicBindings(context);
232 DCHECK(context && context->IsCurrent(NULL) && !g_version_info);
233 g_version_info = new GLVersionInfo(context->GetGLVersion().c_str(),
234 context->GetGLRenderer().c_str());
211 } 235 }
212 236
213 void InitializeDebugGLBindingsGL() { 237 void InitializeDebugGLBindingsGL() {
214 g_driver_gl.InitializeDebugBindings(); 238 g_driver_gl.InitializeDebugBindings();
215 } 239 }
216 240
217 void InitializeNullDrawGLBindingsGL() { 241 void InitializeNullDrawGLBindingsGL() {
218 g_driver_gl.InitializeNullDrawBindings(); 242 g_driver_gl.InitializeNullDrawBindings();
219 } 243 }
220 244
221 void ClearGLBindingsGL() { 245 void ClearGLBindingsGL() {
222 if (g_real_gl) { 246 if (g_real_gl) {
223 delete g_real_gl; 247 delete g_real_gl;
224 g_real_gl = NULL; 248 g_real_gl = NULL;
225 } 249 }
226 if (g_trace_gl) { 250 if (g_trace_gl) {
227 delete g_trace_gl; 251 delete g_trace_gl;
228 g_trace_gl = NULL; 252 g_trace_gl = NULL;
229 } 253 }
230 g_gl = NULL; 254 g_gl = NULL;
231 g_driver_gl.ClearBindings(); 255 g_driver_gl.ClearBindings();
232 if (g_current_gl_context_tls) { 256 if (g_current_gl_context_tls) {
233 delete g_current_gl_context_tls; 257 delete g_current_gl_context_tls;
234 g_current_gl_context_tls = NULL; 258 g_current_gl_context_tls = NULL;
235 } 259 }
260 if (g_version_info) {
261 delete g_version_info;
262 g_version_info = NULL;
263 }
236 } 264 }
237 265
238 GLApi::GLApi() { 266 GLApi::GLApi() {
239 } 267 }
240 268
241 GLApi::~GLApi() { 269 GLApi::~GLApi() {
242 if (GetCurrentGLApi() == this) 270 if (GetCurrentGLApi() == this)
243 SetGLApi(NULL); 271 SetGLApi(NULL);
244 } 272 }
245 273
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { 378 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
351 switch (name) { 379 switch (name) {
352 case GL_EXTENSIONS: 380 case GL_EXTENSIONS:
353 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); 381 return reinterpret_cast<const GLubyte*>(extensions_.c_str());
354 default: 382 default:
355 return driver_->fn.glGetStringFn(name); 383 return driver_->fn.glGetStringFn(name);
356 } 384 }
357 } 385 }
358 386
359 } // namespace gfx 387 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context_stub.cc ('k') | ui/gl/gl_version_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698