| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) | 25 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) |
| 26 protected: | 26 protected: |
| 27 FailImageFilter() : INHERITED(0, NULL) {} | 27 FailImageFilter() : INHERITED(0, NULL) {} |
| 28 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 28 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 29 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { | 29 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { |
| 30 return false; | 30 return false; |
| 31 } | 31 } |
| 32 | 32 |
| 33 FailImageFilter(SkReadBuffer& buffer) | 33 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 34 : INHERITED(0, buffer) {} | 34 FailImageFilter(SkReadBuffer& buffer) : INHERITED(0, buffer) {} |
| 35 #endif |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 typedef SkImageFilter INHERITED; | 38 typedef SkImageFilter INHERITED; |
| 38 }; | 39 }; |
| 39 | 40 |
| 41 SkFlattenable* FailImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 42 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); |
| 43 return FailImageFilter::Create(); |
| 44 } |
| 45 |
| 40 // register the filter with the flattenable registry | 46 // register the filter with the flattenable registry |
| 41 static SkFlattenable::Registrar gFailImageFilterReg("FailImageFilter", | 47 static SkFlattenable::Registrar gFailImageFilterReg("FailImageFilter", |
| 42 FailImageFilter::CreateProc, | 48 FailImageFilter::CreateProc, |
| 43 FailImageFilter::GetFlattena
bleType()); | 49 FailImageFilter::GetFlattena
bleType()); |
| 44 | 50 |
| 45 class IdentityImageFilter : public SkImageFilter { | 51 class IdentityImageFilter : public SkImageFilter { |
| 46 public: | 52 public: |
| 47 static IdentityImageFilter* Create(SkImageFilter* input = NULL) { | 53 static IdentityImageFilter* Create(SkImageFilter* input = NULL) { |
| 48 return SkNEW_ARGS(IdentityImageFilter, (input)); | 54 return SkNEW_ARGS(IdentityImageFilter, (input)); |
| 49 } | 55 } |
| 50 | 56 |
| 51 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter) | 57 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter) |
| 52 protected: | 58 protected: |
| 53 IdentityImageFilter(SkImageFilter* input) : INHERITED(1, &input) {} | 59 IdentityImageFilter(SkImageFilter* input) : INHERITED(1, &input) {} |
| 54 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 60 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 55 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { | 61 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { |
| 56 *result = src; | 62 *result = src; |
| 57 offset->set(0, 0); | 63 offset->set(0, 0); |
| 58 return true; | 64 return true; |
| 59 } | 65 } |
| 60 | 66 |
| 61 IdentityImageFilter(SkReadBuffer& buffer) | 67 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 62 : INHERITED(1, buffer) {} | 68 IdentityImageFilter(SkReadBuffer& buffer) : INHERITED(1, buffer) {} |
| 69 #endif |
| 63 | 70 |
| 64 private: | 71 private: |
| 65 typedef SkImageFilter INHERITED; | 72 typedef SkImageFilter INHERITED; |
| 66 }; | 73 }; |
| 67 | 74 |
| 75 SkFlattenable* IdentityImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 76 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 77 return IdentityImageFilter::Create(common.inputAt(0)); |
| 78 } |
| 79 |
| 68 // register the filter with the flattenable registry | 80 // register the filter with the flattenable registry |
| 69 static SkFlattenable::Registrar gIdentityImageFilterReg("IdentityImageFilter", | 81 static SkFlattenable::Registrar gIdentityImageFilterReg("IdentityImageFilter", |
| 70 IdentityImageFilter::Cre
ateProc, | 82 IdentityImageFilter::Cre
ateProc, |
| 71 IdentityImageFilter::Get
FlattenableType()); | 83 IdentityImageFilter::Get
FlattenableType()); |
| 72 | 84 |
| 73 | 85 |
| 74 /////////////////////////////////////////////////////////////////////////////// | 86 /////////////////////////////////////////////////////////////////////////////// |
| 75 | 87 |
| 76 static void draw_paint(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { | 88 static void draw_paint(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { |
| 77 SkPaint paint; | 89 SkPaint paint; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } | 239 } |
| 228 | 240 |
| 229 private: | 241 private: |
| 230 typedef GM INHERITED; | 242 typedef GM INHERITED; |
| 231 }; | 243 }; |
| 232 | 244 |
| 233 /////////////////////////////////////////////////////////////////////////////// | 245 /////////////////////////////////////////////////////////////////////////////// |
| 234 | 246 |
| 235 static skiagm::GM* MyFactory(void*) { return new ImageFiltersBaseGM; } | 247 static skiagm::GM* MyFactory(void*) { return new ImageFiltersBaseGM; } |
| 236 static skiagm::GMRegistry reg(MyFactory); | 248 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |