void GL::EnableStencilTest(BinaryStencilTest aTest, GLint aComparand, GLuint aTestMask, StencilOperation aOp, GLuint aWriteMask) { MOZ_ASSERT(IsCurrent()); if (!mStencilTestEnabled) { Enable(GL_STENCIL_TEST); mStencilTestEnabled = true; } if (mStencilTest != aTest || mStencilComparand != aComparand || mStencilTestMask != aTestMask) { GLenum func; switch (aTest) { default: MOZ_ASSERT(!"Invalid stencil test"); case ALWAYS_PASS: func = GL_ALWAYS; break; case PASS_IF_EQUAL: func = GL_EQUAL; break; case PASS_IF_NOT_EQUAL: func = GL_NOTEQUAL; break; } StencilFunc(func, aComparand, aTestMask); mStencilTest = aTest; mStencilComparand = aComparand; mStencilTestMask = aTestMask; } if (mStencilOp != aOp) { switch (aOp) { case LEAVE_UNCHANGED: StencilOp(GL_KEEP, GL_KEEP, GL_KEEP); break; case CLEAR_PASSING_VALUES: StencilOp(GL_KEEP, GL_ZERO, GL_ZERO); break; case REPLACE_PASSING_WITH_COMPARAND: StencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); break; case REPLACE_PASSING_CLEAR_FAILING: StencilOp(GL_ZERO, GL_REPLACE, GL_REPLACE); break; } mStencilOp = aOp; } if (mStencilWriteMask != aWriteMask) { StencilMask(aWriteMask); mStencilWriteMask = aWriteMask; } }
static oglplus::context::StencilFuncArgs StencilFuncArgs(bool backface = false) { return oglplus::context::StencilFuncArgs( StencilFunc(backface), StencilRef(backface), StencilValueMask(backface) ); }
static CompareFunction StencilFunc(Face face) { return StencilFunc(face == Face::Back); }
static void StencilFunc(const StencilFuncArgs& fa) { return StencilFunc(fa.Func(), fa.Ref(), fa.ValueMask()); }