OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 SimpleBlurRoundRectGM() | 99 SimpleBlurRoundRectGM() |
100 : fName("simpleblurroundrect") { | 100 : fName("simpleblurroundrect") { |
101 } | 101 } |
102 | 102 |
103 protected: | 103 protected: |
104 virtual SkString onShortName() SK_OVERRIDE { | 104 virtual SkString onShortName() SK_OVERRIDE { |
105 return fName; | 105 return fName; |
106 } | 106 } |
107 | 107 |
108 virtual SkISize onISize() SK_OVERRIDE { | 108 virtual SkISize onISize() SK_OVERRIDE { |
109 return SkISize::Make(750, 750); | 109 return SkISize::Make(950, 950); |
110 } | 110 } |
111 | 111 |
112 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 112 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
113 canvas->scale(1.5f, 1.5f); | 113 canvas->scale(1.5f, 1.5f); |
| 114 canvas->translate(50,50); |
114 | 115 |
115 const int blurRadii[] = { 1, 3, 6, 10 }; | 116 const float blurRadii[] = { 1,5,10,20 }; |
116 const int cornerRadii[] = { 1, 3, 6, 10 }; | 117 const int cornerRadii[] = { 1,5,10,20 }; |
117 const SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); | 118 const SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); |
118 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) { | 119 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) { |
119 SkAutoCanvasRestore autoRestore(canvas, true); | 120 SkAutoCanvasRestore autoRestore(canvas, true); |
120 canvas->translate(0, (r.height() + SkIntToScalar(20)) * i); | 121 canvas->translate(0, (r.height() + SkIntToScalar(50)) * i); |
121 for (size_t j = 0; j < SK_ARRAY_COUNT(cornerRadii); ++j) { | 122 for (size_t j = 0; j < SK_ARRAY_COUNT(cornerRadii); ++j) { |
122 SkMaskFilter* filter = SkBlurMaskFilter::Create( | 123 SkMaskFilter* filter = SkBlurMaskFilter::Create( |
123 kNormal_SkBlurStyle, | 124 kNormal_SkBlurStyle, |
124 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])
)); | 125 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])
), |
| 126 SkBlurMaskFilter::kHighQuality_BlurFlag); |
125 SkPaint paint; | 127 SkPaint paint; |
126 paint.setColor(SK_ColorBLUE); | 128 paint.setColor(SK_ColorBLACK); |
127 paint.setMaskFilter(filter)->unref(); | 129 paint.setMaskFilter(filter)->unref(); |
128 | 130 |
129 SkRRect rrect; | 131 SkRRect rrect; |
130 rrect.setRectXY(r, SkIntToScalar(cornerRadii[j]), SkIntToScalar(
cornerRadii[j])); | 132 rrect.setRectXY(r, SkIntToScalar(cornerRadii[j]), SkIntToScalar(
cornerRadii[j])); |
131 canvas->drawRRect(rrect, paint); | 133 canvas->drawRRect(rrect, paint); |
132 canvas->translate(r.width() + SkIntToScalar(10), 0); | 134 canvas->translate(r.width() + SkIntToScalar(50), 0); |
133 } | 135 } |
134 } | 136 } |
135 } | 137 } |
136 private: | 138 private: |
137 const SkString fName; | 139 const SkString fName; |
138 | 140 |
139 typedef skiagm::GM INHERITED; | 141 typedef skiagm::GM INHERITED; |
140 }; | 142 }; |
141 | 143 |
142 // Create one with dimensions/rounded corners based on the skp | 144 // Create one with dimensions/rounded corners based on the skp |
143 // | 145 // |
144 // TODO(scroggo): Disabled in an attempt to rememdy | 146 // TODO(scroggo): Disabled in an attempt to rememdy |
145 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: | 147 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: |
146 // ran wrong number of tests') | 148 // ran wrong number of tests') |
147 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) | 149 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) |
148 | 150 |
149 // Rounded rect with two opposite corners with large radii, the other two | 151 // Rounded rect with two opposite corners with large radii, the other two |
150 // small. | 152 // small. |
151 DEF_GM(return new BlurRoundRectGM(100, 100);) | 153 DEF_GM(return new BlurRoundRectGM(100, 100);) |
152 | 154 |
153 DEF_GM(return new SimpleBlurRoundRectGM();) | 155 DEF_GM(return new SimpleBlurRoundRectGM();) |
OLD | NEW |