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 <cmath> | |
8 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
9 #include "SkGeometry.h" | 10 #include "SkGeometry.h" |
10 #include "SkPaint.h" | 11 #include "SkPaint.h" |
11 #include "SkParse.h" | 12 #include "SkParse.h" |
12 #include "SkParsePath.h" | 13 #include "SkParsePath.h" |
13 #include "SkPathPriv.h" | 14 #include "SkPathPriv.h" |
14 #include "SkPathEffect.h" | 15 #include "SkPathEffect.h" |
15 #include "SkRRect.h" | 16 #include "SkRRect.h" |
16 #include "SkRandom.h" | 17 #include "SkRandom.h" |
17 #include "SkReader32.h" | 18 #include "SkReader32.h" |
(...skipping 3281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3299 REPORTER_ASSERT(reporter, emptyOval.isEmpty()); | 3300 REPORTER_ASSERT(reporter, emptyOval.isEmpty()); |
3300 p.addArc(emptyOval, 1, 2); | 3301 p.addArc(emptyOval, 1, 2); |
3301 REPORTER_ASSERT(reporter, p.isEmpty()); | 3302 REPORTER_ASSERT(reporter, p.isEmpty()); |
3302 p.reset(); | 3303 p.reset(); |
3303 SkRect oval = {10, 20, 30, 40}; | 3304 SkRect oval = {10, 20, 30, 40}; |
3304 p.addArc(oval, 1, 0); | 3305 p.addArc(oval, 1, 0); |
3305 REPORTER_ASSERT(reporter, p.isEmpty()); | 3306 REPORTER_ASSERT(reporter, p.isEmpty()); |
3306 p.reset(); | 3307 p.reset(); |
3307 SkPath cwOval; | 3308 SkPath cwOval; |
3308 cwOval.addOval(oval); | 3309 cwOval.addOval(oval); |
3309 p.addArc(oval, 1, 360); | 3310 p.addArc(oval, 0, 360); |
3310 REPORTER_ASSERT(reporter, p == cwOval); | 3311 REPORTER_ASSERT(reporter, p == cwOval); |
3311 p.reset(); | 3312 p.reset(); |
3312 SkPath ccwOval; | 3313 SkPath ccwOval; |
3313 ccwOval.addOval(oval, SkPath::kCCW_Direction); | 3314 ccwOval.addOval(oval, SkPath::kCCW_Direction); |
3314 p.addArc(oval, 1, -360); | 3315 p.addArc(oval, 0, -360); |
3315 REPORTER_ASSERT(reporter, p == ccwOval); | 3316 REPORTER_ASSERT(reporter, p == ccwOval); |
3316 p.reset(); | 3317 p.reset(); |
3317 p.addArc(oval, 1, 180); | 3318 p.addArc(oval, 1, 180); |
3318 REPORTER_ASSERT(reporter, p.isConvex()); | 3319 REPORTER_ASSERT(reporter, p.isConvex()); |
3319 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathPriv::k CW_FirstDirection)); | 3320 REPORTER_ASSERT(reporter, SkPathPriv::CheapIsFirstDirection(p, SkPathPriv::k CW_FirstDirection)); |
3320 p.setConvexity(SkPath::kUnknown_Convexity); | 3321 p.setConvexity(SkPath::kUnknown_Convexity); |
3321 REPORTER_ASSERT(reporter, p.isConvex()); | 3322 REPORTER_ASSERT(reporter, p.isConvex()); |
3322 } | 3323 } |
3323 | 3324 |
3325 static void test_arc_ovals(skiatest::Reporter* reporter) { | |
3326 SkRect oval = SkRect::MakeWH(10, 20); | |
3327 for (SkScalar sweep : {-360.f, 360.f}) { | |
3328 for (SkScalar start = -360.f; start <= 360.f; start += 1.f) { | |
3329 SkPath path; | |
3330 path.addArc(oval, start, sweep); | |
3331 SkRect r; | |
3332 SkPath::Direction d; | |
3333 unsigned s; | |
3334 bool isOval = path.isOval(&r, &d, &s); | |
3335 // SkPath's interfaces for inserting and extracting ovals only allow contours | |
3336 // to start at multiples of 90 degrees. | |
3337 if (std::fmod(start, 90.f) == 0) { | |
3338 REPORTER_ASSERT(reporter, isOval); | |
3339 SkPath recreatedPath; | |
3340 recreatedPath.addOval(r, d, s); | |
3341 REPORTER_ASSERT(reporter, path == recreatedPath); | |
robertphillips
2016/05/27 12:12:30
Do we still need these next 3 lines? They look lik
bsalomon
2016/05/27 14:29:33
Done.
| |
3342 path.reset(); | |
3343 path.addArc(oval, start, sweep); | |
3344 path.isOval(&r, &d, &s); | |
3345 } else { | |
3346 REPORTER_ASSERT(reporter, !isOval); | |
3347 } | |
3348 } | |
3349 } | |
3350 } | |
3351 | |
3324 static void check_move(skiatest::Reporter* reporter, SkPath::RawIter* iter, | 3352 static void check_move(skiatest::Reporter* reporter, SkPath::RawIter* iter, |
3325 SkScalar x0, SkScalar y0) { | 3353 SkScalar x0, SkScalar y0) { |
3326 SkPoint pts[4]; | 3354 SkPoint pts[4]; |
3327 SkPath::Verb v = iter->next(pts); | 3355 SkPath::Verb v = iter->next(pts); |
3328 REPORTER_ASSERT(reporter, v == SkPath::kMove_Verb); | 3356 REPORTER_ASSERT(reporter, v == SkPath::kMove_Verb); |
3329 REPORTER_ASSERT(reporter, pts[0].fX == x0); | 3357 REPORTER_ASSERT(reporter, pts[0].fX == x0); |
3330 REPORTER_ASSERT(reporter, pts[0].fY == y0); | 3358 REPORTER_ASSERT(reporter, pts[0].fY == y0); |
3331 } | 3359 } |
3332 | 3360 |
3333 static void check_line(skiatest::Reporter* reporter, SkPath::RawIter* iter, | 3361 static void check_line(skiatest::Reporter* reporter, SkPath::RawIter* iter, |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4114 test_crbug_170666(); | 4142 test_crbug_170666(); |
4115 test_crbug_493450(reporter); | 4143 test_crbug_493450(reporter); |
4116 test_crbug_495894(reporter); | 4144 test_crbug_495894(reporter); |
4117 test_bad_cubic_crbug229478(); | 4145 test_bad_cubic_crbug229478(); |
4118 test_bad_cubic_crbug234190(); | 4146 test_bad_cubic_crbug234190(); |
4119 test_gen_id(reporter); | 4147 test_gen_id(reporter); |
4120 test_path_close_issue1474(reporter); | 4148 test_path_close_issue1474(reporter); |
4121 test_path_to_region(reporter); | 4149 test_path_to_region(reporter); |
4122 test_rrect(reporter); | 4150 test_rrect(reporter); |
4123 test_arc(reporter); | 4151 test_arc(reporter); |
4152 test_arc_ovals(reporter); | |
4124 test_arcTo(reporter); | 4153 test_arcTo(reporter); |
4125 test_addPath(reporter); | 4154 test_addPath(reporter); |
4126 test_addPathMode(reporter, false, false); | 4155 test_addPathMode(reporter, false, false); |
4127 test_addPathMode(reporter, true, false); | 4156 test_addPathMode(reporter, true, false); |
4128 test_addPathMode(reporter, false, true); | 4157 test_addPathMode(reporter, false, true); |
4129 test_addPathMode(reporter, true, true); | 4158 test_addPathMode(reporter, true, true); |
4130 test_extendClosedPath(reporter); | 4159 test_extendClosedPath(reporter); |
4131 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); | 4160 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); |
4132 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); | 4161 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); |
4133 test_conicTo_special_case(reporter); | 4162 test_conicTo_special_case(reporter); |
4134 test_get_point(reporter); | 4163 test_get_point(reporter); |
4135 test_contains(reporter); | 4164 test_contains(reporter); |
4136 PathTest_Private::TestPathTo(reporter); | 4165 PathTest_Private::TestPathTo(reporter); |
4137 PathRefTest_Private::TestPathRef(reporter); | 4166 PathRefTest_Private::TestPathRef(reporter); |
4138 PathTest_Private::TestPathrefListeners(reporter); | 4167 PathTest_Private::TestPathrefListeners(reporter); |
4139 test_dump(reporter); | 4168 test_dump(reporter); |
4140 test_path_crbug389050(reporter); | 4169 test_path_crbug389050(reporter); |
4141 test_path_crbugskia2820(reporter); | 4170 test_path_crbugskia2820(reporter); |
4142 test_skbug_3469(reporter); | 4171 test_skbug_3469(reporter); |
4143 test_skbug_3239(reporter); | 4172 test_skbug_3239(reporter); |
4144 test_bounds_crbug_513799(reporter); | 4173 test_bounds_crbug_513799(reporter); |
4145 } | 4174 } |
OLD | NEW |