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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 // Wrapper for CompressedTexSubImage2D. | 903 // Wrapper for CompressedTexSubImage2D. |
904 void DoCompressedTexSubImage2D( | 904 void DoCompressedTexSubImage2D( |
905 GLenum target, | 905 GLenum target, |
906 GLint level, | 906 GLint level, |
907 GLint xoffset, | 907 GLint xoffset, |
908 GLint yoffset, | 908 GLint yoffset, |
909 GLsizei width, | 909 GLsizei width, |
910 GLsizei height, | 910 GLsizei height, |
911 GLenum format, | 911 GLenum format, |
912 GLsizei imageSize, | 912 GLsizei imageSize, |
913 const void * data); | 913 const void* data); |
914 | 914 |
915 // Wrapper for CompressedTexSubImage3D. | 915 // Wrapper for CompressedTexSubImage3D. |
916 void DoCompressedTexSubImage3D( | 916 void DoCompressedTexSubImage3D( |
917 GLenum target, | 917 GLenum target, |
918 GLint level, | 918 GLint level, |
919 GLint xoffset, | 919 GLint xoffset, |
920 GLint yoffset, | 920 GLint yoffset, |
921 GLint zoffset, | 921 GLint zoffset, |
922 GLsizei width, | 922 GLsizei width, |
923 GLsizei height, | 923 GLsizei height, |
924 GLsizei depth, | 924 GLsizei depth, |
925 GLenum format, | 925 GLenum format, |
926 GLsizei image_size, | 926 GLsizei image_size, |
927 const void* data); | 927 const void* data); |
928 | 928 |
| 929 // Validate if |format| is valid for CopyTex{Sub}Image functions. |
| 930 // If not, generate a GL error and return false. |
| 931 bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format, |
| 932 GLenum read_format, GLenum read_type); |
| 933 |
929 // Wrapper for CopyTexImage2D. | 934 // Wrapper for CopyTexImage2D. |
930 void DoCopyTexImage2D( | 935 void DoCopyTexImage2D( |
931 GLenum target, | 936 GLenum target, |
932 GLint level, | 937 GLint level, |
933 GLenum internal_format, | 938 GLenum internal_format, |
934 GLint x, | 939 GLint x, |
935 GLint y, | 940 GLint y, |
936 GLsizei width, | 941 GLsizei width, |
937 GLsizei height, | 942 GLsizei height, |
938 GLint border); | 943 GLint border); |
(...skipping 11178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12117 start = 0; | 12122 start = 0; |
12118 } | 12123 } |
12119 GLint end = start + range; | 12124 GLint end = start + range; |
12120 if (end > sourceRange) { | 12125 if (end > sourceRange) { |
12121 range -= end - sourceRange; | 12126 range -= end - sourceRange; |
12122 } | 12127 } |
12123 *out_start = start; | 12128 *out_start = start; |
12124 *out_range = range; | 12129 *out_range = range; |
12125 } | 12130 } |
12126 | 12131 |
| 12132 bool GLES2DecoderImpl::ValidateCopyTexFormat( |
| 12133 const char* func_name, GLenum internal_format, |
| 12134 GLenum read_format, GLenum read_type) { |
| 12135 if (read_format == 0) { |
| 12136 LOCAL_SET_GL_ERROR( |
| 12137 GL_INVALID_OPERATION, func_name, "no valid color image"); |
| 12138 return false; |
| 12139 } |
| 12140 // Check we have compatible formats. |
| 12141 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
| 12142 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); |
| 12143 if (!channels_needed || |
| 12144 (channels_needed & channels_exist) != channels_needed) { |
| 12145 LOCAL_SET_GL_ERROR( |
| 12146 GL_INVALID_OPERATION, func_name, "incompatible format"); |
| 12147 return false; |
| 12148 } |
| 12149 if (feature_info_->IsES3Enabled()) { |
| 12150 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); |
| 12151 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || |
| 12152 GLES2Util::IsFloatFormat(internal_format) || |
| 12153 (GLES2Util::IsSignedIntegerFormat(internal_format) != |
| 12154 GLES2Util::IsSignedIntegerFormat(read_format)) || |
| 12155 (GLES2Util::IsUnsignedIntegerFormat(internal_format) != |
| 12156 GLES2Util::IsUnsignedIntegerFormat(read_format))) { |
| 12157 LOCAL_SET_GL_ERROR( |
| 12158 GL_INVALID_OPERATION, func_name, "incompatible format"); |
| 12159 return false; |
| 12160 } |
| 12161 } |
| 12162 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { |
| 12163 LOCAL_SET_GL_ERROR( |
| 12164 GL_INVALID_OPERATION, |
| 12165 func_name, "can not be used with depth or stencil textures"); |
| 12166 return false; |
| 12167 } |
| 12168 if (feature_info_->IsES3Enabled()) { |
| 12169 if (GLES2Util::IsSizedColorFormat(internal_format)) { |
| 12170 int sr, sg, sb, sa; |
| 12171 GLES2Util::GetColorFormatComponentSizes( |
| 12172 read_format, read_type, &sr, &sg, &sb, &sa); |
| 12173 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0); |
| 12174 int dr, dg, db, da; |
| 12175 GLES2Util::GetColorFormatComponentSizes( |
| 12176 internal_format, 0, &dr, &dg, &db, &da); |
| 12177 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0); |
| 12178 if ((dr > 0 && sr != dr) || |
| 12179 (dg > 0 && sg != dg) || |
| 12180 (db > 0 && sb != db) || |
| 12181 (da > 0 && sa != da)) { |
| 12182 LOCAL_SET_GL_ERROR( |
| 12183 GL_INVALID_OPERATION, |
| 12184 func_name, "imcompatible color component sizes"); |
| 12185 return false; |
| 12186 } |
| 12187 } |
| 12188 } |
| 12189 return true; |
| 12190 } |
| 12191 |
12127 void GLES2DecoderImpl::DoCopyTexImage2D( | 12192 void GLES2DecoderImpl::DoCopyTexImage2D( |
12128 GLenum target, | 12193 GLenum target, |
12129 GLint level, | 12194 GLint level, |
12130 GLenum internal_format, | 12195 GLenum internal_format, |
12131 GLint x, | 12196 GLint x, |
12132 GLint y, | 12197 GLint y, |
12133 GLsizei width, | 12198 GLsizei width, |
12134 GLsizei height, | 12199 GLsizei height, |
12135 GLint border) { | 12200 GLint border) { |
| 12201 const char* func_name = "glCopyTexImage2D"; |
12136 DCHECK(!ShouldDeferReads()); | 12202 DCHECK(!ShouldDeferReads()); |
12137 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( | 12203 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( |
12138 &state_, target); | 12204 &state_, target); |
12139 if (!texture_ref) { | 12205 if (!texture_ref) { |
12140 LOCAL_SET_GL_ERROR( | 12206 LOCAL_SET_GL_ERROR( |
12141 GL_INVALID_OPERATION, | 12207 GL_INVALID_OPERATION, func_name, "unknown texture for target"); |
12142 "glCopyTexImage2D", "unknown texture for target"); | |
12143 return; | 12208 return; |
12144 } | 12209 } |
12145 Texture* texture = texture_ref->texture(); | 12210 Texture* texture = texture_ref->texture(); |
12146 if (texture->IsImmutable()) { | 12211 if (texture->IsImmutable()) { |
12147 LOCAL_SET_GL_ERROR( | 12212 LOCAL_SET_GL_ERROR( |
12148 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable"); | 12213 GL_INVALID_OPERATION, func_name, "texture is immutable"); |
12149 return; | 12214 return; |
12150 } | 12215 } |
12151 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || | 12216 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || |
12152 border != 0) { | 12217 border != 0) { |
12153 LOCAL_SET_GL_ERROR( | 12218 LOCAL_SET_GL_ERROR( |
12154 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range"); | 12219 GL_INVALID_VALUE, func_name, "dimensions out of range"); |
12155 return; | 12220 return; |
12156 } | 12221 } |
12157 | 12222 |
12158 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D", | 12223 if (!CheckBoundReadFramebufferValid(func_name, |
12159 GL_INVALID_FRAMEBUFFER_OPERATION)) { | 12224 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
12160 return; | 12225 return; |
12161 } | 12226 } |
12162 | 12227 |
12163 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 12228 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
12164 if (read_format == 0) { | 12229 GLenum read_type = GetBoundReadFrameBufferTextureType(); |
12165 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", | 12230 if (!ValidateCopyTexFormat(func_name, internal_format, |
12166 "no valid color image"); | 12231 read_format, read_type)) { |
12167 return; | 12232 return; |
12168 } | 12233 } |
12169 | 12234 |
12170 // Check we have compatible formats. | |
12171 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); | |
12172 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); | |
12173 | |
12174 if ((channels_needed & channels_exist) != channels_needed) { | |
12175 LOCAL_SET_GL_ERROR( | |
12176 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format"); | |
12177 return; | |
12178 } | |
12179 | |
12180 if (feature_info_->IsES3Enabled()) { | |
12181 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); | |
12182 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || | |
12183 GLES2Util::IsFloatFormat(internal_format) || | |
12184 (GLES2Util::IsSignedIntegerFormat(internal_format) != | |
12185 GLES2Util::IsSignedIntegerFormat(read_format)) || | |
12186 (GLES2Util::IsUnsignedIntegerFormat(internal_format) != | |
12187 GLES2Util::IsUnsignedIntegerFormat(read_format))) { | |
12188 LOCAL_SET_GL_ERROR( | |
12189 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format"); | |
12190 return; | |
12191 } | |
12192 } | |
12193 | |
12194 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { | |
12195 LOCAL_SET_GL_ERROR( | |
12196 GL_INVALID_OPERATION, | |
12197 "glCopyTexImage2D", "can not be used with depth or stencil textures"); | |
12198 return; | |
12199 } | |
12200 | |
12201 uint32_t pixels_size = 0; | 12235 uint32_t pixels_size = 0; |
12202 GLenum format = TextureManager::ExtractFormatFromStorageFormat( | 12236 GLenum format = TextureManager::ExtractFormatFromStorageFormat( |
12203 internal_format); | 12237 internal_format); |
12204 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); | 12238 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); |
12205 // Only target image size is validated here. | 12239 // Only target image size is validated here. |
12206 if (!GLES2Util::ComputeImageDataSizes( | 12240 if (!GLES2Util::ComputeImageDataSizes( |
12207 width, height, 1, format, type, | 12241 width, height, 1, format, type, |
12208 state_.unpack_alignment, &pixels_size, NULL, NULL)) { | 12242 state_.unpack_alignment, &pixels_size, NULL, NULL)) { |
12209 LOCAL_SET_GL_ERROR( | 12243 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too large"); |
12210 GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too large"); | |
12211 return; | 12244 return; |
12212 } | 12245 } |
12213 | 12246 |
12214 if (!EnsureGPUMemoryAvailable(pixels_size)) { | 12247 if (!EnsureGPUMemoryAvailable(pixels_size)) { |
12215 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexImage2D", "out of memory"); | 12248 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "out of memory"); |
12216 return; | 12249 return; |
12217 } | 12250 } |
12218 | 12251 |
12219 if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) { | 12252 if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) { |
12220 LOCAL_SET_GL_ERROR( | 12253 LOCAL_SET_GL_ERROR( |
12221 GL_INVALID_OPERATION, | 12254 GL_INVALID_OPERATION, |
12222 "glCopyTexImage2D", "source and destination textures are the same"); | 12255 func_name, "source and destination textures are the same"); |
12223 return; | 12256 return; |
12224 } | 12257 } |
12225 | 12258 |
12226 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTexImage2D"); | 12259 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name); |
12227 ScopedResolvedFrameBufferBinder binder(this, false, true); | 12260 ScopedResolvedFrameBufferBinder binder(this, false, true); |
12228 gfx::Size size = GetBoundReadFrameBufferSize(); | 12261 gfx::Size size = GetBoundReadFrameBufferSize(); |
12229 | 12262 |
12230 if (texture->IsAttachedToFramebuffer()) { | 12263 if (texture->IsAttachedToFramebuffer()) { |
12231 framebuffer_state_.clear_state_dirty = true; | 12264 framebuffer_state_.clear_state_dirty = true; |
12232 } | 12265 } |
12233 | 12266 |
12234 // Clip to size to source dimensions | 12267 // Clip to size to source dimensions |
12235 GLint copyX = 0; | 12268 GLint copyX = 0; |
12236 GLint copyY = 0; | 12269 GLint copyY = 0; |
(...skipping 21 matching lines...) Expand all Loading... |
12258 destX, destY, copyX, copyY, | 12291 destX, destY, copyX, copyY, |
12259 copyWidth, copyHeight); | 12292 copyWidth, copyHeight); |
12260 } | 12293 } |
12261 } else { | 12294 } else { |
12262 GLenum final_internal_format = | 12295 GLenum final_internal_format = |
12263 texture_manager()->AdjustTexInternalFormat(internal_format); | 12296 texture_manager()->AdjustTexInternalFormat(internal_format); |
12264 | 12297 |
12265 // The service id and target of the texture attached to READ_FRAMEBUFFER. | 12298 // The service id and target of the texture attached to READ_FRAMEBUFFER. |
12266 GLuint source_texture_service_id = 0; | 12299 GLuint source_texture_service_id = 0; |
12267 GLenum source_texture_target = 0; | 12300 GLenum source_texture_target = 0; |
| 12301 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
12268 bool use_workaround = NeedsCopyTextureImageWorkaround( | 12302 bool use_workaround = NeedsCopyTextureImageWorkaround( |
12269 final_internal_format, channels_exist, &source_texture_service_id, | 12303 final_internal_format, channels_exist, &source_texture_service_id, |
12270 &source_texture_target); | 12304 &source_texture_target); |
12271 if (use_workaround) { | 12305 if (use_workaround) { |
12272 GLenum dest_texture_target = target; | 12306 GLenum dest_texture_target = target; |
12273 GLenum framebuffer_target = features().chromium_framebuffer_multisample | 12307 GLenum framebuffer_target = features().chromium_framebuffer_multisample |
12274 ? GL_READ_FRAMEBUFFER_EXT | 12308 ? GL_READ_FRAMEBUFFER_EXT |
12275 : GL_FRAMEBUFFER; | 12309 : GL_FRAMEBUFFER; |
12276 | 12310 |
12277 GLenum temp_internal_format = 0; | 12311 GLenum temp_internal_format = 0; |
(...skipping 28 matching lines...) Expand all Loading... |
12306 glFramebufferTexture2DEXT(framebuffer_target, GL_COLOR_ATTACHMENT0, | 12340 glFramebufferTexture2DEXT(framebuffer_target, GL_COLOR_ATTACHMENT0, |
12307 source_texture_target, | 12341 source_texture_target, |
12308 source_texture_service_id, 0); | 12342 source_texture_service_id, 0); |
12309 | 12343 |
12310 glDeleteTextures(1, &temp_texture); | 12344 glDeleteTextures(1, &temp_texture); |
12311 } else { | 12345 } else { |
12312 glCopyTexImage2D(target, level, final_internal_format, copyX, copyY, | 12346 glCopyTexImage2D(target, level, final_internal_format, copyX, copyY, |
12313 copyWidth, copyHeight, border); | 12347 copyWidth, copyHeight, border); |
12314 } | 12348 } |
12315 } | 12349 } |
12316 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTexImage2D"); | 12350 GLenum error = LOCAL_PEEK_GL_ERROR(func_name); |
12317 if (error == GL_NO_ERROR) { | 12351 if (error == GL_NO_ERROR) { |
12318 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, | 12352 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, |
12319 width, height, 1, border, format, | 12353 width, height, 1, border, format, |
12320 type, gfx::Rect(width, height)); | 12354 type, gfx::Rect(width, height)); |
12321 texture->ApplyFormatWorkarounds(feature_info_.get()); | 12355 texture->ApplyFormatWorkarounds(feature_info_.get()); |
12322 } | 12356 } |
12323 | 12357 |
12324 // This may be a slow command. Exit command processing to allow for | 12358 // This may be a slow command. Exit command processing to allow for |
12325 // context preemption and GPU watchdog checks. | 12359 // context preemption and GPU watchdog checks. |
12326 ExitCommandProcessingEarly(); | 12360 ExitCommandProcessingEarly(); |
12327 } | 12361 } |
12328 | 12362 |
12329 void GLES2DecoderImpl::DoCopyTexSubImage2D( | 12363 void GLES2DecoderImpl::DoCopyTexSubImage2D( |
12330 GLenum target, | 12364 GLenum target, |
12331 GLint level, | 12365 GLint level, |
12332 GLint xoffset, | 12366 GLint xoffset, |
12333 GLint yoffset, | 12367 GLint yoffset, |
12334 GLint x, | 12368 GLint x, |
12335 GLint y, | 12369 GLint y, |
12336 GLsizei width, | 12370 GLsizei width, |
12337 GLsizei height) { | 12371 GLsizei height) { |
| 12372 const char* func_name = "glCopyTexSubImage2D"; |
12338 DCHECK(!ShouldDeferReads()); | 12373 DCHECK(!ShouldDeferReads()); |
12339 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( | 12374 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( |
12340 &state_, target); | 12375 &state_, target); |
12341 if (!texture_ref) { | 12376 if (!texture_ref) { |
12342 LOCAL_SET_GL_ERROR( | 12377 LOCAL_SET_GL_ERROR( |
12343 GL_INVALID_OPERATION, | 12378 GL_INVALID_OPERATION, func_name, "unknown texture for target"); |
12344 "glCopyTexSubImage2D", "unknown texture for target"); | |
12345 return; | 12379 return; |
12346 } | 12380 } |
12347 Texture* texture = texture_ref->texture(); | 12381 Texture* texture = texture_ref->texture(); |
12348 GLenum type = 0; | 12382 GLenum type = 0; |
12349 GLenum format = 0; | 12383 GLenum internal_format = 0; |
12350 if (!texture->GetLevelType(target, level, &type, &format) || | 12384 if (!texture->GetLevelType(target, level, &type, &internal_format) || |
12351 !texture->ValidForTexture( | 12385 !texture->ValidForTexture( |
12352 target, level, xoffset, yoffset, 0, width, height, 1)) { | 12386 target, level, xoffset, yoffset, 0, width, height, 1)) { |
12353 LOCAL_SET_GL_ERROR( | 12387 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "bad dimensions."); |
12354 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); | |
12355 return; | 12388 return; |
12356 } | 12389 } |
12357 | 12390 |
12358 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D", | 12391 if (!CheckBoundReadFramebufferValid(func_name, |
12359 GL_INVALID_FRAMEBUFFER_OPERATION)) { | 12392 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
12360 return; | 12393 return; |
12361 } | 12394 } |
12362 | 12395 |
12363 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 12396 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
12364 if (read_format == 0) { | 12397 GLenum read_type = GetBoundReadFrameBufferTextureType(); |
12365 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", | 12398 if (!ValidateCopyTexFormat(func_name, internal_format, |
12366 "no valid color image"); | 12399 read_format, read_type)) { |
12367 return; | |
12368 } | |
12369 // Check we have compatible formats. | |
12370 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); | |
12371 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(format); | |
12372 | |
12373 if (!channels_needed || | |
12374 (channels_needed & channels_exist) != channels_needed) { | |
12375 LOCAL_SET_GL_ERROR( | |
12376 GL_INVALID_OPERATION, "glCopyTexSubImage2D", "incompatible format"); | |
12377 return; | |
12378 } | |
12379 | |
12380 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { | |
12381 LOCAL_SET_GL_ERROR( | |
12382 GL_INVALID_OPERATION, | |
12383 "glCopySubImage2D", "can not be used with depth or stencil textures"); | |
12384 return; | 12400 return; |
12385 } | 12401 } |
12386 | 12402 |
12387 if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) { | 12403 if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) { |
12388 LOCAL_SET_GL_ERROR( | 12404 LOCAL_SET_GL_ERROR( |
12389 GL_INVALID_OPERATION, | 12405 GL_INVALID_OPERATION, |
12390 "glCopyTexSubImage2D", "source and destination textures are the same"); | 12406 func_name, "source and destination textures are the same"); |
12391 return; | 12407 return; |
12392 } | 12408 } |
12393 | 12409 |
12394 ScopedResolvedFrameBufferBinder binder(this, false, true); | 12410 ScopedResolvedFrameBufferBinder binder(this, false, true); |
12395 gfx::Size size = GetBoundReadFrameBufferSize(); | 12411 gfx::Size size = GetBoundReadFrameBufferSize(); |
12396 GLint copyX = 0; | 12412 GLint copyX = 0; |
12397 GLint copyY = 0; | 12413 GLint copyY = 0; |
12398 GLint copyWidth = 0; | 12414 GLint copyWidth = 0; |
12399 GLint copyHeight = 0; | 12415 GLint copyHeight = 0; |
12400 Clip(x, width, size.width(), ©X, ©Width); | 12416 Clip(x, width, size.width(), ©X, ©Width); |
(...skipping 10 matching lines...) Expand all Loading... |
12411 texture->GetLevelClearedRect(target, level), | 12427 texture->GetLevelClearedRect(target, level), |
12412 gfx::Rect(destX, destY, copyWidth, copyHeight), &cleared_rect)) { | 12428 gfx::Rect(destX, destY, copyWidth, copyHeight), &cleared_rect)) { |
12413 DCHECK_GE(cleared_rect.size().GetArea(), | 12429 DCHECK_GE(cleared_rect.size().GetArea(), |
12414 texture->GetLevelClearedRect(target, level).size().GetArea()); | 12430 texture->GetLevelClearedRect(target, level).size().GetArea()); |
12415 texture_manager()->SetLevelClearedRect(texture_ref, target, level, | 12431 texture_manager()->SetLevelClearedRect(texture_ref, target, level, |
12416 cleared_rect); | 12432 cleared_rect); |
12417 } else { | 12433 } else { |
12418 // Otherwise clear part of texture level that is not already cleared. | 12434 // Otherwise clear part of texture level that is not already cleared. |
12419 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, | 12435 if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, |
12420 level)) { | 12436 level)) { |
12421 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexSubImage2D", | 12437 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too big"); |
12422 "dimensions too big"); | |
12423 return; | 12438 return; |
12424 } | 12439 } |
12425 } | 12440 } |
12426 } else { | 12441 } else { |
12427 // Write all pixels in below. | 12442 // Write all pixels in below. |
12428 texture_manager()->SetLevelCleared(texture_ref, target, level, true); | 12443 texture_manager()->SetLevelCleared(texture_ref, target, level, true); |
12429 } | 12444 } |
12430 | 12445 |
12431 if (copyHeight > 0 && copyWidth > 0) { | 12446 if (copyHeight > 0 && copyWidth > 0) { |
12432 glCopyTexSubImage2D(target, level, | 12447 glCopyTexSubImage2D(target, level, |
(...skipping 4339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16772 } | 16787 } |
16773 | 16788 |
16774 // Include the auto-generated part of this file. We split this because it means | 16789 // Include the auto-generated part of this file. We split this because it means |
16775 // we can easily edit the non-auto generated parts right here in this file | 16790 // we can easily edit the non-auto generated parts right here in this file |
16776 // instead of having to edit some template or the code generator. | 16791 // instead of having to edit some template or the code generator. |
16777 #include "base/macros.h" | 16792 #include "base/macros.h" |
16778 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16793 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16779 | 16794 |
16780 } // namespace gles2 | 16795 } // namespace gles2 |
16781 } // namespace gpu | 16796 } // namespace gpu |
OLD | NEW |