| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkAlphaThresholdFilter.h" | 8 #include "SkAlphaThresholdFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
| 11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
| 12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
| 13 #include "SkRegion.h" | 13 #include "SkRegion.h" |
| 14 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
| 15 #include "GrDrawContext.h" | 15 #include "GrDrawContext.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter { | 18 class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter { |
| 19 public: | 19 public: |
| 20 SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold, | 20 SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold, |
| 21 SkScalar outerThreshold, SkImageFilter* input); | 21 SkScalar outerThreshold, SkImageFilter* input); |
| 22 | 22 |
| 23 SK_TO_STRING_OVERRIDE() | 23 SK_TO_STRING_OVERRIDE() |
| 24 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm
pl) | 24 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm
pl) |
| 25 friend void SkAlphaThresholdFilter::InitializeFlattenables(); | 25 friend void SkAlphaThresholdFilter::InitializeFlattenables(); |
| 26 | 26 |
| 27 protected: | 27 protected: |
| 28 void flatten(SkWriteBuffer&) const override; | 28 void flatten(SkWriteBuffer&) const override; |
| 29 | 29 |
| 30 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 30 bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, |
| 31 SkBitmap* result, SkIPoint* offset) const override; | 31 SkBitmap* result, SkIPoint* offset) const overr
ide; |
| 32 #if SK_SUPPORT_GPU | 32 #if SK_SUPPORT_GPU |
| 33 bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, | 33 bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, |
| 34 const SkIRect& bounds) const override; | 34 const SkIRect& bounds) const override; |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 SkRegion fRegion; | 38 SkRegion fRegion; |
| 39 SkScalar fInnerThreshold; | 39 SkScalar fInnerThreshold; |
| 40 SkScalar fOuterThreshold; | 40 SkScalar fOuterThreshold; |
| 41 typedef SkImageFilter INHERITED; | 41 typedef SkImageFilter INHERITED; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 324 } |
| 325 #endif | 325 #endif |
| 326 | 326 |
| 327 void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const { | 327 void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const { |
| 328 this->INHERITED::flatten(buffer); | 328 this->INHERITED::flatten(buffer); |
| 329 buffer.writeScalar(fInnerThreshold); | 329 buffer.writeScalar(fInnerThreshold); |
| 330 buffer.writeScalar(fOuterThreshold); | 330 buffer.writeScalar(fOuterThreshold); |
| 331 buffer.writeRegion(fRegion); | 331 buffer.writeRegion(fRegion); |
| 332 } | 332 } |
| 333 | 333 |
| 334 bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy* proxy, const SkBitmap& src
, | 334 bool SkAlphaThresholdFilterImpl::onFilterImageDeprecated(Proxy* proxy, const SkB
itmap& src, |
| 335 const Context& ctx, SkBitmap* dst
, | 335 const Context& ctx, SkB
itmap* dst, |
| 336 SkIPoint* offset) const { | 336 SkIPoint* offset) const
{ |
| 337 SkASSERT(src.colorType() == kN32_SkColorType); | 337 SkASSERT(src.colorType() == kN32_SkColorType); |
| 338 | 338 |
| 339 if (src.colorType() != kN32_SkColorType) { | 339 if (src.colorType() != kN32_SkColorType) { |
| 340 return false; | 340 return false; |
| 341 } | 341 } |
| 342 | 342 |
| 343 SkMatrix localInverse; | 343 SkMatrix localInverse; |
| 344 if (!ctx.ctm().invert(&localInverse)) { | 344 if (!ctx.ctm().invert(&localInverse)) { |
| 345 return false; | 345 return false; |
| 346 } | 346 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 } | 397 } |
| 398 | 398 |
| 399 #ifndef SK_IGNORE_TO_STRING | 399 #ifndef SK_IGNORE_TO_STRING |
| 400 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { | 400 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { |
| 401 str->appendf("SkAlphaThresholdImageFilter: ("); | 401 str->appendf("SkAlphaThresholdImageFilter: ("); |
| 402 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); | 402 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); |
| 403 str->append(")"); | 403 str->append(")"); |
| 404 } | 404 } |
| 405 #endif | 405 #endif |
| 406 | 406 |
| OLD | NEW |