| 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 3212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3223 } | 3223 } |
| 3224 | 3224 |
| 3225 static void check_path_is_quad_and_reset(skiatest::Reporter* reporter, SkPath* p
, | 3225 static void check_path_is_quad_and_reset(skiatest::Reporter* reporter, SkPath* p
, |
| 3226 SkScalar x1, SkScalar y1, SkScalar x2, SkSca
lar y2) { | 3226 SkScalar x1, SkScalar y1, SkScalar x2, SkSca
lar y2) { |
| 3227 SkPath::RawIter iter(*p); | 3227 SkPath::RawIter iter(*p); |
| 3228 check_move(reporter, &iter, 0, 0); | 3228 check_move(reporter, &iter, 0, 0); |
| 3229 check_quad(reporter, &iter, x1, y1, x2, y2); | 3229 check_quad(reporter, &iter, x1, y1, x2, y2); |
| 3230 check_done_and_reset(reporter, p, &iter); | 3230 check_done_and_reset(reporter, p, &iter); |
| 3231 } | 3231 } |
| 3232 | 3232 |
| 3233 static bool nearly_equal(const SkRect& a, const SkRect& b) { |
| 3234 return SkScalarNearlyEqual(a.fLeft, b.fLeft) && |
| 3235 SkScalarNearlyEqual(a.fTop, b.fTop) && |
| 3236 SkScalarNearlyEqual(a.fRight, b.fRight) && |
| 3237 SkScalarNearlyEqual(a.fBottom, b.fBottom); |
| 3238 } |
| 3239 |
| 3233 static void test_arcTo(skiatest::Reporter* reporter) { | 3240 static void test_arcTo(skiatest::Reporter* reporter) { |
| 3234 SkPath p; | 3241 SkPath p; |
| 3235 p.arcTo(0, 0, 1, 2, 1); | 3242 p.arcTo(0, 0, 1, 2, 1); |
| 3236 check_path_is_line_and_reset(reporter, &p, 0, 0); | 3243 check_path_is_line_and_reset(reporter, &p, 0, 0); |
| 3237 p.arcTo(1, 2, 1, 2, 1); | 3244 p.arcTo(1, 2, 1, 2, 1); |
| 3238 check_path_is_line_and_reset(reporter, &p, 1, 2); | 3245 check_path_is_line_and_reset(reporter, &p, 1, 2); |
| 3239 p.arcTo(1, 2, 3, 4, 0); | 3246 p.arcTo(1, 2, 3, 4, 0); |
| 3240 check_path_is_line_and_reset(reporter, &p, 1, 2); | 3247 check_path_is_line_and_reset(reporter, &p, 1, 2); |
| 3241 p.arcTo(1, 2, 0, 0, 1); | 3248 p.arcTo(1, 2, 0, 0, 1); |
| 3242 check_path_is_line_and_reset(reporter, &p, 1, 2); | 3249 check_path_is_line_and_reset(reporter, &p, 1, 2); |
| 3243 p.arcTo(1, 0, 1, 1, 1); | 3250 p.arcTo(1, 0, 1, 1, 1); |
| 3244 SkPoint pt; | 3251 SkPoint pt; |
| 3245 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == 1); | 3252 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == 1); |
| 3246 p.reset(); | 3253 p.reset(); |
| 3247 p.arcTo(1, 0, 1, -1, 1); | 3254 p.arcTo(1, 0, 1, -1, 1); |
| 3248 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == -1); | 3255 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == -1); |
| 3249 p.reset(); | 3256 p.reset(); |
| 3250 SkRect oval = {1, 2, 3, 4}; | 3257 SkRect oval = {1, 2, 3, 4}; |
| 3251 p.arcTo(oval, 0, 0, true); | 3258 p.arcTo(oval, 0, 0, true); |
| 3252 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); | 3259 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); |
| 3253 p.arcTo(oval, 0, 0, false); | 3260 p.arcTo(oval, 0, 0, false); |
| 3254 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); | 3261 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); |
| 3255 p.arcTo(oval, 360, 0, true); | 3262 p.arcTo(oval, 360, 0, true); |
| 3256 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); | 3263 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); |
| 3257 p.arcTo(oval, 360, 0, false); | 3264 p.arcTo(oval, 360, 0, false); |
| 3258 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); | 3265 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); |
| 3266 |
| 3259 for (float sweep = 359, delta = 0.5f; sweep != (float) (sweep + delta); ) { | 3267 for (float sweep = 359, delta = 0.5f; sweep != (float) (sweep + delta); ) { |
| 3260 p.arcTo(oval, 0, sweep, false); | 3268 p.arcTo(oval, 0, sweep, false); |
| 3261 REPORTER_ASSERT(reporter, p.getBounds() == oval); | 3269 REPORTER_ASSERT(reporter, nearly_equal(p.getBounds(), oval)); |
| 3262 sweep += delta; | 3270 sweep += delta; |
| 3263 delta /= 2; | 3271 delta /= 2; |
| 3264 } | 3272 } |
| 3265 for (float sweep = 361, delta = 0.5f; sweep != (float) (sweep - delta);) { | 3273 for (float sweep = 361, delta = 0.5f; sweep != (float) (sweep - delta);) { |
| 3266 p.arcTo(oval, 0, sweep, false); | 3274 p.arcTo(oval, 0, sweep, false); |
| 3267 REPORTER_ASSERT(reporter, p.getBounds() == oval); | 3275 REPORTER_ASSERT(reporter, nearly_equal(p.getBounds(), oval)); |
| 3268 sweep -= delta; | 3276 sweep -= delta; |
| 3269 delta /= 2; | 3277 delta /= 2; |
| 3270 } | 3278 } |
| 3271 SkRect noOvalWidth = {1, 2, 0, 3}; | 3279 SkRect noOvalWidth = {1, 2, 0, 3}; |
| 3272 p.reset(); | 3280 p.reset(); |
| 3273 p.arcTo(noOvalWidth, 0, 360, false); | 3281 p.arcTo(noOvalWidth, 0, 360, false); |
| 3274 REPORTER_ASSERT(reporter, p.isEmpty()); | 3282 REPORTER_ASSERT(reporter, p.isEmpty()); |
| 3275 | 3283 |
| 3276 SkRect noOvalHeight = {1, 2, 3, 1}; | 3284 SkRect noOvalHeight = {1, 2, 3, 1}; |
| 3277 p.reset(); | 3285 p.reset(); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3755 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); | 3763 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); |
| 3756 test_conicTo_special_case(reporter); | 3764 test_conicTo_special_case(reporter); |
| 3757 test_get_point(reporter); | 3765 test_get_point(reporter); |
| 3758 test_contains(reporter); | 3766 test_contains(reporter); |
| 3759 PathTest_Private::TestPathTo(reporter); | 3767 PathTest_Private::TestPathTo(reporter); |
| 3760 PathRefTest_Private::TestPathRef(reporter); | 3768 PathRefTest_Private::TestPathRef(reporter); |
| 3761 test_dump(reporter); | 3769 test_dump(reporter); |
| 3762 test_path_crbugskia2820(reporter); | 3770 test_path_crbugskia2820(reporter); |
| 3763 test_skbug_3239(reporter); | 3771 test_skbug_3239(reporter); |
| 3764 } | 3772 } |
| OLD | NEW |