Bug 1376039 - Convert ValidateBlendFuncEnum to static func. r=jgilbert

--HG--
extra : rebase_source : 0f4603d54951436770388b79bcb6e5d4b7782f5e
This commit is contained in:
Samuel Vargas 2017-06-23 17:31:05 -07:00
parent d7f0c12cd3
commit 3ca06f7de4
3 changed files with 32 additions and 33 deletions

View File

@ -1580,7 +1580,6 @@ public:
, info(nsCString(_info))
{ }
};
bool ValidateBlendFuncEnum(GLenum factor, const char *funcName, const char* varName);
protected:
bool InitWebGL2(FailureReason* const out_failReason);

View File

@ -215,6 +215,34 @@ void WebGLContext::BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
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)
@ -230,10 +258,10 @@ ValidateBlendFuncEnums(WebGLContext* webgl, GLenum srcRGB, GLenum srcAlpha,
}
}
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;
}

View File

@ -63,34 +63,6 @@ WebGLContext::ValidateBlendEquationEnum(GLenum mode, const char* info)
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,