OLD | NEW |
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 Loading... |
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<SkDashPathEffect> dontAssert(SkDashPathEffect::Create(vals, 4,
-248.135982067f)); | 195 SkAutoTUnref<SkPathEffect> dontAssert(SkDashPathEffect::Create(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<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, -
10)); | 205 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(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 19 matching lines...) Expand all Loading... |
235 // Extremely large path_length/dash_length ratios may cause infinite looping | 235 // Extremely large path_length/dash_length ratios may cause infinite looping |
236 // in SkDashPathEffect::filterPath() due to single precision rounding. | 236 // in SkDashPathEffect::filterPath() due to single precision rounding. |
237 // The test is quite expensive, but it should get much faster after the fix | 237 // The test is quite expensive, but it should get much faster after the fix |
238 // for http://crbug.com/165432 goes in. | 238 // for http://crbug.com/165432 goes in. |
239 static void test_infinite_dash(skiatest::Reporter* reporter) { | 239 static void test_infinite_dash(skiatest::Reporter* reporter) { |
240 SkPath path; | 240 SkPath path; |
241 path.moveTo(0, 0); | 241 path.moveTo(0, 0); |
242 path.lineTo(5000000, 0); | 242 path.lineTo(5000000, 0); |
243 | 243 |
244 SkScalar intervals[] = { 0.2f, 0.2f }; | 244 SkScalar intervals[] = { 0.2f, 0.2f }; |
245 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0
)); | 245 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0)); |
246 | 246 |
247 SkPath filteredPath; | 247 SkPath filteredPath; |
248 SkPaint paint; | 248 SkPaint paint; |
249 paint.setStyle(SkPaint::kStroke_Style); | 249 paint.setStyle(SkPaint::kStroke_Style); |
250 paint.setPathEffect(dash); | 250 paint.setPathEffect(dash); |
251 | 251 |
252 paint.getFillPath(path, &filteredPath); | 252 paint.getFillPath(path, &filteredPath); |
253 // If we reach this, we passed. | 253 // If we reach this, we passed. |
254 REPORTER_ASSERT(reporter, true); | 254 REPORTER_ASSERT(reporter, true); |
255 } | 255 } |
256 | 256 |
257 // http://crbug.com/165432 | 257 // http://crbug.com/165432 |
258 // Limit extreme dash path effects to avoid exhausting the system memory. | 258 // Limit extreme dash path effects to avoid exhausting the system memory. |
259 static void test_crbug_165432(skiatest::Reporter* reporter) { | 259 static void test_crbug_165432(skiatest::Reporter* reporter) { |
260 SkPath path; | 260 SkPath path; |
261 path.moveTo(0, 0); | 261 path.moveTo(0, 0); |
262 path.lineTo(10000000, 0); | 262 path.lineTo(10000000, 0); |
263 | 263 |
264 SkScalar intervals[] = { 0.5f, 0.5f }; | 264 SkScalar intervals[] = { 0.5f, 0.5f }; |
265 SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0
)); | 265 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0)); |
266 | 266 |
267 SkPaint paint; | 267 SkPaint paint; |
268 paint.setStyle(SkPaint::kStroke_Style); | 268 paint.setStyle(SkPaint::kStroke_Style); |
269 paint.setPathEffect(dash); | 269 paint.setPathEffect(dash); |
270 | 270 |
271 SkPath filteredPath; | 271 SkPath filteredPath; |
272 SkStrokeRec rec(paint); | 272 SkStrokeRec rec(paint); |
273 REPORTER_ASSERT(reporter, !dash->filterPath(&filteredPath, path, &rec, nullp
tr)); | 273 REPORTER_ASSERT(reporter, !dash->filterPath(&filteredPath, path, &rec, nullp
tr)); |
274 REPORTER_ASSERT(reporter, filteredPath.isEmpty()); | 274 REPORTER_ASSERT(reporter, filteredPath.isEmpty()); |
275 } | 275 } |
276 | 276 |
277 DEF_TEST(DrawPath, reporter) { | 277 DEF_TEST(DrawPath, reporter) { |
278 test_giantaa(); | 278 test_giantaa(); |
279 test_bug533(); | 279 test_bug533(); |
280 test_bigcubic(); | 280 test_bigcubic(); |
281 test_crbug_124652(); | 281 test_crbug_124652(); |
282 test_crbug_140642(); | 282 test_crbug_140642(); |
283 test_crbug_140803(); | 283 test_crbug_140803(); |
284 test_inversepathwithclip(); | 284 test_inversepathwithclip(); |
285 // why? | 285 // why? |
286 if (false) test_crbug131181(); | 286 if (false) test_crbug131181(); |
287 test_infinite_dash(reporter); | 287 test_infinite_dash(reporter); |
288 test_crbug_165432(reporter); | 288 test_crbug_165432(reporter); |
289 test_big_aa_rect(reporter); | 289 test_big_aa_rect(reporter); |
290 } | 290 } |
OLD | NEW |