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

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

Issue 374193002: gpu: Optimize and cleanup code used for CHROMIUM_copy_texture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix window's webgl conformance test Created 6 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 418ca3a4fd03f040d589b0cf4c1875bee11cc2b8..91018cc0b3247c81a0e069803133a0929092616a 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -10055,6 +10055,11 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
return;
}
+ GLenum source_type = 0;
+ GLenum source_internal_format = 0;
+ source_texture->GetLevelType(
+ source_texture->target(), 0, &source_type, &source_internal_format);
+
GLenum dest_type_previous = dest_type;
GLenum dest_internal_format = internal_format;
bool dest_level_defined = dest_texture->GetLevelSize(
@@ -10065,6 +10070,18 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
&dest_internal_format);
}
+ // The format should be GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, or
+ // GL_LUMINANCE_ALPHA.
+ bool valid_source_format = source_internal_format >= GL_ALPHA &&
+ source_internal_format <= GL_LUMINANCE_ALPHA;
+ bool valid_dest_format = dest_internal_format >= GL_ALPHA &&
+ dest_internal_format <= GL_LUMINANCE_ALPHA;
+ if (!valid_source_format || !valid_dest_format) {
+ LOCAL_SET_GL_ERROR(
+ GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid internal format");
+ return;
+ }
+
// Resize the destination texture to the dimensions of the source texture.
if (!dest_level_defined || dest_width != source_width ||
dest_height != source_height ||
@@ -10105,25 +10122,28 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
this,
source_texture->target(),
- dest_texture->target(),
source_texture->service_id(),
- dest_texture->service_id(), level,
- source_width, source_height,
+ dest_texture->service_id(),
+ level,
+ source_width,
+ source_height,
unpack_flip_y_,
unpack_premultiply_alpha_,
unpack_unpremultiply_alpha_,
default_matrix);
} else {
- copy_texture_CHROMIUM_->DoCopyTexture(
- this,
- source_texture->target(),
- dest_texture->target(),
- source_texture->service_id(),
- dest_texture->service_id(), level,
- source_width, source_height,
- unpack_flip_y_,
- unpack_premultiply_alpha_,
- unpack_unpremultiply_alpha_);
+ copy_texture_CHROMIUM_->DoCopyTexture(this,
+ source_texture->target(),
+ source_texture->service_id(),
+ source_internal_format,
+ dest_texture->service_id(),
+ level,
+ internal_format,
+ source_width,
+ source_height,
+ unpack_flip_y_,
+ unpack_premultiply_alpha_,
+ unpack_unpremultiply_alpha_);
}
DoDidUseTexImageIfNeeded(source_texture, source_texture->target());

Powered by Google App Engine
This is Rietveld 408576698