mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
b=570779; validate enums in blend functions; r=vladimir
This commit is contained in:
parent
95bc657a6d
commit
f1bfcf8e35
@ -317,7 +317,9 @@ protected:
|
||||
PRBool InitAndValidateGL();
|
||||
PRBool ValidateBuffers(PRUint32 count);
|
||||
static PRBool ValidateCapabilityEnum(WebGLenum cap);
|
||||
|
||||
static PRBool ValidateBlendEquationEnum(WebGLuint cap);
|
||||
static PRBool ValidateBlendFuncDstEnum(WebGLuint mode);
|
||||
static PRBool ValidateBlendFuncSrcEnum(WebGLuint mode);
|
||||
void Invalidate();
|
||||
|
||||
void MakeContextCurrent() { gl->MakeCurrent(); }
|
||||
|
@ -294,13 +294,54 @@ WebGLContext::BindTexture(WebGLenum target, nsIWebGLTexture *tobj)
|
||||
|
||||
GL_SAME_METHOD_4(BlendColor, BlendColor, float, float, float, float)
|
||||
|
||||
GL_SAME_METHOD_1(BlendEquation, BlendEquation, WebGLenum)
|
||||
NS_IMETHODIMP WebGLContext::BlendEquation(WebGLenum mode)
|
||||
{
|
||||
if (!ValidateBlendEquationEnum(mode))
|
||||
return ErrorInvalidEnum("BlendEquation: invalid mode");
|
||||
|
||||
GL_SAME_METHOD_2(BlendEquationSeparate, BlendEquationSeparate, WebGLenum, WebGLenum)
|
||||
MakeContextCurrent();
|
||||
gl->fBlendEquation(mode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
GL_SAME_METHOD_2(BlendFunc, BlendFunc, WebGLenum, WebGLenum)
|
||||
NS_IMETHODIMP WebGLContext::BlendEquationSeparate(WebGLenum modeRGB, WebGLenum modeAlpha)
|
||||
{
|
||||
if (!ValidateBlendEquationEnum(modeRGB)
|
||||
|| !ValidateBlendEquationEnum(modeAlpha))
|
||||
return ErrorInvalidEnum("BlendEquationSeparate: invalid mode");
|
||||
|
||||
GL_SAME_METHOD_4(BlendFuncSeparate, BlendFuncSeparate, WebGLenum, WebGLenum, WebGLenum, WebGLenum)
|
||||
MakeContextCurrent();
|
||||
gl->fBlendEquationSeparate(modeRGB, modeAlpha);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP WebGLContext::BlendFunc(WebGLenum sfactor, WebGLenum dfactor)
|
||||
{
|
||||
if (!ValidateBlendFuncSrcEnum(sfactor))
|
||||
return ErrorInvalidEnum("BlendFunc: invalid source factor");
|
||||
if (!ValidateBlendFuncDstEnum(dfactor))
|
||||
return ErrorInvalidEnum("BlendFunc: invalid destination factor");
|
||||
|
||||
MakeContextCurrent();
|
||||
gl->fBlendFunc(sfactor, dfactor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::BlendFuncSeparate(WebGLenum srcRGB, WebGLenum dstRGB,
|
||||
WebGLenum srcAlpha, WebGLenum dstAlpha)
|
||||
{
|
||||
if (!ValidateBlendFuncSrcEnum(srcRGB)
|
||||
|| !ValidateBlendFuncSrcEnum(srcAlpha))
|
||||
return ErrorInvalidEnum("BlendFuncSeparate: invalid source factor");
|
||||
if (!ValidateBlendFuncDstEnum(dstRGB)
|
||||
|| !ValidateBlendFuncDstEnum(dstAlpha))
|
||||
return ErrorInvalidEnum("BlendFuncSeparate: invalid destination factor");
|
||||
|
||||
MakeContextCurrent();
|
||||
gl->fBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::BufferData(PRInt32 dummy)
|
||||
|
@ -143,6 +143,49 @@ PRBool WebGLContext::ValidateCapabilityEnum(WebGLenum cap)
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateBlendEquationEnum(WebGLenum mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case LOCAL_GL_FUNC_ADD:
|
||||
case LOCAL_GL_FUNC_SUBTRACT:
|
||||
case LOCAL_GL_FUNC_REVERSE_SUBTRACT:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateBlendFuncDstEnum(WebGLenum factor)
|
||||
{
|
||||
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:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateBlendFuncSrcEnum(WebGLenum factor)
|
||||
{
|
||||
if(factor == LOCAL_GL_SRC_ALPHA_SATURATE)
|
||||
return PR_TRUE;
|
||||
else
|
||||
return ValidateBlendFuncDstEnum(factor);
|
||||
}
|
||||
|
||||
PRBool
|
||||
WebGLContext::InitAndValidateGL()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user