Fix GPU assumption that clipstack begins with intersect or replace.
Review URL: http://codereview.appspot.com/4977043/
git-svn-id: http://skia.googlecode.com/svn/trunk@2183 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp
index 936ada3..5054229 100644
--- a/gpu/src/GrGpuGL.cpp
+++ b/gpu/src/GrGpuGL.cpp
@@ -1388,15 +1388,15 @@
fHWDrawState.fStencilSettings.invalidate();
}
-void GrGpuGL::clearStencilClip(const GrIRect& rect) {
+void GrGpuGL::clearStencilClip(const GrIRect& rect, bool insideClip) {
GrAssert(NULL != fCurrDrawState.fRenderTarget);
// this should only be called internally when we know we have a
// stencil buffer.
GrAssert(NULL != fCurrDrawState.fRenderTarget->getStencilBuffer());
-#if 0
GrGLint stencilBitCount =
fCurrDrawState.fRenderTarget->getStencilBuffer()->bits();
+#if 0
GrAssert(stencilBitCount > 0);
GrGLint clipStencilMask = (1 << (stencilBitCount - 1));
#else
@@ -1407,10 +1407,16 @@
// zero the client's clip bits. So we just clear the whole thing.
static const GrGLint clipStencilMask = ~0;
#endif
+ GrGLint value;
+ if (insideClip) {
+ value = (1 << (stencilBitCount - 1));
+ } else {
+ value = 0;
+ }
this->flushRenderTarget(&GrIRect::EmptyIRect());
this->flushScissor(&rect);
GL_CALL(StencilMask(clipStencilMask));
- GL_CALL(ClearStencil(0));
+ GL_CALL(ClearStencil(value));
GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
fHWDrawState.fStencilSettings.invalidate();
}