Bug 1376039 - Convert ValidateBlendFuncEnum to static func. r=jgilbert
authorSamuel Vargas <svargas@mozilla.com>
Fri, 23 Jun 2017 17:31:05 -0700
changeset 419913 91ad989f575a06790a03b891633fdbdde2bd0f59
parent 419912 a5cf326ec71fb60712b5e71e7806a7bd42eedaa8
child 419914 94a26629a9335bb06fd457cabe801b997096c7d0
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1376039
milestone56.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 1376039 - Convert ValidateBlendFuncEnum to static func. r=jgilbert
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLContextValidate.cpp
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1575,17 +1575,16 @@ public:
         FailureReason() { }
 
         template<typename A, typename B>
         FailureReason(const A& _key, const B& _info)
             : key(nsCString(_key))
             , info(nsCString(_info))
         { }
     };
-    bool ValidateBlendFuncEnum(GLenum factor, const char *funcName, const char* varName);
 protected:
     bool InitWebGL2(FailureReason* const out_failReason);
 
     bool CreateAndInitGL(bool forceEnabled,
                          std::vector<FailureReason>* const out_failReasons);
 
     bool ResizeBackbuffer(uint32_t width, uint32_t height);
 
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -211,34 +211,62 @@ void WebGLContext::BlendEquationSeparate
         !ValidateBlendEquationEnum(modeAlpha, "blendEquationSeparate: modeAlpha"))
         return;
 
     MakeContextCurrent();
     gl->fBlendEquationSeparate(modeRGB, modeAlpha);
 }
 
 static bool
+ValidateBlendFuncEnum(WebGLContext* webgl, GLenum factor, const char* funcName, const char* varName)
+{
+    switch (factor) {
+    case LOCAL_GL_ZERO:
+    case LOCAL_GL_ONE:
+    case LOCAL_GL_SRC_COLOR:
+    case LOCAL_GL_ONE_MINUS_SRC_COLOR:
+    case LOCAL_GL_DST_COLOR:
+    case LOCAL_GL_ONE_MINUS_DST_COLOR:
+    case LOCAL_GL_SRC_ALPHA:
+    case LOCAL_GL_ONE_MINUS_SRC_ALPHA:
+    case LOCAL_GL_DST_ALPHA:
+    case LOCAL_GL_ONE_MINUS_DST_ALPHA:
+    case LOCAL_GL_CONSTANT_COLOR:
+    case LOCAL_GL_ONE_MINUS_CONSTANT_COLOR:
+    case LOCAL_GL_CONSTANT_ALPHA:
+    case LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA:
+    case LOCAL_GL_SRC_ALPHA_SATURATE:
+        return true;
+
+    default:
+        const nsPrintfCString err("%s: %s", funcName, varName);
+        webgl->ErrorInvalidEnumInfo(err.get(), factor);
+        return false;
+    }
+}
+
+static bool
 ValidateBlendFuncEnums(WebGLContext* webgl, GLenum srcRGB, GLenum srcAlpha,
                        GLenum dstRGB, GLenum dstAlpha, const char* funcName)
 {
     if (!webgl->IsWebGL2()) {
        if (dstRGB == LOCAL_GL_SRC_ALPHA_SATURATE || dstAlpha == LOCAL_GL_SRC_ALPHA_SATURATE) {
           const nsPrintfCString err("%s: LOCAL_GL_SRC_ALPHA_SATURATE as a destination"
                                     " blend function is disallowed in WebGL 1 (dstRGB ="
                                     " 0x%04x, dstAlpha = 0x%04x).",
                                     funcName, dstRGB, dstAlpha);
           webgl->ErrorInvalidEnum("%s", err.get());
           return false;
        }
     }
 
-    if (!webgl->ValidateBlendFuncEnum(srcRGB, funcName, "srcRGB") ||
-        !webgl->ValidateBlendFuncEnum(srcAlpha, funcName, "srcAlpha") ||
-        !webgl->ValidateBlendFuncEnum(dstRGB, funcName, "dstRGB") ||
-        !webgl->ValidateBlendFuncEnum(dstAlpha, funcName, "dstAlpha"))
+    if (!ValidateBlendFuncEnum(webgl, srcRGB, funcName, "srcRGB") ||
+        !ValidateBlendFuncEnum(webgl, srcAlpha, funcName, "srcAlpha") ||
+        !ValidateBlendFuncEnum(webgl, dstRGB, funcName, "dstRGB") ||
+        !ValidateBlendFuncEnum(webgl, dstAlpha, funcName, "dstAlpha"))
     {
        return false;
     }
 
     return true;
 }
 
 void WebGLContext::BlendFunc(GLenum sfactor, GLenum dfactor)
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -59,44 +59,16 @@ WebGLContext::ValidateBlendEquationEnum(
         break;
     }
 
     ErrorInvalidEnumInfo(info, mode);
     return false;
 }
 
 bool
-WebGLContext::ValidateBlendFuncEnum(GLenum factor, const char *funcName, const char* varName)
-{
-    switch (factor) {
-    case LOCAL_GL_ZERO:
-    case LOCAL_GL_ONE:
-    case LOCAL_GL_SRC_COLOR:
-    case LOCAL_GL_ONE_MINUS_SRC_COLOR:
-    case LOCAL_GL_DST_COLOR:
-    case LOCAL_GL_ONE_MINUS_DST_COLOR:
-    case LOCAL_GL_SRC_ALPHA:
-    case LOCAL_GL_ONE_MINUS_SRC_ALPHA:
-    case LOCAL_GL_DST_ALPHA:
-    case LOCAL_GL_ONE_MINUS_DST_ALPHA:
-    case LOCAL_GL_CONSTANT_COLOR:
-    case LOCAL_GL_ONE_MINUS_CONSTANT_COLOR:
-    case LOCAL_GL_CONSTANT_ALPHA:
-    case LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA:
-    case LOCAL_GL_SRC_ALPHA_SATURATE:
-        return true;
-
-    default:
-        const nsPrintfCString err("%s: %s", funcName, varName);
-        ErrorInvalidEnumInfo(err.get(), factor);
-        return false;
-    }
-}
-
-bool
 WebGLContext::ValidateBlendFuncEnumsCompatibility(GLenum sfactor,
                                                   GLenum dfactor,
                                                   const char* info)
 {
     bool sfactorIsConstantColor = sfactor == LOCAL_GL_CONSTANT_COLOR ||
                                   sfactor == LOCAL_GL_ONE_MINUS_CONSTANT_COLOR;
     bool sfactorIsConstantAlpha = sfactor == LOCAL_GL_CONSTANT_ALPHA ||
                                   sfactor == LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA;