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

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

Issue 972833004: Revert of gpu: introduce glCopySubTextureCHROMIUM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 0af70c706503c2d5dcfc2e30a0f0e7faf38edcf8..50ae103d860006ede0a77f697f8ff3afcba977a4 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -81,15 +81,10 @@
namespace {
-const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives";
-const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth";
-const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers";
-const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod";
-
-const GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f};
+static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives";
+static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth";
+static const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers";
+static const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod";
static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin,
GLint rangeMax,
@@ -941,17 +936,13 @@
GLuint io_surface_id,
GLuint plane);
- void DoCopyTextureCHROMIUM(GLenum target,
- GLuint source_id,
- GLuint dest_id,
- GLenum internal_format,
- GLenum dest_type);
-
- void DoCopySubTextureCHROMIUM(GLenum target,
- GLuint source_id,
- GLuint dest_id,
- GLint xoffset,
- GLint yoffset);
+ void DoCopyTextureCHROMIUM(
+ GLenum target,
+ GLuint source_id,
+ GLuint target_id,
+ GLint level,
+ GLenum internal_format,
+ GLenum dest_type);
// Wrapper for TexStorage2DEXT.
void DoTexStorage2DEXT(
@@ -1668,11 +1659,6 @@
GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLenum format,
Texture* texture);
- bool ValidateCopyTextureCHROMIUM(const char* function_name,
- GLenum target,
- TextureRef* source_texture_ref,
- TextureRef* dest_texture_ref,
- GLenum dest_internal_format);
void RenderWarning(const char* filename, int line, const std::string& msg);
void PerformanceWarning(
@@ -10948,78 +10934,40 @@
}
}
-bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM(
- const char* function_name,
- GLenum target,
- TextureRef* source_texture_ref,
- TextureRef* dest_texture_ref,
- GLenum dest_internal_format) {
+void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
+ GLenum target, GLuint source_id, GLuint dest_id, GLint level,
+ GLenum internal_format, GLenum dest_type) {
+ TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
+
+ TextureRef* dest_texture_ref = GetTexture(dest_id);
+ TextureRef* source_texture_ref = GetTexture(source_id);
+
if (!source_texture_ref || !dest_texture_ref) {
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
- return false;
+ LOCAL_SET_GL_ERROR(
+ GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id");
+ return;
}
if (GL_TEXTURE_2D != target) {
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
- "invalid texture target");
- return false;
+ LOCAL_SET_GL_ERROR(
+ GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid texture target");
+ return;
}
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)) {
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
+ "glCopyTextureCHROMIUM",
"invalid texture target binding");
- return false;
- }
-
- GLenum source_type = 0;
- GLenum source_internal_format = 0;
- source_texture->GetLevelType(source_texture->target(), 0, &source_type,
- &source_internal_format);
-
- // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA,
- // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not
- // renderable on some platforms.
- bool valid_dest_format = dest_internal_format == GL_RGB ||
- dest_internal_format == GL_RGBA ||
- dest_internal_format == GL_BGRA_EXT;
- bool valid_source_format = source_internal_format == GL_ALPHA ||
- source_internal_format == GL_RGB ||
- source_internal_format == GL_RGBA ||
- source_internal_format == GL_LUMINANCE ||
- source_internal_format == GL_LUMINANCE_ALPHA ||
- source_internal_format == GL_BGRA_EXT;
- if (!valid_source_format || !valid_dest_format) {
- LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
- "invalid internal format");
- return false;
- }
- return true;
-}
-
-void GLES2DecoderImpl::DoCopyTextureCHROMIUM(GLenum target,
- GLuint source_id,
- GLuint dest_id,
- GLenum internal_format,
- GLenum dest_type) {
- TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
-
- TextureRef* source_texture_ref = GetTexture(source_id);
- TextureRef* dest_texture_ref = GetTexture(dest_id);
- Texture* source_texture = source_texture_ref->texture();
- Texture* dest_texture = dest_texture_ref->texture();
- int source_width = 0;
- int source_height = 0;
+ return;
+ }
+
+ int source_width, source_height, dest_width, dest_height;
+
gfx::GLImage* image =
source_texture->GetLevelImage(source_texture->target(), 0);
if (image) {
@@ -11042,12 +10990,20 @@
}
// Check that this type of texture is allowed.
- if (!texture_manager()->ValidForTarget(source_texture->target(), 0,
- source_width, source_height, 1)) {
+ if (!texture_manager()->ValidForTarget(
+ source_texture->target(), level, source_width, source_height, 1)) {
LOCAL_SET_GL_ERROR(
GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions");
return;
}
+ }
+
+ // Clear the source texture if necessary.
+ if (!texture_manager()->ClearTextureLevel(
+ this, source_texture_ref, source_texture->target(), 0)) {
+ LOCAL_SET_GL_ERROR(
+ GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM", "dimensions too big");
+ return;
}
GLenum source_type = 0;
@@ -11055,23 +11011,22 @@
source_texture->GetLevelType(
source_texture->target(), 0, &source_type, &source_internal_format);
- if (dest_texture->IsImmutable()) {
- LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTextureCHROMIUM",
- "texture is immutable");
- 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)) {
- LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM",
- "dimensions too big");
+ // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA,
+ // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not
+ // renderable on some platforms.
+ bool valid_dest_format = internal_format == GL_RGB ||
+ internal_format == GL_RGBA ||
+ internal_format == GL_BGRA_EXT;
+ bool valid_source_format = source_internal_format == GL_ALPHA ||
+ source_internal_format == GL_RGB ||
+ source_internal_format == GL_RGBA ||
+ source_internal_format == GL_LUMINANCE ||
+ source_internal_format == GL_LUMINANCE_ALPHA ||
+ source_internal_format == GL_BGRA_EXT;
+ if (!valid_source_format || !valid_dest_format) {
+ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
+ "glCopyTextureCHROMIUM",
+ "invalid internal format");
return;
}
@@ -11088,13 +11043,11 @@
GLenum dest_type_previous = dest_type;
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);
+ bool dest_level_defined = dest_texture->GetLevelSize(
+ GL_TEXTURE_2D, level, &dest_width, &dest_height);
if (dest_level_defined) {
- dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous,
+ dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous,
&dest_internal_format);
}
@@ -11106,8 +11059,9 @@
// 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);
+ glTexImage2D(
+ GL_TEXTURE_2D, level, 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);
@@ -11115,11 +11069,11 @@
}
texture_manager()->SetLevelInfo(
- dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width,
+ dest_texture_ref, GL_TEXTURE_2D, level, internal_format, source_width,
source_height, 1, 0, internal_format, dest_type, true);
} else {
- texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
- true);
+ texture_manager()->SetLevelCleared(
+ dest_texture_ref, GL_TEXTURE_2D, level, true);
}
ScopedModifyPixels modify(dest_texture_ref);
@@ -11127,7 +11081,7 @@
// Try using GLImage::CopyTexImage when possible.
bool unpack_premultiply_alpha_change =
unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_;
- if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change) {
+ if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change && !level) {
glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
if (image->CopyTexImage(GL_TEXTURE_2D))
return;
@@ -11139,149 +11093,36 @@
// before presenting.
if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
// TODO(hkuang): get the StreamTexture transform matrix in GPU process
- // instead of using kIdentityMatrix crbug.com/226218.
+ // instead of using default matrix crbug.com/226218.
+ const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f};
copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
- this, source_texture->target(), source_texture->service_id(),
- dest_texture->service_id(), source_width, source_height, unpack_flip_y_,
- unpack_premultiply_alpha_, unpack_unpremultiply_alpha_,
- kIdentityMatrix);
+ this,
+ source_texture->target(),
+ source_texture->service_id(),
+ 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(), source_texture->service_id(),
- source_internal_format, dest_texture->service_id(), internal_format,
- source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
- unpack_unpremultiply_alpha_);
- }
-
- DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
-}
-
-void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(GLenum target,
- GLuint source_id,
- GLuint dest_id,
- GLint xoffset,
- GLint yoffset) {
- TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM");
-
- TextureRef* source_texture_ref = GetTexture(source_id);
- TextureRef* dest_texture_ref = GetTexture(dest_id);
- Texture* source_texture = source_texture_ref->texture();
- Texture* dest_texture = dest_texture_ref->texture();
- int source_width = 0;
- int source_height = 0;
- gfx::GLImage* image =
- source_texture->GetLevelImage(source_texture->target(), 0);
- if (image) {
- gfx::Size size = image->GetSize();
- source_width = size.width();
- source_height = size.height();
- if (source_width <= 0 || source_height <= 0) {
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
- "invalid image size");
- return;
- }
- } else {
- if (!source_texture->GetLevelSize(source_texture->target(), 0,
- &source_width, &source_height)) {
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
- "source texture has no level 0");
- return;
- }
-
- // Check that this type of texture is allowed.
- if (!texture_manager()->ValidForTarget(source_texture->target(), 0,
- source_width, source_height, 1)) {
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
- "source texture bad dimensions");
- 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 = 0;
- GLenum dest_internal_format = 0;
- 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(dest_texture->target(), 0, xoffset,
- yoffset, source_width, source_height,
- dest_type)) {
- 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)) {
- return;
- }
-
- // Clear the source texture if necessary.
- if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
- source_texture->target(), 0)) {
- LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
- "source texture dimensions too big");
- return;
- }
-
- // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
- // needed because it takes 10s of milliseconds to initialize.
- if (!copy_texture_CHROMIUM_.get()) {
- LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM");
- copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
- copy_texture_CHROMIUM_->Initialize(this);
- RestoreCurrentFramebufferBindings();
- if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR)
- return;
- }
-
- int dest_width = 0;
- int dest_height = 0;
- bool ok =
- dest_texture->GetLevelSize(GL_TEXTURE_2D, 0, &dest_width, &dest_height);
- DCHECK(ok);
- if (xoffset != 0 || yoffset != 0 || source_width != dest_width ||
- source_height != dest_height) {
- if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, 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,
- true);
- }
-
- ScopedModifyPixels modify(dest_texture_ref);
-
- DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
-
- // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
- // before presenting.
- if (source_texture->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_->DoCopySubTextureWithTransform(
- this, source_texture->target(), source_texture->service_id(),
- dest_texture->service_id(), xoffset, yoffset, dest_width, dest_height,
- source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
- unpack_unpremultiply_alpha_, kIdentityMatrix);
- } else {
- copy_texture_CHROMIUM_->DoCopySubTexture(
- this, source_texture->target(), source_texture->service_id(),
- source_internal_format, dest_texture->service_id(),
- dest_internal_format, xoffset, yoffset, dest_width, dest_height,
- 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());
@@ -11886,6 +11727,10 @@
return;
}
+ static GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f};
+
GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM
? state_.projection_matrix
: state_.modelview_matrix;
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698