From 70fc152576d3e7e1405e8234a097054c609eeb77 Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Mon, 25 Jun 2012 18:03:46 +0000 Subject: [PATCH] Fix the stencil rules to perfom an rdiff with an inverse path Review URL: http://codereview.appspot.com/6336056/ git-svn-id: http://skia.googlecode.com/svn/trunk@4328 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/GrStencil.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/gpu/GrStencil.cpp b/src/gpu/GrStencil.cpp index 8d7534a..ac2d6d8 100644 --- a/src/gpu/GrStencil.cpp +++ b/src/gpu/GrStencil.cpp @@ -167,7 +167,9 @@ GR_STATIC_CONST_SAME_STENCIL(gUserToClipRDiffPass1, 0x0000, // set clip bit 0xffff); -GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipRDiff, +// We are looking for stencil values that are all zero. The first pass sets the +// clip bit if the stencil is all zeros. The second pass clears the user bits. +GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipRDiffPass0, kInvert_StencilOp, kZero_StencilOp, kEqual_StencilFunc, @@ -175,6 +177,16 @@ GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipRDiff, 0x0000, 0x0000 // set clip bit ); + +GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipRDiffPass1, + kZero_StencilOp, + kZero_StencilOp, + kAlways_StencilFunc, + 0xffff, + 0x0000, + 0xffff // unset clip bit +); + /////// // Direct to Stencil @@ -348,11 +360,15 @@ bool GrStencilSettings::GetClipPasses( break; case SkRegion::kReverseDifference_Op: if (invertedFill) { - *numPasses = 1; - settings[0] = gInvUserToClipRDiff; + *numPasses = 2; + settings[0] = gInvUserToClipRDiffPass0; settings[0].fWriteMasks[kFront_Face] |= stencilClipMask; settings[0].fWriteMasks[kBack_Face] = settings[0].fWriteMasks[kFront_Face]; + settings[1] = gInvUserToClipRDiffPass1; + settings[1].fWriteMasks[kFront_Face] &= ~stencilClipMask; + settings[1].fWriteMasks[kBack_Face] = + settings[1].fWriteMasks[kFront_Face]; } else { *numPasses = 2; settings[0] = gUserToClipRDiffPass0; -- 2.7.4