Bug 1403798 - Fix EXT_sRGB activation, particularly on Windows+ANGLE+ES2. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Wed, 27 Sep 2017 19:38:04 -0700
changeset 671573 8fbc79340d95921c9017b694e547e09bbf2676bb
parent 671565 5ebe2e8980c6fd3ede2b6617bbbc4073dd9b0369
child 733555 c8faddde8b24a278e13b4f3250d99d9ada144b76
push id81976
push userbmo:jgilbert@mozilla.com
push dateThu, 28 Sep 2017 02:39:22 +0000
reviewersdaoshengmu
bugs1403798
milestone58.0a1
Bug 1403798 - Fix EXT_sRGB activation, particularly on Windows+ANGLE+ES2. - r=daoshengmu MozReview-Commit-ID: 9gC3B1jsX5I
dom/canvas/WebGL2Context.cpp
dom/canvas/WebGLExtensionSRGB.cpp
dom/canvas/WebGLTexture.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextFeatures.cpp
--- a/dom/canvas/WebGL2Context.cpp
+++ b/dom/canvas/WebGL2Context.cpp
@@ -73,18 +73,17 @@ static const gl::GLFeature kRequiredFeat
     gl::GLFeature::instanced_arrays,
     gl::GLFeature::instanced_non_arrays,
     gl::GLFeature::map_buffer_range, // Used by GetBufferSubData.
     gl::GLFeature::occlusion_query2,
     gl::GLFeature::packed_depth_stencil,
     gl::GLFeature::query_objects,
     gl::GLFeature::renderbuffer_color_float,
     gl::GLFeature::renderbuffer_color_half_float,
-    gl::GLFeature::sRGB_framebuffer,
-    gl::GLFeature::sRGB_texture,
+    gl::GLFeature::sRGB,
     gl::GLFeature::sampler_objects,
     gl::GLFeature::standard_derivatives,
     gl::GLFeature::texture_3D,
     gl::GLFeature::texture_3D_compressed,
     gl::GLFeature::texture_3D_copy,
     gl::GLFeature::texture_float,
     gl::GLFeature::texture_half_float,
     gl::GLFeature::texture_half_float_linear,
--- a/dom/canvas/WebGLExtensionSRGB.cpp
+++ b/dom/canvas/WebGLExtensionSRGB.cpp
@@ -53,20 +53,17 @@ WebGLExtensionSRGB::WebGLExtensionSRGB(W
     fua->AllowRBFormat(LOCAL_GL_SRGB8_ALPHA8, usage);
 }
 
 WebGLExtensionSRGB::~WebGLExtensionSRGB()
 {
 }
 
 bool
-WebGLExtensionSRGB::IsSupported(const WebGLContext* webgl)
+WebGLExtensionSRGB::IsSupported(const WebGLContext* const webgl)
 {
-    gl::GLContext* gl = webgl->GL();
-
-    return gl->IsSupported(gl::GLFeature::sRGB_framebuffer) &&
-           gl->IsSupported(gl::GLFeature::sRGB_texture);
+    return webgl->gl->IsSupported(gl::GLFeature::sRGB);
 }
 
 
 IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionSRGB, EXT_sRGB)
 
 } // namespace mozilla
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -877,24 +877,32 @@ WebGLTexture::GenerateMipmap(TexTarget t
     }
 
     if (IsCubeMap() && !IsCubeComplete()) {
       mContext->ErrorInvalidOperation("%s: Cube maps must be \"cube complete\".",
                                       funcName);
       return;
     }
 
-    if (!mContext->IsWebGL2() && !baseImageInfo.IsPowerOfTwo()) {
-        mContext->ErrorInvalidOperation("%s: The base level of the texture does not have"
-                                        " power-of-two dimensions.",
-                                        funcName);
-        return;
+    const auto format = baseImageInfo.mFormat->format;
+    if (!mContext->IsWebGL2()) {
+        if (!baseImageInfo.IsPowerOfTwo()) {
+            mContext->ErrorInvalidOperation("%s: The base level of the texture does not"
+                                            " have power-of-two dimensions.",
+                                            funcName);
+            return;
+        }
+        if (format->isSRGB) {
+            mContext->ErrorInvalidOperation("%s: EXT_sRGB forbids GenerateMipmap with"
+                                            " sRGB.",
+                                            funcName);
+            return;
+        }
     }
 
-    auto format = baseImageInfo.mFormat->format;
     if (format->compression) {
         mContext->ErrorInvalidOperation("%s: Texture data at base level is compressed.",
                                         funcName);
         return;
     }
 
     if (format->d) {
         mContext->ErrorInvalidOperation("%s: Depth textures are not supported.",
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -117,18 +117,17 @@ enum class GLFeature {
     query_counter,
     query_objects,
     query_time_elapsed,
     read_buffer,
     renderbuffer_color_float,
     renderbuffer_color_half_float,
     robust_buffer_access_behavior,
     robustness,
-    sRGB_framebuffer,
-    sRGB_texture,
+    sRGB,
     sampler_objects,
     seamless_cube_map_opt_in,
     shader_texture_lod,
     split_framebuffer,
     standard_derivatives,
     sync,
     texture_3D,
     texture_3D_compressed,
--- a/gfx/gl/GLContextFeatures.cpp
+++ b/gfx/gl/GLContextFeatures.cpp
@@ -541,34 +541,23 @@ static const FeatureInfo sFeatureInfoArr
         {
             GLContext::ARB_robustness,
             GLContext::EXT_robustness,
             GLContext::KHR_robustness,
             GLContext::Extensions_End
         }
     },
     {
-        "sRGB_framebuffer",
+        "sRGB",
         GLVersion::GL3,
         GLESVersion::ES3,
         GLContext::ARB_framebuffer_sRGB,
         {
+            GLContext::EXT_sRGB,
             GLContext::EXT_framebuffer_sRGB,
-            GLContext::EXT_sRGB_write_control,
-            GLContext::Extensions_End
-        }
-    },
-    {
-        "sRGB_texture",
-        GLVersion::GL2_1,
-        GLESVersion::ES3,
-        GLContext::Extension_None,
-        {
-            GLContext::EXT_sRGB,
-            GLContext::EXT_texture_sRGB,
             GLContext::Extensions_End
         }
     },
     {
         "sampler_objects",
         GLVersion::GL3_3,
         GLESVersion::ES3,
         GLContext::ARB_sampler_objects,