Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 // A GL Api that calls TRACE and then calls another GL api. | 29 // A GL Api that calls TRACE and then calls another GL api. |
| 30 static TraceGLApi* g_trace_gl = NULL; | 30 static TraceGLApi* g_trace_gl = NULL; |
| 31 // The GL Api being used for stub contexts. If null, g_gl is used instead. | 31 // The GL Api being used for stub contexts. If null, g_gl is used instead. |
| 32 static GLApi* g_stub_gl = NULL; | 32 static GLApi* g_stub_gl = NULL; |
| 33 // GL version used when initializing dynamic bindings. | 33 // GL version used when initializing dynamic bindings. |
| 34 static GLVersionInfo* g_version_info = NULL; | 34 static GLVersionInfo* g_version_info = NULL; |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 static inline GLenum GetInternalFormat(GLenum internal_format) { | 38 static inline GLenum GetInternalFormat(GLenum internal_format) { |
| 39 if (GetGLImplementation() != kGLImplementationEGLGLES2) { | 39 if (!g_version_info->is_es) { |
| 40 if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT) | 40 if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT) |
| 41 return GL_RGBA8; | 41 return GL_RGBA8; |
| 42 } | 42 } |
| 43 if (g_version_info->is_es && g_version_info->is_mesa) { | |
| 44 // Mesa bug workaround: Mipmapping does not work when using GL_BGRA_EXT | |
| 45 if (internal_format == GL_BGRA_EXT) | |
| 46 return GL_RGBA; | |
|
piman
2016/07/21 16:31:37
This isn't valid on ES2. Did you mean to restrict
Justin Novosad
2016/07/21 17:33:56
Right, because it would violate the internal == ex
| |
| 47 } | |
| 43 return internal_format; | 48 return internal_format; |
| 44 } | 49 } |
| 45 | 50 |
| 46 // TODO(epenner): Could the above function be merged into this and removed? | 51 // TODO(epenner): Could the above function be merged into this and removed? |
| 47 static inline GLenum GetTexInternalFormat(GLenum internal_format, | 52 static inline GLenum GetTexInternalFormat(GLenum internal_format, |
| 48 GLenum format, | 53 GLenum format, |
| 49 GLenum type) { | 54 GLenum type) { |
| 55 DCHECK(g_version_info); | |
| 50 GLenum gl_internal_format = GetInternalFormat(internal_format); | 56 GLenum gl_internal_format = GetInternalFormat(internal_format); |
| 51 | 57 |
| 52 // g_version_info must be initialized when this function is bound. | 58 // g_version_info must be initialized when this function is bound. |
| 53 DCHECK(g_version_info); | |
| 54 if (g_version_info->is_es3) { | 59 if (g_version_info->is_es3) { |
| 55 if (internal_format == GL_RED_EXT) { | 60 if (internal_format == GL_RED_EXT) { |
| 56 // GL_EXT_texture_rg case in ES2. | 61 // GL_EXT_texture_rg case in ES2. |
| 57 switch (type) { | 62 switch (type) { |
| 58 case GL_UNSIGNED_BYTE: | 63 case GL_UNSIGNED_BYTE: |
| 59 gl_internal_format = GL_R8_EXT; | 64 gl_internal_format = GL_R8_EXT; |
| 60 break; | 65 break; |
| 61 case GL_HALF_FLOAT_OES: | 66 case GL_HALF_FLOAT_OES: |
| 62 gl_internal_format = GL_R16F_EXT; | 67 gl_internal_format = GL_R16F_EXT; |
| 63 break; | 68 break; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 TraceGLApi::~TraceGLApi() { | 568 TraceGLApi::~TraceGLApi() { |
| 564 } | 569 } |
| 565 | 570 |
| 566 NoContextGLApi::NoContextGLApi() { | 571 NoContextGLApi::NoContextGLApi() { |
| 567 } | 572 } |
| 568 | 573 |
| 569 NoContextGLApi::~NoContextGLApi() { | 574 NoContextGLApi::~NoContextGLApi() { |
| 570 } | 575 } |
| 571 | 576 |
| 572 } // namespace gl | 577 } // namespace gl |
| OLD | NEW |