aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkCanvas.cpp
diff options
context:
space:
mode:
authorGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-24 20:07:08 +0000
committerGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-02-24 20:07:08 +0000
commit421bcc375af0616c37a59b0508957ab54d8f6d12 (patch)
treee80529f6e6aefd08da53b3a4a333431544fad5ce /src/core/SkCanvas.cpp
parentddd0ed560721bc082b38eed7c11ea792ae0713ca (diff)
Modify SkDeferredCanvas so that it uses its inherited SkCanvas to track matrix and clipping state
Removed 'virtual' from a few canvas methods that no longer need it thanks to this change. BUG=http://code.google.com/p/skia/issues/detail?id=506 TEST=Canvas unit test REVIEW=http://codereview.appspot.com/5697052/ git-svn-id: http://skia.googlecode.com/svn/trunk@3256 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkCanvas.cpp')
-rw-r--r--src/core/SkCanvas.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 6e061c2005..78751de216 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -707,19 +707,12 @@ static bool bounds_affects_clip(SkCanvas::SaveFlags flags) {
return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0;
}
-int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
- SaveFlags flags) {
- // do this before we create the layer. We don't call the public save() since
- // that would invoke a possibly overridden virtual
- int count = this->internalSave(flags);
-
- fDeviceCMDirty = true;
-
+bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags,
+ SkIRect* intersection) {
SkIRect clipBounds;
if (!this->getClipDeviceBounds(&clipBounds)) {
- return count;
+ return false;
}
-
SkIRect ir;
if (NULL != bounds) {
SkRect r;
@@ -731,16 +724,36 @@ int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
if (bounds_affects_clip(flags)) {
fMCRec->fRasterClip->setEmpty();
}
- return count;
+ return false;
}
} else { // no user bounds, so just use the clip
ir = clipBounds;
}
fClipStack.clipDevRect(ir, SkRegion::kIntersect_Op);
+
// early exit if the clip is now empty
if (bounds_affects_clip(flags) &&
!fMCRec->fRasterClip->op(ir, SkRegion::kIntersect_Op)) {
+ return false;
+ }
+
+ if (intersection) {
+ *intersection = ir;
+ }
+ return true;
+}
+
+int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
+ SaveFlags flags) {
+ // do this before we create the layer. We don't call the public save() since
+ // that would invoke a possibly overridden virtual
+ int count = this->internalSave(flags);
+
+ fDeviceCMDirty = true;
+
+ SkIRect ir;
+ if (!this->clipRectBounds(bounds, flags, &ir)) {
return count;
}