OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 SkISize onISize() override { | 28 SkISize onISize() override { |
29 return SkISize::Make(WIDTH, HEIGHT); | 29 return SkISize::Make(WIDTH, HEIGHT); |
30 } | 30 } |
31 | 31 |
32 void onDraw(SkCanvas* canvas) override { | 32 void onDraw(SkCanvas* canvas) override { |
33 SkPaint paint; | 33 SkPaint paint; |
34 paint.setImageFilter(SkBlurImageFilter::Make(fSigmaX, fSigmaY, nullptr))
; | 34 paint.setImageFilter(SkBlurImageFilter::Make(fSigmaX, fSigmaY, nullptr))
; |
35 const SkScalar tileSize = SkIntToScalar(128); | 35 const SkScalar tileSize = SkIntToScalar(128); |
36 SkRect bounds; | 36 SkRect bounds = SkRect::MakeWH(WIDTH, HEIGHT); |
37 if (!canvas->getClipBounds(&bounds)) { | |
38 bounds.setEmpty(); | |
39 } | |
40 for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tileSize) { | 37 for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tileSize) { |
41 for (SkScalar x = bounds.left(); x < bounds.right(); x += tileSize)
{ | 38 for (SkScalar x = bounds.left(); x < bounds.right(); x += tileSize)
{ |
42 canvas->save(); | 39 canvas->save(); |
43 canvas->clipRect(SkRect::MakeXYWH(x, y, tileSize, tileSize)); | 40 canvas->clipRect(SkRect::MakeXYWH(x, y, tileSize, tileSize)); |
44 canvas->saveLayer(nullptr, &paint); | 41 canvas->saveLayer(nullptr, &paint); |
45 const char* str[] = { | 42 const char* str[] = { |
46 "The quick", | 43 "The quick", |
47 "brown fox", | 44 "brown fox", |
48 "jumped over", | 45 "jumped over", |
49 "the lazy dog.", | 46 "the lazy dog.", |
(...skipping 19 matching lines...) Expand all Loading... |
69 SkScalar fSigmaY; | 66 SkScalar fSigmaY; |
70 | 67 |
71 typedef GM INHERITED; | 68 typedef GM INHERITED; |
72 }; | 69 }; |
73 | 70 |
74 ////////////////////////////////////////////////////////////////////////////// | 71 ////////////////////////////////////////////////////////////////////////////// |
75 | 72 |
76 DEF_GM(return new ImageBlurTiledGM(3.0f, 3.0f);) | 73 DEF_GM(return new ImageBlurTiledGM(3.0f, 3.0f);) |
77 | 74 |
78 } | 75 } |
OLD | NEW |