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 "Test.h" | 8 #include "Test.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return true; | 95 return true; |
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 radius = SkIntToScalar(5); | 105 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)); |
106 for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) { | 106 for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) { |
107 SkBlurMaskFilter::BlurStyle blurStyle = | 107 SkBlurMaskFilter::BlurStyle blurStyle = |
108 static_cast<SkBlurMaskFilter::BlurStyle>(style); | 108 static_cast<SkBlurMaskFilter::BlurStyle>(style); |
109 | 109 |
110 const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag; | 110 const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag; |
111 for (uint32_t flags = 0; flags < flagPermutations; ++flags) { | 111 for (uint32_t flags = 0; flags < flagPermutations; ++flags) { |
112 SkMaskFilter* filter; | 112 SkMaskFilter* filter; |
113 filter = SkBlurMaskFilter::Create(radius, blurStyle, flags); | 113 filter = SkBlurMaskFilter::Create(blurStyle, sigma, flags); |
114 | 114 |
115 paint.setMaskFilter(filter); | 115 paint.setMaskFilter(filter); |
116 filter->unref(); | 116 filter->unref(); |
117 | 117 |
118 for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) { | 118 for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) { |
119 SkPath path; | 119 SkPath path; |
120 tests[test].addPath(&path); | 120 tests[test].addPath(&path); |
121 SkPath strokedPath; | 121 SkPath strokedPath; |
122 paint.getFillPath(path, &strokedPath); | 122 paint.getFillPath(path, &strokedPath); |
123 SkRect refBound = strokedPath.getBounds(); | 123 SkRect refBound = strokedPath.getBounds(); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 /////////////////////////////////////////////////////////////////////////////// | 379 /////////////////////////////////////////////////////////////////////////////// |
380 | 380 |
381 static void test_blur(skiatest::Reporter* reporter, GrContextFactory* factory) { | 381 static void test_blur(skiatest::Reporter* reporter, GrContextFactory* factory) { |
382 test_blur_drawing(reporter); | 382 test_blur_drawing(reporter); |
383 test_sigma_range(reporter, factory); | 383 test_sigma_range(reporter, factory); |
384 } | 384 } |
385 | 385 |
386 #include "TestClassDef.h" | 386 #include "TestClassDef.h" |
387 DEFINE_GPUTESTCLASS("BlurMaskFilter", BlurTestClass, test_blur) | 387 DEFINE_GPUTESTCLASS("BlurMaskFilter", BlurTestClass, test_blur) |
OLD | NEW |