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 "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
11 #include "SkBlendImageFilter.h" | |
12 #include "SkBlurImageFilter.h" | 11 #include "SkBlurImageFilter.h" |
13 #include "SkColorFilter.h" | 12 #include "SkColorFilter.h" |
14 #include "SkColorMatrixFilter.h" | 13 #include "SkColorMatrixFilter.h" |
15 #include "SkColorFilterImageFilter.h" | 14 #include "SkColorFilterImageFilter.h" |
16 #include "SkMergeImageFilter.h" | 15 #include "SkMergeImageFilter.h" |
17 #include "SkMorphologyImageFilter.h" | 16 #include "SkMorphologyImageFilter.h" |
| 17 #include "SkXfermodeImageFilter.h" |
18 | 18 |
19 #include "SkTestImageFilters.h" | 19 #include "SkTestImageFilters.h" |
20 | 20 |
21 /////////////////////////////////////////////////////////////////////////////// | 21 /////////////////////////////////////////////////////////////////////////////// |
22 | 22 |
23 class ImageFiltersGraphGM : public skiagm::GM { | 23 class ImageFiltersGraphGM : public skiagm::GM { |
24 public: | 24 public: |
25 ImageFiltersGraphGM() : fInitialized(false) {} | 25 ImageFiltersGraphGM() : fInitialized(false) {} |
26 | 26 |
27 protected: | 27 protected: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 { | 67 { |
68 SkAutoTUnref<SkImageFilter> morph(new SkDilateImageFilter(5, 5)); | 68 SkAutoTUnref<SkImageFilter> morph(new SkDilateImageFilter(5, 5)); |
69 | 69 |
70 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0, | 70 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0, |
71 0, SK_Scalar1, 0, 0, 0, | 71 0, SK_Scalar1, 0, 0, 0, |
72 0, 0, SK_Scalar1, 0, 0, | 72 0, 0, SK_Scalar1, 0, 0, |
73 0, 0, 0, SkFloatToScalar(0.5f), 0 }; | 73 0, 0, 0, SkFloatToScalar(0.5f), 0 }; |
74 | 74 |
75 SkAutoTUnref<SkColorFilter> matrixFilter(new SkColorMatrixFilter(mat
rix)); | 75 SkAutoTUnref<SkColorFilter> matrixFilter(new SkColorMatrixFilter(mat
rix)); |
76 SkAutoTUnref<SkImageFilter> colorMorph(SkColorFilterImageFilter::Cre
ate(matrixFilter, morph)); | 76 SkAutoTUnref<SkImageFilter> colorMorph(SkColorFilterImageFilter::Cre
ate(matrixFilter, morph)); |
77 SkAutoTUnref<SkImageFilter> blendColor(new SkBlendImageFilter(SkBlen
dImageFilter::kNormal_Mode, colorMorph)); | 77 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOve
r_Mode)); |
| 78 SkAutoTUnref<SkImageFilter> blendColor(new SkXfermodeImageFilter(mod
e, colorMorph)); |
78 | 79 |
79 SkPaint paint; | 80 SkPaint paint; |
80 paint.setImageFilter(blendColor); | 81 paint.setImageFilter(blendColor); |
81 canvas->drawBitmap(fBitmap, 100, 0, &paint); | 82 canvas->drawBitmap(fBitmap, 100, 0, &paint); |
82 } | 83 } |
83 } | 84 } |
84 | 85 |
85 private: | 86 private: |
86 typedef GM INHERITED; | 87 typedef GM INHERITED; |
87 SkBitmap fBitmap; | 88 SkBitmap fBitmap; |
88 bool fInitialized; | 89 bool fInitialized; |
89 }; | 90 }; |
90 | 91 |
91 /////////////////////////////////////////////////////////////////////////////// | 92 /////////////////////////////////////////////////////////////////////////////// |
92 | 93 |
93 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } | 94 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } |
94 static skiagm::GMRegistry reg(MyFactory); | 95 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |