OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkBlurMask.h" | 8 #include "SkBlurMask.h" |
9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 static void test_blur_drawing(skiatest::Reporter* reporter) { | 98 static void test_blur_drawing(skiatest::Reporter* reporter) { |
99 | 99 |
100 SkPaint paint; | 100 SkPaint paint; |
101 paint.setColor(SK_ColorGRAY); | 101 paint.setColor(SK_ColorGRAY); |
102 paint.setStyle(SkPaint::kStroke_Style); | 102 paint.setStyle(SkPaint::kStroke_Style); |
103 paint.setStrokeWidth(SkIntToScalar(strokeWidth)); | 103 paint.setStrokeWidth(SkIntToScalar(strokeWidth)); |
104 | 104 |
105 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)); | 105 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)); |
106 for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) { | 106 for (int style = 0; style <= kLastEnum_SkBlurStyle; ++style) { |
107 SkBlurMaskFilter::BlurStyle blurStyle = | 107 SkBlurStyle blurStyle = static_cast<SkBlurStyle>(style); |
108 static_cast<SkBlurMaskFilter::BlurStyle>(style); | |
109 | 108 |
110 const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag; | 109 const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag; |
111 for (uint32_t flags = 0; flags < flagPermutations; ++flags) { | 110 for (uint32_t flags = 0; flags < flagPermutations; ++flags) { |
112 SkMaskFilter* filter; | 111 SkMaskFilter* filter; |
113 filter = SkBlurMaskFilter::Create(blurStyle, sigma, flags); | 112 filter = SkBlurMaskFilter::Create(blurStyle, sigma, flags); |
114 | 113 |
115 paint.setMaskFilter(filter); | 114 paint.setMaskFilter(filter); |
116 filter->unref(); | 115 filter->unref(); |
117 | 116 |
118 for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) { | 117 for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 SkMask src, dst; | 161 SkMask src, dst; |
163 | 162 |
164 src.fBounds.set(0, 0, width, height); | 163 src.fBounds.set(0, 0, width, height); |
165 src.fFormat = SkMask::kA8_Format; | 164 src.fFormat = SkMask::kA8_Format; |
166 src.fRowBytes = src.fBounds.width(); | 165 src.fRowBytes = src.fBounds.width(); |
167 src.fImage = SkMask::AllocImage(src.computeTotalImageSize()); | 166 src.fImage = SkMask::AllocImage(src.computeTotalImageSize()); |
168 | 167 |
169 memset(src.fImage, 0xff, src.computeTotalImageSize()); | 168 memset(src.fImage, 0xff, src.computeTotalImageSize()); |
170 | 169 |
171 dst.fImage = NULL; | 170 dst.fImage = NULL; |
172 SkBlurMask::BlurGroundTruth(sigma, &dst, src, SkBlurMask::kNormal_Style); | 171 SkBlurMask::BlurGroundTruth(sigma, &dst, src, kNormal_SkBlurStyle); |
173 | 172 |
174 int midX = dst.fBounds.centerX(); | 173 int midX = dst.fBounds.centerX(); |
175 int midY = dst.fBounds.centerY(); | 174 int midY = dst.fBounds.centerY(); |
176 uint8_t* bytes = dst.getAddr8(midX, midY); | 175 uint8_t* bytes = dst.getAddr8(midX, midY); |
177 int i; | 176 int i; |
178 for (i = 0; i < dst.fBounds.width()-(midX-dst.fBounds.fLeft); ++i) { | 177 for (i = 0; i < dst.fBounds.width()-(midX-dst.fBounds.fLeft); ++i) { |
179 if (i < resultCount) { | 178 if (i < resultCount) { |
180 result[i] = bytes[i]; | 179 result[i] = bytes[i]; |
181 } | 180 } |
182 } | 181 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 static void blur_path(SkCanvas* canvas, const SkPath& path, | 223 static void blur_path(SkCanvas* canvas, const SkPath& path, |
225 SkScalar gaussianSigma) { | 224 SkScalar gaussianSigma) { |
226 | 225 |
227 SkScalar midX = path.getBounds().centerX(); | 226 SkScalar midX = path.getBounds().centerX(); |
228 SkScalar midY = path.getBounds().centerY(); | 227 SkScalar midY = path.getBounds().centerY(); |
229 | 228 |
230 canvas->translate(-midX, -midY); | 229 canvas->translate(-midX, -midY); |
231 | 230 |
232 SkPaint blurPaint; | 231 SkPaint blurPaint; |
233 blurPaint.setColor(SK_ColorWHITE); | 232 blurPaint.setColor(SK_ColorWHITE); |
234 SkMaskFilter* filter = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_Bl
urStyle, | 233 SkMaskFilter* filter = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, |
235 gaussianSigma, | 234 gaussianSigma, |
236 SkBlurMaskFilter::kHighQuali
ty_BlurFlag); | 235 SkBlurMaskFilter::kHighQuali
ty_BlurFlag); |
237 blurPaint.setMaskFilter(filter)->unref(); | 236 blurPaint.setMaskFilter(filter)->unref(); |
238 | 237 |
239 canvas->drawColor(SK_ColorBLACK); | 238 canvas->drawColor(SK_ColorBLACK); |
240 canvas->drawPath(path, blurPaint); | 239 canvas->drawPath(path, blurPaint); |
241 } | 240 } |
242 | 241 |
243 // Readback the blurred draw results from the canvas | 242 // Readback the blurred draw results from the canvas |
244 static void readback(SkCanvas* canvas, int* result, int resultCount) { | 243 static void readback(SkCanvas* canvas, int* result, int resultCount) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 write_as_csv("GroundTruth2D", sigma, groundTruthResult, kSize); | 377 write_as_csv("GroundTruth2D", sigma, groundTruthResult, kSize); |
379 write_as_csv("BruteForce1D", sigma, bruteForce1DResult, kSize); | 378 write_as_csv("BruteForce1D", sigma, bruteForce1DResult, kSize); |
380 #endif | 379 #endif |
381 } | 380 } |
382 } | 381 } |
383 | 382 |
384 DEF_GPUTEST(Blur, reporter, factory) { | 383 DEF_GPUTEST(Blur, reporter, factory) { |
385 test_blur_drawing(reporter); | 384 test_blur_drawing(reporter); |
386 test_sigma_range(reporter, factory); | 385 test_sigma_range(reporter, factory); |
387 } | 386 } |
OLD | NEW |