Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| index 4ab92b2592b4710bfc57987a1a62c32b405e907b..f5ecaffd8596a7bc7c88e4d0d2ab1ce5ee728ad5 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -941,8 +941,7 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient { |
| GLuint io_surface_id, |
| GLuint plane); |
| - void DoCopyTextureCHROMIUM(GLenum target, |
| - GLuint source_id, |
| + void DoCopyTextureCHROMIUM(GLuint source_id, |
| GLuint dest_id, |
| GLenum internal_format, |
| GLenum dest_type, |
| @@ -950,8 +949,7 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient { |
| GLboolean unpack_premultiply_alpha, |
| GLboolean unpack_unmultiply_alpha); |
| - void DoCopySubTextureCHROMIUM(GLenum target, |
| - GLuint source_id, |
| + void DoCopySubTextureCHROMIUM(GLuint source_id, |
| GLuint dest_id, |
| GLint xoffset, |
| GLint yoffset, |
| @@ -1812,7 +1810,6 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient { |
| GLsizei width, GLsizei height, GLsizei depth, GLenum format, |
| Texture* texture); |
| bool ValidateCopyTextureCHROMIUM(const char* function_name, |
| - GLenum target, |
| TextureRef* source_texture_ref, |
| TextureRef* dest_texture_ref, |
| GLenum dest_internal_format); |
| @@ -13069,7 +13066,6 @@ void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM( |
| bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM( |
| const char* function_name, |
| - GLenum target, |
| TextureRef* source_texture_ref, |
| TextureRef* dest_texture_ref, |
| GLenum dest_internal_format) { |
| @@ -13078,12 +13074,6 @@ bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM( |
| return false; |
| } |
| - if (GL_TEXTURE_2D != target) { |
| - LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| - "invalid texture target"); |
| - return false; |
| - } |
| - |
| Texture* source_texture = source_texture_ref->texture(); |
| Texture* dest_texture = dest_texture_ref->texture(); |
| if (source_texture == dest_texture) { |
| @@ -13182,7 +13172,6 @@ bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( |
| } |
| void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| - GLenum target, |
| GLuint source_id, |
| GLuint dest_id, |
| GLenum internal_format, |
| @@ -13203,10 +13192,12 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| Texture* source_texture = source_texture_ref->texture(); |
| Texture* dest_texture = dest_texture_ref->texture(); |
| + GLenum source_target = source_texture->target(); |
| + GLenum dest_target = dest_texture->target(); |
|
piman
2016/01/05 00:21:09
These can be 0 if this is used before the texture
erikchen
2016/01/05 00:34:15
This is checked by ValidateCopyTextureChromium().
|
| int source_width = 0; |
| int source_height = 0; |
| gl::GLImage* image = |
| - source_texture->GetLevelImage(source_texture->target(), 0); |
| + source_texture->GetLevelImage(source_target, 0); |
| if (image) { |
| gfx::Size size = image->GetSize(); |
| source_width = size.width(); |
| @@ -13218,7 +13209,7 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| return; |
| } |
| } else { |
| - if (!source_texture->GetLevelSize(source_texture->target(), 0, |
| + if (!source_texture->GetLevelSize(source_target, 0, |
| &source_width, &source_height, nullptr)) { |
| LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, |
| "glCopyTextureChromium", |
| @@ -13227,7 +13218,7 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| } |
| // Check that this type of texture is allowed. |
| - if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
| + if (!texture_manager()->ValidForTarget(source_target, 0, |
| source_width, source_height, 1)) { |
| LOCAL_SET_GL_ERROR( |
| GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions"); |
| @@ -13237,8 +13228,8 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| GLenum source_type = 0; |
| GLenum source_internal_format = 0; |
| - source_texture->GetLevelType( |
| - source_texture->target(), 0, &source_type, &source_internal_format); |
| + source_texture->GetLevelType(source_target, 0, &source_type, |
| + &source_internal_format); |
| if (dest_texture->IsImmutable()) { |
| LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTextureCHROMIUM", |
| @@ -13246,15 +13237,14 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| return; |
| } |
| - if (!ValidateCopyTextureCHROMIUM("glCopyTextureCHROMIUM", target, |
| - source_texture_ref, dest_texture_ref, |
| - internal_format)) { |
| + if (!ValidateCopyTextureCHROMIUM("glCopyTextureCHROMIUM", source_texture_ref, |
| + dest_texture_ref, internal_format)) { |
| return; |
| } |
| // Clear the source texture if necessary. |
| if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, |
| - source_texture->target(), 0)) { |
| + source_target, 0)) { |
| LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM", |
| "dimensions too big"); |
| return; |
| @@ -13276,10 +13266,10 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| int dest_width = 0; |
| int dest_height = 0; |
| bool dest_level_defined = dest_texture->GetLevelSize( |
| - GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); |
| + dest_target, 0, &dest_width, &dest_height, nullptr); |
| if (dest_level_defined) { |
| - dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous, |
| + dest_texture->GetLevelType(dest_target, 0, &dest_type_previous, |
| &dest_internal_format); |
| } |
| @@ -13290,21 +13280,21 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| dest_type_previous != dest_type) { |
| // Ensure that the glTexImage2D succeeds. |
| LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); |
| - glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
| - glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height, |
| + glBindTexture(dest_target, dest_texture->service_id()); |
| + glTexImage2D(dest_target, 0, internal_format, source_width, source_height, |
| 0, internal_format, dest_type, NULL); |
| GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); |
| if (error != GL_NO_ERROR) { |
| - RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); |
| + RestoreCurrentTextureBindings(&state_, dest_target); |
| return; |
| } |
| texture_manager()->SetLevelInfo( |
| - dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width, |
| + dest_texture_ref, dest_target, 0, internal_format, source_width, |
| source_height, 1, 0, internal_format, dest_type, |
| gfx::Rect(source_width, source_height)); |
| } else { |
| - texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, |
| + texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, |
| true); |
| } |
| @@ -13312,20 +13302,20 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| bool unpack_premultiply_alpha_change = |
| (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
| if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
| - glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
| - if (image->CopyTexImage(GL_TEXTURE_2D)) |
| + glBindTexture(dest_target, dest_texture->service_id()); |
| + if (image->CopyTexImage(dest_target)) |
| return; |
| } |
| - DoCopyTexImageIfNeeded(source_texture, source_texture->target()); |
| + DoCopyTexImageIfNeeded(source_texture, source_target); |
| // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
| // before presenting. |
| - if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
| + if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
| // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
| // instead of using kIdentityMatrix crbug.com/226218. |
| copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| - this, source_texture->target(), source_texture->service_id(), |
| + this, source_target, source_texture->service_id(), |
| dest_texture->service_id(), source_width, source_height, |
| unpack_flip_y == GL_TRUE, |
| unpack_premultiply_alpha == GL_TRUE, |
| @@ -13333,7 +13323,7 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| kIdentityMatrix); |
| } else { |
| copy_texture_CHROMIUM_->DoCopyTexture( |
| - this, source_texture->target(), source_texture->service_id(), |
| + this, source_target, source_texture->service_id(), |
| source_internal_format, dest_texture->service_id(), internal_format, |
| source_width, source_height, |
| unpack_flip_y == GL_TRUE, |
| @@ -13343,7 +13333,6 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
| } |
| void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| - GLenum target, |
| GLuint source_id, |
| GLuint dest_id, |
| GLint xoffset, |
| @@ -13368,10 +13357,12 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| Texture* source_texture = source_texture_ref->texture(); |
| Texture* dest_texture = dest_texture_ref->texture(); |
| + GLenum source_target = source_texture->target(); |
| + GLenum dest_target = dest_texture->target(); |
|
piman
2016/01/05 00:21:10
Ditto.
erikchen
2016/01/05 00:34:15
Done.
|
| int source_width = 0; |
| int source_height = 0; |
| gl::GLImage* image = |
| - source_texture->GetLevelImage(source_texture->target(), 0); |
| + source_texture->GetLevelImage(source_target, 0); |
| if (image) { |
| gfx::Size size = image->GetSize(); |
| source_width = size.width(); |
| @@ -13382,7 +13373,7 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| return; |
| } |
| } else { |
| - if (!source_texture->GetLevelSize(source_texture->target(), 0, |
| + if (!source_texture->GetLevelSize(source_target, 0, |
| &source_width, &source_height, nullptr)) { |
| LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| "source texture has no level 0"); |
| @@ -13390,7 +13381,7 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| } |
| // Check that this type of texture is allowed. |
| - if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
| + if (!texture_manager()->ValidForTarget(source_target, 0, |
| source_width, source_height, 1)) { |
| LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| "source texture bad dimensions"); |
| @@ -13400,9 +13391,9 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| GLenum source_type = 0; |
| GLenum source_internal_format = 0; |
| - source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
| + source_texture->GetLevelType(source_target, 0, &source_type, |
| &source_internal_format); |
| - if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, |
| + if (!source_texture->ValidForTexture(source_target, 0, x, y, 0, |
| width, height, 1)) { |
| LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| "source texture bad dimensions."); |
| @@ -13412,20 +13403,20 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| GLenum dest_type = 0; |
| GLenum dest_internal_format = 0; |
| bool dest_level_defined = dest_texture->GetLevelType( |
| - dest_texture->target(), 0, &dest_type, &dest_internal_format); |
| + dest_target, 0, &dest_type, &dest_internal_format); |
| if (!dest_level_defined) { |
| LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", |
| "destination texture is not defined"); |
| return; |
| } |
| - if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, |
| + if (!dest_texture->ValidForTexture(dest_target, 0, xoffset, |
| yoffset, 0, width, height, 1)) { |
| LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", |
| "destination texture bad dimensions."); |
| return; |
| } |
| - if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, |
| + if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", |
| source_texture_ref, dest_texture_ref, |
| dest_internal_format)) { |
| return; |
| @@ -13433,7 +13424,7 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| // Clear the source texture if necessary. |
| if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, |
| - source_texture->target(), 0)) { |
| + source_target, 0)) { |
| LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", |
| "source texture dimensions too big"); |
| return; |
| @@ -13453,29 +13444,30 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| int dest_width = 0; |
| int dest_height = 0; |
| bool ok = dest_texture->GetLevelSize( |
| - GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); |
| + dest_target, 0, &dest_width, &dest_height, nullptr); |
| DCHECK(ok); |
| if (xoffset != 0 || yoffset != 0 || width != dest_width || |
| height != dest_height) { |
| gfx::Rect cleared_rect; |
| if (TextureManager::CombineAdjacentRects( |
| - dest_texture->GetLevelClearedRect(target, 0), |
| + dest_texture->GetLevelClearedRect(dest_target, 0), |
| gfx::Rect(xoffset, yoffset, width, height), &cleared_rect)) { |
| - DCHECK_GE(cleared_rect.size().GetArea(), |
| - dest_texture->GetLevelClearedRect(target, 0).size().GetArea()); |
| - texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0, |
| + DCHECK_GE( |
| + cleared_rect.size().GetArea(), |
| + dest_texture->GetLevelClearedRect(dest_target, 0).size().GetArea()); |
| + texture_manager()->SetLevelClearedRect(dest_texture_ref, dest_target, 0, |
| cleared_rect); |
| } else { |
| // Otherwise clear part of texture level that is not already cleared. |
| - if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, |
| - 0)) { |
| + if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, |
| + dest_target, 0)) { |
| LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", |
| "destination texture dimensions too big"); |
| return; |
| } |
| } |
| } else { |
| - texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, |
| + texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, |
| true); |
| } |
| @@ -13484,19 +13476,19 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
| (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
| if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
| ScopedTextureBinder binder( |
| - &state_, dest_texture->service_id(), GL_TEXTURE_2D); |
| - if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset), |
| + &state_, dest_texture->service_id(), dest_target); |
| + if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset), |
| gfx::Rect(x, y, width, height))) { |
| return; |
| } |
| } |
| - DoCopyTexImageIfNeeded(source_texture, source_texture->target()); |
| + DoCopyTexImageIfNeeded(source_texture, source_target); |
| // TODO(hkuang): get the StreamTexture transform matrix in GPU process. |
| // crbug.com/226218. |
| copy_texture_CHROMIUM_->DoCopySubTexture( |
| - this, source_texture->target(), source_texture->service_id(), |
| + this, source_target, source_texture->service_id(), |
| source_internal_format, dest_texture->service_id(), dest_internal_format, |
| xoffset, yoffset, x, y, width, height, dest_width, dest_height, |
| source_width, source_height, |
| @@ -13567,8 +13559,7 @@ void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, |
| } |
| if (!ValidateCompressedCopyTextureCHROMIUM( |
| - "glCompressedCopyTextureCHROMIUM", |
| - target, |
| + "glCompressedCopyTextureCHROMIUM", target, |
| source_texture_ref, dest_texture_ref)) { |
| return; |
| } |
| @@ -13764,7 +13755,7 @@ void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target, |
| if (!ValidateCompressedCopyTextureCHROMIUM( |
| "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref, |
| - dest_texture_ref)) { |
| + dest_texture_ref)) { |
| return; |
| } |