| 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 5c9b323a8c2b3174fb2542068ba65b0bccf77f96..1541a7772d945cfa52f05f57426034211475c15b 100644
|
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
|
| @@ -12522,6 +12522,12 @@ 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) {
|
| @@ -12530,18 +12536,10 @@ bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM(
|
| return false;
|
| }
|
|
|
| - GLenum binding_target = GLES2Util::GLTextureTargetToBindingTarget(target);
|
| - if (dest_texture->target() != binding_target ||
|
| - (GL_TEXTURE_2D != binding_target &&
|
| - GL_TEXTURE_CUBE_MAP != binding_target)) {
|
| - LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
|
| - "invalid texture target");
|
| - return false;
|
| - }
|
| -
|
| - if (source_texture->target() != GL_TEXTURE_2D &&
|
| - source_texture->target() != GL_TEXTURE_RECTANGLE_ARB &&
|
| - source_texture->target() != GL_TEXTURE_EXTERNAL_OES) {
|
| + if (dest_texture->target() != GL_TEXTURE_2D ||
|
| + (source_texture->target() != GL_TEXTURE_2D &&
|
| + source_texture->target() != GL_TEXTURE_RECTANGLE_ARB &&
|
| + source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) {
|
| LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
|
| "invalid texture target binding");
|
| return false;
|
| @@ -12714,11 +12712,11 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
|
| GLenum dest_internal_format = internal_format;
|
| int dest_width = 0;
|
| int dest_height = 0;
|
| - bool dest_level_defined =
|
| - dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr);
|
| + bool dest_level_defined = dest_texture->GetLevelSize(
|
| + GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr);
|
|
|
| if (dest_level_defined) {
|
| - dest_texture->GetLevelType(target, 0, &dest_type_previous,
|
| + dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous,
|
| &dest_internal_format);
|
| }
|
|
|
| @@ -12729,21 +12727,22 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
|
| dest_type_previous != dest_type) {
|
| // Ensure that the glTexImage2D succeeds.
|
| LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
|
| - glBindTexture(dest_texture->target(), dest_texture->service_id());
|
| - glTexImage2D(target, 0, internal_format, source_width, source_height, 0,
|
| - internal_format, dest_type, NULL);
|
| + glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
|
| + glTexImage2D(GL_TEXTURE_2D, 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_, dest_texture->target());
|
| + RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D);
|
| return;
|
| }
|
|
|
| texture_manager()->SetLevelInfo(
|
| - dest_texture_ref, target, 0, internal_format, source_width,
|
| + dest_texture_ref, GL_TEXTURE_2D, 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, target, 0, true);
|
| + texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
|
| + true);
|
| }
|
|
|
| ScopedModifyPixels modify(dest_texture_ref);
|
| @@ -12752,8 +12751,8 @@ 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(dest_texture->target(), dest_texture->service_id());
|
| - if (image->CopyTexSubImage(target, gfx::Point(0, 0),
|
| + glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
|
| + if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(0, 0),
|
| gfx::Rect(0, 0, source_width, source_height))) {
|
| return;
|
| }
|
| @@ -12767,18 +12766,20 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
|
| // 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(), target,
|
| - dest_texture->service_id(), internal_format, dest_type, source_width,
|
| - source_height, unpack_flip_y == GL_TRUE,
|
| - unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE,
|
| - &texture_state_, kIdentityMatrix);
|
| + this, source_texture->target(), source_texture->service_id(),
|
| + dest_texture->service_id(), source_width, source_height,
|
| + unpack_flip_y == GL_TRUE,
|
| + unpack_premultiply_alpha == GL_TRUE,
|
| + unpack_unmultiply_alpha == GL_TRUE,
|
| + kIdentityMatrix);
|
| } else {
|
| copy_texture_CHROMIUM_->DoCopyTexture(
|
| this, source_texture->target(), source_texture->service_id(),
|
| - source_internal_format, target, dest_texture->service_id(),
|
| - internal_format, dest_type, source_width, source_height,
|
| - unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
|
| - unpack_unmultiply_alpha == GL_TRUE, &texture_state_);
|
| + source_internal_format, dest_texture->service_id(), internal_format,
|
| + source_width, source_height,
|
| + unpack_flip_y == GL_TRUE,
|
| + unpack_premultiply_alpha == GL_TRUE,
|
| + unpack_unmultiply_alpha == GL_TRUE);
|
| }
|
|
|
| DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
|
| @@ -12803,10 +12804,6 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
|
| TextureRef* dest_texture_ref = GetTexture(dest_id);
|
| Texture* source_texture = source_texture_ref->texture();
|
| Texture* dest_texture = dest_texture_ref->texture();
|
| - GLenum source_type = 0;
|
| - GLenum source_internal_format = 0;
|
| - source_texture->GetLevelType(source_texture->target(), 0, &source_type,
|
| - &source_internal_format);
|
| int source_width = 0;
|
| int source_height = 0;
|
| gfx::GLImage* image =
|
| @@ -12828,13 +12825,6 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
|
| return;
|
| }
|
|
|
| - if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0,
|
| - width, height, 1, source_type)) {
|
| - LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
|
| - "source texture bad dimensions.");
|
| - return;
|
| - }
|
| -
|
| // Check that this type of texture is allowed.
|
| if (!texture_manager()->ValidForTarget(source_texture->target(), 0,
|
| source_width, source_height, 1)) {
|
| @@ -12844,17 +12834,28 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
|
| }
|
| }
|
|
|
| + GLenum source_type = 0;
|
| + GLenum source_internal_format = 0;
|
| + source_texture->GetLevelType(source_texture->target(), 0, &source_type,
|
| + &source_internal_format);
|
| + if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0,
|
| + width, height, 1, source_type)) {
|
| + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
|
| + "source texture bad dimensions.");
|
| + return;
|
| + }
|
| +
|
| GLenum dest_type = 0;
|
| GLenum dest_internal_format = 0;
|
| - bool dest_level_defined =
|
| - dest_texture->GetLevelType(target, 0, &dest_type, &dest_internal_format);
|
| + bool dest_level_defined = dest_texture->GetLevelType(
|
| + dest_texture->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(target, 0, xoffset, yoffset, 0, width,
|
| - height, 1, dest_type)) {
|
| + if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset,
|
| + yoffset, 0, width, height, 1, dest_type)) {
|
| LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
|
| "destination texture bad dimensions.");
|
| return;
|
| @@ -12887,8 +12888,8 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
|
|
|
| int dest_width = 0;
|
| int dest_height = 0;
|
| - bool ok =
|
| - dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr);
|
| + bool ok = dest_texture->GetLevelSize(
|
| + GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr);
|
| DCHECK(ok);
|
| if (xoffset != 0 || yoffset != 0 || width != dest_width ||
|
| height != dest_height) {
|
| @@ -12910,7 +12911,8 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
|
| }
|
| }
|
| } else {
|
| - texture_manager()->SetLevelCleared(dest_texture_ref, target, 0, true);
|
| + texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
|
| + true);
|
| }
|
|
|
| ScopedModifyPixels modify(dest_texture_ref);
|
| @@ -12919,8 +12921,8 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
|
| bool unpack_premultiply_alpha_change =
|
| (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
|
| if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
|
| - glBindTexture(dest_texture->target(), dest_texture->service_id());
|
| - if (image->CopyTexSubImage(target, gfx::Point(xoffset, yoffset),
|
| + glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
|
| + if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset),
|
| gfx::Rect(x, y, width, height))) {
|
| return;
|
| }
|
| @@ -12932,11 +12934,12 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
|
| // crbug.com/226218.
|
| copy_texture_CHROMIUM_->DoCopySubTexture(
|
| this, source_texture->target(), source_texture->service_id(),
|
| - source_internal_format, target, dest_texture->service_id(),
|
| - dest_internal_format, dest_type, xoffset, yoffset, x, y, width, height,
|
| - dest_width, dest_height, source_width, source_height,
|
| - unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
|
| - unpack_unmultiply_alpha == GL_TRUE, &texture_state_);
|
| + source_internal_format, dest_texture->service_id(), dest_internal_format,
|
| + xoffset, yoffset, x, y, width, height, dest_width, dest_height,
|
| + source_width, source_height,
|
| + unpack_flip_y == GL_TRUE,
|
| + unpack_premultiply_alpha == GL_TRUE,
|
| + unpack_unmultiply_alpha == GL_TRUE);
|
|
|
| DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
|
| }
|
| @@ -13105,15 +13108,13 @@ void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target,
|
| // instead of using kIdentityMatrix crbug.com/226218.
|
| copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
|
| this, source_texture->target(), source_texture->service_id(),
|
| - GL_TEXTURE_2D, dest_texture->service_id(), GL_RGBA, GL_UNSIGNED_BYTE,
|
| - source_width, source_height, false, false, false, &texture_state_,
|
| - kIdentityMatrix);
|
| + dest_texture->service_id(), source_width, source_height,
|
| + false, false, false, kIdentityMatrix);
|
| } else {
|
| copy_texture_CHROMIUM_->DoCopyTexture(
|
| this, source_texture->target(), source_texture->service_id(),
|
| - source_internal_format, GL_TEXTURE_2D, dest_texture->service_id(),
|
| - GL_RGBA, GL_UNSIGNED_BYTE, source_width, source_height, false, false,
|
| - false, &texture_state_);
|
| + source_internal_format, dest_texture->service_id(), GL_RGBA,
|
| + source_width, source_height, false, false, false);
|
| }
|
|
|
| DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
|
| @@ -13301,9 +13302,8 @@ void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target,
|
|
|
| copy_texture_CHROMIUM_->DoCopyTexture(
|
| this, dest_texture->target(), dest_texture->service_id(),
|
| - dest_internal_format, GL_TEXTURE_2D, tmp_service_id, GL_RGBA,
|
| - GL_UNSIGNED_BYTE, dest_width, dest_height, false, false, false,
|
| - &texture_state_);
|
| + dest_internal_format, tmp_service_id, GL_RGBA,
|
| + dest_width, dest_height, false, false, false);
|
|
|
| // Redefine destination texture to use RGBA.
|
| glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
|
| @@ -13319,9 +13319,9 @@ void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target,
|
| 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(dest_width, dest_height));
|
|
|
| copy_texture_CHROMIUM_->DoCopyTexture(
|
| - this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA, GL_TEXTURE_2D,
|
| - dest_texture->service_id(), GL_RGBA, GL_UNSIGNED_BYTE, dest_width,
|
| - dest_height, false, false, false, &texture_state_);
|
| + this, GL_TEXTURE_2D, tmp_service_id, GL_RGBA,
|
| + dest_texture->service_id(), GL_RGBA,
|
| + dest_width, dest_height, false, false, false);
|
|
|
| glDeleteTextures(1, &tmp_service_id);
|
| }
|
| @@ -13330,10 +13330,9 @@ void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target,
|
| // crbug.com/226218.
|
| copy_texture_CHROMIUM_->DoCopySubTexture(
|
| this, source_texture->target(), source_texture->service_id(),
|
| - source_internal_format, GL_TEXTURE_2D, dest_texture->service_id(),
|
| - GL_RGBA, GL_UNSIGNED_BYTE, xoffset, yoffset, x, y, width, height,
|
| - dest_width, dest_height, source_width, source_height, false, false, false,
|
| - &texture_state_);
|
| + source_internal_format, dest_texture->service_id(), GL_RGBA,
|
| + xoffset, yoffset, x, y, width, height, dest_width, dest_height,
|
| + source_width, source_height, false, false, false);
|
|
|
| DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
|
| }
|
|
|