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

Side by Side Diff: tests/PathTest.cpp

Issue 151353006: Adding new 'extend' mode to SkPath::addPath (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: further improvements 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
« src/core/SkPath.cpp ('K') | « src/core/SkPath.cpp ('k') | no next file » | 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 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
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_addPathJoin(skiatest::Reporter* reporter, bool explicitMoveTo) {
reed1 2014/02/07 18:05:50 addPathExtend?
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, SkPath::kJoin_AddPathMode);
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] == SkPath::kLine_Verb);
3080 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kLine_Verb);
3081 }
3082
3083 static void test_addPathAppend(skiatest::Reporter* reporter, bool explicitMoveTo ) {
3084 SkPath p, q;
3085 if (explicitMoveTo) {
3086 p.moveTo(1, 1);
3087 }
3088 p.lineTo(1, 2);
3089 if (explicitMoveTo) {
3090 q.moveTo(2, 1);
3091 }
3092 q.lineTo(2, 2);
3093 p.addPath(q, SkPath::kAppend_AddPathMode);
3094 uint8_t verbs[4];
3095 int verbcount = p.getVerbs(verbs, 4);
3096 REPORTER_ASSERT(reporter, verbcount == 4);
3097 REPORTER_ASSERT(reporter, verbs[0] == SkPath::kMove_Verb);
3098 REPORTER_ASSERT(reporter, verbs[1] == SkPath::kLine_Verb);
3099 REPORTER_ASSERT(reporter, verbs[2] == SkPath::kMove_Verb);
reed1 2014/02/07 18:05:50 I wonder if we can make these new test more compac
3100 REPORTER_ASSERT(reporter, verbs[3] == SkPath::kLine_Verb);
3101 }
3102
3063 static void test_conicTo_special_case(skiatest::Reporter* reporter) { 3103 static void test_conicTo_special_case(skiatest::Reporter* reporter) {
3064 SkPath p; 3104 SkPath p;
3065 p.conicTo(1, 2, 3, 4, -1); 3105 p.conicTo(1, 2, 3, 4, -1);
3066 check_path_is_line_and_reset(reporter, &p, 3, 4); 3106 check_path_is_line_and_reset(reporter, &p, 3, 4);
3067 p.conicTo(1, 2, 3, 4, SK_ScalarInfinity); 3107 p.conicTo(1, 2, 3, 4, SK_ScalarInfinity);
3068 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4); 3108 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4);
3069 p.conicTo(1, 2, 3, 4, 1); 3109 p.conicTo(1, 2, 3, 4, 1);
3070 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4); 3110 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4);
3071 } 3111 }
3072 3112
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 test_bad_cubic_crbug229478(); 3410 test_bad_cubic_crbug229478();
3371 test_bad_cubic_crbug234190(); 3411 test_bad_cubic_crbug234190();
3372 test_android_specific_behavior(reporter); 3412 test_android_specific_behavior(reporter);
3373 test_gen_id(reporter); 3413 test_gen_id(reporter);
3374 test_path_close_issue1474(reporter); 3414 test_path_close_issue1474(reporter);
3375 test_path_to_region(reporter); 3415 test_path_to_region(reporter);
3376 test_rrect(reporter); 3416 test_rrect(reporter);
3377 test_arc(reporter); 3417 test_arc(reporter);
3378 test_arcTo(reporter); 3418 test_arcTo(reporter);
3379 test_addPath(reporter); 3419 test_addPath(reporter);
3420 test_addPathJoin(reporter, false);
3421 test_addPathJoin(reporter, true);
3422 test_addPathAppend(reporter, false);
3423 test_addPathAppend(reporter, true);
3380 test_conicTo_special_case(reporter); 3424 test_conicTo_special_case(reporter);
3381 test_get_point(reporter); 3425 test_get_point(reporter);
3382 test_contains(reporter); 3426 test_contains(reporter);
3383 PathTest_Private::TestPathTo(reporter); 3427 PathTest_Private::TestPathTo(reporter);
3384 PathRefTest_Private::TestPathRef(reporter); 3428 PathRefTest_Private::TestPathRef(reporter);
3385 } 3429 }
OLDNEW
« src/core/SkPath.cpp ('K') | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698