Bug 890926 - WebGL2 Min/max blend equations. r=jgilbert
authorGuillaume Abadie <gabadie@mozilla.com>
Thu, 18 Jul 2013 11:24:23 -0400
changeset 139094 19bf4aeaa0529df82538832df9991a446c18c4b5
parent 139093 de1f0de356a131ddc7b08f0f72caa4a516780af0
child 139095 4380a4e6c73a4eb80a2df0c666c81ca61d4e3883
push id24977
push userryanvm@gmail.com
push dateFri, 19 Jul 2013 00:35:38 +0000
treeherdermozilla-central@0d0263a58f06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs890926
milestone25.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 890926 - WebGL2 Min/max blend equations. r=jgilbert
content/canvas/src/WebGLContextValidate.cpp
dom/webidl/WebGL2RenderingContext.webidl
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -191,20 +191,29 @@ bool WebGLContext::ValidateCapabilityEnu
 
 bool WebGLContext::ValidateBlendEquationEnum(WebGLenum mode, const char *info)
 {
     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
+                return true;
+            }
+            break;
         default:
-            ErrorInvalidEnumInfo(info, mode);
-            return false;
+            break;
     }
+
+    ErrorInvalidEnumInfo(info, mode);
+    return false;
 }
 
 bool WebGLContext::ValidateBlendFuncDstEnum(WebGLenum factor, const char *info)
 {
     switch (factor) {
         case LOCAL_GL_ZERO:
         case LOCAL_GL_ONE:
         case LOCAL_GL_SRC_COLOR:
@@ -1047,17 +1056,18 @@ WebGLContext::InitAndValidateGL()
     if (error != LOCAL_GL_NO_ERROR) {
         GenerateWarning("GL error 0x%x occurred during WebGL context initialization!", error);
         return false;
     }
 
     if (IsWebGL2() &&
         (!IsExtensionSupported(OES_vertex_array_object) ||
          !IsExtensionSupported(WEBGL_draw_buffers) ||
-         !gl->IsExtensionSupported(gl::GLContext::EXT_gpu_shader4)
+         !gl->IsExtensionSupported(gl::GLContext::EXT_gpu_shader4) ||
+         !gl->IsExtensionSupported(gl::GLContext::EXT_blend_minmax)
         ))
     {
         return false;
     }
 
     mMemoryPressureObserver
         = new WebGLMemoryPressureObserver(this);
     nsCOMPtr<nsIObserverService> observerService
--- a/dom/webidl/WebGL2RenderingContext.webidl
+++ b/dom/webidl/WebGL2RenderingContext.webidl
@@ -43,16 +43,20 @@ interface WebGL2RenderingContext : WebGL
     const GLenum DRAW_BUFFER15               = 0x8834;
 
     const GLenum MAX_COLOR_ATTACHMENTS       = 0x8CDF;
     const GLenum MAX_DRAW_BUFFERS            = 0x8824;
 
     /* vertex array objects */
     const GLenum VERTEX_ARRAY_BINDING        = 0x85B5;
 
+    /* blend equations */
+    const GLenum MIN                         = 0x8007;
+    const GLenum MAX                         = 0x8008;
+
 
     void bindVertexArray(WebGLVertexArray? arrayObject);
     WebGLVertexArray? createVertexArray();
     void drawBuffers(sequence<GLenum> buffers);
     void deleteVertexArray(WebGLVertexArray? arrayObject);
     [WebGLHandlesContextLoss] GLboolean isVertexArray(WebGLVertexArray? arrayObject);
 
 };
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -87,16 +87,17 @@ static const char *sExtensionNames[] = {
     "GL_EXT_packed_depth_stencil",
     "GL_OES_element_index_uint",
     "GL_OES_vertex_array_object",
     "GL_ARB_vertex_array_object",
     "GL_APPLE_vertex_array_object",
     "GL_ARB_draw_buffers",
     "GL_EXT_draw_buffers",
     "GL_EXT_gpu_shader4",
+    "GL_EXT_blend_minmax",
     nullptr
 };
 
 static int64_t sTextureMemoryUsage = 0;
 
 static int64_t
 GetTextureMemoryUsage()
 {
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -1075,16 +1075,17 @@ public:
         EXT_packed_depth_stencil,
         OES_element_index_uint,
         OES_vertex_array_object,
         ARB_vertex_array_object,
         APPLE_vertex_array_object,
         ARB_draw_buffers,
         EXT_draw_buffers,
         EXT_gpu_shader4,
+        EXT_blend_minmax,
         Extensions_Max
     };
 
     bool IsExtensionSupported(GLExtensions aKnownExtension) const {
         return mAvailableExtensions[aKnownExtension];
     }
 
     void MarkExtensionUnsupported(GLExtensions aKnownExtension) {