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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 10436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10447 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCompressedTexSubImage3D", | 10447 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCompressedTexSubImage3D", |
10448 "level does not exist"); | 10448 "level does not exist"); |
10449 return; | 10449 return; |
10450 } | 10450 } |
10451 if (internal_format != format) { | 10451 if (internal_format != format) { |
10452 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCompressedTexSubImage3D", | 10452 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCompressedTexSubImage3D", |
10453 "format does not match internal format"); | 10453 "format does not match internal format"); |
10454 return; | 10454 return; |
10455 } | 10455 } |
10456 if (!texture->ValidForTexture(target, level, xoffset, yoffset, zoffset, | 10456 if (!texture->ValidForTexture(target, level, xoffset, yoffset, zoffset, |
10457 width, height, depth, type)) { | 10457 width, height, depth)) { |
10458 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage3D", | 10458 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedTexSubImage3D", |
10459 "bad dimensions"); | 10459 "bad dimensions"); |
10460 return; | 10460 return; |
10461 } | 10461 } |
10462 if (!ValidateCompressedTexFuncData("glCompressedTexSubImage3D", | 10462 if (!ValidateCompressedTexFuncData("glCompressedTexSubImage3D", |
10463 width, height, depth, format, | 10463 width, height, depth, format, |
10464 image_size) || | 10464 image_size) || |
10465 !ValidateCompressedTexSubDimensions("glCompressedTexSubImage3D", | 10465 !ValidateCompressedTexSubDimensions("glCompressedTexSubImage3D", |
10466 target, level, xoffset, yoffset, | 10466 target, level, xoffset, yoffset, |
10467 zoffset, width, height, depth, | 10467 zoffset, width, height, depth, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10654 "glCompressedTexSubImage2D", "level does not exist."); | 10654 "glCompressedTexSubImage2D", "level does not exist."); |
10655 return; | 10655 return; |
10656 } | 10656 } |
10657 if (internal_format != format) { | 10657 if (internal_format != format) { |
10658 LOCAL_SET_GL_ERROR( | 10658 LOCAL_SET_GL_ERROR( |
10659 GL_INVALID_OPERATION, | 10659 GL_INVALID_OPERATION, |
10660 "glCompressedTexSubImage2D", "format does not match internal format."); | 10660 "glCompressedTexSubImage2D", "format does not match internal format."); |
10661 return; | 10661 return; |
10662 } | 10662 } |
10663 if (!texture->ValidForTexture(target, level, xoffset, yoffset, 0, width, | 10663 if (!texture->ValidForTexture(target, level, xoffset, yoffset, 0, width, |
10664 height, 1, type)) { | 10664 height, 1)) { |
10665 LOCAL_SET_GL_ERROR( | 10665 LOCAL_SET_GL_ERROR( |
10666 GL_INVALID_VALUE, "glCompressedTexSubImage2D", "bad dimensions."); | 10666 GL_INVALID_VALUE, "glCompressedTexSubImage2D", "bad dimensions."); |
10667 return; | 10667 return; |
10668 } | 10668 } |
10669 | 10669 |
10670 if (!ValidateCompressedTexFuncData("glCompressedTexSubImage2D", | 10670 if (!ValidateCompressedTexFuncData("glCompressedTexSubImage2D", |
10671 width, height, 1, format, image_size) || | 10671 width, height, 1, format, image_size) || |
10672 !ValidateCompressedTexSubDimensions("glCompressedTexSubImage2D", | 10672 !ValidateCompressedTexSubDimensions("glCompressedTexSubImage2D", |
10673 target, level, xoffset, yoffset, 0, | 10673 target, level, xoffset, yoffset, 0, |
10674 width, height, 1, format, texture)) { | 10674 width, height, 1, format, texture)) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10864 LOCAL_SET_GL_ERROR( | 10864 LOCAL_SET_GL_ERROR( |
10865 GL_INVALID_OPERATION, | 10865 GL_INVALID_OPERATION, |
10866 "glCopyTexSubImage2D", "unknown texture for target"); | 10866 "glCopyTexSubImage2D", "unknown texture for target"); |
10867 return; | 10867 return; |
10868 } | 10868 } |
10869 Texture* texture = texture_ref->texture(); | 10869 Texture* texture = texture_ref->texture(); |
10870 GLenum type = 0; | 10870 GLenum type = 0; |
10871 GLenum format = 0; | 10871 GLenum format = 0; |
10872 if (!texture->GetLevelType(target, level, &type, &format) || | 10872 if (!texture->GetLevelType(target, level, &type, &format) || |
10873 !texture->ValidForTexture( | 10873 !texture->ValidForTexture( |
10874 target, level, xoffset, yoffset, 0, width, height, 1, type)) { | 10874 target, level, xoffset, yoffset, 0, width, height, 1)) { |
10875 LOCAL_SET_GL_ERROR( | 10875 LOCAL_SET_GL_ERROR( |
10876 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); | 10876 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); |
10877 return; | 10877 return; |
10878 } | 10878 } |
10879 | 10879 |
10880 // Check we have compatible formats. | 10880 // Check we have compatible formats. |
10881 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 10881 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
10882 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 10882 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
10883 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format); | 10883 uint32 channels_needed = GLES2Util::GetChannelsForFormat(format); |
10884 | 10884 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11019 GLenum internal_format = 0; | 11019 GLenum internal_format = 0; |
11020 if (!texture->GetLevelType(target, level, ¤t_type, &internal_format)) { | 11020 if (!texture->GetLevelType(target, level, ¤t_type, &internal_format)) { |
11021 LOCAL_SET_GL_ERROR( | 11021 LOCAL_SET_GL_ERROR( |
11022 GL_INVALID_OPERATION, function_name, "level does not exist."); | 11022 GL_INVALID_OPERATION, function_name, "level does not exist."); |
11023 return false; | 11023 return false; |
11024 } | 11024 } |
11025 if (!texture_manager()->ValidateTextureParameters(state_.GetErrorState(), | 11025 if (!texture_manager()->ValidateTextureParameters(state_.GetErrorState(), |
11026 function_name, format, type, internal_format, level)) { | 11026 function_name, format, type, internal_format, level)) { |
11027 return false; | 11027 return false; |
11028 } | 11028 } |
11029 if (type != current_type) { | 11029 if (type != current_type && !feature_info_->IsES3Enabled()) { |
11030 LOCAL_SET_GL_ERROR( | 11030 LOCAL_SET_GL_ERROR( |
11031 GL_INVALID_OPERATION, | 11031 GL_INVALID_OPERATION, |
11032 function_name, "type does not match type of texture."); | 11032 function_name, "type does not match type of texture."); |
11033 return false; | 11033 return false; |
11034 } | 11034 } |
11035 if (!texture->ValidForTexture( | 11035 if (!texture->ValidForTexture( |
11036 target, level, xoffset, yoffset, 0, width, height, 1, type)) { | 11036 target, level, xoffset, yoffset, 0, width, height, 1)) { |
11037 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "bad dimensions."); | 11037 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "bad dimensions."); |
11038 return false; | 11038 return false; |
11039 } | 11039 } |
11040 if ((GLES2Util::GetChannelsForFormat(format) & | 11040 if ((GLES2Util::GetChannelsForFormat(format) & |
11041 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 | 11041 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 |
11042 && !feature_info_->IsES3Enabled()) { | 11042 && !feature_info_->IsES3Enabled()) { |
11043 LOCAL_SET_GL_ERROR( | 11043 LOCAL_SET_GL_ERROR( |
11044 GL_INVALID_OPERATION, | 11044 GL_INVALID_OPERATION, |
11045 function_name, "can not supply data for depth or stencil textures"); | 11045 function_name, "can not supply data for depth or stencil textures"); |
11046 return false; | 11046 return false; |
(...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13092 "source texture bad dimensions"); | 13092 "source texture bad dimensions"); |
13093 return; | 13093 return; |
13094 } | 13094 } |
13095 } | 13095 } |
13096 | 13096 |
13097 GLenum source_type = 0; | 13097 GLenum source_type = 0; |
13098 GLenum source_internal_format = 0; | 13098 GLenum source_internal_format = 0; |
13099 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | 13099 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
13100 &source_internal_format); | 13100 &source_internal_format); |
13101 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, | 13101 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, |
13102 width, height, 1, source_type)) { | 13102 width, height, 1)) { |
13103 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 13103 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
13104 "source texture bad dimensions."); | 13104 "source texture bad dimensions."); |
13105 return; | 13105 return; |
13106 } | 13106 } |
13107 | 13107 |
13108 GLenum dest_type = 0; | 13108 GLenum dest_type = 0; |
13109 GLenum dest_internal_format = 0; | 13109 GLenum dest_internal_format = 0; |
13110 bool dest_level_defined = dest_texture->GetLevelType( | 13110 bool dest_level_defined = dest_texture->GetLevelType( |
13111 dest_texture->target(), 0, &dest_type, &dest_internal_format); | 13111 dest_texture->target(), 0, &dest_type, &dest_internal_format); |
13112 if (!dest_level_defined) { | 13112 if (!dest_level_defined) { |
13113 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", | 13113 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", |
13114 "destination texture is not defined"); | 13114 "destination texture is not defined"); |
13115 return; | 13115 return; |
13116 } | 13116 } |
13117 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, | 13117 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, |
13118 yoffset, 0, width, height, 1, dest_type)) { | 13118 yoffset, 0, width, height, 1)) { |
13119 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", | 13119 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
13120 "destination texture bad dimensions."); | 13120 "destination texture bad dimensions."); |
13121 return; | 13121 return; |
13122 } | 13122 } |
13123 | 13123 |
13124 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, | 13124 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, |
13125 source_texture_ref, dest_texture_ref, | 13125 source_texture_ref, dest_texture_ref, |
13126 dest_internal_format)) { | 13126 dest_internal_format)) { |
13127 return; | 13127 return; |
13128 } | 13128 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13424 "source texture bad dimensions"); | 13424 "source texture bad dimensions"); |
13425 return; | 13425 return; |
13426 } | 13426 } |
13427 } | 13427 } |
13428 | 13428 |
13429 GLenum source_type = 0; | 13429 GLenum source_type = 0; |
13430 GLenum source_internal_format = 0; | 13430 GLenum source_internal_format = 0; |
13431 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | 13431 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
13432 &source_internal_format); | 13432 &source_internal_format); |
13433 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, | 13433 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, |
13434 width, height, 1, source_type)) { | 13434 width, height, 1)) { |
13435 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", | 13435 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", |
13436 "source texture bad dimensions."); | 13436 "source texture bad dimensions."); |
13437 return; | 13437 return; |
13438 } | 13438 } |
13439 | 13439 |
13440 GLenum dest_type = 0; | 13440 GLenum dest_type = 0; |
13441 GLenum dest_internal_format = 0; | 13441 GLenum dest_internal_format = 0; |
13442 bool dest_level_defined = dest_texture->GetLevelType( | 13442 bool dest_level_defined = dest_texture->GetLevelType( |
13443 dest_texture->target(), 0, &dest_type, &dest_internal_format); | 13443 dest_texture->target(), 0, &dest_type, &dest_internal_format); |
13444 if (!dest_level_defined) { | 13444 if (!dest_level_defined) { |
13445 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 13445 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
13446 "glCompressedCopySubTextureCHROMIUM", | 13446 "glCompressedCopySubTextureCHROMIUM", |
13447 "destination texture is not defined"); | 13447 "destination texture is not defined"); |
13448 return; | 13448 return; |
13449 } | 13449 } |
13450 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, | 13450 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, |
13451 yoffset, 0, width, height, 1, dest_type)) { | 13451 yoffset, 0, width, height, 1)) { |
13452 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", | 13452 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", |
13453 "destination texture bad dimensions."); | 13453 "destination texture bad dimensions."); |
13454 return; | 13454 return; |
13455 } | 13455 } |
13456 | 13456 |
13457 if (!ValidateCompressedCopyTextureCHROMIUM( | 13457 if (!ValidateCompressedCopyTextureCHROMIUM( |
13458 "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref, | 13458 "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref, |
13459 dest_texture_ref)) { | 13459 dest_texture_ref)) { |
13460 return; | 13460 return; |
13461 } | 13461 } |
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15049 return error::kNoError; | 15049 return error::kNoError; |
15050 } | 15050 } |
15051 | 15051 |
15052 // Include the auto-generated part of this file. We split this because it means | 15052 // Include the auto-generated part of this file. We split this because it means |
15053 // we can easily edit the non-auto generated parts right here in this file | 15053 // we can easily edit the non-auto generated parts right here in this file |
15054 // instead of having to edit some template or the code generator. | 15054 // instead of having to edit some template or the code generator. |
15055 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15055 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15056 | 15056 |
15057 } // namespace gles2 | 15057 } // namespace gles2 |
15058 } // namespace gpu | 15058 } // namespace gpu |
OLD | NEW |