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

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 zhenyao's comment: mapping format when context is not es2. 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->is_es2)) {
Ken Russell (switch to Gerrit) 2016/05/02 21:16:48 This negative if-statement is pretty broad and I t
xinghua.cao 2016/05/04 02:55:41 Done.
159 switch (internal_format) {
160 case GL_SRGB_EXT:
161 gl_internal_format = GL_SRGB8;
162 break;
163 case GL_SRGB_ALPHA_EXT:
164 gl_internal_format = GL_SRGB8_ALPHA8;
165 break;
166 default:
167 break;
168 }
169 }
170
157 return gl_internal_format; 171 return gl_internal_format;
158 } 172 }
159 173
174 static inline GLenum GetTexFormat(GLenum format) {
175 GLenum gl_format = format;
176
177 DCHECK(gfx::g_version_info);
178 if (!(gfx::g_version_info->is_es2)) {
Ken Russell (switch to Gerrit) 2016/05/02 21:16:48 Same comment as above in GetTexInternalFormat.
xinghua.cao 2016/05/04 02:55:40 Done.
179 switch (format) {
180 case GL_SRGB_EXT:
181 gl_format = GL_RGB;
182 break;
183 case GL_SRGB_ALPHA_EXT:
184 gl_format = GL_RGBA;
185 break;
186 default:
187 break;
188 }
189 }
190
191 return gl_format;
192 }
193
160 static inline GLenum GetTexType(GLenum type) { 194 static inline GLenum GetTexType(GLenum type) {
161 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 195 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
162 if (type == GL_HALF_FLOAT_OES) 196 if (type == GL_HALF_FLOAT_OES)
163 return GL_HALF_FLOAT_ARB; 197 return GL_HALF_FLOAT_ARB;
164 } 198 }
165 return type; 199 return type;
166 } 200 }
167 201
168 static void GL_BINDING_CALL CustomTexImage2D( 202 static void GL_BINDING_CALL CustomTexImage2D(
169 GLenum target, GLint level, GLint internalformat, 203 GLenum target, GLint level, GLint internalformat,
170 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, 204 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type,
171 const void* pixels) { 205 const void* pixels) {
172 GLenum gl_internal_format = GetTexInternalFormat( 206 GLenum gl_internal_format = GetTexInternalFormat(
173 internalformat, format, type); 207 internalformat, format, type);
208 GLenum gl_format = GetTexFormat(format);
174 GLenum gl_type = GetTexType(type); 209 GLenum gl_type = GetTexType(type);
175 g_driver_gl.orig_fn.glTexImage2DFn( 210 g_driver_gl.orig_fn.glTexImage2DFn(
176 target, level, gl_internal_format, width, height, border, format, gl_type, 211 target, level, gl_internal_format, width, height, border, gl_format,
177 pixels); 212 gl_type, pixels);
178 } 213 }
179 214
180 static void GL_BINDING_CALL CustomTexSubImage2D( 215 static void GL_BINDING_CALL CustomTexSubImage2D(
181 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, 216 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
182 GLsizei height, GLenum format, GLenum type, const void* pixels) { 217 GLsizei height, GLenum format, GLenum type, const void* pixels) {
218 GLenum gl_format = GetTexFormat(format);
183 GLenum gl_type = GetTexType(type); 219 GLenum gl_type = GetTexType(type);
184 g_driver_gl.orig_fn.glTexSubImage2DFn( 220 g_driver_gl.orig_fn.glTexSubImage2DFn(
185 target, level, xoffset, yoffset, width, height, format, gl_type, pixels); 221 target, level, xoffset, yoffset, width, height, gl_format, gl_type,
222 pixels);
186 } 223 }
187 224
188 static void GL_BINDING_CALL CustomTexStorage2DEXT( 225 static void GL_BINDING_CALL CustomTexStorage2DEXT(
189 GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, 226 GLenum target, GLsizei levels, GLenum internalformat, GLsizei width,
190 GLsizei height) { 227 GLsizei height) {
191 GLenum gl_internal_format = GetInternalFormat(internalformat); 228 GLenum gl_internal_format = GetInternalFormat(internalformat);
192 g_driver_gl.orig_fn.glTexStorage2DEXTFn( 229 g_driver_gl.orig_fn.glTexStorage2DEXTFn(
193 target, levels, gl_internal_format, width, height); 230 target, levels, gl_internal_format, width, height);
194 } 231 }
195 232
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 664
628 void VirtualGLApi::glFlushFn() { 665 void VirtualGLApi::glFlushFn() {
629 GLApiBase::glFlushFn(); 666 GLApiBase::glFlushFn();
630 } 667 }
631 668
632 void VirtualGLApi::glFinishFn() { 669 void VirtualGLApi::glFinishFn() {
633 GLApiBase::glFinishFn(); 670 GLApiBase::glFinishFn();
634 } 671 }
635 672
636 } // namespace gfx 673 } // 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