aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkClipStackDevice.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-03-03 13:58:10 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-03 19:39:43 +0000
commitcfaa63237b152ae216f1351207bce3ea9808814c (patch)
tree4812b9bc5f6c8908ec2de778ef31c1447bc181a6 /src/core/SkClipStackDevice.cpp
parentb7115c68baef47b88f70b14d408e6cf5fab523f7 (diff)
Revert[2] "Remove SkDraw from device-draw methods, and enable device-centric clipping.""
passes new (augmented) CanvasClipType unittest fixed rasterclipstack::setnewsize This reverts commit ea5e676a7b75600edcde3912886486004ccd7626. BUG=skia: Change-Id: I004653e0f4d01454662f8516fccab0046486f273 Reviewed-on: https://skia-review.googlesource.com/9185 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core/SkClipStackDevice.cpp')
-rw-r--r--src/core/SkClipStackDevice.cpp62
1 files changed, 53 insertions, 9 deletions
diff --git a/src/core/SkClipStackDevice.cpp b/src/core/SkClipStackDevice.cpp
index 799850b839..dd5118d319 100644
--- a/src/core/SkClipStackDevice.cpp
+++ b/src/core/SkClipStackDevice.cpp
@@ -9,6 +9,16 @@
#include "SkDraw.h"
#include "SkRasterClip.h"
+SkIRect SkClipStackDevice::devClipBounds() const {
+ SkIRect r = fClipStack.bounds(this->imageInfo().bounds()).roundOut();
+ if (!r.isEmpty()) {
+ SkASSERT(this->imageInfo().bounds().contains(r));
+ }
+ return r;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
void SkClipStackDevice::onSave() {
fClipStack.save();
}
@@ -52,13 +62,47 @@ void SkClipStackDevice::onSetDeviceClipRestriction(SkIRect* clipRestriction) {
}
}
-SkIRect SkClipStackDevice::devClipBounds(const SkDraw& draw) const {
-#ifdef SK_USE_DEVICE_CLIPPING
- SkIRect r = fClipStack.bounds(this->imageInfo().bounds()).roundOut();
- SkASSERT(this->imageInfo().bounds().contains(r));
- SkASSERT(draw.fRC->getBounds().contains(r));
- return r;
-#else
- return draw.fRC->getBounds();
-#endif
+bool SkClipStackDevice::onClipIsAA() const {
+ SkClipStack::B2TIter iter(fClipStack);
+ const SkClipStack::Element* element;
+
+ while ((element = iter.next()) != nullptr) {
+ if (element->isAA()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void SkClipStackDevice::onAsRgnClip(SkRegion* rgn) const {
+ SkClipStack::BoundsType boundType;
+ bool isIntersectionOfRects;
+ SkRect bounds;
+ fClipStack.getBounds(&bounds, &boundType, &isIntersectionOfRects);
+ if (isIntersectionOfRects && SkClipStack::kNormal_BoundsType == boundType) {
+ rgn->setRect(bounds.round());
+ } else {
+ SkPath path;
+ fClipStack.asPath(&path);
+ rgn->setPath(path, SkRegion(SkIRect::MakeWH(this->width(), this->height())));
+ }
+}
+
+SkBaseDevice::ClipType SkClipStackDevice::onGetClipType() const {
+ if (fClipStack.isWideOpen()) {
+ return kRect_ClipType;
+ }
+ if (fClipStack.isEmpty(SkIRect::MakeWH(this->width(), this->height()))) {
+ return kEmpty_ClipType;
+ } else {
+ SkClipStack::BoundsType boundType;
+ bool isIntersectionOfRects;
+ SkRect bounds;
+ fClipStack.getBounds(&bounds, &boundType, &isIntersectionOfRects);
+ if (isIntersectionOfRects && SkClipStack::kNormal_BoundsType == boundType) {
+ return kRect_ClipType;
+ } else {
+ return kComplex_ClipType;
+ }
+ }
}