Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: tests/BlurTest.cpp

Issue 23701006: Push sigma-based blur interface into our GMs/benches/tests/samplecode (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Cleaned up Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return true; 88 return true;
89 } 89 }
90 90
91 static void test_blur(skiatest::Reporter* reporter) { 91 static void test_blur(skiatest::Reporter* reporter) {
92 92
93 SkPaint paint; 93 SkPaint paint;
94 paint.setColor(SK_ColorGRAY); 94 paint.setColor(SK_ColorGRAY);
95 paint.setStyle(SkPaint::kStroke_Style); 95 paint.setStyle(SkPaint::kStroke_Style);
96 paint.setStrokeWidth(SkIntToScalar(strokeWidth)); 96 paint.setStrokeWidth(SkIntToScalar(strokeWidth));
97 97
98 SkScalar radius = SkIntToScalar(5); 98 SkScalar sigma = SkFloatToScalar(3.38675f);
99 for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) { 99 for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) {
100 SkBlurMaskFilter::BlurStyle blurStyle = 100 SkBlurMaskFilter::BlurStyle blurStyle =
101 static_cast<SkBlurMaskFilter::BlurStyle>(style); 101 static_cast<SkBlurMaskFilter::BlurStyle>(style);
102 102
103 const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag; 103 const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag;
104 for (uint32_t flags = 0; flags < flagPermutations; ++flags) { 104 for (uint32_t flags = 0; flags < flagPermutations; ++flags) {
105 SkMaskFilter* filter; 105 SkMaskFilter* filter;
106 filter = SkBlurMaskFilter::Create(radius, blurStyle, flags); 106 filter = SkBlurMaskFilter::Create(blurStyle, sigma, flags);
107 107
108 paint.setMaskFilter(filter); 108 paint.setMaskFilter(filter);
109 filter->unref(); 109 filter->unref();
110 110
111 for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) { 111 for (size_t test = 0; test < SK_ARRAY_COUNT(tests); ++test) {
112 SkPath path; 112 SkPath path;
113 tests[test].addPath(&path); 113 tests[test].addPath(&path);
114 SkPath strokedPath; 114 SkPath strokedPath;
115 paint.getFillPath(path, &strokedPath); 115 paint.getFillPath(path, &strokedPath);
116 SkRect refBound = strokedPath.getBounds(); 116 SkRect refBound = strokedPath.getBounds();
(...skipping 23 matching lines...) Expand all
140 REPORTER_ASSERT(reporter, 140 REPORTER_ASSERT(reporter,
141 compare(refBitmap, iref, testBitmap, itest)); 141 compare(refBitmap, iref, testBitmap, itest));
142 } 142 }
143 } 143 }
144 } 144 }
145 } 145 }
146 } 146 }
147 147
148 #include "TestClassDef.h" 148 #include "TestClassDef.h"
149 DEFINE_TESTCLASS("BlurMaskFilter", BlurTestClass, test_blur) 149 DEFINE_TESTCLASS("BlurMaskFilter", BlurTestClass, test_blur)
OLDNEW
« bench/BlurBench.cpp ('K') | « src/animator/SkDrawBlur.cpp ('k') | tests/PaintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698