b=573705; fix computation of texel sizes and refactor WebGLenum validation functions; r=vladimir
This commit is contained in:
@@ -125,7 +125,7 @@ WebGLContext::ValidateBuffers(PRUint32 count)
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateCapabilityEnum(WebGLenum cap)
|
||||
PRBool WebGLContext::ValidateCapabilityEnum(WebGLenum cap, const char *info)
|
||||
{
|
||||
switch (cap) {
|
||||
case LOCAL_GL_BLEND:
|
||||
@@ -139,11 +139,12 @@ PRBool WebGLContext::ValidateCapabilityEnum(WebGLenum cap)
|
||||
case LOCAL_GL_STENCIL_TEST:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateBlendEquationEnum(WebGLenum mode)
|
||||
PRBool WebGLContext::ValidateBlendEquationEnum(WebGLenum mode, const char *info)
|
||||
{
|
||||
switch (mode) {
|
||||
case LOCAL_GL_FUNC_ADD:
|
||||
@@ -151,11 +152,12 @@ PRBool WebGLContext::ValidateBlendEquationEnum(WebGLenum mode)
|
||||
case LOCAL_GL_FUNC_REVERSE_SUBTRACT:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateBlendFuncDstEnum(WebGLenum factor)
|
||||
PRBool WebGLContext::ValidateBlendFuncDstEnum(WebGLenum factor, const char *info)
|
||||
{
|
||||
switch (factor) {
|
||||
case LOCAL_GL_ZERO:
|
||||
@@ -174,30 +176,32 @@ PRBool WebGLContext::ValidateBlendFuncDstEnum(WebGLenum factor)
|
||||
case LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateBlendFuncSrcEnum(WebGLenum factor)
|
||||
PRBool WebGLContext::ValidateBlendFuncSrcEnum(WebGLenum factor, const char *info)
|
||||
{
|
||||
if(factor == LOCAL_GL_SRC_ALPHA_SATURATE)
|
||||
if (factor == LOCAL_GL_SRC_ALPHA_SATURATE)
|
||||
return PR_TRUE;
|
||||
else
|
||||
return ValidateBlendFuncDstEnum(factor);
|
||||
return ValidateBlendFuncDstEnum(factor, info);
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateTextureTargetEnum(WebGLenum target)
|
||||
PRBool WebGLContext::ValidateTextureTargetEnum(WebGLenum target, const char *info)
|
||||
{
|
||||
switch (target) {
|
||||
case LOCAL_GL_TEXTURE_2D:
|
||||
case LOCAL_GL_TEXTURE_CUBE_MAP:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateComparisonEnum(WebGLenum target)
|
||||
PRBool WebGLContext::ValidateComparisonEnum(WebGLenum target, const char *info)
|
||||
{
|
||||
switch (target) {
|
||||
case LOCAL_GL_NEVER:
|
||||
@@ -210,11 +214,12 @@ PRBool WebGLContext::ValidateComparisonEnum(WebGLenum target)
|
||||
case LOCAL_GL_ALWAYS:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateStencilOpEnum(WebGLenum action)
|
||||
PRBool WebGLContext::ValidateStencilOpEnum(WebGLenum action, const char *info)
|
||||
{
|
||||
switch (action) {
|
||||
case LOCAL_GL_KEEP:
|
||||
@@ -227,11 +232,12 @@ PRBool WebGLContext::ValidateStencilOpEnum(WebGLenum action)
|
||||
case LOCAL_GL_INVERT:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateFaceEnum(WebGLenum target)
|
||||
PRBool WebGLContext::ValidateFaceEnum(WebGLenum target, const char *info)
|
||||
{
|
||||
switch (target) {
|
||||
case LOCAL_GL_FRONT:
|
||||
@@ -239,10 +245,63 @@ PRBool WebGLContext::ValidateFaceEnum(WebGLenum target)
|
||||
case LOCAL_GL_FRONT_AND_BACK:
|
||||
return PR_TRUE;
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool WebGLContext::ValidateTexFormatAndType(WebGLenum format, WebGLenum type,
|
||||
PRUint32 *texelSize, const char *info)
|
||||
{
|
||||
if (type == LOCAL_GL_UNSIGNED_BYTE)
|
||||
{
|
||||
switch (format) {
|
||||
case LOCAL_GL_RED:
|
||||
case LOCAL_GL_GREEN:
|
||||
case LOCAL_GL_BLUE:
|
||||
case LOCAL_GL_ALPHA:
|
||||
case LOCAL_GL_LUMINANCE:
|
||||
*texelSize = 1;
|
||||
return PR_TRUE;
|
||||
case LOCAL_GL_LUMINANCE_ALPHA:
|
||||
*texelSize = 2;
|
||||
return PR_TRUE;
|
||||
case LOCAL_GL_RGB:
|
||||
*texelSize = 3;
|
||||
return PR_TRUE;
|
||||
case LOCAL_GL_RGBA:
|
||||
*texelSize = 4;
|
||||
return PR_TRUE;
|
||||
default:
|
||||
ErrorInvalidEnum("%s: invalid format", info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
} else {
|
||||
switch (type) {
|
||||
case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
|
||||
case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:
|
||||
if (format == LOCAL_GL_RGBA) {
|
||||
*texelSize = 2;
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
ErrorInvalidOperation("%s: mutually incompatible format and type", info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
case LOCAL_GL_UNSIGNED_SHORT_5_6_5:
|
||||
if (format == LOCAL_GL_RGB) {
|
||||
*texelSize = 2;
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
ErrorInvalidOperation("%s: mutually incompatible format and type", info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
default:
|
||||
ErrorInvalidEnum("%s: invalid type", info);
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
WebGLContext::InitAndValidateGL()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user