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

Side by Side Diff: tests/DrawPathTest.cpp

Issue 1813553005: switch patheffects over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try to fix xpsdevice Created 4 years, 9 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 | « tests/DashPathEffectTest.cpp ('k') | tests/GpuDrawPathTest.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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 * A different (better) fix might be to rewrite dashing to do all of its 186 * A different (better) fix might be to rewrite dashing to do all of its
187 * length/phase/measure math using double, but this may need to be 187 * length/phase/measure math using double, but this may need to be
188 * coordinated with SkPathMeasure, to be consistent between the two. 188 * coordinated with SkPathMeasure, to be consistent between the two.
189 189
190 <path stroke="mintcream" stroke-dasharray="27734 35660 2157846850 247" 190 <path stroke="mintcream" stroke-dasharray="27734 35660 2157846850 247"
191 stroke-dashoffset="-248.135982067"> 191 stroke-dashoffset="-248.135982067">
192 */ 192 */
193 193
194 const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 }; 194 const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 };
195 SkAutoTUnref<SkPathEffect> dontAssert(SkDashPathEffect::Create(vals, 4, -248 .135982067f)); 195 auto dontAssert = SkDashPathEffect::Make(vals, 4, -248.135982067f);
196 } 196 }
197 197
198 static void test_crbug_124652() { 198 static void test_crbug_124652() {
199 /* 199 /*
200 http://code.google.com/p/chromium/issues/detail?id=124652 200 http://code.google.com/p/chromium/issues/detail?id=124652
201 This particular test/bug only applies to the float case, where 201 This particular test/bug only applies to the float case, where
202 large values can "swamp" small ones. 202 large values can "swamp" small ones.
203 */ 203 */
204 SkScalar intervals[2] = {837099584, 33450}; 204 SkScalar intervals[2] = {837099584, 33450};
205 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, -10)) ; 205 auto dontAssert = SkDashPathEffect::Make(intervals, 2, -10);
206 } 206 }
207 207
208 static void test_bigcubic() { 208 static void test_bigcubic() {
209 SkPath path; 209 SkPath path;
210 path.moveTo(64, 3); 210 path.moveTo(64, 3);
211 path.cubicTo(-329936, -100000000, -329936, 100000000, 1153, 330003); 211 path.cubicTo(-329936, -100000000, -329936, 100000000, 1153, 330003);
212 212
213 SkPaint paint; 213 SkPaint paint;
214 paint.setAntiAlias(true); 214 paint.setAntiAlias(true);
215 215
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // Extremely large path_length/dash_length ratios may cause infinite looping 274 // Extremely large path_length/dash_length ratios may cause infinite looping
275 // in SkDashPathEffect::filterPath() due to single precision rounding. 275 // in SkDashPathEffect::filterPath() due to single precision rounding.
276 // The test is quite expensive, but it should get much faster after the fix 276 // The test is quite expensive, but it should get much faster after the fix
277 // for http://crbug.com/165432 goes in. 277 // for http://crbug.com/165432 goes in.
278 static void test_infinite_dash(skiatest::Reporter* reporter) { 278 static void test_infinite_dash(skiatest::Reporter* reporter) {
279 SkPath path; 279 SkPath path;
280 path.moveTo(0, 0); 280 path.moveTo(0, 0);
281 path.lineTo(5000000, 0); 281 path.lineTo(5000000, 0);
282 282
283 SkScalar intervals[] = { 0.2f, 0.2f }; 283 SkScalar intervals[] = { 0.2f, 0.2f };
284 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0)); 284 sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0));
285 285
286 SkPath filteredPath; 286 SkPath filteredPath;
287 SkPaint paint; 287 SkPaint paint;
288 paint.setStyle(SkPaint::kStroke_Style); 288 paint.setStyle(SkPaint::kStroke_Style);
289 paint.setPathEffect(dash); 289 paint.setPathEffect(dash);
290 290
291 paint.getFillPath(path, &filteredPath); 291 paint.getFillPath(path, &filteredPath);
292 // If we reach this, we passed. 292 // If we reach this, we passed.
293 REPORTER_ASSERT(reporter, true); 293 REPORTER_ASSERT(reporter, true);
294 } 294 }
295 295
296 // http://crbug.com/165432 296 // http://crbug.com/165432
297 // Limit extreme dash path effects to avoid exhausting the system memory. 297 // Limit extreme dash path effects to avoid exhausting the system memory.
298 static void test_crbug_165432(skiatest::Reporter* reporter) { 298 static void test_crbug_165432(skiatest::Reporter* reporter) {
299 SkPath path; 299 SkPath path;
300 path.moveTo(0, 0); 300 path.moveTo(0, 0);
301 path.lineTo(10000000, 0); 301 path.lineTo(10000000, 0);
302 302
303 SkScalar intervals[] = { 0.5f, 0.5f }; 303 SkScalar intervals[] = { 0.5f, 0.5f };
304 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0)); 304 sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0));
305 305
306 SkPaint paint; 306 SkPaint paint;
307 paint.setStyle(SkPaint::kStroke_Style); 307 paint.setStyle(SkPaint::kStroke_Style);
308 paint.setPathEffect(dash); 308 paint.setPathEffect(dash);
309 309
310 SkPath filteredPath; 310 SkPath filteredPath;
311 SkStrokeRec rec(paint); 311 SkStrokeRec rec(paint);
312 REPORTER_ASSERT(reporter, !dash->filterPath(&filteredPath, path, &rec, nullp tr)); 312 REPORTER_ASSERT(reporter, !dash->filterPath(&filteredPath, path, &rec, nullp tr));
313 REPORTER_ASSERT(reporter, filteredPath.isEmpty()); 313 REPORTER_ASSERT(reporter, filteredPath.isEmpty());
314 } 314 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 test_inversepathwithclip(); 356 test_inversepathwithclip();
357 // why? 357 // why?
358 if (false) test_crbug131181(); 358 if (false) test_crbug131181();
359 test_infinite_dash(reporter); 359 test_infinite_dash(reporter);
360 test_crbug_165432(reporter); 360 test_crbug_165432(reporter);
361 test_crbug_472147_simple(reporter); 361 test_crbug_472147_simple(reporter);
362 test_crbug_472147_actual(reporter); 362 test_crbug_472147_actual(reporter);
363 test_big_aa_rect(reporter); 363 test_big_aa_rect(reporter);
364 test_halfway(); 364 test_halfway();
365 } 365 }
OLDNEW
« no previous file with comments | « tests/DashPathEffectTest.cpp ('k') | tests/GpuDrawPathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698