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

Side by Side Diff: tests/PathOpsQuadLineIntersectionThreadedTest.cpp

Issue 2391133005: remove sprintf (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "PathOpsExtendedTest.h" 7 #include "PathOpsExtendedTest.h"
8 #include "PathOpsThreadedCommon.h" 8 #include "PathOpsThreadedCommon.h"
9 #include "SkIntersections.h" 9 #include "SkIntersections.h"
10 #include "SkPathOpsLine.h" 10 #include "SkPathOpsLine.h"
11 #include "SkPathOpsQuad.h" 11 #include "SkPathOpsQuad.h"
12 #include "SkReduceOrder.h" 12 #include "SkReduceOrder.h"
13 #include "SkString.h"
13 14
14 static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, cons t SkDLine& line, 15 static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, cons t SkDLine& line,
15 bool& flipped) { 16 bool& flipped) {
16 int result; 17 int result;
17 flipped = false; 18 flipped = false;
18 if (line[0].fX == line[1].fX) { 19 if (line[0].fX == line[1].fX) {
19 double top = line[0].fY; 20 double top = line[0].fY;
20 double bottom = line[1].fY; 21 double bottom = line[1].fY;
21 flipped = top > bottom; 22 flipped = top > bottom;
22 if (flipped) { 23 if (flipped) {
(...skipping 10 matching lines...) Expand all
33 result = intersections.horizontal(quad, left, right, line[0].fY, flipped ); 34 result = intersections.horizontal(quad, left, right, line[0].fY, flipped );
34 } else { 35 } else {
35 intersections.intersect(quad, line); 36 intersections.intersect(quad, line);
36 result = intersections.used(); 37 result = intersections.used();
37 } 38 }
38 return result; 39 return result;
39 } 40 }
40 41
41 static void testLineIntersect(skiatest::Reporter* reporter, const SkDQuad& quad, 42 static void testLineIntersect(skiatest::Reporter* reporter, const SkDQuad& quad,
42 const SkDLine& line, const double x, const double y) { 43 const SkDLine& line, const double x, const double y) {
43 char pathStr[1024]; 44 SkString pathStr;
44 sk_bzero(pathStr, sizeof(pathStr)); 45 pathStr.appendf(" path.moveTo(%1.9g, %1.9g);\n", quad[0].fX, quad[0].fY);
45 char* str = pathStr; 46 pathStr.appendf(" path.quadTo(%1.9g, %1.9g, %1.9g, %1.9g);\n", quad[1].fX ,
46 str += sprintf(str, " path.moveTo(%1.9g, %1.9g);\n", quad[0].fX, quad[0]. fY);
47 str += sprintf(str, " path.quadTo(%1.9g, %1.9g, %1.9g, %1.9g);\n", quad[1 ].fX,
48 quad[1].fY, quad[2].fX, quad[2].fY); 47 quad[1].fY, quad[2].fX, quad[2].fY);
49 str += sprintf(str, " path.moveTo(%1.9g, %1.9g);\n", line[0].fX, line[0]. fY); 48 pathStr.appendf(" path.moveTo(%1.9g, %1.9g);\n", line[0].fX, line[0].fY);
50 str += sprintf(str, " path.lineTo(%1.9g, %1.9g);\n", line[1].fX, line[1]. fY); 49 pathStr.appendf(" path.lineTo(%1.9g, %1.9g);\n", line[1].fX, line[1].fY);
51 50
52 SkIntersections intersections; 51 SkIntersections intersections;
53 bool flipped = false; 52 bool flipped = false;
54 int result = doIntersect(intersections, quad, line, flipped); 53 int result = doIntersect(intersections, quad, line, flipped);
55 bool found = false; 54 bool found = false;
56 for (int index = 0; index < result; ++index) { 55 for (int index = 0; index < result; ++index) {
57 double quadT = intersections[0][index]; 56 double quadT = intersections[0][index];
58 SkDPoint quadXY = quad.ptAtT(quadT); 57 SkDPoint quadXY = quad.ptAtT(quadT);
59 double lineT = intersections[1][index]; 58 double lineT = intersections[1][index];
60 SkDPoint lineXY = line.ptAtT(lineT); 59 SkDPoint lineXY = line.ptAtT(lineT);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 for (int c = 0 ; c < 16; ++c) { 117 for (int c = 0 ; c < 16; ++c) {
119 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable( 118 *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
120 &testQuadLineIntersectMain, a, b, c, 0, &testRunner); 119 &testQuadLineIntersectMain, a, b, c, 0, &testRunner);
121 } 120 }
122 if (!reporter->allowExtendedTest()) goto finish; 121 if (!reporter->allowExtendedTest()) goto finish;
123 } 122 }
124 } 123 }
125 finish: 124 finish:
126 testRunner.render(); 125 testRunner.render();
127 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698