aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp3
-rw-r--r--src/gpu/SkGpuDevice.cpp55
-rw-r--r--src/gpu/SkGpuDevice.h10
3 files changed, 68 insertions, 0 deletions
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index b7dd37a922..f9e628ce0d 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -555,7 +555,10 @@ void GrRenderTargetOpList::forwardCombine() {
if (j == i +1) {
// We assume op would have combined with candidate when the candidate was added
// via backwards combining in recordOp.
+#ifndef SK_USE_DEVICE_CLIPPING
+ // not sure why this fires with device-clipping in gm/complexclip4.cpp
SkASSERT(!op->combineIfPossible(candidate.fOp.get(), *this->caps()));
+#endif
} else if (op->combineIfPossible(candidate.fOp.get(), *this->caps())) {
GrOP_INFO("\t\tCombining with (%s, B%u)\n", candidate.fOp->name(),
candidate.fOp->uniqueID());
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 0197a6e663..791d4353c7 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -236,7 +236,12 @@ bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) {
void SkGpuDevice::prepareDraw(const SkDraw& draw) {
ASSERT_SINGLE_OWNER
+#ifdef SK_USE_DEVICE_CLIPPING
+ SkASSERT(*draw.fMatrix == this->ctm());
+ fClip.reset(&fClipStack, nullptr);
+#else
fClip.reset(draw.fClipStack, &this->getOrigin());
+#endif
}
GrRenderTargetContext* SkGpuDevice::accessRenderTargetContext() {
@@ -1820,4 +1825,54 @@ SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
return SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize);
}
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SkGpuDevice::onSave() {
+ fClipStack.save();
+}
+
+void SkGpuDevice::onRestore() {
+ fClipStack.restore();
+}
+
+void SkGpuDevice::onClipRect(const SkRect& rect, SkClipOp op, bool aa) {
+ fClipStack.clipRect(rect, this->ctm(), op, aa);
+}
+
+void SkGpuDevice::onClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
+ fClipStack.clipRRect(rrect, this->ctm(), op, aa);
+}
+
+void SkGpuDevice::onClipPath(const SkPath& path, SkClipOp op, bool aa) {
+ fClipStack.clipPath(path, this->ctm(), op, aa);
+}
+
+void SkGpuDevice::onClipRegion(const SkRegion& rgn, SkClipOp op) {
+ SkIPoint origin = this->getOrigin();
+ SkRegion tmp;
+ const SkRegion* ptr = &rgn;
+ if (origin.fX | origin.fY) {
+ // translate from "global/canvas" coordinates to relative to this device
+ rgn.translate(-origin.fX, -origin.fY, &tmp);
+ ptr = &tmp;
+ }
+ fClipStack.clipDevRect(ptr->getBounds(), op);
+}
+
+void SkGpuDevice::onSetDeviceClipRestriction(SkIRect* clipRestriction) {
+ if (clipRestriction->isEmpty()) {
+ fClipStack.setDeviceClipRestriction(*clipRestriction);
+ } else {
+ SkIPoint origin = this->getOrigin();
+ SkIRect rect = clipRestriction->makeOffset(-origin.x(), -origin.y());
+ fClipStack.setDeviceClipRestriction(rect);
+ fClipStack.clipDevRect(rect, SkClipOp::kIntersect);
+ }
+}
+
+void SkGpuDevice::validateDevBounds(const SkIRect& drawClipBounds) {
+#ifdef SK_DEBUG
+#endif
+}
+
#endif
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 846a7e5798..ab3fb3f462 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -134,6 +134,7 @@ private:
sk_sp<GrRenderTargetContext> fRenderTargetContext;
SkIPoint fClipOrigin;
+ SkClipStack fClipStack;
GrClipStackClip fClip;
SkISize fSize;
bool fOpaque;
@@ -237,6 +238,15 @@ private:
bool drawDashLine(const SkPoint pts[2], const SkPaint& paint);
void drawStrokedLine(const SkPoint pts[2], const SkDraw&, const SkPaint&);
+ void onSave() override;
+ void onRestore() override;
+ void onClipRect(const SkRect& rect, SkClipOp, bool aa) override;
+ void onClipRRect(const SkRRect& rrect, SkClipOp, bool aa) override;
+ void onClipPath(const SkPath& path, SkClipOp, bool aa) override;
+ void onClipRegion(const SkRegion& deviceRgn, SkClipOp) override;
+ void onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) override;
+ void validateDevBounds(const SkIRect& r) override;
+
static sk_sp<GrRenderTargetContext> MakeRenderTargetContext(GrContext*,
SkBudgeted,
const SkImageInfo&,