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" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 typedef SkImageFilter INHERITED; | 82 typedef SkImageFilter INHERITED; |
83 }; | 83 }; |
84 | 84 |
85 static SimpleOffsetFilter::Registrar gReg; | 85 static SimpleOffsetFilter::Registrar gReg; |
86 | 86 |
87 SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) { | 87 SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) { |
88 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 88 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
89 SkScalar dx = buffer.readScalar(); | 89 SkScalar dx = buffer.readScalar(); |
90 SkScalar dy = buffer.readScalar(); | 90 SkScalar dy = buffer.readScalar(); |
91 return Create(dx, dy, common.getInput(0)); | 91 return Create(dx, dy, common.getInput(0).get()); |
92 } | 92 } |
93 | 93 |
94 #ifndef SK_IGNORE_TO_STRING | 94 #ifndef SK_IGNORE_TO_STRING |
95 void SimpleOffsetFilter::toString(SkString* str) const { | 95 void SimpleOffsetFilter::toString(SkString* str) const { |
96 str->appendf("SimpleOffsetFilter: ("); | 96 str->appendf("SimpleOffsetFilter: ("); |
97 str->append(")"); | 97 str->append(")"); |
98 } | 98 } |
99 #endif | 99 #endif |
100 | 100 |
101 class ImageFiltersGraphGM : public skiagm::GM { | 101 class ImageFiltersGraphGM : public skiagm::GM { |
102 public: | 102 public: |
103 ImageFiltersGraphGM() {} | 103 ImageFiltersGraphGM() {} |
104 | 104 |
105 protected: | 105 protected: |
106 | 106 |
107 SkString onShortName() override { | 107 SkString onShortName() override { |
108 return SkString("imagefiltersgraph"); | 108 return SkString("imagefiltersgraph"); |
109 } | 109 } |
110 | 110 |
111 SkISize onISize() override { return SkISize::Make(600, 150); } | 111 SkISize onISize() override { return SkISize::Make(600, 150); } |
112 | 112 |
113 void onOnceBeforeDraw() override { | 113 void onOnceBeforeDraw() override { |
114 fImage = SkImage::MakeFromBitmap( | 114 fImage = SkImage::MakeFromBitmap( |
115 sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70,
96, "e")); | 115 sk_tool_utils::create_string_bitmap(100, 100, SK_ColorWHITE, 20, 70,
96, "e")); |
116 } | 116 } |
117 | 117 |
118 void onDraw(SkCanvas* canvas) override { | 118 void onDraw(SkCanvas* canvas) override { |
119 canvas->clear(SK_ColorBLACK); | 119 canvas->clear(SK_ColorBLACK); |
120 { | 120 { |
121 SkAutoTUnref<SkImageFilter> bitmapSource(SkImageSource::Create(fImag
e.get())); | 121 sk_sp<SkImageFilter> bitmapSource(SkImageSource::Create(fImage.get()
)); |
122 auto cf(SkColorFilter::MakeModeFilter(SK_ColorRED, SkXfermode::kSrcI
n_Mode)); | 122 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED, |
123 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0
f, bitmapSource)); | 123 SkXfermode::kS
rcIn_Mode)); |
124 SkAutoTUnref<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, b
lur)); | 124 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0f, bitm
apSource.get())); |
125 SkAutoTUnref<SkImageFilter> color(SkColorFilterImageFilter::Create(c
f.get(), erode)); | 125 sk_sp<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, blur.get
())); |
126 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(blur, c
olor)); | 126 sk_sp<SkImageFilter> color(SkColorFilterImageFilter::Create(cf.get()
, erode.get())); |
| 127 sk_sp<SkImageFilter> merge(SkMergeImageFilter::Make(blur, color)); |
127 | 128 |
128 SkPaint paint; | 129 SkPaint paint; |
129 paint.setImageFilter(merge); | 130 paint.setImageFilter(std::move(merge)); |
130 canvas->drawPaint(paint); | 131 canvas->drawPaint(paint); |
131 canvas->translate(SkIntToScalar(100), 0); | 132 canvas->translate(SkIntToScalar(100), 0); |
132 } | 133 } |
133 { | 134 { |
134 SkAutoTUnref<SkImageFilter> morph(SkDilateImageFilter::Create(5, 5))
; | 135 SkAutoTUnref<SkImageFilter> morph(SkDilateImageFilter::Create(5, 5))
; |
135 | 136 |
136 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0, | 137 SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0, |
137 0, SK_Scalar1, 0, 0, 0, | 138 0, SK_Scalar1, 0, 0, 0, |
138 0, 0, SK_Scalar1, 0, 0, | 139 0, 0, SK_Scalar1, 0, 0, |
139 0, 0, 0, 0.5f, 0 }; | 140 0, 0, 0, 0.5f, 0 }; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 238 } |
238 | 239 |
239 sk_sp<SkImage> fImage; | 240 sk_sp<SkImage> fImage; |
240 | 241 |
241 typedef GM INHERITED; | 242 typedef GM INHERITED; |
242 }; | 243 }; |
243 | 244 |
244 /////////////////////////////////////////////////////////////////////////////// | 245 /////////////////////////////////////////////////////////////////////////////// |
245 | 246 |
246 DEF_GM(return new ImageFiltersGraphGM;) | 247 DEF_GM(return new ImageFiltersGraphGM;) |
OLD | NEW |