OLD | NEW |
1 #ifndef _SkTestImageFilters_h | 1 #ifndef _SkTestImageFilters_h |
2 #define _SkTestImageFilters_h | 2 #define _SkTestImageFilters_h |
3 | 3 |
4 #include "SkImageFilter.h" | 4 #include "SkImageFilter.h" |
5 #include "SkPoint.h" | 5 #include "SkPoint.h" |
6 | 6 |
7 // Fun mode that scales down (only) and then scales back up to look pixelated | 7 // Fun mode that scales down (only) and then scales back up to look pixelated |
8 class SK_API SkDownSampleImageFilter : public SkImageFilter { | 8 class SK_API SkDownSampleImageFilter : public SkImageFilter { |
9 public: | 9 public: |
10 static SkDownSampleImageFilter* Create(SkScalar scale, SkImageFilter* input
= NULL) { | 10 static SkDownSampleImageFilter* Create(SkScalar scale, SkImageFilter* input
= NULL) { |
11 if (!SkScalarIsFinite(scale)) { | 11 if (!SkScalarIsFinite(scale)) { |
12 return NULL; | 12 return NULL; |
13 } | 13 } |
14 // we don't support scale in this range | 14 // we don't support scale in this range |
15 if (scale > SK_Scalar1 || scale <= 0) { | 15 if (scale > SK_Scalar1 || scale <= 0) { |
16 return NULL; | 16 return NULL; |
17 } | 17 } |
18 return SkNEW_ARGS(SkDownSampleImageFilter, (scale, input)); | 18 return SkNEW_ARGS(SkDownSampleImageFilter, (scale, input)); |
19 } | 19 } |
20 | 20 |
21 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter) | 21 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter) |
22 | 22 |
23 protected: | 23 protected: |
24 SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input) | 24 SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input) |
25 : INHERITED(1, &input), fScale(scale) {} | 25 : INHERITED(1, &input), fScale(scale) {} |
26 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | |
27 SkDownSampleImageFilter(SkReadBuffer& buffer); | |
28 #endif | |
29 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 26 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
30 | 27 |
31 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 28 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
32 SkBitmap* result, SkIPoint* loc) const SK_OVERRID
E; | 29 SkBitmap* result, SkIPoint* loc) const SK_OVERRID
E; |
33 | 30 |
34 private: | 31 private: |
35 SkScalar fScale; | 32 SkScalar fScale; |
36 | 33 |
37 typedef SkImageFilter INHERITED; | 34 typedef SkImageFilter INHERITED; |
38 }; | 35 }; |
39 | 36 |
40 #endif | 37 #endif |
OLD | NEW |