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" |
(...skipping 3042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3053 q.close(); | 3053 q.close(); |
3054 p.addPath(q, -4, -4); | 3054 p.addPath(q, -4, -4); |
3055 SkRect expected = {0, 0, 4, 4}; | 3055 SkRect expected = {0, 0, 4, 4}; |
3056 REPORTER_ASSERT(reporter, p.getBounds() == expected); | 3056 REPORTER_ASSERT(reporter, p.getBounds() == expected); |
3057 p.reset(); | 3057 p.reset(); |
3058 p.reverseAddPath(q); | 3058 p.reverseAddPath(q); |
3059 SkRect reverseExpected = {4, 4, 8, 8}; | 3059 SkRect reverseExpected = {4, 4, 8, 8}; |
3060 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected); | 3060 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected); |
3061 } | 3061 } |
3062 | 3062 |
| 3063 static void test_addPathMode(skiatest::Reporter* reporter, bool explicitMoveTo,
bool extend) { |
| 3064 SkPath p, q; |
| 3065 if (explicitMoveTo) { |
| 3066 p.moveTo(1, 1); |
| 3067 } |
| 3068 p.lineTo(1, 2); |
| 3069 if (explicitMoveTo) { |
| 3070 q.moveTo(2, 1); |
| 3071 } |
| 3072 q.lineTo(2, 2); |
| 3073 p.addPath(q, extend ? SkPath::kExtend_AddPathMode : SkPath::kAppend_AddPathM
ode); |
| 3074 uint8_t verbs[4]; |
| 3075 int verbcount = p.getVerbs(verbs, 4); |
| 3076 REPORTER_ASSERT(reporter, verbcount == 4); |
| 3077 REPORTER_ASSERT(reporter, verbs[0] == SkPath::kMove_Verb); |
| 3078 REPORTER_ASSERT(reporter, verbs[1] == SkPath::kLine_Verb); |
| 3079 REPORTER_ASSERT(reporter, verbs[2] == (extend ? SkPath::kLine_Verb : SkPath:
:kMove_Verb)); |
| 3080 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kLine_Verb); |
| 3081 } |
| 3082 |
| 3083 static void test_extendClosedPath(skiatest::Reporter* reporter) { |
| 3084 SkPath p, q; |
| 3085 p.moveTo(1, 1); |
| 3086 p.lineTo(1, 2); |
| 3087 p.lineTo(2, 2); |
| 3088 p.close(); |
| 3089 q.moveTo(2, 1); |
| 3090 q.lineTo(2, 3); |
| 3091 p.addPath(q, SkPath::kExtend_AddPathMode); |
| 3092 uint8_t verbs[7]; |
| 3093 int verbcount = p.getVerbs(verbs, 7); |
| 3094 REPORTER_ASSERT(reporter, verbcount == 7); |
| 3095 REPORTER_ASSERT(reporter, verbs[0] == SkPath::kMove_Verb); |
| 3096 REPORTER_ASSERT(reporter, verbs[1] == SkPath::kLine_Verb); |
| 3097 REPORTER_ASSERT(reporter, verbs[2] == SkPath::kLine_Verb); |
| 3098 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kClose_Verb); |
| 3099 REPORTER_ASSERT(reporter, verbs[4] == SkPath::kMove_Verb); |
| 3100 REPORTER_ASSERT(reporter, verbs[5] == SkPath::kLine_Verb); |
| 3101 REPORTER_ASSERT(reporter, verbs[6] == SkPath::kLine_Verb); |
| 3102 |
| 3103 SkPoint pt; |
| 3104 REPORTER_ASSERT(reporter, p.getLastPt(&pt)); |
| 3105 REPORTER_ASSERT(reporter, pt == SkPoint::Make(2, 3)); |
| 3106 REPORTER_ASSERT(reporter, p.getPoint(3) == SkPoint::Make(1, 1)); |
| 3107 } |
| 3108 |
3063 static void test_conicTo_special_case(skiatest::Reporter* reporter) { | 3109 static void test_conicTo_special_case(skiatest::Reporter* reporter) { |
3064 SkPath p; | 3110 SkPath p; |
3065 p.conicTo(1, 2, 3, 4, -1); | 3111 p.conicTo(1, 2, 3, 4, -1); |
3066 check_path_is_line_and_reset(reporter, &p, 3, 4); | 3112 check_path_is_line_and_reset(reporter, &p, 3, 4); |
3067 p.conicTo(1, 2, 3, 4, SK_ScalarInfinity); | 3113 p.conicTo(1, 2, 3, 4, SK_ScalarInfinity); |
3068 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4); | 3114 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4); |
3069 p.conicTo(1, 2, 3, 4, 1); | 3115 p.conicTo(1, 2, 3, 4, 1); |
3070 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4); | 3116 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4); |
3071 } | 3117 } |
3072 | 3118 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3370 test_bad_cubic_crbug229478(); | 3416 test_bad_cubic_crbug229478(); |
3371 test_bad_cubic_crbug234190(); | 3417 test_bad_cubic_crbug234190(); |
3372 test_android_specific_behavior(reporter); | 3418 test_android_specific_behavior(reporter); |
3373 test_gen_id(reporter); | 3419 test_gen_id(reporter); |
3374 test_path_close_issue1474(reporter); | 3420 test_path_close_issue1474(reporter); |
3375 test_path_to_region(reporter); | 3421 test_path_to_region(reporter); |
3376 test_rrect(reporter); | 3422 test_rrect(reporter); |
3377 test_arc(reporter); | 3423 test_arc(reporter); |
3378 test_arcTo(reporter); | 3424 test_arcTo(reporter); |
3379 test_addPath(reporter); | 3425 test_addPath(reporter); |
| 3426 test_addPathMode(reporter, false, false); |
| 3427 test_addPathMode(reporter, true, false); |
| 3428 test_addPathMode(reporter, false, true); |
| 3429 test_addPathMode(reporter, true, true); |
| 3430 test_extendClosedPath(reporter); |
3380 test_conicTo_special_case(reporter); | 3431 test_conicTo_special_case(reporter); |
3381 test_get_point(reporter); | 3432 test_get_point(reporter); |
3382 test_contains(reporter); | 3433 test_contains(reporter); |
3383 PathTest_Private::TestPathTo(reporter); | 3434 PathTest_Private::TestPathTo(reporter); |
3384 PathRefTest_Private::TestPathRef(reporter); | 3435 PathRefTest_Private::TestPathRef(reporter); |
3385 } | 3436 } |
OLD | NEW |