stencilBuffer->setLastClip(genID, clipSpaceIBounds, clipSpaceToStencilOffset);
- // we set the current clip to the bounds so that our recursive draws are scissored to them.
- // We use the copy of the GrClipData we just stashed on the SB to render from. We set it
- // back after we finish drawing it into the stencil.
- const GrClipData* oldClipData = fGpu->getClip();
-
+ // We set the current clip to the bounds so that our recursive draws are scissored to them.
SkIRect stencilSpaceIBounds(clipSpaceIBounds);
stencilSpaceIBounds.offset(clipSpaceToStencilOffset);
-
- SkClipStack newClipStack(stencilSpaceIBounds);
- GrClipData newClipData; // origin defaults to (0,0)
- newClipData.fClipStack = &newClipStack;
-
- fGpu->setClip(&newClipData);
+ GrDrawTarget::AutoClipRestore(fGpu, stencilSpaceIBounds);
GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
drawState = fGpu->drawState();
GrPathRendererChain::kStencilOnly_DrawType,
&stencilSupport);
if (NULL == pr) {
- fGpu->setClip(oldClipData);
return false;
}
}
}
}
}
- // restore clip
- fGpu->setClip(oldClipData);
}
// set this last because recursive draws may overwrite it back to kNone.
GrAssert(kNone_ClipMaskType == fCurrClipMaskType);
fIndices = NULL;
}
+GrDrawTarget::AutoClipRestore::AutoClipRestore(GrDrawTarget* target, const SkIRect& newClip) {
+ fTarget = target;
+ fClip = fTarget->getClip();
+ fStack.init();
+ fStack.get()->clipDevRect(newClip, SkRegion::kReplace_Op);
+ fReplacementClip.fClipStack = fStack.get();
+ target->setClip(&fReplacementClip);
+}
+
void GrDrawTarget::Caps::print() const {
static const char* gNY[] = {"NO", "YES"};
GrPrintf("8 Bit Palette Support : %s\n", gNY[fInternals.f8BitPaletteSupport]);
#ifndef GrDrawTarget_DEFINED
#define GrDrawTarget_DEFINED
+#include "GrClipData.h"
#include "GrDrawState.h"
#include "GrIndexBuffer.h"
#include "SkMatrix.h"
#include "GrRefCnt.h"
#include "GrTemplates.h"
+#include "SkClipStack.h"
#include "SkPath.h"
-#include "SkXfermode.h"
#include "SkTLazy.h"
#include "SkTArray.h"
+#include "SkXfermode.h"
class GrClipData;
class GrPath;
fClip = fTarget->getClip();
}
+ AutoClipRestore(GrDrawTarget* target, const SkIRect& newClip);
+
~AutoClipRestore() {
fTarget->setClip(fClip);
}
private:
- GrDrawTarget* fTarget;
- const GrClipData* fClip;
+ GrDrawTarget* fTarget;
+ const GrClipData* fClip;
+ SkTLazy<SkClipStack> fStack;
+ GrClipData fReplacementClip;
};
////////////////////////////////////////////////////////////////////////////