OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkShader.h" | 12 #include "SkShader.h" |
13 | 13 |
14 #include "SkBlurImageFilter.h" | 14 #include "SkBlurImageFilter.h" |
15 #include "SkColorFilterImageFilter.h" | 15 #include "SkColorFilterImageFilter.h" |
16 #include "SkDropShadowImageFilter.h" | 16 #include "SkDropShadowImageFilter.h" |
17 #include "SkTestImageFilters.h" | 17 #include "SkTestImageFilters.h" |
18 | 18 |
19 class FailImageFilter : public SkImageFilter { | 19 class FailImageFilter : public SkImageFilter { |
20 public: | 20 public: |
21 class Registrar { | 21 class Registrar { |
22 public: | 22 public: |
23 Registrar() { | 23 Registrar() { |
24 SkFlattenable::Register("FailImageFilter", | 24 SkFlattenable::Register("FailImageFilter", |
| 25 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 26 FailImageFilter::DeepCreateProc, |
| 27 #else |
25 FailImageFilter::CreateProc, | 28 FailImageFilter::CreateProc, |
| 29 #endif |
26 FailImageFilter::GetFlattenableType()); | 30 FailImageFilter::GetFlattenableType()); |
27 } | 31 } |
28 }; | 32 }; |
29 static FailImageFilter* Create() { | 33 static FailImageFilter* Create() { |
30 return SkNEW(FailImageFilter); | 34 return SkNEW(FailImageFilter); |
31 } | 35 } |
32 | 36 |
33 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) | 37 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) |
34 | 38 |
35 protected: | 39 protected: |
36 FailImageFilter() : INHERITED(0, NULL) {} | 40 FailImageFilter() : INHERITED(0, NULL) {} |
37 | 41 |
38 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 42 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
39 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { | 43 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { |
40 return false; | 44 return false; |
41 } | 45 } |
42 | 46 |
| 47 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 48 FailImageFilter(SkReadBuffer& buffer) : INHERITED(0, buffer) {} |
| 49 #endif |
| 50 |
43 private: | 51 private: |
44 typedef SkImageFilter INHERITED; | 52 typedef SkImageFilter INHERITED; |
45 }; | 53 }; |
46 | 54 |
47 static FailImageFilter::Registrar gReg0; | 55 static FailImageFilter::Registrar gReg0; |
48 | 56 |
49 SkFlattenable* FailImageFilter::CreateProc(SkReadBuffer& buffer) { | 57 SkFlattenable* FailImageFilter::CreateProc(SkReadBuffer& buffer) { |
50 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); | 58 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); |
51 return FailImageFilter::Create(); | 59 return FailImageFilter::Create(); |
52 } | 60 } |
53 | 61 |
54 class IdentityImageFilter : public SkImageFilter { | 62 class IdentityImageFilter : public SkImageFilter { |
55 public: | 63 public: |
56 class Registrar { | 64 class Registrar { |
57 public: | 65 public: |
58 Registrar() { | 66 Registrar() { |
59 SkFlattenable::Register("IdentityImageFilter", | 67 SkFlattenable::Register("IdentityImageFilter", |
| 68 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 69 IdentityImageFilter::DeepCreateProc, |
| 70 #else |
60 IdentityImageFilter::CreateProc, | 71 IdentityImageFilter::CreateProc, |
| 72 #endif |
61 IdentityImageFilter::GetFlattenableType()); | 73 IdentityImageFilter::GetFlattenableType()); |
62 } | 74 } |
63 }; | 75 }; |
64 static IdentityImageFilter* Create(SkImageFilter* input = NULL) { | 76 static IdentityImageFilter* Create(SkImageFilter* input = NULL) { |
65 return SkNEW_ARGS(IdentityImageFilter, (input)); | 77 return SkNEW_ARGS(IdentityImageFilter, (input)); |
66 } | 78 } |
67 | 79 |
68 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter) | 80 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter) |
69 protected: | 81 protected: |
70 IdentityImageFilter(SkImageFilter* input) : INHERITED(1, &input) {} | 82 IdentityImageFilter(SkImageFilter* input) : INHERITED(1, &input) {} |
71 | 83 |
72 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 84 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
73 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { | 85 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { |
74 *result = src; | 86 *result = src; |
75 offset->set(0, 0); | 87 offset->set(0, 0); |
76 return true; | 88 return true; |
77 } | 89 } |
78 | 90 |
| 91 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 92 IdentityImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) {} |
| 93 #endif |
| 94 |
79 private: | 95 private: |
80 typedef SkImageFilter INHERITED; | 96 typedef SkImageFilter INHERITED; |
81 }; | 97 }; |
82 | 98 |
83 static IdentityImageFilter::Registrar gReg1; | 99 static IdentityImageFilter::Registrar gReg1; |
84 | 100 |
85 SkFlattenable* IdentityImageFilter::CreateProc(SkReadBuffer& buffer) { | 101 SkFlattenable* IdentityImageFilter::CreateProc(SkReadBuffer& buffer) { |
86 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 102 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
87 return IdentityImageFilter::Create(common.getInput(0)); | 103 return IdentityImageFilter::Create(common.getInput(0)); |
88 } | 104 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 260 } |
245 | 261 |
246 private: | 262 private: |
247 typedef GM INHERITED; | 263 typedef GM INHERITED; |
248 }; | 264 }; |
249 | 265 |
250 /////////////////////////////////////////////////////////////////////////////// | 266 /////////////////////////////////////////////////////////////////////////////// |
251 | 267 |
252 static skiagm::GM* MyFactory(void*) { return new ImageFiltersBaseGM; } | 268 static skiagm::GM* MyFactory(void*) { return new ImageFiltersBaseGM; } |
253 static skiagm::GMRegistry reg(MyFactory); | 269 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |