Chromium Code Reviews| 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 <list> | 10 #include <list> |
| (...skipping 9087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9098 void GLES2DecoderImpl::DoCopyTexImage2D( | 9098 void GLES2DecoderImpl::DoCopyTexImage2D( |
| 9099 GLenum target, | 9099 GLenum target, |
| 9100 GLint level, | 9100 GLint level, |
| 9101 GLenum internal_format, | 9101 GLenum internal_format, |
| 9102 GLint x, | 9102 GLint x, |
| 9103 GLint y, | 9103 GLint y, |
| 9104 GLsizei width, | 9104 GLsizei width, |
| 9105 GLsizei height, | 9105 GLsizei height, |
| 9106 GLint border) { | 9106 GLint border) { |
| 9107 DCHECK(!ShouldDeferReads()); | 9107 DCHECK(!ShouldDeferReads()); |
| 9108 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format); | |
| 9109 // We need to reject DEPTH or STENCIL internal formats here because it shares | |
| 9110 // the same validator as TexImage*D's internal format, where such formats are | |
| 9111 // supported. | |
| 9112 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { | |
| 9113 LOCAL_SET_GL_ERROR( | |
| 9114 GL_INVALID_ENUM, | |
|
Zhenyao Mo
2015/03/12 22:16:38
This is correct because such format is not one of
| |
| 9115 "glCopyImage2D", "invalid internal format"); | |
| 9116 return; | |
| 9117 } | |
| 9108 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( | 9118 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( |
| 9109 &state_, target); | 9119 &state_, target); |
| 9110 if (!texture_ref) { | 9120 if (!texture_ref) { |
| 9111 LOCAL_SET_GL_ERROR( | 9121 LOCAL_SET_GL_ERROR( |
| 9112 GL_INVALID_OPERATION, | 9122 GL_INVALID_OPERATION, |
| 9113 "glCopyTexImage2D", "unknown texture for target"); | 9123 "glCopyTexImage2D", "unknown texture for target"); |
| 9114 return; | 9124 return; |
| 9115 } | 9125 } |
| 9116 Texture* texture = texture_ref->texture(); | 9126 Texture* texture = texture_ref->texture(); |
| 9117 if (texture->IsImmutable()) { | 9127 if (texture->IsImmutable()) { |
| 9118 LOCAL_SET_GL_ERROR( | 9128 LOCAL_SET_GL_ERROR( |
| 9119 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable"); | 9129 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable"); |
| 9120 return; | 9130 return; |
| 9121 } | 9131 } |
| 9122 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || | 9132 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || |
| 9123 border != 0) { | 9133 border != 0) { |
| 9124 LOCAL_SET_GL_ERROR( | 9134 LOCAL_SET_GL_ERROR( |
| 9125 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range"); | 9135 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range"); |
| 9126 return; | 9136 return; |
| 9127 } | 9137 } |
| 9128 if (!texture_manager()->ValidateFormatAndTypeCombination( | 9138 if (!texture_manager()->ValidateFormatAndTypeCombination( |
| 9129 state_.GetErrorState(), "glCopyTexImage2D", internal_format, | 9139 state_.GetErrorState(), "glCopyTexImage2D", internal_format, |
| 9130 GL_UNSIGNED_BYTE)) { | 9140 GL_UNSIGNED_BYTE)) { |
| 9131 return; | 9141 return; |
| 9132 } | 9142 } |
| 9133 | 9143 |
| 9134 // Check we have compatible formats. | 9144 // Check we have compatible formats. |
| 9135 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 9145 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
| 9136 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 9146 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
| 9137 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format); | |
| 9138 | 9147 |
| 9139 if ((channels_needed & channels_exist) != channels_needed) { | 9148 if ((channels_needed & channels_exist) != channels_needed) { |
| 9140 LOCAL_SET_GL_ERROR( | 9149 LOCAL_SET_GL_ERROR( |
| 9141 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format"); | 9150 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format"); |
| 9142 return; | 9151 return; |
| 9143 } | 9152 } |
| 9144 | 9153 |
| 9145 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { | |
| 9146 LOCAL_SET_GL_ERROR( | |
| 9147 GL_INVALID_OPERATION, | |
| 9148 "glCopyTexImage2D", "can not be used with depth or stencil textures"); | |
| 9149 return; | |
| 9150 } | |
| 9151 | |
| 9152 uint32 estimated_size = 0; | 9154 uint32 estimated_size = 0; |
| 9153 if (!GLES2Util::ComputeImageDataSizes( | 9155 if (!GLES2Util::ComputeImageDataSizes( |
| 9154 width, height, 1, internal_format, GL_UNSIGNED_BYTE, | 9156 width, height, 1, internal_format, GL_UNSIGNED_BYTE, |
| 9155 state_.unpack_alignment, &estimated_size, NULL, NULL)) { | 9157 state_.unpack_alignment, &estimated_size, NULL, NULL)) { |
| 9156 LOCAL_SET_GL_ERROR( | 9158 LOCAL_SET_GL_ERROR( |
| 9157 GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too large"); | 9159 GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too large"); |
| 9158 return; | 9160 return; |
| 9159 } | 9161 } |
| 9160 | 9162 |
| 9161 if (!EnsureGPUMemoryAvailable(estimated_size)) { | 9163 if (!EnsureGPUMemoryAvailable(estimated_size)) { |
| (...skipping 3255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12417 } | 12419 } |
| 12418 } | 12420 } |
| 12419 | 12421 |
| 12420 // Include the auto-generated part of this file. We split this because it means | 12422 // Include the auto-generated part of this file. We split this because it means |
| 12421 // we can easily edit the non-auto generated parts right here in this file | 12423 // we can easily edit the non-auto generated parts right here in this file |
| 12422 // instead of having to edit some template or the code generator. | 12424 // instead of having to edit some template or the code generator. |
| 12423 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12425 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 12424 | 12426 |
| 12425 } // namespace gles2 | 12427 } // namespace gles2 |
| 12426 } // namespace gpu | 12428 } // namespace gpu |
| OLD | NEW |