| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 77     path.close(); | 77     path.close(); | 
| 78     path.rCubicTo(50, 50, 85, 85, 95, 95); | 78     path.rCubicTo(50, 50, 85, 85, 95, 95); | 
| 79 | 79 | 
| 80     path.getLastPt(&last); | 80     path.getLastPt(&last); | 
| 81     REPORTER_ASSERT(reporter, 95 == last.fX); | 81     REPORTER_ASSERT(reporter, 95 == last.fX); | 
| 82     REPORTER_ASSERT(reporter, 95 == last.fY); | 82     REPORTER_ASSERT(reporter, 95 == last.fY); | 
| 83 } | 83 } | 
| 84 | 84 | 
| 85 static void test_android_specific_behavior(skiatest::Reporter* reporter) { | 85 static void test_android_specific_behavior(skiatest::Reporter* reporter) { | 
| 86 #ifdef SK_BUILD_FOR_ANDROID | 86 #ifdef SK_BUILD_FOR_ANDROID | 
| 87     // Copy constructor should preserve generation ID, but assignment shouldn't. | 87     // Make sure we treat fGenerationID and fSourcePath correctly for each of | 
| 88     SkPath original; | 88     // copy, assign, rewind, reset, and swap. | 
|  | 89     SkPath original, source, anotherSource; | 
|  | 90     original.setSourcePath(&source); | 
| 89     original.moveTo(0, 0); | 91     original.moveTo(0, 0); | 
| 90     original.lineTo(1, 1); | 92     original.lineTo(1, 1); | 
| 91     REPORTER_ASSERT(reporter, original.getGenerationID() > 0); | 93     REPORTER_ASSERT(reporter, original.getGenerationID() > 0); | 
|  | 94     REPORTER_ASSERT(reporter, original.getSourcePath() == &source); | 
| 92 | 95 | 
| 93     const SkPath copy(original); | 96     uint32_t copyID, assignID; | 
|  | 97 | 
|  | 98     // Test copy constructor.  Copy generation ID, copy source path. | 
|  | 99     SkPath copy(original); | 
| 94     REPORTER_ASSERT(reporter, copy.getGenerationID() == original.getGenerationID
      ()); | 100     REPORTER_ASSERT(reporter, copy.getGenerationID() == original.getGenerationID
      ()); | 
|  | 101     REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); | 
| 95 | 102 | 
|  | 103     // Test assigment operator.  Increment generation ID, copy source path. | 
| 96     SkPath assign; | 104     SkPath assign; | 
|  | 105     assignID = assign.getGenerationID(); | 
| 97     assign = original; | 106     assign = original; | 
| 98     REPORTER_ASSERT(reporter, assign.getGenerationID() != original.getGeneration
      ID()); | 107     REPORTER_ASSERT(reporter, assign.getGenerationID() > assignID); | 
|  | 108     REPORTER_ASSERT(reporter, assign.getSourcePath() == original.getSourcePath()
      ); | 
|  | 109 | 
|  | 110     // Test rewind.  Increment generation ID, don't touch source path. | 
|  | 111     copyID = copy.getGenerationID(); | 
|  | 112     copy.rewind(); | 
|  | 113     REPORTER_ASSERT(reporter, copy.getGenerationID() > copyID); | 
|  | 114     REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); | 
|  | 115 | 
|  | 116     // Test reset.  Increment generation ID, don't touch source path. | 
|  | 117     assignID = assign.getGenerationID(); | 
|  | 118     assign.reset(); | 
|  | 119     REPORTER_ASSERT(reporter, assign.getGenerationID() > assignID); | 
|  | 120     REPORTER_ASSERT(reporter, assign.getSourcePath() == original.getSourcePath()
      ); | 
|  | 121 | 
|  | 122     // Test swap.  Increment both generation IDs, swap source paths. | 
|  | 123     copy.setSourcePath(&anotherSource); | 
|  | 124     copyID = copy.getGenerationID(); | 
|  | 125     assignID = assign.getGenerationID(); | 
|  | 126     copy.swap(assign); | 
|  | 127     REPORTER_ASSERT(reporter, copy.getGenerationID() > copyID); | 
|  | 128     REPORTER_ASSERT(reporter, assign.getGenerationID() > assignID); | 
|  | 129     REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); | 
|  | 130     REPORTER_ASSERT(reporter, assign.getSourcePath() == &anotherSource); | 
| 99 #endif | 131 #endif | 
| 100 } | 132 } | 
| 101 | 133 | 
| 102 // This used to assert in the debug build, as the edges did not all line-up. | 134 // This used to assert in the debug build, as the edges did not all line-up. | 
| 103 static void test_bad_cubic_crbug234190() { | 135 static void test_bad_cubic_crbug234190() { | 
| 104     SkPath path; | 136     SkPath path; | 
| 105     path.moveTo(13.8509f, 3.16858f); | 137     path.moveTo(13.8509f, 3.16858f); | 
| 106     path.cubicTo(-2.35893e+08f, -4.21044e+08f, | 138     path.cubicTo(-2.35893e+08f, -4.21044e+08f, | 
| 107                  -2.38991e+08f, -4.26573e+08f, | 139                  -2.38991e+08f, -4.26573e+08f, | 
| 108                  -2.41016e+08f, -4.30188e+08f); | 140                  -2.41016e+08f, -4.30188e+08f); | 
| (...skipping 2408 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2517     test_clipped_cubic(); | 2549     test_clipped_cubic(); | 
| 2518     test_crbug_170666(); | 2550     test_crbug_170666(); | 
| 2519     test_bad_cubic_crbug229478(); | 2551     test_bad_cubic_crbug229478(); | 
| 2520     test_bad_cubic_crbug234190(); | 2552     test_bad_cubic_crbug234190(); | 
| 2521     test_android_specific_behavior(reporter); | 2553     test_android_specific_behavior(reporter); | 
| 2522     test_path_close_issue1474(reporter); | 2554     test_path_close_issue1474(reporter); | 
| 2523 } | 2555 } | 
| 2524 | 2556 | 
| 2525 #include "TestClassDef.h" | 2557 #include "TestClassDef.h" | 
| 2526 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) | 2558 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) | 
| OLD | NEW | 
|---|