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 "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
11 | 11 |
12 #define WIDTH 500 | 12 #define WIDTH 500 |
13 #define HEIGHT 500 | 13 #define HEIGHT 500 |
14 | 14 |
15 namespace skiagm { | 15 namespace skiagm { |
16 | 16 |
17 class ImageBlurGM : public GM { | 17 class ImageBlurGM : public GM { |
18 public: | 18 public: |
19 ImageBlurGM(SkScalar sigmaX, SkScalar sigmaY, const char* suffix) | 19 ImageBlurGM(SkScalar sigmaX, SkScalar sigmaY, const char* suffix) |
20 : fSigmaX(sigmaX), fSigmaY(sigmaY) { | 20 : fSigmaX(sigmaX), fSigmaY(sigmaY) { |
21 this->setBGColor(0xFF000000); | 21 this->setBGColor(0xFF000000); |
22 fName.printf("imageblur%s", suffix); | 22 fName.printf("imageblur%s", suffix); |
23 } | 23 } |
24 | 24 |
25 protected: | 25 protected: |
26 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 26 uint32_t onGetFlags() const SK_OVERRIDE { |
27 return kSkipTiled_Flag; | 27 return kSkipTiled_Flag; |
28 } | 28 } |
29 | 29 |
30 virtual SkString onShortName() SK_OVERRIDE { | 30 SkString onShortName() SK_OVERRIDE { |
31 return fName; | 31 return fName; |
32 } | 32 } |
33 | 33 |
34 virtual SkISize onISize() SK_OVERRIDE { | 34 SkISize onISize() SK_OVERRIDE { |
35 return SkISize::Make(WIDTH, HEIGHT); | 35 return SkISize::Make(WIDTH, HEIGHT); |
36 } | 36 } |
37 | 37 |
38 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 38 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
39 SkPaint paint; | 39 SkPaint paint; |
40 paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref
(); | 40 paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref
(); |
41 canvas->saveLayer(NULL, &paint); | 41 canvas->saveLayer(NULL, &paint); |
42 const char* str = "The quick brown fox jumped over the lazy dog."; | 42 const char* str = "The quick brown fox jumped over the lazy dog."; |
43 | 43 |
44 SkRandom rand; | 44 SkRandom rand; |
45 SkPaint textPaint; | 45 SkPaint textPaint; |
46 textPaint.setAntiAlias(true); | 46 textPaint.setAntiAlias(true); |
47 sk_tool_utils::set_portable_typeface(&textPaint); | 47 sk_tool_utils::set_portable_typeface(&textPaint); |
48 for (int i = 0; i < 25; ++i) { | 48 for (int i = 0; i < 25; ++i) { |
(...skipping 17 matching lines...) Expand all Loading... |
66 | 66 |
67 ////////////////////////////////////////////////////////////////////////////// | 67 ////////////////////////////////////////////////////////////////////////////// |
68 | 68 |
69 static GM* MyFactory1(void*) { return new ImageBlurGM(24.0f, 0.0f, ""); } | 69 static GM* MyFactory1(void*) { return new ImageBlurGM(24.0f, 0.0f, ""); } |
70 static GMRegistry reg1(MyFactory1); | 70 static GMRegistry reg1(MyFactory1); |
71 | 71 |
72 static GM* MyFactory2(void*) { return new ImageBlurGM(80.0f, 80.0f, "_large"); } | 72 static GM* MyFactory2(void*) { return new ImageBlurGM(80.0f, 80.0f, "_large"); } |
73 static GMRegistry reg2(MyFactory2); | 73 static GMRegistry reg2(MyFactory2); |
74 | 74 |
75 } | 75 } |
OLD | NEW |