Bug 973815 - Implements WebGL extension EXT_blend_minmax - r=jgilbert,bzbarsky
☠☠ backed out by f903c0f48969 ☠ ☠
authorGuillaume Abadie <guillaume.abadie@gmail.com>
Tue, 10 Jun 2014 18:20:12 -0700
changeset 209530 ca5b7ed0dd5ae7ed22f29de1fe71240737cfb468
parent 209529 1d0eb8fb8d87660b4fcac6f5dbac53737469b78a
child 209531 e9f6e6ec3cde68e4c7e99ac360b8fef1ce4568d1
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, bzbarsky
bugs973815
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 973815 - Implements WebGL extension EXT_blend_minmax - r=jgilbert,bzbarsky
content/canvas/src/WebGL2Context.cpp
content/canvas/src/WebGLContextExtensions.cpp
content/canvas/src/WebGLContextValidate.cpp
content/canvas/src/WebGLExtensionBlendMinMax.cpp
content/canvas/src/WebGLExtensions.h
content/canvas/src/WebGLTypes.h
content/canvas/src/moz.build
dom/bindings/Bindings.conf
dom/webidl/WebGLRenderingContext.webidl
--- a/content/canvas/src/WebGL2Context.cpp
+++ b/content/canvas/src/WebGL2Context.cpp
@@ -59,26 +59,26 @@ WebGL2Context::WrapObject(JSContext *cx)
 
 bool
 WebGLContext::InitWebGL2()
 {
     MOZ_ASSERT(IsWebGL2(), "WebGLContext is not a WebGL 2 context!");
 
     const WebGLExtensionID sExtensionNativelySupportedArr[] = {
         WebGLExtensionID::ANGLE_instanced_arrays,
+        WebGLExtensionID::EXT_blend_minmax,
         WebGLExtensionID::OES_element_index_uint,
         WebGLExtensionID::OES_standard_derivatives,
         WebGLExtensionID::OES_texture_float,
         WebGLExtensionID::OES_texture_float_linear,
         WebGLExtensionID::OES_vertex_array_object,
         WebGLExtensionID::WEBGL_depth_texture,
         WebGLExtensionID::WEBGL_draw_buffers
     };
     const GLFeature sFeatureRequiredArr[] = {
-        GLFeature::blend_minmax,
         GLFeature::instanced_non_arrays,
         GLFeature::transform_feedback
     };
 
     // check WebGL extensions that are supposed to be natively supported
     for (size_t i = 0; i < size_t(MOZ_ARRAY_LENGTH(sExtensionNativelySupportedArr)); i++)
     {
         WebGLExtensionID extension = sExtensionNativelySupportedArr[i];
--- a/content/canvas/src/WebGLContextExtensions.cpp
+++ b/content/canvas/src/WebGLContextExtensions.cpp
@@ -26,16 +26,17 @@ WebGLContext::GetExtensionString(WebGLEx
 
     if (!initialized) {
         initialized = true;
 
 #define WEBGL_EXTENSION_IDENTIFIER(x) \
         sExtensionNamesEnumeratedArray[WebGLExtensionID::x] = #x;
 
         WEBGL_EXTENSION_IDENTIFIER(ANGLE_instanced_arrays)
+        WEBGL_EXTENSION_IDENTIFIER(EXT_blend_minmax)
         WEBGL_EXTENSION_IDENTIFIER(EXT_color_buffer_half_float)
         WEBGL_EXTENSION_IDENTIFIER(EXT_frag_depth)
         WEBGL_EXTENSION_IDENTIFIER(EXT_sRGB)
         WEBGL_EXTENSION_IDENTIFIER(EXT_texture_filter_anisotropic)
         WEBGL_EXTENSION_IDENTIFIER(OES_element_index_uint)
         WEBGL_EXTENSION_IDENTIFIER(OES_standard_derivatives)
         WEBGL_EXTENSION_IDENTIFIER(OES_texture_float)
         WEBGL_EXTENSION_IDENTIFIER(OES_texture_float_linear)
@@ -157,26 +158,26 @@ bool WebGLContext::IsExtensionSupported(
         case WebGLExtensionID::WEBGL_draw_buffers:
             return WebGLExtensionDrawBuffers::IsSupported(this);
         case WebGLExtensionID::EXT_frag_depth:
             return WebGLExtensionFragDepth::IsSupported(this);
         default:
             // For warnings-as-errors.
             break;
     }
-// Uncomment this switch for any new extensions
-#if 0
+
     if (Preferences::GetBool("webgl.enable-draft-extensions", false) || IsWebGL2()) {
         switch (ext) {
+            case WebGLExtensionID::EXT_blend_minmax:
+                return WebGLExtensionBlendMinMax::IsSupported(this);
             default:
                 // For warnings-as-errors.
                 break;
         }
     }
-#endif
 
     return false;
 }
 
 static bool
 CompareWebGLExtensionName(const nsACString& name, const char *other)
 {
     return name.Equals(other, nsCaseInsensitiveCStringComparator());
@@ -325,16 +326,19 @@ WebGLContext::EnableExtension(WebGLExten
             obj = new WebGLExtensionInstancedArrays(this);
             break;
         case WebGLExtensionID::EXT_sRGB:
             obj = new WebGLExtensionSRGB(this);
             break;
         case WebGLExtensionID::EXT_frag_depth:
             obj = new WebGLExtensionFragDepth(this);
             break;
+        case WebGLExtensionID::EXT_blend_minmax:
+            obj = new WebGLExtensionBlendMinMax(this);
+            break;
         default:
             MOZ_ASSERT(false, "should not get there.");
     }
 
     mExtensions[ext] = obj;
 }
 
 void
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -323,18 +323,17 @@ bool WebGLContext::ValidateBlendEquation
 {
     switch (mode) {
         case LOCAL_GL_FUNC_ADD:
         case LOCAL_GL_FUNC_SUBTRACT:
         case LOCAL_GL_FUNC_REVERSE_SUBTRACT:
             return true;
         case LOCAL_GL_MIN:
         case LOCAL_GL_MAX:
-            if (IsWebGL2()) {
-                // http://www.opengl.org/registry/specs/EXT/blend_minmax.txt
+            if (IsExtensionEnabled(WebGLExtensionID::EXT_blend_minmax)) {
                 return true;
             }
             break;
         default:
             break;
     }
 
     ErrorInvalidEnumInfo(info, mode);
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/WebGLExtensionBlendMinMax.cpp
@@ -0,0 +1,30 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "WebGLContext.h"
+#include "WebGLExtensions.h"
+
+#include "GLContext.h"
+
+#include "mozilla/dom/WebGLRenderingContextBinding.h"
+
+using namespace mozilla;
+
+WebGLExtensionBlendMinMax::WebGLExtensionBlendMinMax(WebGLContext* context)
+    : WebGLExtensionBase(context)
+{
+}
+
+WebGLExtensionBlendMinMax::~WebGLExtensionBlendMinMax()
+{
+}
+
+bool WebGLExtensionBlendMinMax::IsSupported(const WebGLContext* context)
+{
+    gl::GLContext * gl = context->GL();
+
+    return gl->IsSupported(GLFeature::blend_minmax);
+}
+
+IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionBlendMinMax)
--- a/content/canvas/src/WebGLExtensions.h
+++ b/content/canvas/src/WebGLExtensions.h
@@ -304,11 +304,23 @@ public:
                                     GLsizei primcount);
     void VertexAttribDivisorANGLE(GLuint index, GLuint divisor);
 
     static bool IsSupported(const WebGLContext* context);
 
     DECL_WEBGL_EXTENSION_GOOP
 };
 
+class WebGLExtensionBlendMinMax
+    : public WebGLExtensionBase
+{
+public:
+    WebGLExtensionBlendMinMax(WebGLContext*);
+    virtual ~WebGLExtensionBlendMinMax();
+
+    static bool IsSupported(const WebGLContext*);
+
+    DECL_WEBGL_EXTENSION_GOOP
+};
+
 } // namespace mozilla
 
 #endif // WEBGLEXTENSIONS_H_
--- a/content/canvas/src/WebGLTypes.h
+++ b/content/canvas/src/WebGLTypes.h
@@ -141,16 +141,17 @@ MOZ_BEGIN_ENUM_CLASS(WebGLTexImageFunc, 
     CopyTexSubImage,
     CompTexImage,
     CompTexSubImage,
 MOZ_END_ENUM_CLASS(WebGLTexImageFunc)
 
 // Please keep extensions in alphabetic order.
 MOZ_BEGIN_ENUM_CLASS(WebGLExtensionID, uint8_t)
     ANGLE_instanced_arrays,
+    EXT_blend_minmax,
     EXT_color_buffer_half_float,
     EXT_frag_depth,
     EXT_sRGB,
     EXT_texture_filter_anisotropic,
     OES_element_index_uint,
     OES_standard_derivatives,
     OES_texture_float,
     OES_texture_float_linear,
--- a/content/canvas/src/moz.build
+++ b/content/canvas/src/moz.build
@@ -40,16 +40,17 @@ if CONFIG['MOZ_WEBGL']:
         'WebGLContextReporter.cpp',
         'WebGLContextState.cpp',
         'WebGLContextUtils.cpp',
         'WebGLContextValidate.cpp',
         'WebGLContextVertexArray.cpp',
         'WebGLContextVertices.cpp',
         'WebGLElementArrayCache.cpp',
         'WebGLExtensionBase.cpp',
+        'WebGLExtensionBlendMinMax.cpp',
         'WebGLExtensionColorBufferFloat.cpp',
         'WebGLExtensionColorBufferHalfFloat.cpp',
         'WebGLExtensionCompressedTextureATC.cpp',
         'WebGLExtensionCompressedTextureETC1.cpp',
         'WebGLExtensionCompressedTexturePVRTC.cpp',
         'WebGLExtensionCompressedTextureS3TC.cpp',
         'WebGLExtensionDebugRendererInfo.cpp',
         'WebGLExtensionDebugShaders.cpp',
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1484,16 +1484,21 @@ DOMInterfaces = {
     'headerFile': 'WebGLExtensions.h'
 },
 
 'WebGLExtensionInstancedArrays': {
     'nativeType': 'mozilla::WebGLExtensionInstancedArrays',
     'headerFile': 'WebGLExtensions.h'
 },
 
+'WebGLExtensionBlendMinMax': {
+    'nativeType': 'mozilla::WebGLExtensionBlendMinMax',
+    'headerFile': 'WebGLExtensions.h'
+},
+
 'WebGLFramebuffer': {
     'nativeType': 'mozilla::WebGLFramebuffer',
     'headerFile': 'WebGLFramebuffer.h'
 },
 
 'WebGLProgram': {
     'nativeType': 'mozilla::WebGLProgram',
     'headerFile': 'WebGLProgram.h'
--- a/dom/webidl/WebGLRenderingContext.webidl
+++ b/dom/webidl/WebGLRenderingContext.webidl
@@ -954,8 +954,14 @@ interface WebGLExtensionVertexArray {
 [NoInterfaceObject]
 interface WebGLExtensionInstancedArrays {
     const GLenum VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE;
 
     void drawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
     void drawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, GLintptr offset, GLsizei primcount);
     void vertexAttribDivisorANGLE(GLuint index, GLuint divisor);
 };
+
+[NoInterfaceObject]
+interface WebGLExtensionBlendMinMax {
+    const GLenum MIN_EXT = 0x8007;
+    const GLenum MAX_EXT = 0x8008;
+};