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 ca955da6627c4a5a22fdb9394bdf1fd41ef2c752..3140d6f55dedf9f0609dc6705a4749d76afa771f 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -1295,6 +1295,9 @@ |
// Returns: true if glEnable/glDisable should actually be called. |
bool SetCapabilityState(GLenum cap, bool enabled); |
+ // Infer color encoding from internalformat |
+ static GLint GetColorEncodingFromInternalFormat(GLenum internalformat); |
+ |
// Check that the currently bound read framebuffer's color image |
// isn't the target texture of the glCopyTex{Sub}Image{2D|3D}. |
bool FormsTextureCopyingFeedbackLoop( |
@@ -4414,6 +4417,19 @@ |
return valid; |
} |
+GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( |
+ GLenum internalformat) { |
+ switch (internalformat) { |
+ case GL_SRGB_EXT: |
+ case GL_SRGB_ALPHA_EXT: |
+ case GL_SRGB8: |
+ case GL_SRGB8_ALPHA8: |
+ return GL_SRGB; |
+ default: |
+ return GL_LINEAR; |
+ } |
+} |
+ |
bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( |
TextureRef* texture, GLint level, GLint layer) { |
Framebuffer* framebuffer = GetBoundReadFramebuffer(); |
@@ -6214,8 +6230,8 @@ |
bool enable_srgb = 0; |
if (target == GL_TEXTURE_2D) { |
tex->GetLevelType(target, tex->base_level(), &type, &internal_format); |
- enable_srgb = GLES2Util::GetColorEncodingFromInternalFormat( |
- internal_format) == GL_SRGB; |
+ enable_srgb = |
+ GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB; |
} |
if (enable_srgb && feature_info_->feature_flags().desktop_srgb_support) { |
state_.EnableDisableFramebufferSRGB(enable_srgb); |
@@ -8035,8 +8051,8 @@ |
GLenum src_internal_format = GetBoundReadFramebufferInternalFormat(); |
GLenum src_type = GetBoundReadFramebufferTextureType(); |
- bool read_buffer_has_srgb = GLES2Util::GetColorEncodingFromInternalFormat( |
- src_internal_format) == GL_SRGB; |
+ bool read_buffer_has_srgb = |
+ GetColorEncodingFromInternalFormat(src_internal_format) == GL_SRGB; |
bool draw_buffers_has_srgb = false; |
if ((mask & GL_COLOR_BUFFER_BIT) != 0) { |
bool is_src_signed_int = |
@@ -8068,7 +8084,7 @@ |
if (!src_internal_format) { |
read_framebuffer_miss_image = true; |
} |
- if (GLES2Util::GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB) |
+ if (GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB) |
draw_buffers_has_srgb = true; |
if (read_buffer_samples > 0 && |
(src_sized_format != |
@@ -13948,16 +13964,15 @@ |
return false; |
} |
if (feature_info_->IsWebGL2OrES3Context()) { |
- GLint color_encoding = |
- GLES2Util::GetColorEncodingFromInternalFormat(read_format); |
+ GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); |
bool float_mismatch = feature_info_->ext_color_buffer_float_available() ? |
(GLES2Util::IsIntegerFormat(internal_format) != |
GLES2Util::IsIntegerFormat(read_format)) : |
GLES2Util::IsFloatFormat(internal_format); |
- if (color_encoding != |
- GLES2Util::GetColorEncodingFromInternalFormat(internal_format) || |
- float_mismatch || (GLES2Util::IsSignedIntegerFormat(internal_format) != |
- GLES2Util::IsSignedIntegerFormat(read_format)) || |
+ if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || |
+ float_mismatch || |
+ (GLES2Util::IsSignedIntegerFormat(internal_format) != |
+ GLES2Util::IsSignedIntegerFormat(read_format)) || |
(GLES2Util::IsUnsignedIntegerFormat(internal_format) != |
GLES2Util::IsUnsignedIntegerFormat(read_format))) { |
*output_error_msg = std::string("incompatible format"); |
@@ -16456,10 +16471,8 @@ |
if (feature_info_->feature_flags().desktop_srgb_support) { |
bool enable_framebuffer_srgb = |
- GLES2Util::GetColorEncodingFromInternalFormat(source_internal_format) == |
- GL_SRGB || |
- GLES2Util::GetColorEncodingFromInternalFormat(internal_format) == |
- GL_SRGB; |
+ GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB || |
+ GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB; |
state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); |
} |
@@ -16705,17 +16718,6 @@ |
return; |
} |
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
- // glDrawArrays is faster than glCopyTexSubImage2D on IA Mesa driver, |
- // although opposite in Android. |
- // TODO(dshwang): After Mesa fixes this issue, remove this hack. |
- // https://bugs.freedesktop.org/show_bug.cgi?id=98478, crbug.com/535198. |
- if (Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format, false) && |
- method == DIRECT_COPY) { |
- method = DIRECT_DRAW; |
- } |
-#endif |
- |
// Draw to a fbo attaching level 0 of an intermediate texture, |
// then copy from the fbo to dest texture level with glCopyTexImage2D. |
// For WebGL 1.0 or OpenGL ES 2.0, DIRECT_DRAW path isn't available for |
@@ -16736,10 +16738,8 @@ |
if (feature_info_->feature_flags().desktop_srgb_support) { |
bool enable_framebuffer_srgb = |
- GLES2Util::GetColorEncodingFromInternalFormat(source_internal_format) == |
- GL_SRGB || |
- GLES2Util::GetColorEncodingFromInternalFormat(dest_internal_format) == |
- GL_SRGB; |
+ GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB || |
+ GetColorEncodingFromInternalFormat(dest_internal_format) == GL_SRGB; |
state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); |
} |