diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 2747705720..02735e1fe2 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -757,8 +757,8 @@ void SkBitmapDevice::onClipPath(const SkPath& path, SkClipOp op, bool aa) { fRCStack.clipPath(this->localToDevice(), path, op, aa); } -void SkBitmapDevice::onClipShader(sk_sp sh, SkClipOp op) { - fRCStack.clipShader(this->localToDevice(), std::move(sh), op); +void SkBitmapDevice::onClipShader(sk_sp sh) { + fRCStack.clipShader(std::move(sh)); } void SkBitmapDevice::onClipRegion(const SkRegion& rgn, SkClipOp op) { diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h index 9df2eeb83a..7a54c0c187 100644 --- a/src/core/SkBitmapDevice.h +++ b/src/core/SkBitmapDevice.h @@ -125,7 +125,7 @@ protected: 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 onClipShader(sk_sp, SkClipOp) override; + void onClipShader(sk_sp) override; void onClipRegion(const SkRegion& deviceRgn, SkClipOp) override; void onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) override; bool onClipIsAA() const override; diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h index c1c851635f..d9e7fd6a4b 100644 --- a/src/core/SkDevice.h +++ b/src/core/SkDevice.h @@ -15,6 +15,7 @@ #include "include/core/SkShader.h" #include "include/core/SkSurfaceProps.h" #include "include/private/SkNoncopyable.h" +#include "src/shaders/SkShaderBase.h" class SkBitmap; struct SkDrawShadowRec; @@ -152,7 +153,11 @@ public: this->onClipPath(path, op, aa); } void clipShader(sk_sp sh, SkClipOp op) { - this->onClipShader(std::move(sh), op); + sh = as_SB(sh)->makeWithCTM(this->localToDevice()); + if (op == SkClipOp::kDifference) { + sh = as_SB(sh)->makeInvertAlpha(); + } + this->onClipShader(std::move(sh)); } void clipRegion(const SkRegion& region, SkClipOp op) { this->onClipRegion(region, op); @@ -188,7 +193,7 @@ protected: virtual void onClipRect(const SkRect& rect, SkClipOp, bool aa) {} virtual void onClipRRect(const SkRRect& rrect, SkClipOp, bool aa) {} virtual void onClipPath(const SkPath& path, SkClipOp, bool aa) {} - virtual void onClipShader(sk_sp, SkClipOp) {} + virtual void onClipShader(sk_sp) {} virtual void onClipRegion(const SkRegion& deviceRgn, SkClipOp) {} virtual void onSetDeviceClipRestriction(SkIRect* mutableClipRestriction) {} virtual bool onClipIsAA() const = 0; diff --git a/src/core/SkRasterClip.cpp b/src/core/SkRasterClip.cpp index f8c92b9b3e..f9773ff632 100644 --- a/src/core/SkRasterClip.cpp +++ b/src/core/SkRasterClip.cpp @@ -347,20 +347,13 @@ bool SkRasterClip::op(const SkRasterClip& clip, SkRegion::Op op) { return this->updateCacheAndReturnNonEmpty(); } -bool SkRasterClip::op(sk_sp sh, const SkMatrix& ctm, SkRegion::Op op) { +bool SkRasterClip::op(sk_sp sh) { AUTO_RASTERCLIP_VALIDATE(*this); - sh = as_SB(sh)->makeWithCTM(ctm); if (!fShader) { - if (op != SkRegion::kIntersect_Op) { - sh = as_SB(sh)->makeInvertAlpha(); - } fShader = sh; } else { - SkBlendMode mode = (op == SkRegion::kIntersect_Op) ? - SkBlendMode::kSrcIn : - SkBlendMode::kSrcOut; - fShader = SkShaders::Blend(mode, sh, fShader); + fShader = SkShaders::Blend(SkBlendMode::kSrcIn, sh, fShader); } return !this->isEmpty(); } diff --git a/src/core/SkRasterClip.h b/src/core/SkRasterClip.h index 1e5b3d9106..223ab0de5e 100644 --- a/src/core/SkRasterClip.h +++ b/src/core/SkRasterClip.h @@ -98,7 +98,7 @@ public: bool op(const SkRect&, const SkMatrix& matrix, const SkIRect&, SkRegion::Op, bool doAA); bool op(const SkRRect&, const SkMatrix& matrix, const SkIRect&, SkRegion::Op, bool doAA); bool op(const SkPath&, const SkMatrix& matrix, const SkIRect&, SkRegion::Op, bool doAA); - bool op(sk_sp, const SkMatrix&, SkRegion::Op); + bool op(sk_sp); void translate(int dx, int dy, SkRasterClip* dst) const; void translate(int dx, int dy) { diff --git a/src/core/SkRasterClipStack.h b/src/core/SkRasterClipStack.h index 822407191e..bdcd7b50a1 100644 --- a/src/core/SkRasterClipStack.h +++ b/src/core/SkRasterClipStack.h @@ -117,8 +117,8 @@ public: this->validate(); } - void clipShader(const SkMatrix& ctm, sk_sp sh, SkClipOp op) { - this->writable_rc().op(std::move(sh), ctm, (SkRegion::Op)op); + void clipShader(sk_sp sh) { + this->writable_rc().op(std::move(sh)); this->validate(); }