diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-28 15:28:02 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-28 15:28:02 +0000 |
commit | 03fc3b4f67a115e4a7945d173856a6c80b09311e (patch) | |
tree | 76665d4141136cb091f7c9e3e5d3bdc2342cdfa2 /src | |
parent | d85f32ca40475fb246dd8ca93abaf1c3db0389e1 (diff) |
Revert of r13620 (add new onClip* methods to SkCanvas - https://codereview.chromium.org/183453002/) due to broken Chrome Canary and failing tests.
git-svn-id: http://skia.googlecode.com/svn/trunk@13622 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkBBoxHierarchyRecord.cpp | 30 | ||||
-rw-r--r-- | src/core/SkBBoxHierarchyRecord.h | 18 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 119 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 12 | ||||
-rw-r--r-- | src/core/SkPictureRecord.cpp | 36 | ||||
-rw-r--r-- | src/core/SkPictureRecord.h | 9 | ||||
-rw-r--r-- | src/pipe/SkGPipeWrite.cpp | 47 | ||||
-rw-r--r-- | src/utils/SkCanvasStack.cpp | 19 | ||||
-rw-r--r-- | src/utils/SkCanvasStack.h | 11 | ||||
-rw-r--r-- | src/utils/SkDeferredCanvas.cpp | 39 | ||||
-rw-r--r-- | src/utils/SkDumpCanvas.cpp | 26 | ||||
-rw-r--r-- | src/utils/SkLuaCanvas.cpp | 22 | ||||
-rw-r--r-- | src/utils/SkNWayCanvas.cpp | 22 | ||||
-rw-r--r-- | src/utils/SkNoSaveLayerCanvas.h | 21 | ||||
-rw-r--r-- | src/utils/SkProxyCanvas.cpp | 16 | ||||
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.cpp | 23 | ||||
-rw-r--r-- | src/utils/debugger/SkDebugCanvas.h | 32 |
17 files changed, 233 insertions, 269 deletions
diff --git a/src/core/SkBBoxHierarchyRecord.cpp b/src/core/SkBBoxHierarchyRecord.cpp index 5d310be7bc..b120b1da87 100644 --- a/src/core/SkBBoxHierarchyRecord.cpp +++ b/src/core/SkBBoxHierarchyRecord.cpp @@ -77,31 +77,31 @@ void SkBBoxHierarchyRecord::setMatrix(const SkMatrix& matrix) { fStateTree->appendTransform(getTotalMatrix()); } -void SkBBoxHierarchyRecord::onClipRect(const SkRect& rect, - SkRegion::Op op, - ClipEdgeStyle edgeStyle) { +bool SkBBoxHierarchyRecord::clipRect(const SkRect& rect, + SkRegion::Op op, + bool doAntiAlias) { fStateTree->appendClip(this->writeStream().bytesWritten()); - this->INHERITED::onClipRect(rect, op, edgeStyle); + return INHERITED::clipRect(rect, op, doAntiAlias); } -void SkBBoxHierarchyRecord::onClipRegion(const SkRegion& region, - SkRegion::Op op) { +bool SkBBoxHierarchyRecord::clipRegion(const SkRegion& region, + SkRegion::Op op) { fStateTree->appendClip(this->writeStream().bytesWritten()); - this->INHERITED::onClipRegion(region, op); + return INHERITED::clipRegion(region, op); } -void SkBBoxHierarchyRecord::onClipPath(const SkPath& path, - SkRegion::Op op, - ClipEdgeStyle edgeStyle) { +bool SkBBoxHierarchyRecord::clipPath(const SkPath& path, + SkRegion::Op op, + bool doAntiAlias) { fStateTree->appendClip(this->writeStream().bytesWritten()); - this->INHERITED::onClipPath(path, op, edgeStyle); + return INHERITED::clipPath(path, op, doAntiAlias); } -void SkBBoxHierarchyRecord::onClipRRect(const SkRRect& rrect, - SkRegion::Op op, - ClipEdgeStyle edgeStyle) { +bool SkBBoxHierarchyRecord::clipRRect(const SkRRect& rrect, + SkRegion::Op op, + bool doAntiAlias) { fStateTree->appendClip(this->writeStream().bytesWritten()); - this->INHERITED::onClipRRect(rrect, op, edgeStyle); + return INHERITED::clipRRect(rrect, op, doAntiAlias); } bool SkBBoxHierarchyRecord::shouldRewind(void* data) { diff --git a/src/core/SkBBoxHierarchyRecord.h b/src/core/SkBBoxHierarchyRecord.h index 80f59c3907..f264334807 100644 --- a/src/core/SkBBoxHierarchyRecord.h +++ b/src/core/SkBBoxHierarchyRecord.h @@ -35,15 +35,21 @@ public: virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE; virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE; + virtual bool clipRect(const SkRect& rect, + SkRegion::Op op = SkRegion::kIntersect_Op, + bool doAntiAlias = false) SK_OVERRIDE; + virtual bool clipRegion(const SkRegion& region, + SkRegion::Op op = SkRegion::kIntersect_Op) SK_OVERRIDE; + virtual bool clipPath(const SkPath& path, + SkRegion::Op op = SkRegion::kIntersect_Op, + bool doAntiAlias = false) SK_OVERRIDE; + virtual bool clipRRect(const SkRRect& rrect, + SkRegion::Op op = SkRegion::kIntersect_Op, + bool doAntiAlias = false) SK_OVERRIDE; + // Implementation of the SkBBoxHierarchyClient interface virtual bool shouldRewind(void* data) SK_OVERRIDE; -protected: - virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; - private: typedef SkBBoxRecord INHERITED; }; diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 7851fdbb81..bc14974b7d 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1166,12 +1166,6 @@ void SkCanvas::resetMatrix() { ////////////////////////////////////////////////////////////////////////////// bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { - ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; - this->onClipRect(rect, op, edgeStyle); - return !this->isClipEmpty(); -} - -void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { #ifdef SK_ENABLE_CLIP_QUICKREJECT if (SkRegion::kIntersect_Op == op) { if (fMCRec->fRasterClip->isEmpty()) { @@ -1192,9 +1186,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg fDeviceCMDirty = true; fCachedLocalClipBoundsDirty = true; - if (!fAllowSoftClip) { - edgeStyle = kHard_ClipEdgeStyle; - } + doAA &= fAllowSoftClip; if (fMCRec->fMatrix->rectStaysRect()) { // for these simpler matrices, we can stay a rect even after applying @@ -1204,8 +1196,8 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg SkRect r; fMCRec->fMatrix->mapRect(&r, rect); - fClipStack.clipDevRect(r, op, kSoft_ClipEdgeStyle == edgeStyle); - fMCRec->fRasterClip->op(r, op, kSoft_ClipEdgeStyle == edgeStyle); + fClipStack.clipDevRect(r, op, doAA); + return fMCRec->fRasterClip->op(r, op, doAA); } else { // since we're rotated or some such thing, we convert the rect to a path // and clip against that, since it can handle any matrix. However, to @@ -1214,12 +1206,12 @@ void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg SkPath path; path.addRect(rect); - this->SkCanvas::onClipPath(path, op, edgeStyle); + return this->SkCanvas::clipPath(path, op, doAA); } } -static void clip_path_helper(const SkCanvas* canvas, SkRasterClip* currClip, - const SkPath& devPath, SkRegion::Op op, bool doAA) { +static bool clipPathHelper(const SkCanvas* canvas, SkRasterClip* currClip, + const SkPath& devPath, SkRegion::Op op, bool doAA) { // base is used to limit the size (and therefore memory allocation) of the // region that results from scan converting devPath. SkRegion base; @@ -1232,81 +1224,60 @@ static void clip_path_helper(const SkCanvas* canvas, SkRasterClip* currClip, // FIXME: we should also be able to do this when currClip->isBW(), // but relaxing the test above triggers GM asserts in // SkRgnBuilder::blitH(). We need to investigate what's going on. - currClip->setPath(devPath, currClip->bwRgn(), doAA); + return currClip->setPath(devPath, currClip->bwRgn(), doAA); } else { base.setRect(currClip->getBounds()); SkRasterClip clip; clip.setPath(devPath, base, doAA); - currClip->op(clip, op); + return currClip->op(clip, op); } } else { const SkBaseDevice* device = canvas->getDevice(); if (!device) { - currClip->setEmpty(); - return; + return currClip->setEmpty(); } base.setRect(0, 0, device->width(), device->height()); if (SkRegion::kReplace_Op == op) { - currClip->setPath(devPath, base, doAA); + return currClip->setPath(devPath, base, doAA); } else { SkRasterClip clip; clip.setPath(devPath, base, doAA); - currClip->op(clip, op); + return currClip->op(clip, op); } } } bool SkCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { - ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; if (rrect.isRect()) { - this->onClipRect(rrect.getBounds(), op, edgeStyle); - } else { - this->onClipRRect(rrect, op, edgeStyle); + // call the non-virtual version + return this->SkCanvas::clipRect(rrect.getBounds(), op, doAA); } - return !this->isClipEmpty(); -} -void SkCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { SkRRect transformedRRect; if (rrect.transform(*fMCRec->fMatrix, &transformedRRect)) { AutoValidateClip avc(this); fDeviceCMDirty = true; fCachedLocalClipBoundsDirty = true; - if (!fAllowSoftClip) { - edgeStyle = kHard_ClipEdgeStyle; - } + doAA &= fAllowSoftClip; - fClipStack.clipDevRRect(transformedRRect, op, kSoft_ClipEdgeStyle == edgeStyle); + fClipStack.clipDevRRect(transformedRRect, op, doAA); SkPath devPath; devPath.addRRect(transformedRRect); - clip_path_helper(this, fMCRec->fRasterClip, devPath, op, kSoft_ClipEdgeStyle == edgeStyle); - return; + return clipPathHelper(this, fMCRec->fRasterClip, devPath, op, doAA); } SkPath path; path.addRRect(rrect); // call the non-virtual version - this->SkCanvas::onClipPath(path, op, edgeStyle); + return this->SkCanvas::clipPath(path, op, doAA); } bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { - ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; - SkRect r; - if (!path.isInverseFillType() && path.isRect(&r)) { - this->onClipRect(r, op, edgeStyle); - } else { - this->onClipPath(path, op, edgeStyle); - } - - return !this->isClipEmpty(); -} - -void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { #ifdef SK_ENABLE_CLIP_QUICKREJECT if (SkRegion::kIntersect_Op == op && !path.isInverseFillType()) { if (fMCRec->fRasterClip->isEmpty()) { @@ -1327,9 +1298,7 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg fDeviceCMDirty = true; fCachedLocalClipBoundsDirty = true; - if (!fAllowSoftClip) { - edgeStyle = kHard_ClipEdgeStyle; - } + doAA &= fAllowSoftClip; SkPath devPath; path.transform(*fMCRec->fMatrix, &devPath); @@ -1345,7 +1314,7 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg } // if we called path.swap() we could avoid a deep copy of this path - fClipStack.clipDevPath(devPath, op, kSoft_ClipEdgeStyle == edgeStyle); + fClipStack.clipDevPath(devPath, op, doAA); if (fAllowSimplifyClip) { devPath.reset(); @@ -1369,17 +1338,15 @@ void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg // if the prev and curr clips disagree about aa -vs- not, favor the aa request. // perhaps we need an API change to avoid this sort of mixed-signals about // clipping. - if (element->isAA()) { - edgeStyle = kSoft_ClipEdgeStyle; - } + doAA |= element->isAA(); } op = SkRegion::kReplace_Op; } - clip_path_helper(this, fMCRec->fRasterClip, devPath, op, edgeStyle); + return clipPathHelper(this, fMCRec->fRasterClip, devPath, op, doAA); } -void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegion::Op op, +bool SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegion::Op op, bool inverseFilled) { // This is for updating the clip conservatively using only bounds // information. @@ -1403,7 +1370,7 @@ void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegio case SkRegion::kDifference_Op: // These ops can only shrink the current clip. So leaving // the clip unchanges conservatively respects the contract. - return; + return this->getClipDeviceBounds(NULL); case SkRegion::kUnion_Op: case SkRegion::kReplace_Op: case SkRegion::kReverseDifference_Op: @@ -1419,9 +1386,10 @@ void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegio this->SkCanvas::save(SkCanvas::kMatrix_SaveFlag); // set the clip in device space this->SkCanvas::setMatrix(SkMatrix::I()); - this->SkCanvas::clipRect(deviceBounds, SkRegion::kReplace_Op, false); + bool result = this->SkCanvas::clipRect(deviceBounds, + SkRegion::kReplace_Op, false); this->SkCanvas::restore(); //pop the matrix, but keep the clip - return; + return result; } default: SkASSERT(0); // unhandled op? @@ -1432,34 +1400,27 @@ void SkCanvas::updateClipConservativelyUsingBounds(const SkRect& bounds, SkRegio case SkRegion::kIntersect_Op: case SkRegion::kUnion_Op: case SkRegion::kReplace_Op: - this->SkCanvas::clipRect(bounds, op, false); - return; + return this->SkCanvas::clipRect(bounds, op, false); case SkRegion::kDifference_Op: // Difference can only shrink the current clip. // Leaving clip unchanged conservatively fullfills the contract. - return; + return this->getClipDeviceBounds(NULL); case SkRegion::kReverseDifference_Op: // To reverse, we swap in the bounds with a replace op. // As with difference, leave it unchanged. - this->SkCanvas::clipRect(bounds, SkRegion::kReplace_Op, false); - return; + return this->SkCanvas::clipRect(bounds, SkRegion::kReplace_Op, false); case SkRegion::kXOR_Op: // Be conservative, based on (A XOR B) always included in (A union B), // which is always included in (bounds(A) union bounds(B)) - this->SkCanvas::clipRect(bounds, SkRegion::kUnion_Op, false); - return; + return this->SkCanvas::clipRect(bounds, SkRegion::kUnion_Op, false); default: SkASSERT(0); // unhandled op? } } + return true; } bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) { - this->onClipRegion(rgn, op); - return !this->isClipEmpty(); -} - -void SkCanvas::onClipRegion(const SkRegion& rgn, SkRegion::Op op) { AutoValidateClip avc(this); fDeviceCMDirty = true; @@ -1469,7 +1430,7 @@ void SkCanvas::onClipRegion(const SkRegion& rgn, SkRegion::Op op) { // we have to ignore it, and use the region directly? fClipStack.clipDevRect(rgn.getBounds(), op); - fMCRec->fRasterClip->op(rgn, op); + return fMCRec->fRasterClip->op(rgn, op); } #ifdef SK_DEBUG @@ -1499,7 +1460,11 @@ void SkCanvas::validateClip() const { default: { SkPath path; element->asPath(&path); - clip_path_helper(this, &tmpClip, path, element->getOp(), element->isAA()); + clipPathHelper(this, + &tmpClip, + path, + element->getOp(), + element->isAA()); break; } } @@ -1578,7 +1543,7 @@ bool SkCanvas::quickReject(const SkPath& path) const { bool SkCanvas::getClipBounds(SkRect* bounds) const { SkIRect ibounds; - if (!this->getClipDeviceBounds(&ibounds)) { + if (!getClipDeviceBounds(&ibounds)) { return false; } @@ -1623,12 +1588,8 @@ const SkMatrix& SkCanvas::getTotalMatrix() const { } SkCanvas::ClipType SkCanvas::getClipType() const { - if (fMCRec->fRasterClip->isEmpty()) { - return kEmpty_ClipType; - } - if (fMCRec->fRasterClip->isRect()) { - return kRect_ClipType; - } + if (fMCRec->fRasterClip->isEmpty()) return kEmpty_ClipType; + if (fMCRec->fRasterClip->isRect()) return kRect_ClipType; return kComplex_ClipType; } diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index f170476241..a8279ca089 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -819,8 +819,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) size_t offsetToRestore = reader.readInt(); SkASSERT(!offsetToRestore || \ offsetToRestore >= reader.offset()); - canvas.clipPath(path, regionOp, doAA); - if (canvas.isClipEmpty() && offsetToRestore) { + if (!canvas.clipPath(path, regionOp, doAA) && offsetToRestore) { #ifdef SPEW_CLIP_SKIPPING skipPath.recordSkip(offsetToRestore - reader.offset()); #endif @@ -835,8 +834,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) size_t offsetToRestore = reader.readInt(); SkASSERT(!offsetToRestore || \ offsetToRestore >= reader.offset()); - canvas.clipRegion(region, regionOp); - if (canvas.isClipEmpty() && offsetToRestore) { + if (!canvas.clipRegion(region, regionOp) && offsetToRestore) { #ifdef SPEW_CLIP_SKIPPING skipRegion.recordSkip(offsetToRestore - reader.offset()); #endif @@ -851,8 +849,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) size_t offsetToRestore = reader.readInt(); SkASSERT(!offsetToRestore || \ offsetToRestore >= reader.offset()); - canvas.clipRect(rect, regionOp, doAA); - if (canvas.isClipEmpty() && offsetToRestore) { + if (!canvas.clipRect(rect, regionOp, doAA) && offsetToRestore) { #ifdef SPEW_CLIP_SKIPPING skipRect.recordSkip(offsetToRestore - reader.offset()); #endif @@ -868,8 +865,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) size_t offsetToRestore = reader.readInt(); SkASSERT(!offsetToRestore || \ offsetToRestore >= reader.offset()); - canvas.clipRRect(rrect, regionOp, doAA); - if (canvas.isClipEmpty() && offsetToRestore) { + if (!canvas.clipRRect(rrect, regionOp, doAA) && offsetToRestore) { #ifdef SPEW_CLIP_SKIPPING skipRRect.recordSkip(offsetToRestore - reader.offset()); #endif diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index dda6f46b10..978e2b37c2 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -847,14 +847,14 @@ int SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) { } #endif -void SkPictureRecord::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE fMCMgr.clipRect(rect, op, doAA); #else - this->recordClipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); + this->recordClipRect(rect, op, doAA); #endif - this->INHERITED::onClipRect(rect, op, edgeStyle); + return this->INHERITED::clipRect(rect, op, doAA); } int SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { @@ -878,17 +878,20 @@ int SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool do return offset; } -void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkPictureRecord::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { + if (rrect.isRect()) { + return this->SkPictureRecord::clipRect(rrect.getBounds(), op, doAA); + } #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE fMCMgr.clipRRect(rrect, op, doAA); #else - this->recordClipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); + this->recordClipRRect(rrect, op, doAA); #endif if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) { - this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); + return this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); } else { - this->INHERITED::onClipRRect(rrect, op, edgeStyle); + return this->INHERITED::clipRRect(rrect, op, doAA); } } @@ -912,20 +915,25 @@ int SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, bool return offset; } -void SkPictureRecord::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkPictureRecord::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { + + SkRect r; + if (!path.isInverseFillType() && path.isRect(&r)) { + return this->clipRect(r, op, doAA); + } #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE fMCMgr.clipPath(path, op, doAA); #else int pathID = this->addPathToHeap(path); - this->recordClipPath(pathID, op, kSoft_ClipEdgeStyle == edgeStyle); + this->recordClipPath(pathID, op, doAA); #endif if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) { - this->updateClipConservativelyUsingBounds(path.getBounds(), op, - path.isInverseFillType()); + return this->updateClipConservativelyUsingBounds(path.getBounds(), op, + path.isInverseFillType()); } else { - this->INHERITED::onClipPath(path, op, edgeStyle); + return this->INHERITED::clipPath(path, op, doAA); } } @@ -949,14 +957,14 @@ int SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) { return offset; } -void SkPictureRecord::onClipRegion(const SkRegion& region, SkRegion::Op op) { +bool SkPictureRecord::clipRegion(const SkRegion& region, SkRegion::Op op) { #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE fMCMgr.clipRegion(region, op); #else this->recordClipRegion(region, op); #endif - this->INHERITED::onClipRegion(region, op); + return this->INHERITED::clipRegion(region, op); } int SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op) { diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h index 1b62f3dadc..dc439a108d 100644 --- a/src/core/SkPictureRecord.h +++ b/src/core/SkPictureRecord.h @@ -45,6 +45,10 @@ public: virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE; virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE; virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE; + virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE; + virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE; + virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE; + virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE; virtual void clear(SkColor) SK_OVERRIDE; virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], @@ -224,11 +228,6 @@ protected: virtual void onPushCull(const SkRect&) SK_OVERRIDE; virtual void onPopCull() SK_OVERRIDE; - virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; - // Return fontmetrics.fTop,fBottom in topbot[0,1], after they have been // tweaked by paint.computeFastBounds(). static void ComputeFontMetricsTopBottom(const SkPaint& paint, SkScalar topbot[2]); diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp index 43209f644b..879ce8288b 100644 --- a/src/pipe/SkGPipeWrite.cpp +++ b/src/pipe/SkGPipeWrite.cpp @@ -240,6 +240,11 @@ public: virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE; virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE; virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE; + virtual bool clipRect(const SkRect&, SkRegion::Op op, bool doAntiAlias = false) SK_OVERRIDE; + virtual bool clipRRect(const SkRRect&, SkRegion::Op op, bool doAntiAlias = false) SK_OVERRIDE; + virtual bool clipPath(const SkPath& path, SkRegion::Op op, + bool doAntiAlias = false) SK_OVERRIDE; + virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE; virtual void clear(SkColor) SK_OVERRIDE; virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE; virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], @@ -289,11 +294,6 @@ public: protected: virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; - virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; - private: enum { kNoSaveLayer = -1, @@ -635,56 +635,47 @@ void SkGPipeCanvas::setMatrix(const SkMatrix& matrix) { this->INHERITED::setMatrix(matrix); } -void SkGPipeCanvas::onClipRect(const SkRect& rect, SkRegion::Op rgnOp, - ClipEdgeStyle edgeStyle) { +bool SkGPipeCanvas::clipRect(const SkRect& rect, SkRegion::Op rgnOp, + bool doAntiAlias) { NOTIFY_SETUP(this); if (this->needOpBytes(sizeof(SkRect))) { - unsigned flags = 0; - if (kSoft_ClipEdgeStyle == edgeStyle) { - flags = kClip_HasAntiAlias_DrawOpFlag; - } + unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag; this->writeOp(kClipRect_DrawOp, flags, rgnOp); fWriter.writeRect(rect); } - this->INHERITED::onClipRect(rect, rgnOp, edgeStyle); + return this->INHERITED::clipRect(rect, rgnOp, doAntiAlias); } -void SkGPipeCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op rgnOp, - ClipEdgeStyle edgeStyle) { +bool SkGPipeCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op rgnOp, + bool doAntiAlias) { NOTIFY_SETUP(this); if (this->needOpBytes(kSizeOfFlatRRect)) { - unsigned flags = 0; - if (kSoft_ClipEdgeStyle == edgeStyle) { - flags = kClip_HasAntiAlias_DrawOpFlag; - } + unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag; this->writeOp(kClipRRect_DrawOp, flags, rgnOp); fWriter.writeRRect(rrect); } - this->INHERITED::onClipRRect(rrect, rgnOp, edgeStyle); + return this->INHERITED::clipRRect(rrect, rgnOp, doAntiAlias); } -void SkGPipeCanvas::onClipPath(const SkPath& path, SkRegion::Op rgnOp, - ClipEdgeStyle edgeStyle) { +bool SkGPipeCanvas::clipPath(const SkPath& path, SkRegion::Op rgnOp, + bool doAntiAlias) { NOTIFY_SETUP(this); if (this->needOpBytes(path.writeToMemory(NULL))) { - unsigned flags = 0; - if (kSoft_ClipEdgeStyle == edgeStyle) { - flags = kClip_HasAntiAlias_DrawOpFlag; - } + unsigned flags = doAntiAlias & kClip_HasAntiAlias_DrawOpFlag; this->writeOp(kClipPath_DrawOp, flags, rgnOp); fWriter.writePath(path); } // we just pass on the bounds of the path - this->INHERITED::onClipRect(path.getBounds(), rgnOp, edgeStyle); + return this->INHERITED::clipRect(path.getBounds(), rgnOp, doAntiAlias); } -void SkGPipeCanvas::onClipRegion(const SkRegion& region, SkRegion::Op rgnOp) { +bool SkGPipeCanvas::clipRegion(const SkRegion& region, SkRegion::Op rgnOp) { NOTIFY_SETUP(this); if (this->needOpBytes(region.writeToMemory(NULL))) { this->writeOp(kClipRegion_DrawOp, 0, rgnOp); fWriter.writeRegion(region); } - this->INHERITED::onClipRegion(region, rgnOp); + return this->INHERITED::clipRegion(region, rgnOp); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/utils/SkCanvasStack.cpp b/src/utils/SkCanvasStack.cpp index d85f34b506..8951149b42 100644 --- a/src/utils/SkCanvasStack.cpp +++ b/src/utils/SkCanvasStack.cpp @@ -77,22 +77,25 @@ void SkCanvasStack::setMatrix(const SkMatrix& matrix) { this->SkCanvas::setMatrix(matrix); } -void SkCanvasStack::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle edgeStyle) { - this->INHERITED::onClipRect(r, op, edgeStyle); +bool SkCanvasStack::clipRect(const SkRect& r, SkRegion::Op op, bool aa) { + bool result = this->INHERITED::clipRect(r, op, aa); this->clipToZOrderedBounds(); + return result; } -void SkCanvasStack::onClipRRect(const SkRRect& rr, SkRegion::Op op, ClipEdgeStyle edgeStyle) { - this->INHERITED::onClipRRect(rr, op, edgeStyle); +bool SkCanvasStack::clipRRect(const SkRRect& rr, SkRegion::Op op, bool aa) { + bool result = this->INHERITED::clipRRect(rr, op, aa); this->clipToZOrderedBounds(); + return result; } -void SkCanvasStack::onClipPath(const SkPath& p, SkRegion::Op op, ClipEdgeStyle edgeStyle) { - this->INHERITED::onClipPath(p, op, edgeStyle); +bool SkCanvasStack::clipPath(const SkPath& p, SkRegion::Op op, bool aa) { + bool result = this->INHERITED::clipPath(p, op, aa); this->clipToZOrderedBounds(); + return result; } -void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { +bool SkCanvasStack::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { SkASSERT(fList.count() == fCanvasData.count()); for (int i = 0; i < fList.count(); ++i) { SkRegion tempRegion; @@ -101,5 +104,5 @@ void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { tempRegion.op(fCanvasData[i].requiredClip, SkRegion::kIntersect_Op); fList[i]->clipRegion(tempRegion, op); } - this->SkCanvas::onClipRegion(deviceRgn, op); + return this->SkCanvas::clipRegion(deviceRgn, op); } diff --git a/src/utils/SkCanvasStack.h b/src/utils/SkCanvasStack.h index ba2fed4932..5311118270 100644 --- a/src/utils/SkCanvasStack.h +++ b/src/utils/SkCanvasStack.h @@ -30,12 +30,11 @@ public: virtual void removeCanvas(SkCanvas*) SK_OVERRIDE { SkDEBUGFAIL("Invalid Op"); } virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE; - -protected: - virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRegion(const SkRegion&, SkRegion::Op) SK_OVERRIDE; + virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE; + virtual bool clipRRect(const SkRRect&, SkRegion::Op, bool) SK_OVERRIDE; + virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE; + virtual bool clipRegion(const SkRegion& deviceRgn, + SkRegion::Op) SK_OVERRIDE; private: void clipToZOrderedBounds(); diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp index 09494c9aaa..3911fd0dfa 100644 --- a/src/utils/SkDeferredCanvas.cpp +++ b/src/utils/SkDeferredCanvas.cpp @@ -789,34 +789,39 @@ void SkDeferredCanvas::setMatrix(const SkMatrix& matrix) { this->recordedDrawCommand(); } -void SkDeferredCanvas::onClipRect(const SkRect& rect, - SkRegion::Op op, - ClipEdgeStyle edgeStyle) { - this->drawingCanvas()->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); - this->INHERITED::onClipRect(rect, op, edgeStyle); +bool SkDeferredCanvas::clipRect(const SkRect& rect, + SkRegion::Op op, + bool doAntiAlias) { + this->drawingCanvas()->clipRect(rect, op, doAntiAlias); + bool val = this->INHERITED::clipRect(rect, op, doAntiAlias); this->recordedDrawCommand(); + return val; } -void SkDeferredCanvas::onClipRRect(const SkRRect& rrect, - SkRegion::Op op, - ClipEdgeStyle edgeStyle) { - this->drawingCanvas()->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); - this->INHERITED::onClipRRect(rrect, op, edgeStyle); +bool SkDeferredCanvas::clipRRect(const SkRRect& rrect, + SkRegion::Op op, + bool doAntiAlias) { + this->drawingCanvas()->clipRRect(rrect, op, doAntiAlias); + bool val = this->INHERITED::clipRRect(rrect, op, doAntiAlias); this->recordedDrawCommand(); + return val; } -void SkDeferredCanvas::onClipPath(const SkPath& path, - SkRegion::Op op, - ClipEdgeStyle edgeStyle) { - this->drawingCanvas()->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle); - this->INHERITED::onClipPath(path, op, edgeStyle); +bool SkDeferredCanvas::clipPath(const SkPath& path, + SkRegion::Op op, + bool doAntiAlias) { + this->drawingCanvas()->clipPath(path, op, doAntiAlias); + bool val = this->INHERITED::clipPath(path, op, doAntiAlias); this->recordedDrawCommand(); + return val; } -void SkDeferredCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { +bool SkDeferredCanvas::clipRegion(const SkRegion& deviceRgn, + SkRegion::Op op) { this->drawingCanvas()->clipRegion(deviceRgn, op); - this->INHERITED::onClipRegion(deviceRgn, op); + bool val = this->INHERITED::clipRegion(deviceRgn, op); this->recordedDrawCommand(); + return val; } void SkDeferredCanvas::clear(SkColor color) { diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp index 4805d6287c..d768137578 100644 --- a/src/utils/SkDumpCanvas.cpp +++ b/src/utils/SkDumpCanvas.cpp @@ -261,40 +261,40 @@ void SkDumpCanvas::setMatrix(const SkMatrix& matrix) { /////////////////////////////////////////////////////////////////////////////// -const char* SkDumpCanvas::EdgeStyleToAAString(ClipEdgeStyle edgeStyle) { - return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW"; +static const char* bool_to_aastring(bool doAA) { + return doAA ? "AA" : "BW"; } -void SkDumpCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkDumpCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { SkString str; toString(rect, &str); this->dump(kClip_Verb, NULL, "clipRect(%s %s %s)", str.c_str(), toString(op), - EdgeStyleToAAString(edgeStyle)); - this->INHERITED::onClipRect(rect, op, edgeStyle); + bool_to_aastring(doAA)); + return this->INHERITED::clipRect(rect, op, doAA); } -void SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkDumpCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { SkString str; toString(rrect, &str); this->dump(kClip_Verb, NULL, "clipRRect(%s %s %s)", str.c_str(), toString(op), - EdgeStyleToAAString(edgeStyle)); - this->INHERITED::onClipRRect(rrect, op, edgeStyle); + bool_to_aastring(doAA)); + return this->INHERITED::clipRRect(rrect, op, doAA); } -void SkDumpCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkDumpCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { SkString str; toString(path, &str); this->dump(kClip_Verb, NULL, "clipPath(%s %s %s)", str.c_str(), toString(op), - EdgeStyleToAAString(edgeStyle)); - this->INHERITED::onClipPath(path, op, edgeStyle); + bool_to_aastring(doAA)); + return this->INHERITED::clipPath(path, op, doAA); } -void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { +bool SkDumpCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { SkString str; toString(deviceRgn, &str); this->dump(kClip_Verb, NULL, "clipRegion(%s %s)", str.c_str(), toString(op)); - this->INHERITED::onClipRegion(deviceRgn, op); + return this->INHERITED::clipRegion(deviceRgn, op); } void SkDumpCanvas::onPushCull(const SkRect& cullRect) { diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp index 0f13073049..8c25dc0401 100644 --- a/src/utils/SkLuaCanvas.cpp +++ b/src/utils/SkLuaCanvas.cpp @@ -139,30 +139,30 @@ void SkLuaCanvas::setMatrix(const SkMatrix& matrix) { this->INHERITED::setMatrix(matrix); } -void SkLuaCanvas::onClipRect(const SkRect& r, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkLuaCanvas::clipRect(const SkRect& r, SkRegion::Op op, bool doAA) { AUTO_LUA("clipRect"); lua.pushRect(r, "rect"); - lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa"); - this->INHERITED::onClipRect(r, op, edgeStyle); + lua.pushBool(doAA, "aa"); + return this->INHERITED::clipRect(r, op, doAA); } -void SkLuaCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkLuaCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { AUTO_LUA("clipRRect"); lua.pushRRect(rrect, "rrect"); - lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa"); - this->INHERITED::onClipRRect(rrect, op, edgeStyle); + lua.pushBool(doAA, "aa"); + return this->INHERITED::clipRRect(rrect, op, doAA); } -void SkLuaCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkLuaCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { AUTO_LUA("clipPath"); lua.pushPath(path, "path"); - lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa"); - this->INHERITED::onClipPath(path, op, edgeStyle); + lua.pushBool(doAA, "aa"); + return this->INHERITED::clipPath(path, op, doAA); } -void SkLuaCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { +bool SkLuaCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { AUTO_LUA("clipRegion"); - this->INHERITED::onClipRegion(deviceRgn, op); + return this->INHERITED::clipRegion(deviceRgn, op); } void SkLuaCanvas::drawPaint(const SkPaint& paint) { diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp index a9543f9c02..27adc6d51d 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -130,36 +130,36 @@ void SkNWayCanvas::setMatrix(const SkMatrix& matrix) { this->INHERITED::setMatrix(matrix); } -void SkNWayCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkNWayCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { Iter iter(fList); while (iter.next()) { - iter->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); + iter->clipRect(rect, op, doAA); } - this->INHERITED::onClipRect(rect, op, edgeStyle); + return this->INHERITED::clipRect(rect, op, doAA); } -void SkNWayCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkNWayCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { Iter iter(fList); while (iter.next()) { - iter->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); + iter->clipRRect(rrect, op, doAA); } - this->INHERITED::onClipRRect(rrect, op, edgeStyle); + return this->INHERITED::clipRRect(rrect, op, doAA); } -void SkNWayCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { +bool SkNWayCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { Iter iter(fList); while (iter.next()) { - iter->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle); + iter->clipPath(path, op, doAA); } - this->INHERITED::onClipPath(path, op, edgeStyle); + return this->INHERITED::clipPath(path, op, doAA); } -void SkNWayCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { +bool SkNWayCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { Iter iter(fList); while (iter.next()) { iter->clipRegion(deviceRgn, op); } - this->INHERITED::onClipRegion(deviceRgn, op); + return this->INHERITED::clipRegion(deviceRgn, op); } void SkNWayCanvas::clear(SkColor color) { diff --git a/src/utils/SkNoSaveLayerCanvas.h b/src/utils/SkNoSaveLayerCanvas.h index 60fad87237..58d28b40b1 100644 --- a/src/utils/SkNoSaveLayerCanvas.h +++ b/src/utils/SkNoSaveLayerCanvas.h @@ -32,20 +32,25 @@ public: return count; } -protected: // disable aa for speed - virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE { - this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle); + virtual bool clipRect(const SkRect& rect, + SkRegion::Op op, + bool doAA) SK_OVERRIDE { + return this->INHERITED::clipRect(rect, op, false); } // for speed, just respect the bounds, and disable AA. May give us a few // false positives and negatives. - virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE { - this->updateClipConservativelyUsingBounds(path.getBounds(), op, - path.isInverseFillType()); + virtual bool clipPath(const SkPath& path, + SkRegion::Op op, + bool doAA) SK_OVERRIDE { + return this->updateClipConservativelyUsingBounds(path.getBounds(), op, + path.isInverseFillType()); } - virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle) SK_OVERRIDE { - this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); + virtual bool clipRRect(const SkRRect& rrect, + SkRegion::Op op, + bool doAA) SK_OVERRIDE { + return this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); } private: diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp index 0a9d7a80c2..245e0a6969 100644 --- a/src/utils/SkProxyCanvas.cpp +++ b/src/utils/SkProxyCanvas.cpp @@ -58,20 +58,20 @@ void SkProxyCanvas::setMatrix(const SkMatrix& matrix) { fProxy->setMatrix(matrix); } -void SkProxyCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { - fProxy->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); +bool SkProxyCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { + return fProxy->clipRect(rect, op, doAA); } -void SkProxyCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { - fProxy->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); +bool SkProxyCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { + return fProxy->clipRRect(rrect, op, doAA); } -void SkProxyCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { - fProxy->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle); +bool SkProxyCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { + return fProxy->clipPath(path, op, doAA); } -void SkProxyCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { - fProxy->clipRegion(deviceRgn, op); +bool SkProxyCanvas::clipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { + return fProxy->clipRegion(deviceRgn, op); } void SkProxyCanvas::drawPaint(const SkPaint& paint) { diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp index fedef697aa..15165c27e2 100644 --- a/src/utils/debugger/SkDebugCanvas.cpp +++ b/src/utils/debugger/SkDebugCanvas.cpp @@ -43,8 +43,7 @@ SkDebugCanvas::SkDebugCanvas(int width, int height) large.roundOut(&largeIRect); SkASSERT(!largeIRect.isEmpty()); #endif - // call the base class' version to avoid adding a draw command - this->INHERITED::onClipRect(large, SkRegion::kReplace_Op, kHard_ClipEdgeStyle); + INHERITED::clipRect(large, SkRegion::kReplace_Op, false); } SkDebugCanvas::~SkDebugCanvas() { @@ -298,20 +297,24 @@ void SkDebugCanvas::clear(SkColor color) { addDrawCommand(new SkClearCommand(color)); } -void SkDebugCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { - this->addDrawCommand(new SkClipPathCommand(path, op, kSoft_ClipEdgeStyle == edgeStyle)); +bool SkDebugCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { + addDrawCommand(new SkClipPathCommand(path, op, doAA)); + return true; } -void SkDebugCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { - this->addDrawCommand(new SkClipRectCommand(rect, op, kSoft_ClipEdgeStyle == edgeStyle)); +bool SkDebugCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { + addDrawCommand(new SkClipRectCommand(rect, op, doAA)); + return true; } -void SkDebugCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { - this->addDrawCommand(new SkClipRRectCommand(rrect, op, kSoft_ClipEdgeStyle == edgeStyle)); +bool SkDebugCanvas::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { + addDrawCommand(new SkClipRRectCommand(rrect, op, doAA)); + return true; } -void SkDebugCanvas::onClipRegion(const SkRegion& region, SkRegion::Op op) { - this->addDrawCommand(new SkClipRegionCommand(region, op)); +bool SkDebugCanvas::clipRegion(const SkRegion& region, SkRegion::Op op) { + addDrawCommand(new SkClipRegionCommand(region, op)); + return true; } bool SkDebugCanvas::concat(const SkMatrix& matrix) { diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h index 11771a4e3e..7d496274ac 100644 --- a/src/utils/debugger/SkDebugCanvas.h +++ b/src/utils/debugger/SkDebugCanvas.h @@ -143,6 +143,16 @@ public: virtual void clear(SkColor) SK_OVERRIDE; + virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE; + + virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE; + + virtual bool clipRRect(const SkRRect& rrect, + SkRegion::Op op = SkRegion::kIntersect_Op, + bool doAntiAlias = false) SK_OVERRIDE; + + virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE; + virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE; virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top, @@ -223,33 +233,11 @@ public: static const int kVizImageHeight = 256; static const int kVizImageWidth = 256; - virtual bool isClipEmpty() const SK_OVERRIDE { return false; } - virtual ClipType getClipType() const SK_OVERRIDE { return kRect_ClipType; } - virtual bool getClipBounds(SkRect* bounds) const SK_OVERRIDE { - if (NULL != bounds) { - bounds->setXYWH(0, 0, - SkIntToScalar(this->imageInfo().fWidth), - SkIntToScalar(this->imageInfo().fHeight)); - } - return true; - } - virtual bool getClipDeviceBounds(SkIRect* bounds) const SK_OVERRIDE { - if (NULL != bounds) { - bounds->setLargest(); - } - return true; - } - protected: virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE; virtual void onPopCull() SK_OVERRIDE; - virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) SK_OVERRIDE; - virtual void onClipRegion(const SkRegion& region, SkRegion::Op) SK_OVERRIDE; - private: SkTDArray<SkDrawCommand*> fCommandVector; int fWidth; |