Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3351)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1275773003: gpu: support GL_TEXTURE_CUBE_MAP destination target to Copy(Sub)TextureCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android build Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 f8450261183746386174e9a043b1ca7fb92066c2..aad09c46f1ab0cae0cfc6ef96d8517e06d43467b 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -12058,24 +12058,25 @@ bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM(
return false;
}
- if (GL_TEXTURE_2D != target) {
+ Texture* source_texture = source_texture_ref->texture();
+ Texture* dest_texture = dest_texture_ref->texture();
+ if (GL_TEXTURE_2D != target &&
+ GL_TEXTURE_CUBE_MAP != GLES2Util::GLFaceToTarget(target) &&
piman 2015/08/06 20:43:23 Did you mean || instead of && ? if target == GL_T
dshwang 2015/08/10 08:04:18 Yes, thx for fixing mistake.
+ dest_texture->target() != target) {
piman 2015/08/06 20:43:23 did you mean dest_texture->target() != GLES2Util::
dshwang 2015/08/10 08:04:18 Yes. oops, double mistake. Done.
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) {
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
"source and destination textures are the same");
return false;
}
- 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)) {
+ if (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;
@@ -12247,14 +12248,16 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
GLenum dest_internal_format = internal_format;
int dest_width = 0;
int dest_height = 0;
- bool dest_level_defined = dest_texture->GetLevelSize(
- GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr);
+ bool dest_level_defined =
+ dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr);
if (dest_level_defined) {
- dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous,
+ dest_texture->GetLevelType(target, 0, &dest_type_previous,
&dest_internal_format);
}
+ GLenum binding_target = GLES2Util::GLFaceToTarget(target);
piman 2015/08/06 20:43:23 You can use dest_texture->target(), which saves a
dshwang 2015/08/10 08:04:17 Done.
+
// Resize the destination texture to the dimensions of the source texture.
if (!dest_level_defined || dest_width != source_width ||
dest_height != source_height ||
@@ -12262,22 +12265,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,
- 0, internal_format, dest_type, NULL);
+ glBindTexture(binding_target, dest_texture->service_id());
+ glTexImage2D(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_, binding_target);
return;
}
texture_manager()->SetLevelInfo(
- dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width,
+ dest_texture_ref, 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,
- true);
+ texture_manager()->SetLevelCleared(dest_texture_ref, target, 0, true);
}
ScopedModifyPixels modify(dest_texture_ref);
@@ -12286,8 +12288,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(GL_TEXTURE_2D, dest_texture->service_id());
- if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(0, 0),
+ glBindTexture(binding_target, dest_texture->service_id());
+ if (image->CopyTexSubImage(target, gfx::Point(0, 0),
gfx::Rect(0, 0, source_width, source_height))) {
return;
}
@@ -12301,18 +12303,15 @@ 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(),
+ this, source_texture->target(), source_texture->service_id(), target,
dest_texture->service_id(), source_width, source_height,
- unpack_flip_y == GL_TRUE,
- unpack_premultiply_alpha == GL_TRUE,
- unpack_unmultiply_alpha == GL_TRUE,
- kIdentityMatrix);
+ 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, dest_texture->service_id(), internal_format,
- source_width, source_height,
- unpack_flip_y == GL_TRUE,
+ source_internal_format, target, 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);
}
@@ -12382,15 +12381,15 @@ 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);
+ bool dest_level_defined =
+ dest_texture->GetLevelType(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,
- yoffset, 0, width, height, 1, dest_type)) {
+ if (!dest_texture->ValidForTexture(target, 0, xoffset, yoffset, 0, width,
+ height, 1, dest_type)) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
"destination texture bad dimensions.");
return;
@@ -12423,8 +12422,8 @@ 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);
+ bool ok =
+ dest_texture->GetLevelSize(target, 0, &dest_width, &dest_height, nullptr);
DCHECK(ok);
if (xoffset != 0 || yoffset != 0 || width != dest_width ||
height != dest_height) {
@@ -12446,8 +12445,7 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
}
}
} else {
- texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
- true);
+ texture_manager()->SetLevelCleared(dest_texture_ref, target, 0, true);
}
ScopedModifyPixels modify(dest_texture_ref);
@@ -12456,8 +12454,9 @@ 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(GL_TEXTURE_2D, dest_texture->service_id());
- if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset),
+ GLenum binding_target = GLES2Util::GLFaceToTarget(target);
piman 2015/08/06 20:43:23 you can use dest_texture->target() to save a switc
dshwang 2015/08/10 08:04:18 Done.
+ glBindTexture(binding_target, dest_texture->service_id());
+ if (image->CopyTexSubImage(target, gfx::Point(xoffset, yoffset),
gfx::Rect(x, y, width, height))) {
return;
}
@@ -12469,12 +12468,10 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
// crbug.com/226218.
copy_texture_CHROMIUM_->DoCopySubTexture(
this, source_texture->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,
- unpack_flip_y == GL_TRUE,
- unpack_premultiply_alpha == GL_TRUE,
- unpack_unmultiply_alpha == GL_TRUE);
+ source_internal_format, target, 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());
}
@@ -12643,13 +12640,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(),
- dest_texture->service_id(), source_width, source_height,
+ GL_TEXTURE_2D, 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, dest_texture->service_id(), GL_RGBA,
- source_width, source_height, false, false, false);
+ source_internal_format, GL_TEXTURE_2D, dest_texture->service_id(),
+ GL_RGBA, source_width, source_height, false, false, false);
}
DoDidUseTexImageIfNeeded(source_texture, source_texture->target());

Powered by Google App Engine
This is Rietveld 408576698