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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2337833002: Implement WEBGL_compressed_texture_s3tc_srgb (Closed)
Patch Set: Implement WEBGL_compressed_texture_s3tc_srgb Created 4 years, 3 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
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 "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 12096 matching lines...) Expand 10 before | Expand all | Expand 10 after
12107 12107
12108 bool GLES2DecoderImpl::GetCompressedTexSizeInBytes( 12108 bool GLES2DecoderImpl::GetCompressedTexSizeInBytes(
12109 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, 12109 const char* function_name, GLsizei width, GLsizei height, GLsizei depth,
12110 GLenum format, GLsizei* size_in_bytes) { 12110 GLenum format, GLsizei* size_in_bytes) {
12111 base::CheckedNumeric<GLsizei> bytes_required(0); 12111 base::CheckedNumeric<GLsizei> bytes_required(0);
12112 12112
12113 switch (format) { 12113 switch (format) {
12114 case GL_ATC_RGB_AMD: 12114 case GL_ATC_RGB_AMD:
12115 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: 12115 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
12116 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: 12116 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
12117 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
12118 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
12117 case GL_ETC1_RGB8_OES: 12119 case GL_ETC1_RGB8_OES:
12118 bytes_required = 12120 bytes_required =
12119 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; 12121 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth;
12120 bytes_required *= 12122 bytes_required *=
12121 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight; 12123 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight;
12122 bytes_required *= kS3TCDXT1BlockSize; 12124 bytes_required *= kS3TCDXT1BlockSize;
12123 break; 12125 break;
12124 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: 12126 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
12125 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: 12127 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
12126 case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: 12128 case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
12161 bytes_required *= 12163 bytes_required *=
12162 (height + kBlockHeight - 1) / kBlockHeight; 12164 (height + kBlockHeight - 1) / kBlockHeight;
12163 12165
12164 bytes_required *= kASTCBlockSize; 12166 bytes_required *= kASTCBlockSize;
12165 break; 12167 break;
12166 } 12168 }
12167 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: 12169 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD:
12168 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: 12170 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
12169 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: 12171 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
12170 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: 12172 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
12173 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
12174 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
12171 bytes_required = 12175 bytes_required =
12172 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; 12176 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth;
12173 bytes_required *= 12177 bytes_required *=
12174 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight; 12178 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight;
12175 bytes_required *= kS3TCDXT3AndDXT5BlockSize; 12179 bytes_required *= kS3TCDXT3AndDXT5BlockSize;
12176 break; 12180 break;
12177 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 12181 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
12178 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 12182 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
12179 bytes_required = std::max(width, 8); 12183 bytes_required = std::max(width, 8);
12180 bytes_required *= std::max(height, 8); 12184 bytes_required *= std::max(height, 8);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
12272 } 12276 }
12273 12277
12274 bool GLES2DecoderImpl::ValidateCompressedTexDimensions( 12278 bool GLES2DecoderImpl::ValidateCompressedTexDimensions(
12275 const char* function_name, GLenum target, GLint level, 12279 const char* function_name, GLenum target, GLint level,
12276 GLsizei width, GLsizei height, GLsizei depth, GLenum format) { 12280 GLsizei width, GLsizei height, GLsizei depth, GLenum format) {
12277 switch (format) { 12281 switch (format) {
12278 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: 12282 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
12279 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: 12283 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
12280 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: 12284 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
12281 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: 12285 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
12286 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
12287 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
12288 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
12289 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
12282 DCHECK_EQ(1, depth); // 2D formats. 12290 DCHECK_EQ(1, depth); // 2D formats.
12283 if (!IsValidDXTSize(level, width) || !IsValidDXTSize(level, height)) { 12291 if (!IsValidDXTSize(level, width) || !IsValidDXTSize(level, height)) {
12284 LOCAL_SET_GL_ERROR( 12292 LOCAL_SET_GL_ERROR(
12285 GL_INVALID_OPERATION, function_name, 12293 GL_INVALID_OPERATION, function_name,
12286 "width or height invalid for level"); 12294 "width or height invalid for level");
12287 return false; 12295 return false;
12288 } 12296 }
12289 return true; 12297 return true;
12290 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: 12298 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
12291 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: 12299 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
12378 if (xoffset < 0 || yoffset < 0 || zoffset < 0) { 12386 if (xoffset < 0 || yoffset < 0 || zoffset < 0) {
12379 LOCAL_SET_GL_ERROR( 12387 LOCAL_SET_GL_ERROR(
12380 GL_INVALID_VALUE, function_name, "x/y/z offset < 0"); 12388 GL_INVALID_VALUE, function_name, "x/y/z offset < 0");
12381 return false; 12389 return false;
12382 } 12390 }
12383 12391
12384 switch (format) { 12392 switch (format) {
12385 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: 12393 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
12386 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: 12394 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
12387 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: 12395 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
12388 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { 12396 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
12397 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
12398 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
12399 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
12400 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: {
12389 const int kBlockWidth = 4; 12401 const int kBlockWidth = 4;
12390 const int kBlockHeight = 4; 12402 const int kBlockHeight = 4;
12391 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { 12403 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) {
12392 LOCAL_SET_GL_ERROR( 12404 LOCAL_SET_GL_ERROR(
12393 GL_INVALID_OPERATION, function_name, 12405 GL_INVALID_OPERATION, function_name,
12394 "xoffset or yoffset not multiple of 4"); 12406 "xoffset or yoffset not multiple of 4");
12395 return false; 12407 return false;
12396 } 12408 }
12397 GLsizei tex_width = 0; 12409 GLsizei tex_width = 0;
12398 GLsizei tex_height = 0; 12410 GLsizei tex_height = 0;
(...skipping 5576 matching lines...) Expand 10 before | Expand all | Expand 10 after
17975 } 17987 }
17976 17988
17977 // Include the auto-generated part of this file. We split this because it means 17989 // Include the auto-generated part of this file. We split this because it means
17978 // we can easily edit the non-auto generated parts right here in this file 17990 // we can easily edit the non-auto generated parts right here in this file
17979 // instead of having to edit some template or the code generator. 17991 // instead of having to edit some template or the code generator.
17980 #include "base/macros.h" 17992 #include "base/macros.h"
17981 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 17993 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17982 17994
17983 } // namespace gles2 17995 } // namespace gles2
17984 } // namespace gpu 17996 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698