aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGpuDevice.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-24 13:54:00 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-24 13:54:00 +0000
commit607fe077c893fdb230e29631be096de614a14e2a (patch)
tree35af1f7d6542059ca8d1bc3f64305bcccf71881f /src/gpu/SkGpuDevice.cpp
parent7866228f06e402d37f8fcab70a688e1f34c1d27b (diff)
Added bound computation to SkClipStack
http://codereview.appspot.com/6419048/ This will require re-baselining of complexclip* and filltypespersp git-svn-id: http://skia.googlecode.com/svn/trunk@4730 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r--src/gpu/SkGpuDevice.cpp59
1 files changed, 50 insertions, 9 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index bd92089cc7..1da5a0a0a4 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -361,22 +361,60 @@ void SkGpuDevice::onDetachFromCanvas() {
fClipStack = NULL;
}
+#ifdef SK_DEBUG
+static void check_bounds(const SkClipStack& clipStack,
+ const SkRegion& clipRegion,
+ const SkIPoint& origin,
+ int renderTargetWidth,
+ int renderTargetHeight) {
+
+ SkIRect bound;
+ SkClipStack::BoundsType boundType;
+ SkRect temp;
+
+ bound.setLTRB(0, 0, renderTargetWidth, renderTargetHeight);
+
+ clipStack.getBounds(&temp, &boundType);
+ if (SkClipStack::kNormal_BoundsType == boundType) {
+ SkIRect temp2;
+
+ temp.roundOut(&temp2);
+
+ temp2.offset(-origin.fX, -origin.fY);
+
+ if (!bound.intersect(temp2)) {
+ bound.setEmpty();
+ }
+ }
+
+// GrAssert(bound.contains(clipRegion.getBounds()));
+}
+#endif
+
///////////////////////////////////////////////////////////////////////////////
static void convert_matrixclip(GrContext* context, const SkMatrix& matrix,
const SkClipStack& clipStack,
const SkRegion& clipRegion,
- const SkIPoint& origin) {
+ const SkIPoint& origin,
+ int renderTargetWidth, int renderTargetHeight) {
context->setMatrix(matrix);
SkGrClipIterator iter;
iter.reset(clipStack);
- const SkIRect& skBounds = clipRegion.getBounds();
- GrRect bounds;
- bounds.setLTRB(GrIntToScalar(skBounds.fLeft),
- GrIntToScalar(skBounds.fTop),
- GrIntToScalar(skBounds.fRight),
- GrIntToScalar(skBounds.fBottom));
+
+#ifdef SK_DEBUG
+ check_bounds(clipStack, clipRegion, origin,
+ renderTargetWidth, renderTargetHeight);
+#endif
+
+ SkRect bounds;
+ clipStack.getConservativeBounds(-origin.fX,
+ -origin.fY,
+ renderTargetWidth,
+ renderTargetHeight,
+ &bounds);
+
GrClip grc(&iter, GrIntToScalar(-origin.x()), GrIntToScalar(-origin.y()),
bounds);
context->setClip(grc);
@@ -392,8 +430,10 @@ void SkGpuDevice::prepareRenderTarget(const SkDraw& draw) {
fContext->setRenderTarget(fRenderTarget);
SkASSERT(draw.fClipStack && draw.fClipStack == fClipStack);
+
convert_matrixclip(fContext, *draw.fMatrix,
- *fClipStack, *draw.fClip, this->getOrigin());
+ *fClipStack, *draw.fClip, this->getOrigin(),
+ fRenderTarget->width(), fRenderTarget->height());
fNeedPrepareRenderTarget = false;
}
}
@@ -413,7 +453,8 @@ void SkGpuDevice::gainFocus(const SkMatrix& matrix, const SkRegion& clip) {
this->INHERITED::gainFocus(matrix, clip);
- convert_matrixclip(fContext, matrix, *fClipStack, clip, this->getOrigin());
+ convert_matrixclip(fContext, matrix, *fClipStack, clip, this->getOrigin(),
+ fRenderTarget->width(), fRenderTarget->height());
DO_DEFERRED_CLEAR;
}