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

Side by Side Diff: tests/PathOpsConicIntersectionTest.cpp

Issue 1842753002: Style bikeshed - remove extraneous whitespace (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 | « tests/PathOpsBuilderConicTest.cpp ('k') | tests/PathOpsConicLineIntersectionTest.cpp » ('j') | 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 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 SkDConic 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
30 {{{{11.17222976684570312, -8.103978157043457031}, 30 {{{{11.17222976684570312, -8.103978157043457031},
31 {22.91432571411132812, -10.37866020202636719}, 31 {22.91432571411132812, -10.37866020202636719},
32 {23.7764129638671875, -7.725424289703369141}}}, 1.00862849f}, 32 {23.7764129638671875, -7.725424289703369141}}}, 1.00862849f},
33 {{{{-1.545085430145263672, -4.755282402038574219}, 33 {{{{-1.545085430145263672, -4.755282402038574219},
34 {22.23132705688476562, -12.48070907592773438}, 34 {22.23132705688476562, -12.48070907592773438},
35 {23.7764129638671875, -7.725427150726318359}}}, 0.707106769f}, 35 {23.7764129638671875, -7.725427150726318359}}}, 0.707106769f},
36 36
37 {{{{-4,1}, {-4,5}, {0,5}}}, 0.707106769f}, 37 {{{{-4,1}, {-4,5}, {0,5}}}, 0.707106769f},
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 paint.setARGB(0x80, 0, 0, 0xFF); 109 paint.setARGB(0x80, 0, 0, 0xFF);
110 canvas.drawPath(path, paint); 110 canvas.drawPath(path, paint);
111 SkString filename("c:\\Users\\caryclark\\Documents\\"); 111 SkString filename("c:\\Users\\caryclark\\Documents\\");
112 filename.appendf("%s.png", name); 112 filename.appendf("%s.png", name);
113 SkImageEncoder::EncodeFile(filename.c_str(), bitmap, 113 SkImageEncoder::EncodeFile(filename.c_str(), bitmap,
114 SkImageEncoder::kPNG_Type, 100); 114 SkImageEncoder::kPNG_Type, 100);
115 } 115 }
116 116
117 static void writeDPng(const SkDConic& dC, const char* name) { 117 static void writeDPng(const SkDConic& dC, const char* name) {
118 const int scale = 5; 118 const int scale = 5;
119 SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale }, 119 SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale },
120 {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale }, 120 {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale },
121 {dC.fPts[2].fX * scale, dC.fPts[2].fY * scale }}}, dC.fWeight }; 121 {dC.fPts[2].fX * scale, dC.fPts[2].fY * scale }}}, dC.fWeight };
122 SkBitmap bitmap; 122 SkBitmap bitmap;
123 SkDRect bounds; 123 SkDRect bounds;
124 bounds.setBounds(dConic); 124 bounds.setBounds(dConic);
125 bounds.fLeft -= 10; 125 bounds.fLeft -= 10;
126 bounds.fTop -= 10; 126 bounds.fTop -= 10;
127 bounds.fRight += 10; 127 bounds.fRight += 10;
128 bounds.fBottom += 10; 128 bounds.fBottom += 10;
129 bitmap.tryAllocPixels(SkImageInfo::MakeN32Premul( 129 bitmap.tryAllocPixels(SkImageInfo::MakeN32Premul(
130 SkScalarRoundToInt(SkDoubleToScalar(bounds.width())), 130 SkScalarRoundToInt(SkDoubleToScalar(bounds.width())),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 }; 219 };
220 220
221 const SkDConic frame6[] = { 221 const SkDConic frame6[] = {
222 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.9763985}}} , 0.707107008f}, 222 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.9763985}}} , 0.707107008f},
223 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}} , 0.707107008f}, 223 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}} , 0.707107008f},
224 {{{{205.78973252799028, -158.12538713371103}, {190.33692178059735, -137.11320166 154385}, {174.87004877564593, -111.2132534799228}}}, 0.858117759f}, 224 {{{{205.78973252799028, -158.12538713371103}, {190.33692178059735, -137.11320166 154385}, {174.87004877564593, -111.2132534799228}}}, 0.858117759f},
225 {{{{252.08225670812539, -156.90491625851064}, {219.70109133058406, -158.81912754 088933}, {190.17095392508796, -158.38373974664466}}}, 0.858306944f}, 225 {{{{252.08225670812539, -156.90491625851064}, {219.70109133058406, -158.81912754 088933}, {190.17095392508796, -158.38373974664466}}}, 0.858306944f},
226 }; 226 };
227 227
228 const SkDConic* frames[] = { 228 const SkDConic* frames[] = {
229 frame0, frame1, frame2, frame3, frame4, frame5, frame6 229 frame0, frame1, frame2, frame3, frame4, frame5, frame6
230 }; 230 };
231 231
232 const int frameSizes[] = { (int) SK_ARRAY_COUNT(frame0), (int) SK_ARRAY_COUNT(fr ame1), 232 const int frameSizes[] = { (int) SK_ARRAY_COUNT(frame0), (int) SK_ARRAY_COUNT(fr ame1),
233 (int) SK_ARRAY_COUNT(frame2), (int) SK_ARRAY_COUNT(frame3), 233 (int) SK_ARRAY_COUNT(frame2), (int) SK_ARRAY_COUNT(frame3),
234 (int) SK_ARRAY_COUNT(frame4), (int) SK_ARRAY_COUNT(frame5), 234 (int) SK_ARRAY_COUNT(frame4), (int) SK_ARRAY_COUNT(frame5),
235 (int) SK_ARRAY_COUNT(frame6), 235 (int) SK_ARRAY_COUNT(frame6),
236 }; 236 };
237 237
238 static void writeFrames() { 238 static void writeFrames() {
239 const int scale = 5; 239 const int scale = 5;
240 240
241 for (int index = 0; index < (int) SK_ARRAY_COUNT(frameSizes); ++index) { 241 for (int index = 0; index < (int) SK_ARRAY_COUNT(frameSizes); ++index) {
242 SkDRect bounds; 242 SkDRect bounds;
243 bool boundsSet = false; 243 bool boundsSet = false;
244 int frameSize = frameSizes[index]; 244 int frameSize = frameSizes[index];
245 for (int fIndex = 0; fIndex < frameSize; ++fIndex) { 245 for (int fIndex = 0; fIndex < frameSize; ++fIndex) {
246 const SkDConic& dC = frames[index][fIndex]; 246 const SkDConic& dC = frames[index][fIndex];
247 SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale }, 247 SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale },
248 {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale }, 248 {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale },
249 {dC.fPts[2].fX * scale, dC.fPts[2].fY * scale }}}, dC.fWeight }; 249 {dC.fPts[2].fX * scale, dC.fPts[2].fY * scale }}}, dC.fWeight };
250 SkDRect dBounds; 250 SkDRect dBounds;
251 dBounds.setBounds(dConic); 251 dBounds.setBounds(dConic);
252 if (!boundsSet) { 252 if (!boundsSet) {
253 bounds = dBounds; 253 bounds = dBounds;
254 boundsSet = true; 254 boundsSet = true;
255 } else { 255 } else {
256 bounds.add((SkDPoint&) dBounds.fLeft); 256 bounds.add((SkDPoint&) dBounds.fLeft);
257 bounds.add((SkDPoint&) dBounds.fRight); 257 bounds.add((SkDPoint&) dBounds.fRight);
258 } 258 }
259 } 259 }
260 bounds.fLeft -= 10; 260 bounds.fLeft -= 10;
261 bounds.fTop -= 10; 261 bounds.fTop -= 10;
262 bounds.fRight += 10; 262 bounds.fRight += 10;
263 bounds.fBottom += 10; 263 bounds.fBottom += 10;
264 SkBitmap bitmap; 264 SkBitmap bitmap;
265 bitmap.tryAllocPixels(SkImageInfo::MakeN32Premul( 265 bitmap.tryAllocPixels(SkImageInfo::MakeN32Premul(
266 SkScalarRoundToInt(SkDoubleToScalar(bounds.width())), 266 SkScalarRoundToInt(SkDoubleToScalar(bounds.width())),
267 SkScalarRoundToInt(SkDoubleToScalar(bounds.height())))); 267 SkScalarRoundToInt(SkDoubleToScalar(bounds.height()))));
268 SkCanvas canvas(bitmap); 268 SkCanvas canvas(bitmap);
269 SkPaint paint; 269 SkPaint paint;
270 paint.setAntiAlias(true); 270 paint.setAntiAlias(true);
271 paint.setStyle(SkPaint::kStroke_Style); 271 paint.setStyle(SkPaint::kStroke_Style);
272 canvas.translate(SkDoubleToScalar(-bounds.fLeft), SkDoubleToScalar(-boun ds.fTop)); 272 canvas.translate(SkDoubleToScalar(-bounds.fLeft), SkDoubleToScalar(-boun ds.fTop));
273 canvas.drawColor(SK_ColorWHITE); 273 canvas.drawColor(SK_ColorWHITE);
274 for (int fIndex = 0; fIndex < frameSize; ++fIndex) { 274 for (int fIndex = 0; fIndex < frameSize; ++fIndex) {
275 const SkDConic& dC = frames[index][fIndex]; 275 const SkDConic& dC = frames[index][fIndex];
276 SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale }, 276 SkDConic dConic = {{{ {dC.fPts[0].fX * scale, dC.fPts[0].fY * scale },
277 {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale }, 277 {dC.fPts[1].fX * scale, dC.fPts[1].fY * scale },
278 {dC.fPts[2].fX * scale, dC.fPts[2].fY * scale }}}, dC.fWeight }; 278 {dC.fPts[2].fX * scale, dC.fPts[2].fY * scale }}}, dC.fWeight };
279 SkPath path; 279 SkPath path;
280 path.moveTo(dConic.fPts[0].asSkPoint()); 280 path.moveTo(dConic.fPts[0].asSkPoint());
281 path.conicTo(dConic.fPts[1].asSkPoint(), dConic.fPts[2].asSkPoint(), dConic.fWeight); 281 path.conicTo(dConic.fPts[1].asSkPoint(), dConic.fPts[2].asSkPoint(), dConic.fWeight);
282 if (fIndex < 2) { 282 if (fIndex < 2) {
283 paint.setARGB(0x80, 0xFF, 0, 0); 283 paint.setARGB(0x80, 0xFF, 0, 0);
284 } else { 284 } else {
285 paint.setARGB(0x80, 0, 0, 0xFF); 285 paint.setARGB(0x80, 0, 0, 0xFF);
286 } 286 }
287 canvas.drawPath(path, paint); 287 canvas.drawPath(path, paint);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 341 }
342 } 342 }
343 343
344 DEF_TEST(PathOpsConicIntersectionOneOff, reporter) { 344 DEF_TEST(PathOpsConicIntersectionOneOff, reporter) {
345 oneOff(reporter, 0, 1); 345 oneOff(reporter, 0, 1);
346 } 346 }
347 347
348 DEF_TEST(PathOpsConicIntersection, reporter) { 348 DEF_TEST(PathOpsConicIntersection, reporter) {
349 oneOffTests(reporter); 349 oneOffTests(reporter);
350 } 350 }
OLDNEW
« no previous file with comments | « tests/PathOpsBuilderConicTest.cpp ('k') | tests/PathOpsConicLineIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698