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 "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 12091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12102 | 12102 |
12103 bool GLES2DecoderImpl::GetCompressedTexSizeInBytes( | 12103 bool GLES2DecoderImpl::GetCompressedTexSizeInBytes( |
12104 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, | 12104 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, |
12105 GLenum format, GLsizei* size_in_bytes) { | 12105 GLenum format, GLsizei* size_in_bytes) { |
12106 base::CheckedNumeric<GLsizei> bytes_required(0); | 12106 base::CheckedNumeric<GLsizei> bytes_required(0); |
12107 | 12107 |
12108 switch (format) { | 12108 switch (format) { |
12109 case GL_ATC_RGB_AMD: | 12109 case GL_ATC_RGB_AMD: |
12110 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 12110 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
12111 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 12111 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
| 12112 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: |
| 12113 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: |
12112 case GL_ETC1_RGB8_OES: | 12114 case GL_ETC1_RGB8_OES: |
12113 bytes_required = | 12115 bytes_required = |
12114 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; | 12116 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; |
12115 bytes_required *= | 12117 bytes_required *= |
12116 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight; | 12118 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight; |
12117 bytes_required *= kS3TCDXT1BlockSize; | 12119 bytes_required *= kS3TCDXT1BlockSize; |
12118 break; | 12120 break; |
12119 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: | 12121 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: |
12120 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: | 12122 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: |
12121 case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: | 12123 case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12156 bytes_required *= | 12158 bytes_required *= |
12157 (height + kBlockHeight - 1) / kBlockHeight; | 12159 (height + kBlockHeight - 1) / kBlockHeight; |
12158 | 12160 |
12159 bytes_required *= kASTCBlockSize; | 12161 bytes_required *= kASTCBlockSize; |
12160 break; | 12162 break; |
12161 } | 12163 } |
12162 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: | 12164 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: |
12163 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | 12165 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
12164 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 12166 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
12165 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: | 12167 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
| 12168 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: |
| 12169 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: |
12166 bytes_required = | 12170 bytes_required = |
12167 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; | 12171 (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth; |
12168 bytes_required *= | 12172 bytes_required *= |
12169 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight; | 12173 (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight; |
12170 bytes_required *= kS3TCDXT3AndDXT5BlockSize; | 12174 bytes_required *= kS3TCDXT3AndDXT5BlockSize; |
12171 break; | 12175 break; |
12172 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: | 12176 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: |
12173 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: | 12177 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: |
12174 bytes_required = std::max(width, 8); | 12178 bytes_required = std::max(width, 8); |
12175 bytes_required *= std::max(height, 8); | 12179 bytes_required *= std::max(height, 8); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12267 } | 12271 } |
12268 | 12272 |
12269 bool GLES2DecoderImpl::ValidateCompressedTexDimensions( | 12273 bool GLES2DecoderImpl::ValidateCompressedTexDimensions( |
12270 const char* function_name, GLenum target, GLint level, | 12274 const char* function_name, GLenum target, GLint level, |
12271 GLsizei width, GLsizei height, GLsizei depth, GLenum format) { | 12275 GLsizei width, GLsizei height, GLsizei depth, GLenum format) { |
12272 switch (format) { | 12276 switch (format) { |
12273 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 12277 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
12274 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 12278 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
12275 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 12279 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
12276 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: | 12280 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
| 12281 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: |
| 12282 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: |
| 12283 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: |
| 12284 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: |
12277 DCHECK_EQ(1, depth); // 2D formats. | 12285 DCHECK_EQ(1, depth); // 2D formats. |
12278 if (!IsValidDXTSize(level, width) || !IsValidDXTSize(level, height)) { | 12286 if (!IsValidDXTSize(level, width) || !IsValidDXTSize(level, height)) { |
12279 LOCAL_SET_GL_ERROR( | 12287 LOCAL_SET_GL_ERROR( |
12280 GL_INVALID_OPERATION, function_name, | 12288 GL_INVALID_OPERATION, function_name, |
12281 "width or height invalid for level"); | 12289 "width or height invalid for level"); |
12282 return false; | 12290 return false; |
12283 } | 12291 } |
12284 return true; | 12292 return true; |
12285 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: | 12293 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: |
12286 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: | 12294 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12373 if (xoffset < 0 || yoffset < 0 || zoffset < 0) { | 12381 if (xoffset < 0 || yoffset < 0 || zoffset < 0) { |
12374 LOCAL_SET_GL_ERROR( | 12382 LOCAL_SET_GL_ERROR( |
12375 GL_INVALID_VALUE, function_name, "x/y/z offset < 0"); | 12383 GL_INVALID_VALUE, function_name, "x/y/z offset < 0"); |
12376 return false; | 12384 return false; |
12377 } | 12385 } |
12378 | 12386 |
12379 switch (format) { | 12387 switch (format) { |
12380 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 12388 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
12381 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 12389 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
12382 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 12390 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
12383 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { | 12391 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
| 12392 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: |
| 12393 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: |
| 12394 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: |
| 12395 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: { |
12384 const int kBlockWidth = 4; | 12396 const int kBlockWidth = 4; |
12385 const int kBlockHeight = 4; | 12397 const int kBlockHeight = 4; |
12386 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { | 12398 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { |
12387 LOCAL_SET_GL_ERROR( | 12399 LOCAL_SET_GL_ERROR( |
12388 GL_INVALID_OPERATION, function_name, | 12400 GL_INVALID_OPERATION, function_name, |
12389 "xoffset or yoffset not multiple of 4"); | 12401 "xoffset or yoffset not multiple of 4"); |
12390 return false; | 12402 return false; |
12391 } | 12403 } |
12392 GLsizei tex_width = 0; | 12404 GLsizei tex_width = 0; |
12393 GLsizei tex_height = 0; | 12405 GLsizei tex_height = 0; |
(...skipping 5576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17970 } | 17982 } |
17971 | 17983 |
17972 // Include the auto-generated part of this file. We split this because it means | 17984 // Include the auto-generated part of this file. We split this because it means |
17973 // we can easily edit the non-auto generated parts right here in this file | 17985 // we can easily edit the non-auto generated parts right here in this file |
17974 // instead of having to edit some template or the code generator. | 17986 // instead of having to edit some template or the code generator. |
17975 #include "base/macros.h" | 17987 #include "base/macros.h" |
17976 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17988 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
17977 | 17989 |
17978 } // namespace gles2 | 17990 } // namespace gles2 |
17979 } // namespace gpu | 17991 } // namespace gpu |
OLD | NEW |