Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: tests/PathTest.cpp

Issue 105083003: Move segment mask from SkPath to SkPathRef (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added const Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/core/SkPathRef.cpp ('K') | « src/core/SkPathRef.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 srcWeights[kRepeatCnt];
3188 memset(srcWeights, 0, kRepeatCnt * sizeof(SkScalar));
3189
3190 ed.growForRepeatedVerb(SkPath::kConic_Verb, kRepeatCnt, srcWeights);
3191 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs());
3192 REPORTER_ASSERT(reporter, 2*kRepeatCnt == pathRef2->countPoints());
3193 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countWeights());
3194 REPORTER_ASSERT(reporter, SkPath::kConic_SegmentMask == pathRef2->getSeg mentMasks());
3195 const SkScalar* weights = pathRef2->conicWeights();
3196 for (int i = 0; i < kRepeatCnt; ++i) {
3197 REPORTER_ASSERT(reporter, SkPath::kConic_Verb == pathRef2->atVerb(i) );
3198 REPORTER_ASSERT(reporter, 0 == weights[0]);
3199 }
3200 ed.resetToSize(0, 0, 0);
3201 }
3202
3203 {
3204 ed.growForRepeatedVerb(SkPath::kCubic_Verb, kRepeatCnt);
3205 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef2->countVerbs());
3206 REPORTER_ASSERT(reporter, 3*kRepeatCnt == pathRef2->countPoints());
3207 REPORTER_ASSERT(reporter, SkPath::kCubic_SegmentMask == pathRef2->getSeg mentMasks());
3208 for (int i = 0; i < kRepeatCnt; ++i) {
3209 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == pathRef2->atVerb(i) );
3210 }
3211 ed.resetToSize(0, 0, 0);
3212 }
3213 }
3214
3140 static void test_operatorEqual(skiatest::Reporter* reporter) { 3215 static void test_operatorEqual(skiatest::Reporter* reporter) {
3141 SkPath a; 3216 SkPath a;
3142 SkPath b; 3217 SkPath b;
3143 REPORTER_ASSERT(reporter, a == a); 3218 REPORTER_ASSERT(reporter, a == a);
3144 REPORTER_ASSERT(reporter, a == b); 3219 REPORTER_ASSERT(reporter, a == b);
3145 a.setFillType(SkPath::kInverseWinding_FillType); 3220 a.setFillType(SkPath::kInverseWinding_FillType);
3146 REPORTER_ASSERT(reporter, a != b); 3221 REPORTER_ASSERT(reporter, a != b);
3147 a.reset(); 3222 a.reset();
3148 REPORTER_ASSERT(reporter, a == b); 3223 REPORTER_ASSERT(reporter, a == b);
3149 a.lineTo(1, 1); 3224 a.lineTo(1, 1);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3289 test_gen_id(reporter); 3364 test_gen_id(reporter);
3290 test_path_close_issue1474(reporter); 3365 test_path_close_issue1474(reporter);
3291 test_path_to_region(reporter); 3366 test_path_to_region(reporter);
3292 test_rrect(reporter); 3367 test_rrect(reporter);
3293 test_arc(reporter); 3368 test_arc(reporter);
3294 test_arcTo(reporter); 3369 test_arcTo(reporter);
3295 test_addPath(reporter); 3370 test_addPath(reporter);
3296 test_conicTo_special_case(reporter); 3371 test_conicTo_special_case(reporter);
3297 test_get_point(reporter); 3372 test_get_point(reporter);
3298 test_contains(reporter); 3373 test_contains(reporter);
3374 test_pathref(reporter);
3299 PathTest_Private::TestPathTo(reporter); 3375 PathTest_Private::TestPathTo(reporter);
3300 } 3376 }
3301 3377
3302 #include "TestClassDef.h" 3378 #include "TestClassDef.h"
3303 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) 3379 DEFINE_TESTCLASS("Path", PathTestClass, TestPath)
OLDNEW
« src/core/SkPathRef.cpp ('K') | « src/core/SkPathRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698