OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden"))) | 25 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden"))) |
26 #endif | 26 #endif |
27 | 27 |
28 static SkSurface* new_surface(int w, int h) { | 28 static SkSurface* new_surface(int w, int h) { |
29 SkImage::Info info = { | 29 SkImage::Info info = { |
30 w, h, SkImage::kPMColor_ColorType, SkImage::kPremul_AlphaType | 30 w, h, SkImage::kPMColor_ColorType, SkImage::kPremul_AlphaType |
31 }; | 31 }; |
32 return SkSurface::NewRaster(info); | 32 return SkSurface::NewRaster(info); |
33 } | 33 } |
34 | 34 |
| 35 static void test_path_close_issue1474(skiatest::Reporter* reporter) { |
| 36 // This test checks that r{Line,Quad,Conic,Cubic}To following a close() |
| 37 // are relative to the point we close to, not relative to the point we close
from. |
| 38 SkPath path; |
| 39 SkPoint last; |
| 40 |
| 41 // Test rLineTo(). |
| 42 path.rLineTo(0, 100); |
| 43 path.rLineTo(100, 0); |
| 44 path.close(); // Returns us back to 0,0. |
| 45 path.rLineTo(50, 50); // This should go to 50,50. |
| 46 |
| 47 path.getLastPt(&last); |
| 48 REPORTER_ASSERT(reporter, 50 == last.fX); |
| 49 REPORTER_ASSERT(reporter, 50 == last.fY); |
| 50 |
| 51 // Test rQuadTo(). |
| 52 path.rewind(); |
| 53 path.rLineTo(0, 100); |
| 54 path.rLineTo(100, 0); |
| 55 path.close(); |
| 56 path.rQuadTo(50, 50, 75, 75); |
| 57 |
| 58 path.getLastPt(&last); |
| 59 REPORTER_ASSERT(reporter, 75 == last.fX); |
| 60 REPORTER_ASSERT(reporter, 75 == last.fY); |
| 61 |
| 62 // Test rConicTo(). |
| 63 path.rewind(); |
| 64 path.rLineTo(0, 100); |
| 65 path.rLineTo(100, 0); |
| 66 path.close(); |
| 67 path.rConicTo(50, 50, 85, 85, 2); |
| 68 |
| 69 path.getLastPt(&last); |
| 70 REPORTER_ASSERT(reporter, 85 == last.fX); |
| 71 REPORTER_ASSERT(reporter, 85 == last.fY); |
| 72 |
| 73 // Test rCubicTo(). |
| 74 path.rewind(); |
| 75 path.rLineTo(0, 100); |
| 76 path.rLineTo(100, 0); |
| 77 path.close(); |
| 78 path.rCubicTo(50, 50, 85, 85, 95, 95); |
| 79 |
| 80 path.getLastPt(&last); |
| 81 REPORTER_ASSERT(reporter, 95 == last.fX); |
| 82 REPORTER_ASSERT(reporter, 95 == last.fY); |
| 83 } |
| 84 |
35 static void test_android_specific_behavior(skiatest::Reporter* reporter) { | 85 static void test_android_specific_behavior(skiatest::Reporter* reporter) { |
36 #ifdef SK_BUILD_FOR_ANDROID | 86 #ifdef SK_BUILD_FOR_ANDROID |
37 // Copy constructor should preserve generation ID, but assignment shouldn't. | 87 // Copy constructor should preserve generation ID, but assignment shouldn't. |
38 SkPath original; | 88 SkPath original; |
39 original.moveTo(0, 0); | 89 original.moveTo(0, 0); |
40 original.lineTo(1, 1); | 90 original.lineTo(1, 1); |
41 REPORTER_ASSERT(reporter, original.getGenerationID() > 0); | 91 REPORTER_ASSERT(reporter, original.getGenerationID() > 0); |
42 | 92 |
43 const SkPath copy(original); | 93 const SkPath copy(original); |
44 REPORTER_ASSERT(reporter, copy.getGenerationID() == original.getGenerationID
()); | 94 REPORTER_ASSERT(reporter, copy.getGenerationID() == original.getGenerationID
()); |
(...skipping 2417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2462 test_isfinite_after_transform(reporter); | 2512 test_isfinite_after_transform(reporter); |
2463 test_arb_round_rect_is_convex(reporter); | 2513 test_arb_round_rect_is_convex(reporter); |
2464 test_arb_zero_rad_round_rect_is_rect(reporter); | 2514 test_arb_zero_rad_round_rect_is_rect(reporter); |
2465 test_addrect_isfinite(reporter); | 2515 test_addrect_isfinite(reporter); |
2466 test_tricky_cubic(); | 2516 test_tricky_cubic(); |
2467 test_clipped_cubic(); | 2517 test_clipped_cubic(); |
2468 test_crbug_170666(); | 2518 test_crbug_170666(); |
2469 test_bad_cubic_crbug229478(); | 2519 test_bad_cubic_crbug229478(); |
2470 test_bad_cubic_crbug234190(); | 2520 test_bad_cubic_crbug234190(); |
2471 test_android_specific_behavior(reporter); | 2521 test_android_specific_behavior(reporter); |
| 2522 test_path_close_issue1474(reporter); |
2472 } | 2523 } |
2473 | 2524 |
2474 #include "TestClassDef.h" | 2525 #include "TestClassDef.h" |
2475 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) | 2526 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) |
OLD | NEW |