| 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 | 26 |
| 26 protected: | 27 protected: |
| 27 void flatten(SkWriteBuffer&) const override; | 28 void flatten(SkWriteBuffer&) const override; |
| 28 | 29 |
| 29 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 30 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 30 SkBitmap* result, SkIPoint* offset) const override; | 31 SkBitmap* result, SkIPoint* offset) const override; |
| 31 #if SK_SUPPORT_GPU | 32 #if SK_SUPPORT_GPU |
| 32 bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, | 33 bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, |
| 33 const SkIRect& bounds) const override; | 34 const SkIRect& bounds) const override; |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 SkRegion fRegion; | 38 SkRegion fRegion; |
| 38 SkScalar fInnerThreshold; | 39 SkScalar fInnerThreshold; |
| 39 SkScalar fOuterThreshold; | 40 SkScalar fOuterThreshold; |
| 40 typedef SkImageFilter INHERITED; | 41 typedef SkImageFilter INHERITED; |
| 41 }; | 42 }; |
| 42 | 43 |
| 44 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkAlphaThresholdFilter) |
| 45 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkAlphaThresholdFilterImpl) |
| 46 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
| 47 |
| 48 |
| 43 SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region, | 49 SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region, |
| 44 SkScalar innerThreshold, | 50 SkScalar innerThreshold, |
| 45 SkScalar outerThreshold, | 51 SkScalar outerThreshold, |
| 46 SkImageFilter* input) { | 52 SkImageFilter* input) { |
| 47 return new SkAlphaThresholdFilterImpl(region, innerThreshold, outerThreshold
, input); | 53 return new SkAlphaThresholdFilterImpl(region, innerThreshold, outerThreshold
, input); |
| 48 } | 54 } |
| 49 | 55 |
| 50 #if SK_SUPPORT_GPU | 56 #if SK_SUPPORT_GPU |
| 51 #include "GrContext.h" | 57 #include "GrContext.h" |
| 52 #include "GrCoordTransform.h" | 58 #include "GrCoordTransform.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 377 } |
| 372 | 378 |
| 373 #ifndef SK_IGNORE_TO_STRING | 379 #ifndef SK_IGNORE_TO_STRING |
| 374 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { | 380 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { |
| 375 str->appendf("SkAlphaThresholdImageFilter: ("); | 381 str->appendf("SkAlphaThresholdImageFilter: ("); |
| 376 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); | 382 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); |
| 377 str->append(")"); | 383 str->append(")"); |
| 378 } | 384 } |
| 379 #endif | 385 #endif |
| 380 | 386 |
| OLD | NEW |