diff options
-rw-r--r-- | include/core/SkCanvas.h | 9 | ||||
-rw-r--r-- | include/core/SkMaskFilter.h | 8 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 3 | ||||
-rw-r--r-- | src/core/SkMaskFilter.cpp | 3 | ||||
-rw-r--r-- | src/effects/SkBlurMaskFilter.cpp | 9 |
5 files changed, 32 insertions, 0 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 0d7b899c73..5c0738c5ac 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -363,6 +363,14 @@ public: SkRegion::Op op = SkRegion::kIntersect_Op, bool doAntiAlias = false); + /** EXPERIMENTAL -- only used for testing + Set to false to force clips to be hard, even if doAntiAlias=true is + passed to clipRect or clipPath. + */ + void setAllowSoftClip(bool allow) { + fAllowSoftClip = allow; + } + /** Modify the current clip with the specified region. Note that unlike clipRect() and clipPath() which transform their arguments by the current matrix, clipRegion() assumes its argument is already in device @@ -1027,6 +1035,7 @@ private: */ mutable SkRectCompareType fLocalBoundsCompareType; mutable bool fLocalBoundsCompareTypeDirty; + bool fAllowSoftClip; const SkRectCompareType& getLocalClipBoundsCompareType() const { if (fLocalBoundsCompareTypeDirty) { diff --git a/include/core/SkMaskFilter.h b/include/core/SkMaskFilter.h index 47cf516f2f..8dc7a6ab69 100644 --- a/include/core/SkMaskFilter.h +++ b/include/core/SkMaskFilter.h @@ -81,6 +81,14 @@ public: virtual BlurType asABlur(BlurInfo*) const; /** + * TEMPORARY HACK -- SkMaskFilters are designed to be immutable + * Optional method for maskfilters that can be described as a blur. If so, + * set the current blur to respect the [radius / ignore-transform / + * quality] settings. + */ + virtual void setAsABlur(const BlurInfo& ); + + /** * The fast bounds function is used to enable the paint to be culled early * in the drawing pipeline. This function accepts the current bounds of the * paint as its src param and the filter adjust those bounds using its diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 18cec44db7..a2354d5fae 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -440,6 +440,7 @@ SkDevice* SkCanvas::init(SkDevice* device) { fBounder = NULL; fLocalBoundsCompareType.setEmpty(); fLocalBoundsCompareTypeDirty = true; + fAllowSoftClip = true; fDeviceCMDirty = false; fSaveLayerCount = 0; fMetaData = NULL; @@ -1061,6 +1062,7 @@ bool SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { fDeviceCMDirty = true; fLocalBoundsCompareTypeDirty = true; + doAA &= fAllowSoftClip; if (fMCRec->fMatrix->rectStaysRect()) { // for these simpler matrices, we can stay a rect ever after applying @@ -1141,6 +1143,7 @@ bool SkCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) { fDeviceCMDirty = true; fLocalBoundsCompareTypeDirty = true; + doAA &= fAllowSoftClip; SkPath devPath; path.transform(*fMCRec->fMatrix, &devPath); diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp index f27ebd1e14..1880873e3e 100644 --- a/src/core/SkMaskFilter.cpp +++ b/src/core/SkMaskFilter.cpp @@ -58,6 +58,9 @@ SkMaskFilter::BlurType SkMaskFilter::asABlur(BlurInfo*) const { return kNone_BlurType; } +void SkMaskFilter::setAsABlur(const BlurInfo& ) { +} + void SkMaskFilter::computeFastBounds(const SkRect& src, SkRect* dst) { SkMask srcM, dstM; diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 4af3bfc039..0b7174dab4 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -22,6 +22,7 @@ public: virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, SkIPoint* margin) SK_OVERRIDE; virtual BlurType asABlur(BlurInfo*) const SK_OVERRIDE; + virtual void setAsABlur(const BlurInfo&) SK_OVERRIDE; virtual void computeFastBounds(const SkRect& src, SkRect* dst) SK_OVERRIDE; SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl) @@ -133,6 +134,14 @@ SkMaskFilter::BlurType SkBlurMaskFilterImpl::asABlur(BlurInfo* info) const { return gBlurStyle2BlurType[fBlurStyle]; } +void SkBlurMaskFilterImpl::setAsABlur(const BlurInfo& info) { + fRadius = info.fRadius; + fBlurFlags = fBlurFlags & ~(SkBlurMaskFilter::kIgnoreTransform_BlurFlag + | SkBlurMaskFilter::kHighQuality_BlurFlag) + | (info.fIgnoreTransform ? SkBlurMaskFilter::kIgnoreTransform_BlurFlag : 0) + | (info.fHighQuality ? SkBlurMaskFilter::kHighQuality_BlurFlag : 0); +} + SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |