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

Side by Side Diff: ui/gl/gl_gl_api_implementation.cc

Issue 1881883002: SRGB_EXT is a valid format of texture in WebGL1.0 and ES2.0 contexts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address ken's comment: shrink the context range Created 4 years, 7 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 | « gpu/command_buffer/service/texture_manager.cc ('k') | no next file » | 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 <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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 gl_internal_format = GL_LUMINANCE16F_ARB; 147 gl_internal_format = GL_LUMINANCE16F_ARB;
148 break; 148 break;
149 case GL_ALPHA: 149 case GL_ALPHA:
150 gl_internal_format = GL_ALPHA16F_ARB; 150 gl_internal_format = GL_ALPHA16F_ARB;
151 break; 151 break;
152 default: 152 default:
153 NOTREACHED(); 153 NOTREACHED();
154 break; 154 break;
155 } 155 }
156 } 156 }
157
158 if (gfx::g_version_info->IsAtLeastGL(2, 1) ||
159 gfx::g_version_info->IsAtLeastGLES(3, 0)) {
160 switch (internal_format) {
161 case GL_SRGB_EXT:
162 gl_internal_format = GL_SRGB8;
163 break;
164 case GL_SRGB_ALPHA_EXT:
165 gl_internal_format = GL_SRGB8_ALPHA8;
166 break;
167 default:
168 break;
169 }
170 }
171
157 return gl_internal_format; 172 return gl_internal_format;
158 } 173 }
159 174
175 static inline GLenum GetTexFormat(GLenum format) {
176 GLenum gl_format = format;
177
178 DCHECK(gfx::g_version_info);
179 if (gfx::g_version_info->IsAtLeastGL(2, 1) ||
180 gfx::g_version_info->IsAtLeastGLES(3, 0)) {
181 switch (format) {
182 case GL_SRGB_EXT:
183 gl_format = GL_RGB;
184 break;
185 case GL_SRGB_ALPHA_EXT:
186 gl_format = GL_RGBA;
187 break;
188 default:
189 break;
190 }
191 }
192
193 return gl_format;
194 }
195
160 static inline GLenum GetTexType(GLenum type) { 196 static inline GLenum GetTexType(GLenum type) {
161 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 197 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
162 if (type == GL_HALF_FLOAT_OES) 198 if (type == GL_HALF_FLOAT_OES)
163 return GL_HALF_FLOAT_ARB; 199 return GL_HALF_FLOAT_ARB;
164 } 200 }
165 return type; 201 return type;
166 } 202 }
167 203
168 static void GL_BINDING_CALL CustomTexImage2D( 204 static void GL_BINDING_CALL CustomTexImage2D(
169 GLenum target, GLint level, GLint internalformat, 205 GLenum target, GLint level, GLint internalformat,
170 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, 206 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type,
171 const void* pixels) { 207 const void* pixels) {
172 GLenum gl_internal_format = GetTexInternalFormat( 208 GLenum gl_internal_format = GetTexInternalFormat(
173 internalformat, format, type); 209 internalformat, format, type);
210 GLenum gl_format = GetTexFormat(format);
174 GLenum gl_type = GetTexType(type); 211 GLenum gl_type = GetTexType(type);
175 g_driver_gl.orig_fn.glTexImage2DFn( 212 g_driver_gl.orig_fn.glTexImage2DFn(
176 target, level, gl_internal_format, width, height, border, format, gl_type, 213 target, level, gl_internal_format, width, height, border, gl_format,
177 pixels); 214 gl_type, pixels);
178 } 215 }
179 216
180 static void GL_BINDING_CALL CustomTexSubImage2D( 217 static void GL_BINDING_CALL CustomTexSubImage2D(
181 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, 218 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
182 GLsizei height, GLenum format, GLenum type, const void* pixels) { 219 GLsizei height, GLenum format, GLenum type, const void* pixels) {
220 GLenum gl_format = GetTexFormat(format);
183 GLenum gl_type = GetTexType(type); 221 GLenum gl_type = GetTexType(type);
184 g_driver_gl.orig_fn.glTexSubImage2DFn( 222 g_driver_gl.orig_fn.glTexSubImage2DFn(
185 target, level, xoffset, yoffset, width, height, format, gl_type, pixels); 223 target, level, xoffset, yoffset, width, height, gl_format, gl_type,
224 pixels);
186 } 225 }
187 226
188 static void GL_BINDING_CALL CustomTexStorage2DEXT( 227 static void GL_BINDING_CALL CustomTexStorage2DEXT(
189 GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, 228 GLenum target, GLsizei levels, GLenum internalformat, GLsizei width,
190 GLsizei height) { 229 GLsizei height) {
191 GLenum gl_internal_format = GetInternalFormat(internalformat); 230 GLenum gl_internal_format = GetInternalFormat(internalformat);
192 g_driver_gl.orig_fn.glTexStorage2DEXTFn( 231 g_driver_gl.orig_fn.glTexStorage2DEXTFn(
193 target, levels, gl_internal_format, width, height); 232 target, levels, gl_internal_format, width, height);
194 } 233 }
195 234
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 666
628 void VirtualGLApi::glFlushFn() { 667 void VirtualGLApi::glFlushFn() {
629 GLApiBase::glFlushFn(); 668 GLApiBase::glFlushFn();
630 } 669 }
631 670
632 void VirtualGLApi::glFinishFn() { 671 void VirtualGLApi::glFinishFn() {
633 GLApiBase::glFinishFn(); 672 GLApiBase::glFinishFn();
634 } 673 }
635 674
636 } // namespace gfx 675 } // namespace gfx
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698