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

Side by Side Diff: tests/DrawPathTest.cpp

Issue 166583002: Factory methods for heap-allocated SkPathEffect and SkXfermode objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update experimental/PdfViewer Created 6 years, 10 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
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.cpp ('k') | tests/XfermodeTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDashPathEffect.h" 10 #include "SkDashPathEffect.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 * A different (better) fix might be to rewrite dashing to do all of its 196 * A different (better) fix might be to rewrite dashing to do all of its
197 * length/phase/measure math using double, but this may need to be 197 * length/phase/measure math using double, but this may need to be
198 * coordinated with SkPathMeasure, to be consistent between the two. 198 * coordinated with SkPathMeasure, to be consistent between the two.
199 199
200 <path stroke="mintcream" stroke-dasharray="27734 35660 2157846850 247" 200 <path stroke="mintcream" stroke-dasharray="27734 35660 2157846850 247"
201 stroke-dashoffset="-248.135982067"> 201 stroke-dashoffset="-248.135982067">
202 */ 202 */
203 203
204 const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 }; 204 const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 };
205 SkDashPathEffect dontAssert(vals, 4, -248.135982067f); 205 SkAutoTUnref<SkDashPathEffect> dontAssert(SkDashPathEffect::Create(vals, 4, -248.135982067f));
206 } 206 }
207 207
208 static void test_crbug_124652() { 208 static void test_crbug_124652() {
209 /* 209 /*
210 http://code.google.com/p/chromium/issues/detail?id=124652 210 http://code.google.com/p/chromium/issues/detail?id=124652
211 This particular test/bug only applies to the float case, where 211 This particular test/bug only applies to the float case, where
212 large values can "swamp" small ones. 212 large values can "swamp" small ones.
213 */ 213 */
214 SkScalar intervals[2] = {837099584, 33450}; 214 SkScalar intervals[2] = {837099584, 33450};
215 SkAutoTUnref<SkDashPathEffect> dash( 215 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, - 10, false));
216 new SkDashPathEffect(intervals, 2, -10, false));
217 } 216 }
218 217
219 static void test_bigcubic() { 218 static void test_bigcubic() {
220 SkPath path; 219 SkPath path;
221 path.moveTo(64, 3); 220 path.moveTo(64, 3);
222 path.cubicTo(-329936, -100000000, -329936, 100000000, 1153, 330003); 221 path.cubicTo(-329936, -100000000, -329936, 100000000, 1153, 330003);
223 222
224 SkPaint paint; 223 SkPaint paint;
225 paint.setAntiAlias(true); 224 paint.setAntiAlias(true);
226 225
(...skipping 20 matching lines...) Expand all
247 // Extremely large path_length/dash_length ratios may cause infinite looping 246 // Extremely large path_length/dash_length ratios may cause infinite looping
248 // in SkDashPathEffect::filterPath() due to single precision rounding. 247 // in SkDashPathEffect::filterPath() due to single precision rounding.
249 // The test is quite expensive, but it should get much faster after the fix 248 // The test is quite expensive, but it should get much faster after the fix
250 // for http://crbug.com/165432 goes in. 249 // for http://crbug.com/165432 goes in.
251 static void test_infinite_dash(skiatest::Reporter* reporter) { 250 static void test_infinite_dash(skiatest::Reporter* reporter) {
252 SkPath path; 251 SkPath path;
253 path.moveTo(0, 0); 252 path.moveTo(0, 0);
254 path.lineTo(5000000, 0); 253 path.lineTo(5000000, 0);
255 254
256 SkScalar intervals[] = { 0.2f, 0.2f }; 255 SkScalar intervals[] = { 0.2f, 0.2f };
257 SkDashPathEffect dash(intervals, 2, 0); 256 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0 ));
258 257
259 SkPath filteredPath; 258 SkPath filteredPath;
260 SkPaint paint; 259 SkPaint paint;
261 paint.setStyle(SkPaint::kStroke_Style); 260 paint.setStyle(SkPaint::kStroke_Style);
262 paint.setPathEffect(&dash); 261 paint.setPathEffect(dash);
263 262
264 paint.getFillPath(path, &filteredPath); 263 paint.getFillPath(path, &filteredPath);
265 // If we reach this, we passed. 264 // If we reach this, we passed.
266 REPORTER_ASSERT(reporter, true); 265 REPORTER_ASSERT(reporter, true);
267 } 266 }
268 267
269 // http://crbug.com/165432 268 // http://crbug.com/165432
270 // Limit extreme dash path effects to avoid exhausting the system memory. 269 // Limit extreme dash path effects to avoid exhausting the system memory.
271 static void test_crbug_165432(skiatest::Reporter* reporter) { 270 static void test_crbug_165432(skiatest::Reporter* reporter) {
272 SkPath path; 271 SkPath path;
273 path.moveTo(0, 0); 272 path.moveTo(0, 0);
274 path.lineTo(10000000, 0); 273 path.lineTo(10000000, 0);
275 274
276 SkScalar intervals[] = { 0.5f, 0.5f }; 275 SkScalar intervals[] = { 0.5f, 0.5f };
277 SkDashPathEffect dash(intervals, 2, 0); 276 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0 ));
278 277
279 SkPaint paint; 278 SkPaint paint;
280 paint.setStyle(SkPaint::kStroke_Style); 279 paint.setStyle(SkPaint::kStroke_Style);
281 paint.setPathEffect(&dash); 280 paint.setPathEffect(dash);
282 281
283 SkPath filteredPath; 282 SkPath filteredPath;
284 SkStrokeRec rec(paint); 283 SkStrokeRec rec(paint);
285 REPORTER_ASSERT(reporter, !dash.filterPath(&filteredPath, path, &rec, NULL)) ; 284 REPORTER_ASSERT(reporter, !dash->filterPath(&filteredPath, path, &rec, NULL) );
286 REPORTER_ASSERT(reporter, filteredPath.isEmpty()); 285 REPORTER_ASSERT(reporter, filteredPath.isEmpty());
287 } 286 }
288 287
289 DEF_TEST(DrawPath, reporter) { 288 DEF_TEST(DrawPath, reporter) {
290 test_giantaa(); 289 test_giantaa();
291 test_bug533(); 290 test_bug533();
292 test_bigcubic(); 291 test_bigcubic();
293 test_crbug_124652(); 292 test_crbug_124652();
294 test_crbug_140642(); 293 test_crbug_140642();
295 test_crbug_140803(); 294 test_crbug_140803();
296 test_inversepathwithclip(); 295 test_inversepathwithclip();
297 // why? 296 // why?
298 if (false) test_crbug131181(); 297 if (false) test_crbug131181();
299 test_infinite_dash(reporter); 298 test_infinite_dash(reporter);
300 test_crbug_165432(reporter); 299 test_crbug_165432(reporter);
301 test_big_aa_rect(reporter); 300 test_big_aa_rect(reporter);
302 } 301 }
OLDNEW
« no previous file with comments | « src/utils/debugger/SkDebugCanvas.cpp ('k') | tests/XfermodeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698