OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "PathOpsTestCommon.h" | 7 #include "PathOpsTestCommon.h" |
8 #include "SkGeometry.h" | 8 #include "SkGeometry.h" |
9 #include "SkIntersections.h" | 9 #include "SkIntersections.h" |
10 #include "Test.h" | 10 #include "Test.h" |
11 | 11 |
12 /* | 12 /* |
13 manually compute the intersection of a pair of circles and see if the conic inte
rsection matches | 13 manually compute the intersection of a pair of circles and see if the conic inte
rsection matches |
14 given two circles | 14 given two circles |
15 construct a line connecting their centers | 15 construct a line connecting their centers |
16 | 16 |
17 */ | 17 */ |
18 | 18 |
19 static const SkDConic testSet[] = { | 19 static const ConicPts testSet[] = { |
20 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.976398
5}}}, 0.707107008f}, | 20 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.976398
5}}}, 0.707107008f}, |
21 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.69799
8}}}, 0.707107008f}, | 21 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.69799
8}}}, 0.707107008f}, |
22 | 22 |
23 {{{{5.1114602088928223, 628.77813720703125}, | 23 {{{{5.1114602088928223, 628.77813720703125}, |
24 {10.834027290344238, 988.964111328125}, | 24 {10.834027290344238, 988.964111328125}, |
25 {163.40835571289062, 988.964111328125}}}, 0.72944212f}, | 25 {163.40835571289062, 988.964111328125}}}, 0.72944212f}, |
26 {{{{163.40835571289062, 988.964111328125}, | 26 {{{{163.40835571289062, 988.964111328125}, |
27 {5, 988.964111328125}, | 27 {5, 988.964111328125}, |
28 {5, 614.7423095703125}}}, 0.707106769f}, | 28 {5, 614.7423095703125}}}, 0.707106769f}, |
29 | 29 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 288 } |
289 canvas.drawPath(path, paint); | 289 canvas.drawPath(path, paint); |
290 } | 290 } |
291 SkString filename("c:\\Users\\caryclark\\Documents\\"); | 291 SkString filename("c:\\Users\\caryclark\\Documents\\"); |
292 filename.appendf("f%d.png", index); | 292 filename.appendf("f%d.png", index); |
293 SkImageEncoder::EncodeFile(filename.c_str(), bitmap, SkImageEncoder::kPN
G_Type, 100); | 293 SkImageEncoder::EncodeFile(filename.c_str(), bitmap, SkImageEncoder::kPN
G_Type, 100); |
294 } | 294 } |
295 } | 295 } |
296 #endif | 296 #endif |
297 | 297 |
298 static void oneOff(skiatest::Reporter* reporter, const SkDConic& c1, const SkDCo
nic& c2, | 298 static void oneOff(skiatest::Reporter* reporter, const ConicPts& conic1, const C
onicPts& conic2, |
299 bool coin) { | 299 bool coin) { |
300 #if DEBUG_VISUALIZE_CONICS | 300 #if DEBUG_VISUALIZE_CONICS |
301 writeFrames(); | 301 writeFrames(); |
302 #endif | 302 #endif |
| 303 SkDConic c1, c2; |
| 304 c1.debugSet(conic1.fPts.fPts, conic1.fWeight); |
| 305 c2.debugSet(conic2.fPts.fPts, conic2.fWeight); |
303 chopBothWays(c1, 0.5, "c1"); | 306 chopBothWays(c1, 0.5, "c1"); |
304 chopBothWays(c2, 0.5, "c2"); | 307 chopBothWays(c2, 0.5, "c2"); |
305 #if DEBUG_VISUALIZE_CONICS | 308 #if DEBUG_VISUALIZE_CONICS |
306 writeDPng(c1, "d1"); | 309 writeDPng(c1, "d1"); |
307 writeDPng(c2, "d2"); | 310 writeDPng(c2, "d2"); |
308 #endif | 311 #endif |
309 SkASSERT(ValidConic(c1)); | 312 SkASSERT(ValidConic(c1)); |
310 SkASSERT(ValidConic(c2)); | 313 SkASSERT(ValidConic(c2)); |
311 SkIntersections intersections; | 314 SkIntersections intersections; |
312 intersections.intersect(c1, c2); | 315 intersections.intersect(c1, c2); |
(...skipping 10 matching lines...) Expand all Loading... |
323 xy2 = c2.ptAtT(tt2); | 326 xy2 = c2.ptAtT(tt2); |
324 const SkDPoint& iPt = intersections.pt(pt3); | 327 const SkDPoint& iPt = intersections.pt(pt3); |
325 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(iPt)); | 328 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(iPt)); |
326 REPORTER_ASSERT(reporter, xy2.approximatelyEqual(iPt)); | 329 REPORTER_ASSERT(reporter, xy2.approximatelyEqual(iPt)); |
327 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); | 330 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); |
328 } | 331 } |
329 reporter->bumpTestCount(); | 332 reporter->bumpTestCount(); |
330 } | 333 } |
331 | 334 |
332 static void oneOff(skiatest::Reporter* reporter, int outer, int inner) { | 335 static void oneOff(skiatest::Reporter* reporter, int outer, int inner) { |
333 const SkDConic& c1 = testSet[outer]; | 336 const ConicPts& c1 = testSet[outer]; |
334 const SkDConic& c2 = testSet[inner]; | 337 const ConicPts& c2 = testSet[inner]; |
335 oneOff(reporter, c1, c2, false); | 338 oneOff(reporter, c1, c2, false); |
336 } | 339 } |
337 | 340 |
338 static void oneOffTests(skiatest::Reporter* reporter) { | 341 static void oneOffTests(skiatest::Reporter* reporter) { |
339 for (int outer = 0; outer < testSetCount - 1; ++outer) { | 342 for (int outer = 0; outer < testSetCount - 1; ++outer) { |
340 for (int inner = outer + 1; inner < testSetCount; ++inner) { | 343 for (int inner = outer + 1; inner < testSetCount; ++inner) { |
341 oneOff(reporter, outer, inner); | 344 oneOff(reporter, outer, inner); |
342 } | 345 } |
343 } | 346 } |
344 } | 347 } |
345 | 348 |
346 DEF_TEST(PathOpsConicIntersectionOneOff, reporter) { | 349 DEF_TEST(PathOpsConicIntersectionOneOff, reporter) { |
347 oneOff(reporter, 0, 1); | 350 oneOff(reporter, 0, 1); |
348 } | 351 } |
349 | 352 |
350 DEF_TEST(PathOpsConicIntersection, reporter) { | 353 DEF_TEST(PathOpsConicIntersection, reporter) { |
351 oneOffTests(reporter); | 354 oneOffTests(reporter); |
352 } | 355 } |
OLD | NEW |