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 "Test.h" | 8 #include "Test.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 3119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3130 p.setFillType(SkPath::kEvenOdd_FillType); | 3130 p.setFillType(SkPath::kEvenOdd_FillType); |
3131 p.moveTo(pts[i].fX, pts[i].fY); | 3131 p.moveTo(pts[i].fX, pts[i].fY); |
3132 p.cubicTo(pts[i + 1].fX, pts[i + 1].fY, pts[i + 2].fX, pts[i + 2].fY, pt
s[i + 3].fX, pts[i + 3].fY); | 3132 p.cubicTo(pts[i + 1].fX, pts[i + 1].fY, pts[i + 2].fX, pts[i + 2].fY, pt
s[i + 3].fX, pts[i + 3].fY); |
3133 p.cubicTo(pts[i + 4].fX, pts[i + 4].fY, pts[i + 5].fX, pts[i + 5].fY, pt
s[i + 6].fX, pts[i + 6].fY); | 3133 p.cubicTo(pts[i + 4].fX, pts[i + 4].fY, pts[i + 5].fX, pts[i + 5].fY, pt
s[i + 6].fX, pts[i + 6].fY); |
3134 p.close(); | 3134 p.close(); |
3135 REPORTER_ASSERT(reporter, p.contains(5.5f, 5.5f)); | 3135 REPORTER_ASSERT(reporter, p.contains(5.5f, 5.5f)); |
3136 REPORTER_ASSERT(reporter, !p.contains(4.5f, 5.5f)); | 3136 REPORTER_ASSERT(reporter, !p.contains(4.5f, 5.5f)); |
3137 } | 3137 } |
3138 } | 3138 } |
3139 | 3139 |
| 3140 static void test_pathref(skiatest::Reporter* reporter) { |
| 3141 static const int kRepeatCnt = 10; |
| 3142 |
| 3143 SkPathRef* pathRef = SkPathRef::CreateEmpty(); |
| 3144 SkAutoTUnref<SkPathRef> pathRef2(SkPathRef::CreateEmpty()); |
| 3145 SkMatrix mat; |
| 3146 |
| 3147 mat.setTranslate(10, 10); |
| 3148 |
| 3149 SkPathRef::CreateTransformedCopy(&pathRef2, *pathRef, mat); |
| 3150 |
| 3151 SkPathRef::Editor ed(&pathRef2); |
| 3152 |
| 3153 { |
| 3154 ed.growForRepeatedVerb(SkPath::kMove_Verb, kRepeatCnt); |
| 3155 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs()); |
| 3156 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countPoints()); |
| 3157 REPORTER_ASSERT(reporter, 0 == pathRef2->getSegmentMasks()); |
| 3158 for (int i = 0; i < kRepeatCnt; ++i) { |
| 3159 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == pathRef2->atVerb(i))
; |
| 3160 } |
| 3161 ed.resetToSize(0, 0, 0); |
| 3162 } |
| 3163 |
| 3164 { |
| 3165 ed.growForRepeatedVerb(SkPath::kLine_Verb, kRepeatCnt); |
| 3166 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs()); |
| 3167 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countPoints()); |
| 3168 REPORTER_ASSERT(reporter, SkPath::kLine_SegmentMask == pathRef2->getSegm
entMasks()); |
| 3169 for (int i = 0; i < kRepeatCnt; ++i) { |
| 3170 REPORTER_ASSERT(reporter, SkPath::kLine_Verb == pathRef2->atVerb(i))
; |
| 3171 } |
| 3172 ed.resetToSize(0, 0, 0); |
| 3173 } |
| 3174 |
| 3175 { |
| 3176 ed.growForRepeatedVerb(SkPath::kQuad_Verb, kRepeatCnt); |
| 3177 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs()); |
| 3178 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef2->countPoints()); |
| 3179 REPORTER_ASSERT(reporter, SkPath::kQuad_SegmentMask == pathRef2->getSegm
entMasks()); |
| 3180 for (int i = 0; i < kRepeatCnt; ++i) { |
| 3181 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == pathRef2->atVerb(i))
; |
| 3182 } |
| 3183 ed.resetToSize(0, 0, 0); |
| 3184 } |
| 3185 |
| 3186 { |
| 3187 SkScalar* weights = NULL; |
| 3188 ed.growForRepeatedVerb(SkPath::kConic_Verb, kRepeatCnt, &weights); |
| 3189 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs()); |
| 3190 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef2->countPoints()); |
| 3191 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countWeights()); |
| 3192 REPORTER_ASSERT(reporter, SkPath::kConic_SegmentMask == pathRef2->getSeg
mentMasks()); |
| 3193 REPORTER_ASSERT(reporter, NULL != weights); |
| 3194 for (int i = 0; i < kRepeatCnt; ++i) { |
| 3195 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == pathRef2->atVerb(i)
); |
| 3196 } |
| 3197 ed.resetToSize(0, 0, 0); |
| 3198 } |
| 3199 |
| 3200 { |
| 3201 ed.growForRepeatedVerb(SkPath::kCubic_Verb, kRepeatCnt); |
| 3202 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs()); |
| 3203 REPORTER_ASSERT(reporter, 3*kRepeatCnt == pathRef2->countPoints()); |
| 3204 REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == pathRef2->getSeg
mentMasks()); |
| 3205 for (int i = 0; i < kRepeatCnt; ++i) { |
| 3206 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == pathRef2->atVerb(i)
); |
| 3207 } |
| 3208 ed.resetToSize(0, 0, 0); |
| 3209 } |
| 3210 } |
| 3211 |
3140 static void test_operatorEqual(skiatest::Reporter* reporter) { | 3212 static void test_operatorEqual(skiatest::Reporter* reporter) { |
3141 SkPath a; | 3213 SkPath a; |
3142 SkPath b; | 3214 SkPath b; |
3143 REPORTER_ASSERT(reporter, a == a); | 3215 REPORTER_ASSERT(reporter, a == a); |
3144 REPORTER_ASSERT(reporter, a == b); | 3216 REPORTER_ASSERT(reporter, a == b); |
3145 a.setFillType(SkPath::kInverseWinding_FillType); | 3217 a.setFillType(SkPath::kInverseWinding_FillType); |
3146 REPORTER_ASSERT(reporter, a != b); | 3218 REPORTER_ASSERT(reporter, a != b); |
3147 a.reset(); | 3219 a.reset(); |
3148 REPORTER_ASSERT(reporter, a == b); | 3220 REPORTER_ASSERT(reporter, a == b); |
3149 a.lineTo(1, 1); | 3221 a.lineTo(1, 1); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3289 test_gen_id(reporter); | 3361 test_gen_id(reporter); |
3290 test_path_close_issue1474(reporter); | 3362 test_path_close_issue1474(reporter); |
3291 test_path_to_region(reporter); | 3363 test_path_to_region(reporter); |
3292 test_rrect(reporter); | 3364 test_rrect(reporter); |
3293 test_arc(reporter); | 3365 test_arc(reporter); |
3294 test_arcTo(reporter); | 3366 test_arcTo(reporter); |
3295 test_addPath(reporter); | 3367 test_addPath(reporter); |
3296 test_conicTo_special_case(reporter); | 3368 test_conicTo_special_case(reporter); |
3297 test_get_point(reporter); | 3369 test_get_point(reporter); |
3298 test_contains(reporter); | 3370 test_contains(reporter); |
| 3371 test_pathref(reporter); |
3299 PathTest_Private::TestPathTo(reporter); | 3372 PathTest_Private::TestPathTo(reporter); |
3300 } | 3373 } |
3301 | 3374 |
3302 #include "TestClassDef.h" | 3375 #include "TestClassDef.h" |
3303 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) | 3376 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) |
OLD | NEW |