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

Side by Side Diff: tests/GeometryTest.cpp

Issue 1035943002: use new faster/vector impl for chopping conics (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix bench Created 5 years, 8 months 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
« no previous file with comments | « src/core/SkGeometry.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 "SkGeometry.h" 8 #include "SkGeometry.h"
9 #include "Test.h" 9 #include "Test.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 check_pairs(reporter, 0, t, "conic-pos", p0.fX, p0.fY, p1.fX, p1.fY); 76 check_pairs(reporter, 0, t, "conic-pos", p0.fX, p0.fY, p1.fX, p1.fY);
77 } 77 }
78 78
79 static void test_conic_eval_tan(skiatest::Reporter* reporter, const SkConic& con ic, SkScalar t) { 79 static void test_conic_eval_tan(skiatest::Reporter* reporter, const SkConic& con ic, SkScalar t) {
80 SkVector v0, v1; 80 SkVector v0, v1;
81 conic.evalAt(t, NULL, &v0); 81 conic.evalAt(t, NULL, &v0);
82 v1 = conic.evalTangentAt(t); 82 v1 = conic.evalTangentAt(t);
83 check_pairs(reporter, 0, t, "conic-tan", v0.fX, v0.fY, v1.fX, v1.fY); 83 check_pairs(reporter, 0, t, "conic-tan", v0.fX, v0.fY, v1.fX, v1.fY);
84 } 84 }
85 85
86 static void test_conic_chop_half(skiatest::Reporter* reporter, const SkConic& co nic) {
87 SkConic dst0[2], dst1[2];
88 conic.chop(dst0);
89 conic.chop2(dst1);
90
91 for (int i = 0; i < 2; ++i) {
92 REPORTER_ASSERT(reporter, dst0[i].fW == dst1[i].fW);
93 for (int j = 0; j < 3; ++j) {
94 check_pairs(reporter, j, 0.5f, "conic-chop",
95 dst0[i].fPts[j].fX, dst0[i].fPts[j].fY,
96 dst0[i].fPts[j].fX, dst1[i].fPts[j].fY);
97 }
98 }
99 }
100
101 static void test_conic(skiatest::Reporter* reporter) { 86 static void test_conic(skiatest::Reporter* reporter) {
102 SkRandom rand; 87 SkRandom rand;
103 for (int i = 0; i < 1000; ++i) { 88 for (int i = 0; i < 1000; ++i) {
104 SkPoint pts[3]; 89 SkPoint pts[3];
105 for (int j = 0; j < 3; ++j) { 90 for (int j = 0; j < 3; ++j) {
106 pts[j].set(rand.nextSScalar1() * 100, rand.nextSScalar1() * 100); 91 pts[j].set(rand.nextSScalar1() * 100, rand.nextSScalar1() * 100);
107 } 92 }
108 for (int k = 0; k < 10; ++k) { 93 for (int k = 0; k < 10; ++k) {
109 SkScalar w = rand.nextUScalar1() * 2; 94 SkScalar w = rand.nextUScalar1() * 2;
110 SkConic conic(pts, w); 95 SkConic conic(pts, w);
111 test_conic_chop_half(reporter, conic);
112 96
113 const SkScalar dt = SK_Scalar1 / 128; 97 const SkScalar dt = SK_Scalar1 / 128;
114 SkScalar t = dt; 98 SkScalar t = dt;
115 for (int j = 1; j < 128; ++j) { 99 for (int j = 1; j < 128; ++j) {
116 test_conic_eval_pos(reporter, conic, t); 100 test_conic_eval_pos(reporter, conic, t);
117 test_conic_eval_tan(reporter, conic, t); 101 test_conic_eval_tan(reporter, conic, t);
118 t += dt; 102 t += dt;
119 } 103 }
120 } 104 }
121 } 105 }
(...skipping 20 matching lines...) Expand all
142 { SkIntToScalar(3), SkIntToScalar(3) }, 126 { SkIntToScalar(3), SkIntToScalar(3) },
143 }; 127 };
144 for (int i = 0; i < 4; ++i) { 128 for (int i = 0; i < 4; ++i) {
145 REPORTER_ASSERT(reporter, nearly_equal(cubic[i], dst[i])); 129 REPORTER_ASSERT(reporter, nearly_equal(cubic[i], dst[i]));
146 } 130 }
147 131
148 testChopCubic(reporter); 132 testChopCubic(reporter);
149 test_evalquadat(reporter); 133 test_evalquadat(reporter);
150 test_conic(reporter); 134 test_conic(reporter);
151 } 135 }
OLDNEW
« no previous file with comments | « src/core/SkGeometry.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698