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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 SkScalar dx = WIDTH / sigmaCount; | 51 SkScalar dx = WIDTH / sigmaCount; |
52 SkScalar dy = HEIGHT / sigmaCount; | 52 SkScalar dy = HEIGHT / sigmaCount; |
53 const SkScalar textSize = 12; | 53 const SkScalar textSize = 12; |
54 | 54 |
55 for (int x = 0; x < sigmaCount; x++) { | 55 for (int x = 0; x < sigmaCount; x++) { |
56 SkScalar sigmaX = kBlurSigmas[x]; | 56 SkScalar sigmaX = kBlurSigmas[x]; |
57 for (int y = 0; y < sigmaCount; y++) { | 57 for (int y = 0; y < sigmaCount; y++) { |
58 SkScalar sigmaY = kBlurSigmas[y]; | 58 SkScalar sigmaY = kBlurSigmas[y]; |
59 | 59 |
60 SkPaint paint; | 60 SkPaint paint; |
61 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(sigma
X, sigmaY)); | 61 paint.setImageFilter(SkBlurImageFilter::Make(sigmaX, sigmaY, nul
lptr)); |
62 paint.setImageFilter(blur); | |
63 canvas->saveLayer(nullptr, &paint); | 62 canvas->saveLayer(nullptr, &paint); |
64 | 63 |
65 SkRandom rand; | 64 SkRandom rand; |
66 SkPaint textPaint; | 65 SkPaint textPaint; |
67 textPaint.setAntiAlias(false); | 66 textPaint.setAntiAlias(false); |
68 textPaint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24)
| 0xFF000000)); | 67 textPaint.setColor(sk_tool_utils::color_to_565(rand.nextBits(24)
| 0xFF000000)); |
69 sk_tool_utils::set_portable_typeface(&textPaint); | 68 sk_tool_utils::set_portable_typeface(&textPaint); |
70 textPaint.setTextSize(textSize); | 69 textPaint.setTextSize(textSize); |
71 | 70 |
72 for (int i = 0; i < testStringCount; i++) { | 71 for (int i = 0; i < testStringCount; i++) { |
73 canvas->drawText(kTestStrings[i], | 72 canvas->drawText(kTestStrings[i], |
74 strlen(kTestStrings[i]), | 73 strlen(kTestStrings[i]), |
75 SkIntToScalar(x * dx), | 74 SkIntToScalar(x * dx), |
76 SkIntToScalar(y * dy + textSize * i + textS
ize), | 75 SkIntToScalar(y * dy + textSize * i + textS
ize), |
77 textPaint); | 76 textPaint); |
78 } | 77 } |
79 canvas->restore(); | 78 canvas->restore(); |
80 } | 79 } |
81 } | 80 } |
82 } | 81 } |
83 | 82 |
84 private: | 83 private: |
85 SkString fName; | 84 SkString fName; |
86 | 85 |
87 typedef GM INHERITED; | 86 typedef GM INHERITED; |
88 }; | 87 }; |
89 | 88 |
90 ////////////////////////////////////////////////////////////////////////////// | 89 ////////////////////////////////////////////////////////////////////////////// |
91 | 90 |
92 static GM* MyFactory(void*) { return new BlurImageFilter; } | 91 DEF_GM(return new BlurImageFilter;) |
93 static GMRegistry reg(MyFactory); | |
94 | 92 |
95 } | 93 } |
OLD | NEW |