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 8c24d3cd1df5f8e04a458d173ec5106f5d3971bd..f76c085eb35b97d269bc5549fb29b0996e1b7a48 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -81,10 +81,15 @@ namespace gles2 { |
namespace { |
-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"; |
+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 bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin, |
GLint rangeMax, |
@@ -585,7 +590,7 @@ class GLES2DecoderImpl : public GLES2Decoder, |
bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, |
const scoped_refptr<gfx::GLContext>& context, |
bool offscreen, |
- const gfx::Size& size, |
+ const gfx::Size& offscreen_size, |
const DisallowedFeatures& disallowed_features, |
const std::vector<int32>& attribs) override; |
void Destroy(bool have_context) override; |
@@ -936,13 +941,17 @@ class GLES2DecoderImpl : public GLES2Decoder, |
GLuint io_surface_id, |
GLuint plane); |
- void DoCopyTextureCHROMIUM( |
- GLenum target, |
- GLuint source_id, |
- GLuint target_id, |
- GLint level, |
- GLenum internal_format, |
- GLenum dest_type); |
+ 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); |
// Wrapper for TexStorage2DEXT. |
void DoTexStorage2DEXT( |
@@ -1658,6 +1667,11 @@ class GLES2DecoderImpl : public GLES2Decoder, |
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( |
@@ -2434,13 +2448,17 @@ bool GLES2DecoderImpl::Initialize( |
const scoped_refptr<gfx::GLSurface>& surface, |
const scoped_refptr<gfx::GLContext>& context, |
bool offscreen, |
- const gfx::Size& size, |
+ const gfx::Size& offscreen_size, |
const DisallowedFeatures& disallowed_features, |
const std::vector<int32>& attribs) { |
TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
DCHECK(context->IsCurrent(surface.get())); |
DCHECK(!context_.get()); |
+ ContextCreationAttribHelper attrib_parser; |
+ if (!attrib_parser.Parse(attribs)) |
+ return false; |
+ |
surfaceless_ = surface->IsSurfaceless() && !offscreen; |
set_initialized(); |
@@ -2457,7 +2475,10 @@ bool GLES2DecoderImpl::Initialize( |
} |
if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
- switches::kEnableUnsafeES3APIs)) { |
+ switches::kEnableUnsafeES3APIs) && |
+ attrib_parser.es3_context_required) { |
+ // TODO(zmo): We need to implement capabilities check to ensure we can |
+ // actually create ES3 contexts. |
set_unsafe_es3_apis_enabled(true); |
} |
@@ -2470,10 +2491,6 @@ bool GLES2DecoderImpl::Initialize( |
context_ = context; |
surface_ = surface; |
- ContextCreationAttribHelper attrib_parser; |
- if (!attrib_parser.Parse(attribs)) |
- return false; |
- |
// Create GPU Tracer for timing values. |
gpu_tracer_.reset(new GPUTracer(this)); |
@@ -2675,12 +2692,15 @@ bool GLES2DecoderImpl::Initialize( |
// Allocate the render buffers at their initial size and check the status |
// of the frame buffers is okay. |
- if (!ResizeOffscreenFrameBuffer(size)) { |
+ if (!ResizeOffscreenFrameBuffer(offscreen_size)) { |
LOG(ERROR) << "Could not allocate offscreen buffer storage."; |
Destroy(true); |
return false; |
} |
+ state_.viewport_width = offscreen_size.width(); |
+ state_.viewport_height = offscreen_size.height(); |
+ |
// Allocate the offscreen saved color texture. |
DCHECK(offscreen_saved_color_format_); |
offscreen_saved_color_texture_->AllocateStorage( |
@@ -2720,6 +2740,9 @@ bool GLES2DecoderImpl::Initialize( |
glGetIntegerv(GL_STENCIL_BITS, &v); |
back_buffer_has_stencil_ = attrib_parser.stencil_size != 0 && v > 0; |
} |
+ |
+ state_.viewport_width = surface->GetSize().width(); |
+ state_.viewport_height = surface->GetSize().height(); |
} |
// OpenGL ES 2.0 implicitly enables the desktop GL capability |
@@ -2742,9 +2765,6 @@ bool GLES2DecoderImpl::Initialize( |
return false; |
} |
- state_.viewport_width = size.width(); |
- state_.viewport_height = size.height(); |
- |
GLint viewport_params[4] = { 0 }; |
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); |
viewport_max_width_ = viewport_params[0]; |
@@ -2956,9 +2976,15 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() { |
features().nv_draw_buffers ? 1 : 0; |
} |
- ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC |
- : SH_GLES2_SPEC; |
- if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) |
+ ShShaderSpec shader_spec; |
+ if (force_webgl_glsl_validation_) { |
+ shader_spec = unsafe_es3_apis_enabled() ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC; |
+ } else { |
+ shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC; |
+ } |
+ |
+ if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) && |
+ features().enable_shader_name_hashing) |
resources.HashFunction = &CityHash64; |
else |
resources.HashFunction = NULL; |
@@ -10935,40 +10961,78 @@ static GLenum ExtractFormatFromStorageFormat(GLenum internalformat) { |
} |
} |
-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); |
- |
+bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM( |
+ const char* function_name, |
+ GLenum target, |
+ TextureRef* source_texture_ref, |
+ TextureRef* dest_texture_ref, |
+ GLenum dest_internal_format) { |
if (!source_texture_ref || !dest_texture_ref) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id"); |
- return; |
+ 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, "glCopyTextureCHROMIUM", "invalid texture target"); |
- return; |
+ 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)) { |
- LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, |
- "glCopyTextureCHROMIUM", |
+ LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
"invalid texture target binding"); |
- return; |
+ return false; |
} |
- int source_width, source_height, dest_width, dest_height; |
+ 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; |
gfx::GLImage* image = |
source_texture->GetLevelImage(source_texture->target(), 0); |
if (image) { |
@@ -10991,43 +11055,36 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
} |
// Check that this type of texture is allowed. |
- if (!texture_manager()->ValidForTarget( |
- source_texture->target(), level, source_width, source_height, 1)) { |
+ if (!texture_manager()->ValidForTarget(source_texture->target(), 0, |
+ 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; |
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 = 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"); |
+ 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"); |
return; |
} |
@@ -11044,11 +11101,13 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
GLenum dest_type_previous = dest_type; |
GLenum dest_internal_format = internal_format; |
- bool dest_level_defined = dest_texture->GetLevelSize( |
- GL_TEXTURE_2D, level, &dest_width, &dest_height); |
+ int dest_width = 0; |
+ int dest_height = 0; |
+ bool dest_level_defined = |
+ dest_texture->GetLevelSize(GL_TEXTURE_2D, 0, &dest_width, &dest_height); |
if (dest_level_defined) { |
- dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, |
+ dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous, |
&dest_internal_format); |
} |
@@ -11060,9 +11119,8 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
// 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, level, internal_format, source_width, source_height, |
- 0, internal_format, dest_type, NULL); |
+ 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_, GL_TEXTURE_2D); |
@@ -11070,11 +11128,11 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
} |
texture_manager()->SetLevelInfo( |
- dest_texture_ref, GL_TEXTURE_2D, level, internal_format, source_width, |
+ dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width, |
source_height, 1, 0, internal_format, dest_type, true); |
} else { |
- texture_manager()->SetLevelCleared( |
- dest_texture_ref, GL_TEXTURE_2D, level, true); |
+ texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, |
+ true); |
} |
ScopedModifyPixels modify(dest_texture_ref); |
@@ -11082,7 +11140,7 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
// 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 && !level) { |
+ if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change) { |
glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
if (image->CopyTexImage(GL_TEXTURE_2D)) |
return; |
@@ -11094,36 +11152,159 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
// before presenting. |
if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { |
// TODO(hkuang): get the StreamTexture transform matrix in GPU process |
- // 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}; |
+ // instead of using kIdentityMatrix crbug.com/226218. |
copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
- 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); |
+ 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); |
+ } 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); |
+ |
+ // Try using GLImage::CopyTexSubImage when possible. |
+ bool unpack_premultiply_alpha_change = |
+ unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_; |
+ if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change && |
+ !xoffset && !yoffset) { |
+ glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); |
+ if (image->CopyTexImage(GL_TEXTURE_2D)) |
+ return; |
+ } |
+ |
+ 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_->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_); |
+ 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_); |
} |
DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); |
@@ -11728,10 +11909,6 @@ void GLES2DecoderImpl::DoMatrixLoadIdentityCHROMIUM(GLenum matrix_mode) { |
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; |