Add support for clipstack to Gr. GrClip is now a list of rects and paths with set operations to combine them. The stencil buffer is used to perform the set operations to put the clip into the stencil buffer. Building Gr's clip from Skia's clipStack is currently disabled due to the fact that Skia's clipStack is relative to the root layer not the current layer. This will be fixed in a subsequent CL.
git-svn-id: http://skia.googlecode.com/svn/trunk@878 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp
index 840e773..a047895 100644
--- a/gpu/src/GrContext.cpp
+++ b/gpu/src/GrContext.cpp
@@ -145,7 +145,7 @@
GrDrawTarget::AutoStateRestore asr(fGpu);
fGpu->setRenderTarget(texture->asRenderTarget());
fGpu->setTexture(0, clampEntry->texture());
- fGpu->setStencilPass(GrDrawTarget::kNone_StencilPass);
+ fGpu->disableStencil();
fGpu->setViewMatrix(GrMatrix::I());
fGpu->setAlpha(0xff);
fGpu->setBlendFunc(kOne_BlendCoeff, kZero_BlendCoeff);
@@ -284,7 +284,7 @@
void GrContext::setClip(const GrIRect& rect) {
GrClip clip;
- clip.setRect(rect);
+ clip.setFromIRect(rect);
fGpu->setClip(clip);
}
@@ -297,7 +297,10 @@
void GrContext::drawPaint(const GrPaint& paint) {
// set rect to be big enough to fill the space, but not super-huge, so we
// don't overflow fixed-point implementations
- GrRect r(fGpu->getClip().getBounds());
+ GrRect r;
+ r.setLTRB(0, 0,
+ GrIntToScalar(getRenderTarget()->width()),
+ GrIntToScalar(getRenderTarget()->height()));
GrMatrix inverse;
if (fGpu->getViewInverse(&inverse)) {
inverse.mapRect(&r);
@@ -546,6 +549,15 @@
fPathRenderer->drawPath(target, enabledStages, path, fill, translate);
}
+void GrContext::drawPath(const GrPaint& paint,
+ const GrPath& path,
+ GrPathFill fill,
+ const GrPoint* translate) {
+ GrPath::Iter iter(path);
+ this->drawPath(paint, &iter, fill, translate);
+}
+
+
////////////////////////////////////////////////////////////////////////////////
void GrContext::flush(bool flushRenderTarget) {
@@ -751,7 +763,8 @@
#if BATCH_RECT_TO_RECT
fDrawBuffer->setQuadIndexBuffer(this->getQuadIndexBuffer());
#endif
- fPathRenderer = new GrDefaultPathRenderer(fGpu->supportsSingleStencilPassWinding());
+ fPathRenderer = new GrDefaultPathRenderer(fGpu->supportsTwoSidedStencil(),
+ fGpu->supportsStencilWrapOps());
}
bool GrContext::finalizeTextureKey(GrTextureKey* key,