diff options
author | Mike Reed <reed@google.com> | 2017-01-23 14:09:13 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-23 20:56:13 +0000 |
commit | 42e8c53b3ef58f887a623b410d9783b4d4ab4921 (patch) | |
tree | a6b9f9aa477c9aab16c69db2b9ab9c00ad1fed30 /src | |
parent | ab23acf4fac009c08588dd9e37b8dd6bf384c9ee (diff) |
rename virtuals for clipbounds, and deprecate older bool/var-arg pattern
BUG=skia:
Change-Id: I08bcc2d0559e02838772538816b928e0716dd3aa
Reviewed-on: https://skia-review.googlesource.com/7412
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkCanvas.cpp | 44 | ||||
-rw-r--r-- | src/core/SkRecorder.cpp | 10 | ||||
-rw-r--r-- | src/core/SkRecorder.h | 6 | ||||
-rw-r--r-- | src/utils/SkDeferredCanvas.cpp | 8 | ||||
-rw-r--r-- | src/utils/SkDeferredCanvas.h | 5 |
5 files changed, 26 insertions, 47 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 7596c3a702..8fb83b46d0 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1742,49 +1742,35 @@ bool SkCanvas::quickReject(const SkPath& path) const { return path.isEmpty() || this->quickReject(path.getBounds()); } -bool SkCanvas::getClipBounds(SkRect* bounds) const { - SkIRect ibounds = this->getDeviceClipBounds(); +SkRect SkCanvas::onGetLocalClipBounds() const { + SkIRect ibounds = this->onGetDeviceClipBounds(); if (ibounds.isEmpty()) { - if (bounds) { - bounds->setEmpty(); - } - return false; + return SkRect::MakeEmpty(); } SkMatrix inverse; // if we can't invert the CTM, we can't return local clip bounds if (!fMCRec->fMatrix.invert(&inverse)) { - if (bounds) { - bounds->setEmpty(); - } - return false; + return SkRect::MakeEmpty(); } - if (bounds) { - SkRect r; - // adjust it outwards in case we are antialiasing - const int inset = 1; + SkRect bounds; + SkRect r; + // adjust it outwards in case we are antialiasing + const int inset = 1; - r.iset(ibounds.fLeft - inset, ibounds.fTop - inset, - ibounds.fRight + inset, ibounds.fBottom + inset); - inverse.mapRect(bounds, r); - } - return true; + r.iset(ibounds.fLeft - inset, ibounds.fTop - inset, + ibounds.fRight + inset, ibounds.fBottom + inset); + inverse.mapRect(&bounds, r); + return bounds; } -bool SkCanvas::getClipDeviceBounds(SkIRect* bounds) const { +SkIRect SkCanvas::onGetDeviceClipBounds() const { const SkRasterClip& clip = fMCRec->fRasterClip; if (clip.isEmpty()) { - if (bounds) { - bounds->setEmpty(); - } - return false; - } - - if (bounds) { - *bounds = clip.getBounds(); + return SkIRect::MakeEmpty(); } - return true; + return clip.getBounds(); } const SkMatrix& SkCanvas::getTotalMatrix() const { diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp index f4c6b50f08..2f0f8369ee 100644 --- a/src/core/SkRecorder.cpp +++ b/src/core/SkRecorder.cpp @@ -383,7 +383,7 @@ SkCanvas::SaveLayerStrategy SkRecorder::getSaveLayerStrategy(const SaveLayerRec& } void SkRecorder::didRestore() { - APPEND(Restore, this->devBounds(), this->getTotalMatrix()); + APPEND(Restore, this->getDeviceClipBounds(), this->getTotalMatrix()); } void SkRecorder::didConcat(const SkMatrix& matrix) { @@ -407,24 +407,24 @@ void SkRecorder::didTranslateZ(SkScalar z) { void SkRecorder::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) { INHERITED(onClipRect, rect, op, edgeStyle); SkRecords::ClipOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); - APPEND(ClipRect, this->devBounds(), rect, opAA); + APPEND(ClipRect, this->getDeviceClipBounds(), rect, opAA); } void SkRecorder::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) { INHERITED(onClipRRect, rrect, op, edgeStyle); SkRecords::ClipOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); - APPEND(ClipRRect, this->devBounds(), rrect, opAA); + APPEND(ClipRRect, this->getDeviceClipBounds(), rrect, opAA); } void SkRecorder::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) { INHERITED(onClipPath, path, op, edgeStyle); SkRecords::ClipOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); - APPEND(ClipPath, this->devBounds(), path, opAA); + APPEND(ClipPath, this->getDeviceClipBounds(), path, opAA); } void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) { INHERITED(onClipRegion, deviceRgn, op); - APPEND(ClipRegion, this->devBounds(), deviceRgn, op); + APPEND(ClipRegion, this->getDeviceClipBounds(), deviceRgn, op); } sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfaceProps&) { diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h index c8100761dd..b5a79039d7 100644 --- a/src/core/SkRecorder.h +++ b/src/core/SkRecorder.h @@ -164,12 +164,6 @@ private: template <typename T> T* copy(const T[], size_t count); - SkIRect devBounds() const { - SkIRect devBounds; - this->getClipDeviceBounds(&devBounds); - return devBounds; - } - DrawPictureMode fDrawPictureMode; size_t fApproxBytesUsedBySubPictures; SkRecord* fRecord; diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp index bba864338a..a2f1bae42a 100644 --- a/src/utils/SkDeferredCanvas.cpp +++ b/src/utils/SkDeferredCanvas.cpp @@ -557,11 +557,11 @@ sk_sp<SkSurface> SkDeferredCanvas::onNewSurface(const SkImageInfo& info, return fCanvas->makeSurface(info, &props); } SkISize SkDeferredCanvas::getBaseLayerSize() const { return fCanvas->getBaseLayerSize(); } -bool SkDeferredCanvas::getClipBounds(SkRect* bounds) const { - return fCanvas->getClipBounds(bounds); +SkRect SkDeferredCanvas::onGetLocalClipBounds() const { + return fCanvas->getLocalClipBounds(); } -bool SkDeferredCanvas::getClipDeviceBounds(SkIRect* bounds) const { - return fCanvas->getClipDeviceBounds(bounds); +SkIRect SkDeferredCanvas::onGetDeviceClipBounds() const { + return fCanvas->getDeviceClipBounds(); } bool SkDeferredCanvas::isClipEmpty() const { return fCanvas->isClipEmpty(); } bool SkDeferredCanvas::isClipRect() const { return fCanvas->isClipRect(); } diff --git a/src/utils/SkDeferredCanvas.h b/src/utils/SkDeferredCanvas.h index af48b20872..f983a19e23 100644 --- a/src/utils/SkDeferredCanvas.h +++ b/src/utils/SkDeferredCanvas.h @@ -1,4 +1,3 @@ - /* * Copyright 2016 Google Inc. * @@ -26,8 +25,8 @@ public: protected: sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override; SkISize getBaseLayerSize() const override; - bool getClipBounds(SkRect* bounds) const override; - bool getClipDeviceBounds(SkIRect* bounds) const override; + SkRect onGetLocalClipBounds() const override; + SkIRect onGetDeviceClipBounds() const override; bool isClipEmpty() const override; bool isClipRect() const override; bool onPeekPixels(SkPixmap*) override; |