Index: src/effects/SkBlurMaskFilter.cpp |
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp |
index 9e0315f2b7471829037429ff537562bbda92a19e..2d03077a34b1252368c13a549db860b21d8e0e83 100644 |
--- a/src/effects/SkBlurMaskFilter.cpp |
+++ b/src/effects/SkBlurMaskFilter.cpp |
@@ -38,7 +38,7 @@ SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) { |
class SkBlurMaskFilterImpl : public SkMaskFilter { |
public: |
- SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle, uint32_t flags); |
+ SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle, const SkRect& occluder, uint32_t flags); |
// overrides from SkMaskFilter |
SkMask::Format getFormat() const override; |
@@ -96,8 +96,12 @@ private: |
// a request like 10,000) |
static const SkScalar kMAX_BLUR_SIGMA; |
+ // This flag should never escape from serialization |
+ static const int kInternalFlag_HasOccluder = 0x08; |
+ |
SkScalar fSigma; |
SkBlurStyle fBlurStyle; |
+ SkRect fOccluder; |
uint32_t fBlurFlags; |
SkBlurQuality getQuality() const { |
@@ -122,27 +126,31 @@ private: |
const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128); |
-sk_sp<SkMaskFilter> SkBlurMaskFilter::Make(SkBlurStyle style, SkScalar sigma, uint32_t flags) { |
+sk_sp<SkMaskFilter> SkBlurMaskFilter::Make(SkBlurStyle style, SkScalar sigma, |
+ const SkRect& occluder, uint32_t flags) { |
if (!SkScalarIsFinite(sigma) || sigma <= 0) { |
return nullptr; |
} |
if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) { |
return nullptr; |
} |
- if (flags > SkBlurMaskFilter::kAll_BlurFlag) { |
- return nullptr; |
- } |
- return sk_sp<SkMaskFilter>(new SkBlurMaskFilterImpl(sigma, style, flags)); |
+ SkASSERT(flags <= SkBlurMaskFilter::kAll_BlurFlag); |
+ flags &= SkBlurMaskFilter::kAll_BlurFlag; |
+ |
+ return sk_sp<SkMaskFilter>(new SkBlurMaskFilterImpl(sigma, style, occluder, flags)); |
} |
/////////////////////////////////////////////////////////////////////////////// |
-SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle style, uint32_t flags) |
+SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle style, |
+ const SkRect& occluder, uint32_t flags) |
: fSigma(sigma) |
, fBlurStyle(style) |
+ , fOccluder(occluder) |
, fBlurFlags(flags) { |
SkASSERT(fSigma > 0); |
SkASSERT((unsigned)style <= kLastEnum_SkBlurStyle); |
+ fOccluder.sort(); |
SkASSERT(flags <= SkBlurMaskFilter::kAll_BlurFlag); |
} |
@@ -584,8 +592,17 @@ sk_sp<SkFlattenable> SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) { |
const SkScalar sigma = buffer.readScalar(); |
const unsigned style = buffer.readUInt(); |
const unsigned flags = buffer.readUInt(); |
+ |
+ SkRect occluder; |
+ if (flags & kInternalFlag_HasOccluder) { |
+ buffer.readRect(&occluder); |
+ } else { |
+ occluder.setEmpty(); |
+ } |
+ |
if (style <= kLastEnum_SkBlurStyle) { |
- return SkBlurMaskFilter::Make((SkBlurStyle)style, sigma, flags); |
+ return SkBlurMaskFilter::Make((SkBlurStyle)style, sigma, occluder, |
+ flags & ~kInternalFlag_HasOccluder); |
} |
return nullptr; |
} |
@@ -593,7 +610,11 @@ sk_sp<SkFlattenable> SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) { |
void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const { |
buffer.writeScalar(fSigma); |
buffer.writeUInt(fBlurStyle); |
- buffer.writeUInt(fBlurFlags); |
+ |
+ SkASSERT(!(fBlurFlags & kInternalFlag_HasOccluder)); |
+ buffer.writeUInt(fBlurFlags | kInternalFlag_HasOccluder); |
+ |
+ buffer.writeRect(fOccluder); |
} |
#if SK_SUPPORT_GPU |