| 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..5484347a333ddc4ae3fc374c51b0c5794ac7827e 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,
|
| @@ -1811,11 +1809,13 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
|
| GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
|
| 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);
|
| + bool ValidateCopyTextureCHROMIUMTextures(const char* function_name,
|
| + TextureRef* source_texture_ref,
|
| + TextureRef* dest_texture_ref);
|
| + bool ValidateCopyTextureCHROMIUMInternalFormats(
|
| + const char* function_name,
|
| + TextureRef* source_texture_ref,
|
| + GLenum dest_internal_format);
|
| bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name,
|
| GLenum target,
|
| TextureRef* source_texture_ref,
|
| @@ -13067,23 +13067,15 @@ void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM(
|
| #endif
|
| }
|
|
|
| -bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM(
|
| +bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMTextures(
|
| const char* function_name,
|
| - GLenum target,
|
| TextureRef* source_texture_ref,
|
| - TextureRef* dest_texture_ref,
|
| - GLenum dest_internal_format) {
|
| + TextureRef* dest_texture_ref) {
|
| if (!source_texture_ref || !dest_texture_ref) {
|
| LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
|
| 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) {
|
| @@ -13100,9 +13092,16 @@ bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM(
|
| "invalid texture target binding");
|
| return false;
|
| }
|
| + return true;
|
| +}
|
|
|
| +bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
|
| + const char* function_name,
|
| + TextureRef* source_texture_ref,
|
| + GLenum dest_internal_format) {
|
| GLenum source_type = 0;
|
| GLenum source_internal_format = 0;
|
| + Texture* source_texture = source_texture_ref->texture();
|
| source_texture->GetLevelType(source_texture->target(), 0, &source_type,
|
| &source_internal_format);
|
|
|
| @@ -13182,7 +13181,6 @@ bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM(
|
| }
|
|
|
| void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
|
| - GLenum target,
|
| GLuint source_id,
|
| GLuint dest_id,
|
| GLenum internal_format,
|
| @@ -13195,18 +13193,24 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
|
| TextureRef* source_texture_ref = GetTexture(source_id);
|
| TextureRef* dest_texture_ref = GetTexture(dest_id);
|
|
|
| - if (!source_texture_ref || !dest_texture_ref) {
|
| - LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
|
| - "unknown texture ids");
|
| + if (!ValidateCopyTextureCHROMIUMTextures(
|
| + "glCopyTextureCHROMIUM", source_texture_ref, dest_texture_ref)) {
|
| + return;
|
| + }
|
| +
|
| + if (!ValidateCopyTextureCHROMIUMInternalFormats(
|
| + "glCopyTextureCHROMIUM", source_texture_ref, internal_format)) {
|
| return;
|
| }
|
|
|
| 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();
|
| 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 +13222,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 +13231,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 +13241,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 +13250,9 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
|
| return;
|
| }
|
|
|
| - if (!ValidateCopyTextureCHROMIUM("glCopyTextureCHROMIUM", target,
|
| - 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 +13274,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 +13288,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 +13310,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 +13331,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 +13341,6 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
|
| }
|
|
|
| void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
|
| - GLenum target,
|
| GLuint source_id,
|
| GLuint dest_id,
|
| GLint xoffset,
|
| @@ -13360,18 +13357,19 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
|
| TextureRef* source_texture_ref = GetTexture(source_id);
|
| TextureRef* dest_texture_ref = GetTexture(dest_id);
|
|
|
| - if (!source_texture_ref || !dest_texture_ref) {
|
| - LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
|
| - "unknown texture ids");
|
| + if (!ValidateCopyTextureCHROMIUMTextures(
|
| + "glCopySubTextureCHROMIUM", source_texture_ref, dest_texture_ref)) {
|
| return;
|
| }
|
|
|
| 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();
|
| 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 +13380,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 +13388,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 +13398,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,28 +13410,28 @@ 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,
|
| - source_texture_ref, dest_texture_ref,
|
| - dest_internal_format)) {
|
| + if (!ValidateCopyTextureCHROMIUMInternalFormats("glCopySubTextureCHROMIUM",
|
| + source_texture_ref,
|
| + dest_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, "glCopySubTextureCHROMIUM",
|
| "source texture dimensions too big");
|
| return;
|
| @@ -13453,29 +13451,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 +13483,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 +13566,7 @@ void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target,
|
| }
|
|
|
| if (!ValidateCompressedCopyTextureCHROMIUM(
|
| - "glCompressedCopyTextureCHROMIUM",
|
| - target,
|
| + "glCompressedCopyTextureCHROMIUM", target,
|
| source_texture_ref, dest_texture_ref)) {
|
| return;
|
| }
|
| @@ -13764,7 +13762,7 @@ void GLES2DecoderImpl::DoCompressedCopySubTextureCHROMIUM(GLenum target,
|
|
|
| if (!ValidateCompressedCopyTextureCHROMIUM(
|
| "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref,
|
| - dest_texture_ref)) {
|
| + dest_texture_ref)) {
|
| return;
|
| }
|
|
|
|
|