OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkParse.h" | 10 #include "SkParse.h" |
11 #include "SkParsePath.h" | 11 #include "SkParsePath.h" |
12 #include "SkPath.h" | 12 #include "SkPath.h" |
13 #include "SkPathEffect.h" | 13 #include "SkPathEffect.h" |
14 #include "SkRRect.h" | 14 #include "SkRRect.h" |
15 #include "SkRandom.h" | 15 #include "SkRandom.h" |
16 #include "SkReader32.h" | 16 #include "SkReader32.h" |
17 #include "SkSize.h" | 17 #include "SkSize.h" |
18 #include "SkSurface.h" | 18 #include "SkSurface.h" |
19 #include "SkTypes.h" | 19 #include "SkTypes.h" |
20 #include "SkWriter32.h" | 20 #include "SkWriter32.h" |
21 #include "Test.h" | 21 #include "Test.h" |
22 | 22 |
| 23 static void make_path_crbug364224(SkPath* path) { |
| 24 path->reset(); |
| 25 path->moveTo(3.747501373f, 2.724499941f); |
| 26 path->lineTo(3.747501373f, 3.75f); |
| 27 path->cubicTo(3.747501373f, 3.88774991f, 3.635501385f, 4.0f, 3.497501373f, 4
.0f); |
| 28 path->lineTo(0.7475013733f, 4.0f); |
| 29 path->cubicTo(0.6095013618f, 4.0f, 0.4975013733f, 3.88774991f, 0.4975013733f
, 3.75f); |
| 30 path->lineTo(0.4975013733f, 1.0f); |
| 31 path->cubicTo(0.4975013733f, 0.8622499704f, 0.6095013618f, 0.75f, 0.74750137
33f,0.75f); |
| 32 path->lineTo(3.497501373f, 0.75f); |
| 33 path->cubicTo(3.50275135f, 0.75f, 3.5070014f, 0.7527500391f, 3.513001442f, 0
.753000021f); |
| 34 path->lineTo(3.715001345f, 0.5512499809f); |
| 35 path->cubicTo(3.648251295f, 0.5194999576f, 3.575501442f, 0.4999999702f, 3.49
7501373f, 0.4999999702f); |
| 36 path->lineTo(0.7475013733f, 0.4999999702f); |
| 37 path->cubicTo(0.4715013802f, 0.4999999702f, 0.2475013733f, 0.7239999771f, 0.
2475013733f, 1.0f); |
| 38 path->lineTo(0.2475013733f, 3.75f); |
| 39 path->cubicTo(0.2475013733f, 4.026000023f, 0.4715013504f, 4.25f, 0.747501373
3f, 4.25f); |
| 40 path->lineTo(3.497501373f, 4.25f); |
| 41 path->cubicTo(3.773501396f, 4.25f, 3.997501373f, 4.026000023f, 3.997501373f,
3.75f); |
| 42 path->lineTo(3.997501373f, 2.474750042f); |
| 43 path->lineTo(3.747501373f, 2.724499941f); |
| 44 path->close(); |
| 45 } |
| 46 |
| 47 static void make_path_crbug364224_simplified(SkPath* path) { |
| 48 path->moveTo(3.747501373f, 2.724499941f); |
| 49 path->cubicTo(3.648251295f, 0.5194999576f, 3.575501442f, 0.4999999702f, 3.49
7501373f, 0.4999999702f); |
| 50 path->close(); |
| 51 } |
| 52 |
| 53 static void test_path_crbug364224() { |
| 54 SkPath path; |
| 55 SkPaint paint; |
| 56 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(84, 88)); |
| 57 SkCanvas* canvas = surface->getCanvas(); |
| 58 |
| 59 make_path_crbug364224_simplified(&path); |
| 60 canvas->drawPath(path, paint); |
| 61 |
| 62 make_path_crbug364224(&path); |
| 63 canvas->drawPath(path, paint); |
| 64 } |
| 65 |
23 static void make_path0(SkPath* path) { | 66 static void make_path0(SkPath* path) { |
24 // from * https://code.google.com/p/skia/issues/detail?id=1706 | 67 // from * https://code.google.com/p/skia/issues/detail?id=1706 |
25 | 68 |
26 path->moveTo(146.939f, 1012.84f); | 69 path->moveTo(146.939f, 1012.84f); |
27 path->lineTo(181.747f, 1009.18f); | 70 path->lineTo(181.747f, 1009.18f); |
28 path->lineTo(182.165f, 1013.16f); | 71 path->lineTo(182.165f, 1013.16f); |
29 path->lineTo(147.357f, 1016.82f); | 72 path->lineTo(147.357f, 1016.82f); |
30 path->lineTo(146.939f, 1012.84f); | 73 path->lineTo(146.939f, 1012.84f); |
31 path->close(); | 74 path->close(); |
32 } | 75 } |
(...skipping 3286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3319 q.quadTo(6, 7, 8, 6); | 3362 q.quadTo(6, 7, 8, 6); |
3320 q.cubicTo(5, 6, 7, 8, 7, 5); | 3363 q.cubicTo(5, 6, 7, 8, 7, 5); |
3321 q.close(); | 3364 q.close(); |
3322 p.reversePathTo(q); | 3365 p.reversePathTo(q); |
3323 SkRect reverseExpected = {-4, -4, 8, 8}; | 3366 SkRect reverseExpected = {-4, -4, 8, 8}; |
3324 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected); | 3367 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected); |
3325 } | 3368 } |
3326 }; | 3369 }; |
3327 | 3370 |
3328 DEF_TEST(Paths, reporter) { | 3371 DEF_TEST(Paths, reporter) { |
| 3372 test_path_crbug364224(); |
| 3373 |
3329 SkTSize<SkScalar>::Make(3,4); | 3374 SkTSize<SkScalar>::Make(3,4); |
3330 | 3375 |
3331 SkPath p, empty; | 3376 SkPath p, empty; |
3332 SkRect bounds, bounds2; | 3377 SkRect bounds, bounds2; |
3333 test_empty(reporter, p); | 3378 test_empty(reporter, p); |
3334 | 3379 |
3335 REPORTER_ASSERT(reporter, p.getBounds().isEmpty()); | 3380 REPORTER_ASSERT(reporter, p.getBounds().isEmpty()); |
3336 | 3381 |
3337 // this triggers a code path in SkPath::operator= which is otherwise unexerc
ised | 3382 // this triggers a code path in SkPath::operator= which is otherwise unexerc
ised |
3338 SkPath& self = p; | 3383 SkPath& self = p; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3445 test_addPathMode(reporter, true, true); | 3490 test_addPathMode(reporter, true, true); |
3446 test_extendClosedPath(reporter); | 3491 test_extendClosedPath(reporter); |
3447 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); | 3492 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); |
3448 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); | 3493 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); |
3449 test_conicTo_special_case(reporter); | 3494 test_conicTo_special_case(reporter); |
3450 test_get_point(reporter); | 3495 test_get_point(reporter); |
3451 test_contains(reporter); | 3496 test_contains(reporter); |
3452 PathTest_Private::TestPathTo(reporter); | 3497 PathTest_Private::TestPathTo(reporter); |
3453 PathRefTest_Private::TestPathRef(reporter); | 3498 PathRefTest_Private::TestPathRef(reporter); |
3454 } | 3499 } |
OLD | NEW |