| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 | 9 |
| 10 #include "SkArithmeticMode.h" | 10 #include "SkArithmeticMode.h" |
| 11 #include "SkBitmapSource.h" | 11 #include "SkBitmapSource.h" |
| 12 #include "SkBlurImageFilter.h" | 12 #include "SkBlurImageFilter.h" |
| 13 #include "SkColorFilter.h" | 13 #include "SkColorFilter.h" |
| 14 #include "SkColorFilterImageFilter.h" |
| 14 #include "SkColorMatrixFilter.h" | 15 #include "SkColorMatrixFilter.h" |
| 15 #include "SkColorFilterImageFilter.h" | |
| 16 #include "SkFlattenableBuffers.h" | 16 #include "SkFlattenableBuffers.h" |
| 17 #include "SkMergeImageFilter.h" | 17 #include "SkMergeImageFilter.h" |
| 18 #include "SkMorphologyImageFilter.h" | 18 #include "SkMorphologyImageFilter.h" |
| 19 #include "SkOnce.h" | 19 #include "SkOnce.h" |
| 20 #include "SkTestImageFilters.h" |
| 20 #include "SkXfermodeImageFilter.h" | 21 #include "SkXfermodeImageFilter.h" |
| 21 | 22 |
| 22 #include "SkTestImageFilters.h" | |
| 23 | |
| 24 /////////////////////////////////////////////////////////////////////////////// | |
| 25 | |
| 26 namespace { | |
| 27 // More closely models how Blink's OffsetFilter works as of 10/23/13. SkOffsetIm
ageFilter doesn't | 23 // More closely models how Blink's OffsetFilter works as of 10/23/13. SkOffsetIm
ageFilter doesn't |
| 28 // perform a draw and this one does. | 24 // perform a draw and this one does. |
| 29 class SimpleOffsetFilter : public SkImageFilter { | 25 class SimpleOffsetFilter : public SkImageFilter { |
| 30 public: | 26 public: |
| 31 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) | 27 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) |
| 32 : SkImageFilter(input), fDX(dx), fDY(dy) {} | 28 : SkImageFilter(input), fDX(dx), fDY(dy) {} |
| 33 | 29 |
| 34 virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix
& ctm, | 30 virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix
& ctm, |
| 35 SkBitmap* dst, SkIPoint* offset) SK_OVERRIDE { | 31 SkBitmap* dst, SkIPoint* offset) SK_OVERRIDE { |
| 36 SkBitmap source = src; | 32 SkBitmap source = src; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 65 |
| 70 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { | 66 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE { |
| 71 this->SkImageFilter::flatten(buffer); | 67 this->SkImageFilter::flatten(buffer); |
| 72 buffer.writeScalar(fDX); | 68 buffer.writeScalar(fDX); |
| 73 buffer.writeScalar(fDY); | 69 buffer.writeScalar(fDY); |
| 74 } | 70 } |
| 75 | 71 |
| 76 private: | 72 private: |
| 77 SkScalar fDX, fDY; | 73 SkScalar fDX, fDY; |
| 78 }; | 74 }; |
| 79 } | |
| 80 | 75 |
| 81 static void init_flattenable(int*) { | 76 static void init_flattenable(int*) { |
| 82 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SimpleOffsetFilter) | 77 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SimpleOffsetFilter) |
| 83 } | 78 } |
| 84 | 79 |
| 85 class ImageFiltersGraphGM : public skiagm::GM { | 80 class ImageFiltersGraphGM : public skiagm::GM { |
| 86 public: | 81 public: |
| 87 ImageFiltersGraphGM() : fInitialized(false) { | 82 ImageFiltersGraphGM() : fInitialized(false) { |
| 88 int dummy; | 83 int dummy; |
| 89 SK_DECLARE_STATIC_ONCE(once); | 84 SK_DECLARE_STATIC_ONCE(once); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 private: | 187 private: |
| 193 typedef GM INHERITED; | 188 typedef GM INHERITED; |
| 194 SkBitmap fBitmap; | 189 SkBitmap fBitmap; |
| 195 bool fInitialized; | 190 bool fInitialized; |
| 196 }; | 191 }; |
| 197 | 192 |
| 198 /////////////////////////////////////////////////////////////////////////////// | 193 /////////////////////////////////////////////////////////////////////////////// |
| 199 | 194 |
| 200 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } | 195 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } |
| 201 static skiagm::GMRegistry reg(MyFactory); | 196 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |