Bug 616608 - Pass the rest of webgl-specific.html test - part 2/3: implement section 6.5 on separate parameters - r=vlad

This commit is contained in:
Benoit Jacob 2010-12-06 06:34:35 -05:00
parent 0f8d9b782f
commit d647a3f4c0
3 changed files with 31 additions and 1 deletions

View File

@ -537,6 +537,9 @@ protected:
WebGLfloat mVertexAttrib0Vector[4];
nsAutoArrayPtr<WebGLfloat> mFakeVertexAttrib0Array;
WebGLint mStencilRef;
WebGLuint mStencilValueMask, mStencilWriteMask;
public:
// console logging helpers
static void LogMessage(const char *fmt, ...);

View File

@ -2773,6 +2773,9 @@ WebGLContext::StencilFunc(WebGLenum func, WebGLint ref, WebGLuint mask)
if (!ValidateComparisonEnum(func, "stencilFunc: func"))
return NS_OK;
mStencilRef = ref;
mStencilValueMask = mask;
MakeContextCurrent();
gl->fStencilFunc(func, ref, mask);
return NS_OK;
@ -2785,12 +2788,27 @@ WebGLContext::StencilFuncSeparate(WebGLenum face, WebGLenum func, WebGLint ref,
!ValidateComparisonEnum(func, "stencilFuncSeparate: func"))
return NS_OK;
if (face != LOCAL_GL_FRONT_AND_BACK && (ref != mStencilRef || mask != mStencilValueMask))
return ErrorInvalidOperation("stencilFuncSeparate: WebGL doesn't currently allow specifying "
"different values for front and back.");
mStencilRef = ref;
mStencilValueMask = mask;
MakeContextCurrent();
gl->fStencilFuncSeparate(face, func, ref, mask);
return NS_OK;
}
GL_SAME_METHOD_1(StencilMask, StencilMask, WebGLuint)
NS_IMETHODIMP
WebGLContext::StencilMask(WebGLuint mask)
{
mStencilWriteMask = mask;
MakeContextCurrent();
gl->fStencilMask(mask);
return NS_OK;
}
NS_IMETHODIMP
WebGLContext::StencilMaskSeparate(WebGLenum face, WebGLuint mask)
@ -2798,6 +2816,11 @@ WebGLContext::StencilMaskSeparate(WebGLenum face, WebGLuint mask)
if (!ValidateFaceEnum(face, "stencilMaskSeparate: face"))
return NS_OK;
if (face != LOCAL_GL_FRONT_AND_BACK && mask != mStencilWriteMask)
return ErrorInvalidOperation("stencilMaskSeparate: WebGL doesn't currently allow specifying "
"different values for front and back.");
mStencilWriteMask = mask;
MakeContextCurrent();
gl->fStencilMaskSeparate(face, mask);
return NS_OK;

View File

@ -483,6 +483,10 @@ WebGLContext::InitAndValidateGL()
gl->fGetIntegerv(LOCAL_GL_PACK_ALIGNMENT, (GLint*) &mPixelStorePackAlignment);
gl->fGetIntegerv(LOCAL_GL_UNPACK_ALIGNMENT, (GLint*) &mPixelStoreUnpackAlignment);
gl->fGetIntegerv(LOCAL_GL_STENCIL_WRITEMASK, (GLint*) &mStencilWriteMask);
gl->fGetIntegerv(LOCAL_GL_STENCIL_VALUE_MASK, (GLint*) &mStencilValueMask);
gl->fGetIntegerv(LOCAL_GL_STENCIL_REF, (GLint*) &mStencilRef);
// Check the shader validator pref
nsCOMPtr<nsIPrefBranch> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
NS_ENSURE_TRUE(prefService != nsnull, NS_ERROR_FAILURE);