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 19 matching lines...) Expand all Loading... |
30 return SkNEW(FailImageFilter); | 30 return SkNEW(FailImageFilter); |
31 } | 31 } |
32 | 32 |
33 SK_TO_STRING_OVERRIDE() | 33 SK_TO_STRING_OVERRIDE() |
34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) | 34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) |
35 | 35 |
36 protected: | 36 protected: |
37 FailImageFilter() : INHERITED(0, NULL) {} | 37 FailImageFilter() : INHERITED(0, NULL) {} |
38 | 38 |
39 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 39 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
40 SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE { | 40 SkBitmap* result, SkIPoint* offset) const override { |
41 return false; | 41 return false; |
42 } | 42 } |
43 | 43 |
44 private: | 44 private: |
45 typedef SkImageFilter INHERITED; | 45 typedef SkImageFilter INHERITED; |
46 }; | 46 }; |
47 | 47 |
48 static FailImageFilter::Registrar gReg0; | 48 static FailImageFilter::Registrar gReg0; |
49 | 49 |
50 SkFlattenable* FailImageFilter::CreateProc(SkReadBuffer& buffer) { | 50 SkFlattenable* FailImageFilter::CreateProc(SkReadBuffer& buffer) { |
(...skipping 21 matching lines...) Expand all Loading... |
72 static IdentityImageFilter* Create(SkImageFilter* input = NULL) { | 72 static IdentityImageFilter* Create(SkImageFilter* input = NULL) { |
73 return SkNEW_ARGS(IdentityImageFilter, (input)); | 73 return SkNEW_ARGS(IdentityImageFilter, (input)); |
74 } | 74 } |
75 | 75 |
76 SK_TO_STRING_OVERRIDE() | 76 SK_TO_STRING_OVERRIDE() |
77 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter) | 77 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter) |
78 protected: | 78 protected: |
79 IdentityImageFilter(SkImageFilter* input) : INHERITED(1, &input) {} | 79 IdentityImageFilter(SkImageFilter* input) : INHERITED(1, &input) {} |
80 | 80 |
81 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 81 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
82 SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE { | 82 SkBitmap* result, SkIPoint* offset) const override { |
83 *result = src; | 83 *result = src; |
84 offset->set(0, 0); | 84 offset->set(0, 0); |
85 return true; | 85 return true; |
86 } | 86 } |
87 | 87 |
88 private: | 88 private: |
89 typedef SkImageFilter INHERITED; | 89 typedef SkImageFilter INHERITED; |
90 }; | 90 }; |
91 | 91 |
92 static IdentityImageFilter::Registrar gReg1; | 92 static IdentityImageFilter::Registrar gReg1; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 &paint); | 187 &paint); |
188 } | 188 } |
189 | 189 |
190 /////////////////////////////////////////////////////////////////////////////// | 190 /////////////////////////////////////////////////////////////////////////////// |
191 | 191 |
192 class ImageFiltersBaseGM : public skiagm::GM { | 192 class ImageFiltersBaseGM : public skiagm::GM { |
193 public: | 193 public: |
194 ImageFiltersBaseGM () {} | 194 ImageFiltersBaseGM () {} |
195 | 195 |
196 protected: | 196 protected: |
197 SkString onShortName() SK_OVERRIDE { | 197 SkString onShortName() override { |
198 return SkString("imagefiltersbase"); | 198 return SkString("imagefiltersbase"); |
199 } | 199 } |
200 | 200 |
201 SkISize onISize() SK_OVERRIDE { return SkISize::Make(700, 500); } | 201 SkISize onISize() override { return SkISize::Make(700, 500); } |
202 | 202 |
203 void draw_frame(SkCanvas* canvas, const SkRect& r) { | 203 void draw_frame(SkCanvas* canvas, const SkRect& r) { |
204 SkPaint paint; | 204 SkPaint paint; |
205 paint.setStyle(SkPaint::kStroke_Style); | 205 paint.setStyle(SkPaint::kStroke_Style); |
206 paint.setColor(SK_ColorRED); | 206 paint.setColor(SK_ColorRED); |
207 canvas->drawRect(r, paint); | 207 canvas->drawRect(r, paint); |
208 } | 208 } |
209 | 209 |
210 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 210 void onDraw(SkCanvas* canvas) override { |
211 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { | 211 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { |
212 draw_paint, | 212 draw_paint, |
213 draw_line, draw_rect, draw_path, draw_text, | 213 draw_line, draw_rect, draw_path, draw_text, |
214 draw_bitmap, | 214 draw_bitmap, |
215 draw_sprite | 215 draw_sprite |
216 }; | 216 }; |
217 | 217 |
218 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED, | 218 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED, |
219 SkXfermode::kSrcIn_Mode); | 219 SkXfermode::kSrcIn_Mode); |
220 SkImageFilter* filters[] = { | 220 SkImageFilter* filters[] = { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 /* | 261 /* |
262 * Want to test combos of filter and LCD text, to be sure we disable LCD in the
presence of | 262 * Want to test combos of filter and LCD text, to be sure we disable LCD in the
presence of |
263 * a filter. | 263 * a filter. |
264 */ | 264 */ |
265 class ImageFiltersTextBaseGM : public skiagm::GM { | 265 class ImageFiltersTextBaseGM : public skiagm::GM { |
266 SkString fSuffix; | 266 SkString fSuffix; |
267 public: | 267 public: |
268 ImageFiltersTextBaseGM(const char suffix[]) : fSuffix(suffix) {} | 268 ImageFiltersTextBaseGM(const char suffix[]) : fSuffix(suffix) {} |
269 | 269 |
270 protected: | 270 protected: |
271 SkString onShortName() SK_OVERRIDE { | 271 SkString onShortName() override { |
272 SkString name; | 272 SkString name; |
273 name.printf("%s_%s", "textfilter", fSuffix.c_str()); | 273 name.printf("%s_%s", "textfilter", fSuffix.c_str()); |
274 return name; | 274 return name; |
275 } | 275 } |
276 | 276 |
277 SkISize onISize() SK_OVERRIDE { return SkISize::Make(512, 342); } | 277 SkISize onISize() override { return SkISize::Make(512, 342); } |
278 | 278 |
279 void drawWaterfall(SkCanvas* canvas, const SkPaint& origPaint) { | 279 void drawWaterfall(SkCanvas* canvas, const SkPaint& origPaint) { |
280 const uint32_t flags[] = { | 280 const uint32_t flags[] = { |
281 0, | 281 0, |
282 SkPaint::kAntiAlias_Flag, | 282 SkPaint::kAntiAlias_Flag, |
283 SkPaint::kAntiAlias_Flag | SkPaint::kLCDRenderText_Flag, | 283 SkPaint::kAntiAlias_Flag | SkPaint::kLCDRenderText_Flag, |
284 }; | 284 }; |
285 SkPaint paint(origPaint); | 285 SkPaint paint(origPaint); |
286 paint.setTextSize(30); | 286 paint.setTextSize(30); |
287 | 287 |
288 SkAutoCanvasRestore acr(canvas, true); | 288 SkAutoCanvasRestore acr(canvas, true); |
289 for (size_t i = 0; i < SK_ARRAY_COUNT(flags); ++i) { | 289 for (size_t i = 0; i < SK_ARRAY_COUNT(flags); ++i) { |
290 paint.setFlags(flags[i]); | 290 paint.setFlags(flags[i]); |
291 canvas->drawText("Hamburgefons", 11, 0, 0, paint); | 291 canvas->drawText("Hamburgefons", 11, 0, 0, paint); |
292 canvas->translate(0, 40); | 292 canvas->translate(0, 40); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 virtual void installFilter(SkPaint* paint) = 0; | 296 virtual void installFilter(SkPaint* paint) = 0; |
297 | 297 |
298 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 298 void onDraw(SkCanvas* canvas) override { |
299 SkPaint paint; | 299 SkPaint paint; |
300 | 300 |
301 canvas->translate(20, 40); | 301 canvas->translate(20, 40); |
302 | 302 |
303 for (int doSaveLayer = 0; doSaveLayer <= 1; ++doSaveLayer) { | 303 for (int doSaveLayer = 0; doSaveLayer <= 1; ++doSaveLayer) { |
304 SkAutoCanvasRestore acr(canvas, true); | 304 SkAutoCanvasRestore acr(canvas, true); |
305 for (int useFilter = 0; useFilter <= 1; ++useFilter) { | 305 for (int useFilter = 0; useFilter <= 1; ++useFilter) { |
306 SkAutoCanvasRestore acr2(canvas, true); | 306 SkAutoCanvasRestore acr2(canvas, true); |
307 | 307 |
308 SkPaint paint; | 308 SkPaint paint; |
(...skipping 15 matching lines...) Expand all Loading... |
324 } | 324 } |
325 | 325 |
326 private: | 326 private: |
327 typedef GM INHERITED; | 327 typedef GM INHERITED; |
328 }; | 328 }; |
329 | 329 |
330 class ImageFiltersText_IF : public ImageFiltersTextBaseGM { | 330 class ImageFiltersText_IF : public ImageFiltersTextBaseGM { |
331 public: | 331 public: |
332 ImageFiltersText_IF() : ImageFiltersTextBaseGM("image") {} | 332 ImageFiltersText_IF() : ImageFiltersTextBaseGM("image") {} |
333 | 333 |
334 void installFilter(SkPaint* paint) SK_OVERRIDE { | 334 void installFilter(SkPaint* paint) override { |
335 paint->setImageFilter(SkBlurImageFilter::Create(1.5f, 1.5f))->unref(); | 335 paint->setImageFilter(SkBlurImageFilter::Create(1.5f, 1.5f))->unref(); |
336 } | 336 } |
337 }; | 337 }; |
338 DEF_GM( return new ImageFiltersText_IF; ) | 338 DEF_GM( return new ImageFiltersText_IF; ) |
339 | 339 |
340 class ImageFiltersText_CF : public ImageFiltersTextBaseGM { | 340 class ImageFiltersText_CF : public ImageFiltersTextBaseGM { |
341 public: | 341 public: |
342 ImageFiltersText_CF() : ImageFiltersTextBaseGM("color") {} | 342 ImageFiltersText_CF() : ImageFiltersTextBaseGM("color") {} |
343 | 343 |
344 void installFilter(SkPaint* paint) SK_OVERRIDE { | 344 void installFilter(SkPaint* paint) override { |
345 paint->setColorFilter(SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXf
ermode::kSrcIn_Mode))->unref(); | 345 paint->setColorFilter(SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXf
ermode::kSrcIn_Mode))->unref(); |
346 } | 346 } |
347 }; | 347 }; |
348 DEF_GM( return new ImageFiltersText_CF; ) | 348 DEF_GM( return new ImageFiltersText_CF; ) |
349 | 349 |
OLD | NEW |