remove sprintf
Most uses of sprintf are in pathops testing. Replace them with SkString::appendf and replace the remaining with snprintf R=scroggo@google.com BUG=skia:2716 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2391133005 Review-Url: https://codereview.chromium.org/2391133005
This commit is contained in:
parent
33cbfd75af
commit
8f18643867
@ -116,7 +116,7 @@ void SkErrorInternals::SetError(SkError code, const char *fmt, ...) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf( str, "%s: ", error_name );
|
snprintf( str, ERROR_STRING_LENGTH, "%s: ", error_name );
|
||||||
int string_left = SkToInt(ERROR_STRING_LENGTH - strlen(str));
|
int string_left = SkToInt(ERROR_STRING_LENGTH - strlen(str));
|
||||||
str += strlen(str);
|
str += strlen(str);
|
||||||
|
|
||||||
|
@ -196,14 +196,15 @@ char* SkRegion::toString() {
|
|||||||
if (result == nullptr) {
|
if (result == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
count = sprintf(result, "SkRegion(");
|
count = snprintf(result, max, "SkRegion(");
|
||||||
iter.reset(*this);
|
iter.reset(*this);
|
||||||
while (!iter.done()) {
|
while (!iter.done()) {
|
||||||
const SkIRect& r = iter.rect();
|
const SkIRect& r = iter.rect();
|
||||||
count += sprintf(result+count, "(%d,%d,%d,%d)", r.fLeft, r.fTop, r.fRight, r.fBottom);
|
count += snprintf(result+count, max - count,
|
||||||
|
"(%d,%d,%d,%d)", r.fLeft, r.fTop, r.fRight, r.fBottom);
|
||||||
iter.next();
|
iter.next();
|
||||||
}
|
}
|
||||||
count += sprintf(result+count, ")");
|
count += snprintf(result+count, max - count, ")");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,16 +6,14 @@
|
|||||||
*/
|
*/
|
||||||
#include "PathOpsExtendedTest.h"
|
#include "PathOpsExtendedTest.h"
|
||||||
#include "PathOpsThreadedCommon.h"
|
#include "PathOpsThreadedCommon.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
|
static int loopNo = 4;
|
||||||
|
|
||||||
static void testOpCirclesMain(PathOpsThreadState* data) {
|
static void testOpCirclesMain(PathOpsThreadState* data) {
|
||||||
SkASSERT(data);
|
SkASSERT(data);
|
||||||
PathOpsThreadState& state = *data;
|
PathOpsThreadState& state = *data;
|
||||||
char pathStr[1024];
|
SkString pathStr;
|
||||||
bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
|
|
||||||
if (progress) {
|
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int a = 0 ; a < 6; ++a) {
|
for (int a = 0 ; a < 6; ++a) {
|
||||||
for (int b = a + 1 ; b < 7; ++b) {
|
for (int b = a + 1 ; b < 7; ++b) {
|
||||||
for (int c = 0 ; c < 6; ++c) {
|
for (int c = 0 ; c < 6; ++c) {
|
||||||
@ -23,26 +21,6 @@ static void testOpCirclesMain(PathOpsThreadState* data) {
|
|||||||
for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
|
for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
|
||||||
for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
|
for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
|
||||||
SkPath pathA, pathB;
|
SkPath pathA, pathB;
|
||||||
if (progress) {
|
|
||||||
char* str = pathStr;
|
|
||||||
const int loopNo = 4;
|
|
||||||
str += sprintf(str, "static void circlesOp%d(skiatest::Reporter* reporter,"
|
|
||||||
" const char* filename) {\n", loopNo);
|
|
||||||
str += sprintf(str, " SkPath path, pathB;\n");
|
|
||||||
str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
|
|
||||||
e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
|
|
||||||
? "EvenOdd" : "?UNDEFINED");
|
|
||||||
str += sprintf(str, " path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB,
|
|
||||||
state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
|
|
||||||
str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
|
|
||||||
f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
|
|
||||||
? "EvenOdd" : "?UNDEFINED");
|
|
||||||
str += sprintf(str, " pathB.addCircle(%d, %d, %d, %s);\n", a, b,
|
|
||||||
c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
|
|
||||||
str += sprintf(str, " testPathOp(reporter, path, pathB, kDifference_SkPathOp,"
|
|
||||||
" filename);\n");
|
|
||||||
str += sprintf(str, "}\n");
|
|
||||||
}
|
|
||||||
pathA.setFillType((SkPath::FillType) e);
|
pathA.setFillType((SkPath::FillType) e);
|
||||||
pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC),
|
pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC),
|
||||||
state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
|
state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
|
||||||
@ -50,13 +28,35 @@ static void testOpCirclesMain(PathOpsThreadState* data) {
|
|||||||
pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c),
|
pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c),
|
||||||
d ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
|
d ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
|
||||||
for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
|
for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
|
pathStr.printf("static void circlesOp%d(skiatest::Reporter* reporter,"
|
||||||
|
" const char* filename) {\n", loopNo);
|
||||||
|
pathStr.appendf(" SkPath path, pathB;\n");
|
||||||
|
pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n",
|
||||||
|
e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
|
||||||
|
? "EvenOdd" : "?UNDEFINED");
|
||||||
|
pathStr.appendf(" path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB,
|
||||||
|
state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
|
||||||
|
pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
|
||||||
|
f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
|
||||||
|
? "EvenOdd" : "?UNDEFINED");
|
||||||
|
pathStr.appendf(" pathB.addCircle(%d, %d, %d, %s);\n", a, b,
|
||||||
|
c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
|
||||||
|
pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
|
||||||
|
SkPathOpsDebug::OpStr((SkPathOp) op));
|
||||||
|
pathStr.appendf("}\n");
|
||||||
|
outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op);
|
||||||
|
}
|
||||||
|
if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "circles")) {
|
||||||
|
if (state.fReporter->verbose()) {
|
||||||
|
++loopNo;
|
||||||
|
goto skipToNext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "circles");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
skipToNext: ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "PathOpsExtendedTest.h"
|
#include "PathOpsExtendedTest.h"
|
||||||
#include "PathOpsThreadedCommon.h"
|
#include "PathOpsThreadedCommon.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
static int loopNo = 158;
|
static int loopNo = 158;
|
||||||
|
|
||||||
@ -15,11 +16,7 @@ static void testOpCubicsMain(PathOpsThreadState* data) {
|
|||||||
#endif
|
#endif
|
||||||
SkASSERT(data);
|
SkASSERT(data);
|
||||||
PathOpsThreadState& state = *data;
|
PathOpsThreadState& state = *data;
|
||||||
char pathStr[1024];
|
SkString pathStr;
|
||||||
bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
|
|
||||||
if (progress) {
|
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
|
||||||
}
|
|
||||||
for (int a = 0 ; a < 6; ++a) {
|
for (int a = 0 ; a < 6; ++a) {
|
||||||
for (int b = a + 1 ; b < 7; ++b) {
|
for (int b = a + 1 ; b < 7; ++b) {
|
||||||
for (int c = 0 ; c < 6; ++c) {
|
for (int c = 0 ; c < 6; ++c) {
|
||||||
@ -38,34 +35,31 @@ static void testOpCubicsMain(PathOpsThreadState* data) {
|
|||||||
SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC));
|
SkIntToScalar(state.fA), SkIntToScalar(state.fD), SkIntToScalar(state.fC));
|
||||||
pathB.close();
|
pathB.close();
|
||||||
for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
|
for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
|
pathStr.printf("static void cubicOp%d(skiatest::Reporter* reporter,"
|
||||||
}
|
|
||||||
if (progress) {
|
|
||||||
char* str = pathStr;
|
|
||||||
str += sprintf(str, "static void cubicOp%d(skiatest::Reporter* reporter,"
|
|
||||||
" const char* filename) {\n", loopNo);
|
" const char* filename) {\n", loopNo);
|
||||||
str += sprintf(str, " SkPath path, pathB;\n");
|
pathStr.appendf(" SkPath path, pathB;\n");
|
||||||
str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
|
pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n",
|
||||||
e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
|
e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
|
||||||
? "EvenOdd" : "?UNDEFINED");
|
? "EvenOdd" : "?UNDEFINED");
|
||||||
str += sprintf(str, " path.moveTo(%d,%d);\n", state.fA, state.fB);
|
pathStr.appendf(" path.moveTo(%d,%d);\n", state.fA, state.fB);
|
||||||
str += sprintf(str, " path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD,
|
pathStr.appendf(" path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD,
|
||||||
b, a, d, c);
|
b, a, d, c);
|
||||||
str += sprintf(str, " path.close();\n");
|
pathStr.appendf(" path.close();\n");
|
||||||
str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
|
pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
|
||||||
f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
|
f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
|
||||||
? "EvenOdd" : "?UNDEFINED");
|
? "EvenOdd" : "?UNDEFINED");
|
||||||
str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b);
|
pathStr.appendf(" pathB.moveTo(%d,%d);\n", a, b);
|
||||||
str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
|
pathStr.appendf(" pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d,
|
||||||
state.fB, state.fA, state.fD, state.fC);
|
state.fB, state.fA, state.fD, state.fC);
|
||||||
str += sprintf(str, " pathB.close();\n");
|
pathStr.appendf(" pathB.close();\n");
|
||||||
str += sprintf(str, " testPathOp(reporter, path, pathB, %s, filename);\n",
|
pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
|
||||||
SkPathOpsDebug::OpStr((SkPathOp) op));
|
SkPathOpsDebug::OpStr((SkPathOp) op));
|
||||||
str += sprintf(str, "}\n");
|
pathStr.appendf("}\n");
|
||||||
|
outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op);
|
||||||
}
|
}
|
||||||
if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubics")) {
|
if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "cubics")) {
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
++loopNo;
|
++loopNo;
|
||||||
goto skipToNext;
|
goto skipToNext;
|
||||||
}
|
}
|
||||||
|
@ -6,23 +6,24 @@
|
|||||||
*/
|
*/
|
||||||
#include "PathOpsExtendedTest.h"
|
#include "PathOpsExtendedTest.h"
|
||||||
#include "PathOpsThreadedCommon.h"
|
#include "PathOpsThreadedCommon.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
static int add_point(char* str, SkScalar x, SkScalar y) {
|
static int loopNo = 17;
|
||||||
int result;
|
|
||||||
|
static void add_point(SkString* str, SkScalar x, SkScalar y) {
|
||||||
int asInt = SkScalarRoundToInt(x);
|
int asInt = SkScalarRoundToInt(x);
|
||||||
if (SkIntToScalar(asInt) == x) {
|
if (SkIntToScalar(asInt) == x) {
|
||||||
result = sprintf(str, "%d", asInt);
|
str->appendf("%d", asInt);
|
||||||
} else {
|
} else {
|
||||||
result = sprintf(str, "%1.9gf", x);
|
str->appendf("%1.9gf", x);
|
||||||
}
|
}
|
||||||
result += sprintf(str + result, ",");
|
str->appendf(",");
|
||||||
asInt = SkScalarRoundToInt(y);
|
asInt = SkScalarRoundToInt(y);
|
||||||
if (SkIntToScalar(asInt) == y) {
|
if (SkIntToScalar(asInt) == y) {
|
||||||
result += sprintf(str + result, "%d", asInt);
|
str->appendf("%d", asInt);
|
||||||
} else {
|
} else {
|
||||||
result += sprintf(str + result, "%1.9gf", y);
|
str->appendf("%1.9gf", y);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void testOpLoopsMain(PathOpsThreadState* data) {
|
static void testOpLoopsMain(PathOpsThreadState* data) {
|
||||||
@ -31,11 +32,7 @@ static void testOpLoopsMain(PathOpsThreadState* data) {
|
|||||||
#endif
|
#endif
|
||||||
SkASSERT(data);
|
SkASSERT(data);
|
||||||
PathOpsThreadState& state = *data;
|
PathOpsThreadState& state = *data;
|
||||||
char pathStr[1024]; // gdb: set print elements 400
|
SkString pathStr;
|
||||||
bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
|
|
||||||
if (progress) {
|
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
|
||||||
}
|
|
||||||
for (int a = 0 ; a < 6; ++a) {
|
for (int a = 0 ; a < 6; ++a) {
|
||||||
for (int b = a + 1 ; b < 7; ++b) {
|
for (int b = a + 1 ; b < 7; ++b) {
|
||||||
for (int c = 0 ; c < 6; ++c) {
|
for (int c = 0 ; c < 6; ++c) {
|
||||||
@ -51,30 +48,6 @@ static void testOpLoopsMain(PathOpsThreadState* data) {
|
|||||||
SkPoint endD = { midB.fX - v.fY * state.fD / 3,
|
SkPoint endD = { midB.fX - v.fY * state.fD / 3,
|
||||||
midB.fY + v.fX * state.fD / 3 };
|
midB.fY + v.fX * state.fD / 3 };
|
||||||
SkPath pathA, pathB;
|
SkPath pathA, pathB;
|
||||||
if (progress) {
|
|
||||||
char* str = pathStr;
|
|
||||||
const int loopNo = 17;
|
|
||||||
str += sprintf(str, "static void loop%d(skiatest::Reporter* reporter,"
|
|
||||||
" const char* filename) {\n", loopNo);
|
|
||||||
str += sprintf(str, " SkPath path, pathB;\n");
|
|
||||||
str += sprintf(str, " path.moveTo(%d,%d);\n", a, b);
|
|
||||||
str += sprintf(str, " path.cubicTo(%d,%d, ", c, d);
|
|
||||||
str += add_point(str, endC.fX, endC.fY);
|
|
||||||
str += sprintf(str, ", ");
|
|
||||||
str += add_point(str, endD.fX, endD.fY);
|
|
||||||
str += sprintf(str, ");\n");
|
|
||||||
str += sprintf(str, " path.close();\n");
|
|
||||||
str += sprintf(str, " pathB.moveTo(%d,%d);\n", c, d);
|
|
||||||
str += sprintf(str, " pathB.cubicTo(");
|
|
||||||
str += add_point(str, endC.fX, endC.fY);
|
|
||||||
str += sprintf(str, ", ");
|
|
||||||
str += add_point(str, endD.fX, endD.fY);
|
|
||||||
str += sprintf(str, ", %d,%d);\n", a, b);
|
|
||||||
str += sprintf(str, " pathB.close();\n");
|
|
||||||
str += sprintf(str, " testPathOp(reporter, path, pathB, kIntersect_SkPathOp,"
|
|
||||||
" filename);\n");
|
|
||||||
str += sprintf(str, "}\n");
|
|
||||||
}
|
|
||||||
pathA.moveTo(SkIntToScalar(a), SkIntToScalar(b));
|
pathA.moveTo(SkIntToScalar(a), SkIntToScalar(b));
|
||||||
pathA.cubicTo(SkIntToScalar(c), SkIntToScalar(d), endC.fX, endC.fY, endD.fX, endD.fY);
|
pathA.cubicTo(SkIntToScalar(c), SkIntToScalar(d), endC.fX, endC.fY, endD.fX, endD.fY);
|
||||||
pathA.close();
|
pathA.close();
|
||||||
@ -82,8 +55,28 @@ static void testOpLoopsMain(PathOpsThreadState* data) {
|
|||||||
pathB.cubicTo(endC.fX, endC.fY, endD.fX, endD.fY, SkIntToScalar(a), SkIntToScalar(b));
|
pathB.cubicTo(endC.fX, endC.fY, endD.fX, endD.fY, SkIntToScalar(a), SkIntToScalar(b));
|
||||||
pathB.close();
|
pathB.close();
|
||||||
// SkDebugf("%s\n", pathStr);
|
// SkDebugf("%s\n", pathStr);
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, kIntersect_SkPathOp);
|
pathStr.printf("static void loop%d(skiatest::Reporter* reporter,"
|
||||||
|
" const char* filename) {\n", loopNo);
|
||||||
|
pathStr.appendf(" SkPath path, pathB;\n");
|
||||||
|
pathStr.appendf(" path.moveTo(%d,%d);\n", a, b);
|
||||||
|
pathStr.appendf(" path.cubicTo(%d,%d, ", c, d);
|
||||||
|
add_point(&pathStr, endC.fX, endC.fY);
|
||||||
|
pathStr.appendf(", ");
|
||||||
|
add_point(&pathStr, endD.fX, endD.fY);
|
||||||
|
pathStr.appendf(");\n");
|
||||||
|
pathStr.appendf(" path.close();\n");
|
||||||
|
pathStr.appendf(" pathB.moveTo(%d,%d);\n", c, d);
|
||||||
|
pathStr.appendf(" pathB.cubicTo(");
|
||||||
|
add_point(&pathStr, endC.fX, endC.fY);
|
||||||
|
pathStr.appendf(", ");
|
||||||
|
add_point(&pathStr, endD.fX, endD.fY);
|
||||||
|
pathStr.appendf(", %d,%d);\n", a, b);
|
||||||
|
pathStr.appendf(" pathB.close();\n");
|
||||||
|
pathStr.appendf(" testPathOp(reporter, path, pathB, kIntersect_SkPathOp,"
|
||||||
|
" filename);\n");
|
||||||
|
pathStr.appendf("}\n");
|
||||||
|
outputProgress(state.fPathStr, pathStr.c_str(), kIntersect_SkPathOp);
|
||||||
}
|
}
|
||||||
testPathOp(state.fReporter, pathA, pathB, kIntersect_SkPathOp, "loops");
|
testPathOp(state.fReporter, pathA, pathB, kIntersect_SkPathOp, "loops");
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "PathOpsExtendedTest.h"
|
#include "PathOpsExtendedTest.h"
|
||||||
#include "PathOpsThreadedCommon.h"
|
#include "PathOpsThreadedCommon.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
// four rects, of four sizes
|
// four rects, of four sizes
|
||||||
// for 3 smaller sizes, tall, wide
|
// for 3 smaller sizes, tall, wide
|
||||||
@ -14,46 +15,19 @@
|
|||||||
// not included, square, tall, wide (2 bits)
|
// not included, square, tall, wide (2 bits)
|
||||||
// cw or ccw (1 bit)
|
// cw or ccw (1 bit)
|
||||||
|
|
||||||
|
static int loopNo = 6;
|
||||||
|
|
||||||
static void testPathOpsRectsMain(PathOpsThreadState* data)
|
static void testPathOpsRectsMain(PathOpsThreadState* data)
|
||||||
{
|
{
|
||||||
SkASSERT(data);
|
SkASSERT(data);
|
||||||
PathOpsThreadState& state = *data;
|
PathOpsThreadState& state = *data;
|
||||||
char pathStr[1024]; // gdb: set print elements 400
|
SkString pathStr;
|
||||||
bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
|
|
||||||
if (progress) {
|
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
|
||||||
}
|
|
||||||
for (int a = 0 ; a < 6; ++a) {
|
for (int a = 0 ; a < 6; ++a) {
|
||||||
for (int b = a + 1 ; b < 7; ++b) {
|
for (int b = a + 1 ; b < 7; ++b) {
|
||||||
for (int c = 0 ; c < 6; ++c) {
|
for (int c = 0 ; c < 6; ++c) {
|
||||||
for (int d = c + 1 ; d < 7; ++d) {
|
for (int d = c + 1 ; d < 7; ++d) {
|
||||||
for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
|
for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
|
||||||
for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
|
for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
|
||||||
static int testNum = 6;
|
|
||||||
if (progress) {
|
|
||||||
char* str = pathStr;
|
|
||||||
str += sprintf(str,
|
|
||||||
"static void rects%d(skiatest::Reporter* reporter, const char* filename) {\n",
|
|
||||||
testNum);
|
|
||||||
str += sprintf(str, " SkPath path, pathB;");
|
|
||||||
str += sprintf(str, " path.setFillType(SkPath::k%s_FillType);\n",
|
|
||||||
e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
|
|
||||||
? "EvenOdd" : "?UNDEFINED");
|
|
||||||
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
|
||||||
" SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB);
|
|
||||||
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
|
||||||
" SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD);
|
|
||||||
str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n",
|
|
||||||
f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
|
|
||||||
? "EvenOdd" : "?UNDEFINED");
|
|
||||||
str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
|
|
||||||
" SkPath::kCW_Direction);\n", a, a, b, b);
|
|
||||||
str += sprintf(str, " pathB.addRect(%d, %d, %d, %d,"
|
|
||||||
" SkPath::kCW_Direction);\n", c, c, d, d);
|
|
||||||
str += sprintf(str,
|
|
||||||
" testPathOp(reporter, path, pathB, kDifference_SkPathOp, filename);\n");
|
|
||||||
str += sprintf(str, "}\n\n");
|
|
||||||
}
|
|
||||||
SkPath pathA, pathB;
|
SkPath pathA, pathB;
|
||||||
pathA.setFillType((SkPath::FillType) e);
|
pathA.setFillType((SkPath::FillType) e);
|
||||||
pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB),
|
pathA.addRect(SkIntToScalar(state.fA), SkIntToScalar(state.fA), SkIntToScalar(state.fB),
|
||||||
@ -68,13 +42,40 @@ static void testPathOpsRectsMain(PathOpsThreadState* data)
|
|||||||
SkIntToScalar(d), SkPath::kCW_Direction);
|
SkIntToScalar(d), SkPath::kCW_Direction);
|
||||||
pathB.close();
|
pathB.close();
|
||||||
for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
|
for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, (SkPathOp) op);
|
pathStr.printf(
|
||||||
|
"static void rects%d(skiatest::Reporter* reporter,"
|
||||||
|
"const char* filename) {\n", loopNo);
|
||||||
|
pathStr.appendf(" SkPath path, pathB;");
|
||||||
|
pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n",
|
||||||
|
e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
|
||||||
|
? "EvenOdd" : "?UNDEFINED");
|
||||||
|
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
|
||||||
|
" SkPath::kCW_Direction);\n", state.fA, state.fA, state.fB, state.fB);
|
||||||
|
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
|
||||||
|
" SkPath::kCW_Direction);\n", state.fC, state.fC, state.fD, state.fD);
|
||||||
|
pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
|
||||||
|
f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
|
||||||
|
? "EvenOdd" : "?UNDEFINED");
|
||||||
|
pathStr.appendf(" pathB.addRect(%d, %d, %d, %d,"
|
||||||
|
" SkPath::kCW_Direction);\n", a, a, b, b);
|
||||||
|
pathStr.appendf(" pathB.addRect(%d, %d, %d, %d,"
|
||||||
|
" SkPath::kCW_Direction);\n", c, c, d, d);
|
||||||
|
pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
|
||||||
|
SkPathOpsDebug::OpStr((SkPathOp) op));
|
||||||
|
pathStr.appendf("}\n\n");
|
||||||
|
outputProgress(state.fPathStr, pathStr.c_str(), (SkPathOp) op);
|
||||||
|
}
|
||||||
|
if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "rects")) {
|
||||||
|
if (state.fReporter->verbose()) {
|
||||||
|
++loopNo;
|
||||||
|
goto skipToNext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, "rects");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
skipToNext: ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "SkPathOpsLine.h"
|
#include "SkPathOpsLine.h"
|
||||||
#include "SkPathOpsQuad.h"
|
#include "SkPathOpsQuad.h"
|
||||||
#include "SkReduceOrder.h"
|
#include "SkReduceOrder.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, const SkDLine& line,
|
static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, const SkDLine& line,
|
||||||
bool& flipped) {
|
bool& flipped) {
|
||||||
@ -40,14 +41,12 @@ static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, cons
|
|||||||
|
|
||||||
static void testLineIntersect(skiatest::Reporter* reporter, const SkDQuad& quad,
|
static void testLineIntersect(skiatest::Reporter* reporter, const SkDQuad& quad,
|
||||||
const SkDLine& line, const double x, const double y) {
|
const SkDLine& line, const double x, const double y) {
|
||||||
char pathStr[1024];
|
SkString pathStr;
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
pathStr.appendf(" path.moveTo(%1.9g, %1.9g);\n", quad[0].fX, quad[0].fY);
|
||||||
char* str = pathStr;
|
pathStr.appendf(" path.quadTo(%1.9g, %1.9g, %1.9g, %1.9g);\n", quad[1].fX,
|
||||||
str += sprintf(str, " path.moveTo(%1.9g, %1.9g);\n", quad[0].fX, quad[0].fY);
|
|
||||||
str += sprintf(str, " path.quadTo(%1.9g, %1.9g, %1.9g, %1.9g);\n", quad[1].fX,
|
|
||||||
quad[1].fY, quad[2].fX, quad[2].fY);
|
quad[1].fY, quad[2].fX, quad[2].fY);
|
||||||
str += sprintf(str, " path.moveTo(%1.9g, %1.9g);\n", line[0].fX, line[0].fY);
|
pathStr.appendf(" path.moveTo(%1.9g, %1.9g);\n", line[0].fX, line[0].fY);
|
||||||
str += sprintf(str, " path.lineTo(%1.9g, %1.9g);\n", line[1].fX, line[1].fY);
|
pathStr.appendf(" path.lineTo(%1.9g, %1.9g);\n", line[1].fX, line[1].fY);
|
||||||
|
|
||||||
SkIntersections intersections;
|
SkIntersections intersections;
|
||||||
bool flipped = false;
|
bool flipped = false;
|
||||||
|
@ -6,15 +6,11 @@
|
|||||||
*/
|
*/
|
||||||
#include "PathOpsExtendedTest.h"
|
#include "PathOpsExtendedTest.h"
|
||||||
#include "PathOpsThreadedCommon.h"
|
#include "PathOpsThreadedCommon.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
static void testSimplifyDegeneratesMain(PathOpsThreadState* data) {
|
static void testSimplifyDegeneratesMain(PathOpsThreadState* data) {
|
||||||
SkASSERT(data);
|
SkASSERT(data);
|
||||||
PathOpsThreadState& state = *data;
|
PathOpsThreadState& state = *data;
|
||||||
char pathStr[1024];
|
|
||||||
bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
|
|
||||||
if (progress) {
|
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
|
||||||
}
|
|
||||||
int ax = state.fA & 0x03;
|
int ax = state.fA & 0x03;
|
||||||
int ay = state.fA >> 2;
|
int ay = state.fA >> 2;
|
||||||
int bx = state.fB & 0x03;
|
int bx = state.fB & 0x03;
|
||||||
@ -34,6 +30,7 @@ static void testSimplifyDegeneratesMain(PathOpsThreadState* data) {
|
|||||||
!= (ey - dy) * (fx - dx)) {
|
!= (ey - dy) * (fx - dx)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
SkString pathStr;
|
||||||
SkPath path, out;
|
SkPath path, out;
|
||||||
path.setFillType(SkPath::kWinding_FillType);
|
path.setFillType(SkPath::kWinding_FillType);
|
||||||
path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
|
path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
|
||||||
@ -44,24 +41,23 @@ static void testSimplifyDegeneratesMain(PathOpsThreadState* data) {
|
|||||||
path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey));
|
path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey));
|
||||||
path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
|
path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
|
||||||
path.close();
|
path.close();
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
char* str = pathStr;
|
pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay);
|
||||||
str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", bx, by);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", cx, cy);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy);
|
pathStr.appendf(" path.close();\n");
|
||||||
str += sprintf(str, " path.close();\n");
|
pathStr.appendf(" path.moveTo(%d, %d);\n", dx, dy);
|
||||||
str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", ex, ey);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
|
pathStr.appendf(" path.close();\n");
|
||||||
str += sprintf(str, " path.close();\n");
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
|
|
||||||
}
|
}
|
||||||
testSimplify(path, false, out, state, pathStr);
|
testSimplify(path, false, out, state, pathStr.c_str());
|
||||||
path.setFillType(SkPath::kEvenOdd_FillType);
|
path.setFillType(SkPath::kEvenOdd_FillType);
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
|
||||||
}
|
}
|
||||||
testSimplify(path, true, out, state, pathStr);
|
testSimplify(path, true, out, state, pathStr.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,15 @@
|
|||||||
*/
|
*/
|
||||||
#include "PathOpsExtendedTest.h"
|
#include "PathOpsExtendedTest.h"
|
||||||
#include "PathOpsThreadedCommon.h"
|
#include "PathOpsThreadedCommon.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
|
static int quadTest = 66;
|
||||||
|
|
||||||
static void testSimplifyQuadsMain(PathOpsThreadState* data)
|
static void testSimplifyQuadsMain(PathOpsThreadState* data)
|
||||||
{
|
{
|
||||||
SkASSERT(data);
|
SkASSERT(data);
|
||||||
PathOpsThreadState& state = *data;
|
PathOpsThreadState& state = *data;
|
||||||
char pathStr[1024];
|
SkString pathStr;
|
||||||
bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
|
|
||||||
if (progress) {
|
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
|
||||||
}
|
|
||||||
int ax = state.fA & 0x03;
|
int ax = state.fA & 0x03;
|
||||||
int ay = state.fA >> 2;
|
int ay = state.fA >> 2;
|
||||||
int bx = state.fB & 0x03;
|
int bx = state.fB & 0x03;
|
||||||
@ -48,30 +47,28 @@ static void testSimplifyQuadsMain(PathOpsThreadState* data)
|
|||||||
path.quadTo(SkIntToScalar(gx), SkIntToScalar(gy),
|
path.quadTo(SkIntToScalar(gx), SkIntToScalar(gy),
|
||||||
SkIntToScalar(hx), SkIntToScalar(hy));
|
SkIntToScalar(hx), SkIntToScalar(hy));
|
||||||
path.close();
|
path.close();
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
static int quadTest = 66;
|
pathStr.printf("static void testQuads%d(skiatest::Reporter* reporter,"
|
||||||
char* str = pathStr;
|
|
||||||
str += sprintf(str, "static void testQuads%d(skiatest::Reporter* reporter,"
|
|
||||||
"const char* filename) {\n", quadTest);
|
"const char* filename) {\n", quadTest);
|
||||||
str += sprintf(str, " SkPath path;\n");
|
pathStr.appendf(" SkPath path;\n");
|
||||||
str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay);
|
pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay);
|
||||||
str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy);
|
pathStr.appendf(" path.quadTo(%d, %d, %d, %d);\n", bx, by, cx, cy);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", dx, dy);
|
||||||
str += sprintf(str, " path.close();\n");
|
pathStr.appendf(" path.close();\n");
|
||||||
str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey);
|
pathStr.appendf(" path.moveTo(%d, %d);\n", ex, ey);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy);
|
||||||
str += sprintf(str, " path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy);
|
pathStr.appendf(" path.quadTo(%d, %d, %d, %d);\n", gx, gy, hx, hy);
|
||||||
str += sprintf(str, " path.close();\n");
|
pathStr.appendf(" path.close();\n");
|
||||||
str += sprintf(str, " testSimplify(reporter, path, filename);\n");
|
pathStr.appendf(" testSimplify(reporter, path, filename);\n");
|
||||||
str += sprintf(str, "}\n");
|
pathStr.appendf("}\n");
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
|
||||||
}
|
}
|
||||||
testSimplify(path, false, out, state, pathStr);
|
testSimplify(path, false, out, state, pathStr.c_str());
|
||||||
path.setFillType(SkPath::kEvenOdd_FillType);
|
path.setFillType(SkPath::kEvenOdd_FillType);
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
|
||||||
}
|
}
|
||||||
testSimplify(path, true, out, state, pathStr);
|
testSimplify(path, true, out, state, pathStr.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,15 @@
|
|||||||
*/
|
*/
|
||||||
#include "PathOpsExtendedTest.h"
|
#include "PathOpsExtendedTest.h"
|
||||||
#include "PathOpsThreadedCommon.h"
|
#include "PathOpsThreadedCommon.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
|
static int loopNo = 1;
|
||||||
|
|
||||||
static void testSimplifyQuadralateralsMain(PathOpsThreadState* data)
|
static void testSimplifyQuadralateralsMain(PathOpsThreadState* data)
|
||||||
{
|
{
|
||||||
SkASSERT(data);
|
SkASSERT(data);
|
||||||
PathOpsThreadState& state = *data;
|
PathOpsThreadState& state = *data;
|
||||||
char pathStr[1024];
|
SkString pathStr;
|
||||||
bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
|
|
||||||
if (progress) {
|
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
|
||||||
}
|
|
||||||
int ax = state.fA & 0x03;
|
int ax = state.fA & 0x03;
|
||||||
int ay = state.fA >> 2;
|
int ay = state.fA >> 2;
|
||||||
int bx = state.fB & 0x03;
|
int bx = state.fB & 0x03;
|
||||||
@ -48,27 +47,30 @@ static void testSimplifyQuadralateralsMain(PathOpsThreadState* data)
|
|||||||
path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy));
|
path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy));
|
||||||
path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy));
|
path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy));
|
||||||
path.close();
|
path.close();
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
// gdb: set print elements 400
|
pathStr.printf("static void quadralateralSimplify%d(skiatest::Reporter*"
|
||||||
char* str = pathStr;
|
"reporter, const char* filename) {\n", loopNo);
|
||||||
str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay);
|
pathStr.appendf(" SkPath path;\n");
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by);
|
pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", bx, by);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", cx, cy);
|
||||||
str += sprintf(str, " path.close();\n");
|
pathStr.appendf(" path.lineTo(%d, %d);\n", dx, dy);
|
||||||
str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey);
|
pathStr.appendf(" path.close();\n");
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
|
pathStr.appendf(" path.moveTo(%d, %d);\n", ex, ey);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", gx, gy);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", hx, hy);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", gx, gy);
|
||||||
str += sprintf(str, " path.close();\n");
|
pathStr.appendf(" path.lineTo(%d, %d);\n", hx, hy);
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
|
pathStr.appendf(" path.close();\n");
|
||||||
|
pathStr.appendf(" testPathSimplify(reporter, path, filename);\n");
|
||||||
|
pathStr.appendf("}\n");
|
||||||
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
|
||||||
}
|
}
|
||||||
testSimplify(path, false, out, state, pathStr);
|
testSimplify(path, false, out, state, pathStr.c_str());
|
||||||
path.setFillType(SkPath::kEvenOdd_FillType);
|
path.setFillType(SkPath::kEvenOdd_FillType);
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
|
||||||
}
|
}
|
||||||
testSimplify(path, true, out, state, pathStr);
|
testSimplify(path, true, out, state, pathStr.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "PathOpsExtendedTest.h"
|
#include "PathOpsExtendedTest.h"
|
||||||
#include "PathOpsThreadedCommon.h"
|
#include "PathOpsThreadedCommon.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
// four rects, of four sizes
|
// four rects, of four sizes
|
||||||
// for 3 smaller sizes, tall, wide
|
// for 3 smaller sizes, tall, wide
|
||||||
@ -18,11 +19,6 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
|
|||||||
{
|
{
|
||||||
SkASSERT(data);
|
SkASSERT(data);
|
||||||
PathOpsThreadState& state = *data;
|
PathOpsThreadState& state = *data;
|
||||||
char pathStr[1024]; // gdb: set print elements 400
|
|
||||||
bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
|
|
||||||
if (progress) {
|
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
|
||||||
}
|
|
||||||
int aShape = state.fA & 0x03;
|
int aShape = state.fA & 0x03;
|
||||||
SkPath::Direction aCW = state.fA >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
|
SkPath::Direction aCW = state.fA >> 2 ? SkPath::kCCW_Direction : SkPath::kCW_Direction;
|
||||||
int bShape = state.fB & 0x03;
|
int bShape = state.fB & 0x03;
|
||||||
@ -39,8 +35,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
|
|||||||
for (int cYAlign = 0; cYAlign < 5; ++cYAlign) {
|
for (int cYAlign = 0; cYAlign < 5; ++cYAlign) {
|
||||||
for (int dXAlign = 0; dXAlign < 5; ++dXAlign) {
|
for (int dXAlign = 0; dXAlign < 5; ++dXAlign) {
|
||||||
for (int dYAlign = 0; dYAlign < 5; ++dYAlign) {
|
for (int dYAlign = 0; dYAlign < 5; ++dYAlign) {
|
||||||
|
SkString pathStr;
|
||||||
SkPath path, out;
|
SkPath path, out;
|
||||||
char* str = pathStr;
|
|
||||||
path.setFillType(SkPath::kWinding_FillType);
|
path.setFillType(SkPath::kWinding_FillType);
|
||||||
int l SK_INIT_TO_AVOID_WARNING, t SK_INIT_TO_AVOID_WARNING,
|
int l SK_INIT_TO_AVOID_WARNING, t SK_INIT_TO_AVOID_WARNING,
|
||||||
r SK_INIT_TO_AVOID_WARNING, b SK_INIT_TO_AVOID_WARNING;
|
r SK_INIT_TO_AVOID_WARNING, b SK_INIT_TO_AVOID_WARNING;
|
||||||
@ -67,8 +63,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
|
|||||||
}
|
}
|
||||||
path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
|
path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
|
||||||
aCW);
|
aCW);
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
|
||||||
" SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" : "");
|
" SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" : "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -98,8 +94,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
|
|||||||
}
|
}
|
||||||
path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
|
path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
|
||||||
bCW);
|
bCW);
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
|
||||||
" SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" : "");
|
" SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" : "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -129,8 +125,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
|
|||||||
}
|
}
|
||||||
path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
|
path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
|
||||||
cCW);
|
cCW);
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
|
||||||
" SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" : "");
|
" SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" : "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -160,8 +156,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
|
|||||||
}
|
}
|
||||||
path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
|
path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), SkIntToScalar(b),
|
||||||
dCW);
|
dCW);
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
str += sprintf(str, " path.addRect(%d, %d, %d, %d,"
|
pathStr.appendf(" path.addRect(%d, %d, %d, %d,"
|
||||||
" SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" : "");
|
" SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" : "");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -169,14 +165,14 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
|
|||||||
dYAlign = 5;
|
dYAlign = 5;
|
||||||
}
|
}
|
||||||
path.close();
|
path.close();
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
|
||||||
}
|
}
|
||||||
testSimplify(path, false, out, state, pathStr);
|
testSimplify(path, false, out, state, pathStr.c_str());
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
|
||||||
}
|
}
|
||||||
testSimplify(path, true, out, state, pathStr);
|
testSimplify(path, true, out, state, pathStr.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,11 @@
|
|||||||
*/
|
*/
|
||||||
#include "PathOpsExtendedTest.h"
|
#include "PathOpsExtendedTest.h"
|
||||||
#include "PathOpsThreadedCommon.h"
|
#include "PathOpsThreadedCommon.h"
|
||||||
|
#include "SkString.h"
|
||||||
|
|
||||||
static void testSimplifyTrianglesMain(PathOpsThreadState* data) {
|
static void testSimplifyTrianglesMain(PathOpsThreadState* data) {
|
||||||
SkASSERT(data);
|
SkASSERT(data);
|
||||||
PathOpsThreadState& state = *data;
|
PathOpsThreadState& state = *data;
|
||||||
char pathStr[1024];
|
|
||||||
bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter?
|
|
||||||
if (progress) {
|
|
||||||
sk_bzero(pathStr, sizeof(pathStr));
|
|
||||||
}
|
|
||||||
state.fKey = "?";
|
state.fKey = "?";
|
||||||
int ax = state.fA & 0x03;
|
int ax = state.fA & 0x03;
|
||||||
int ay = state.fA >> 2;
|
int ay = state.fA >> 2;
|
||||||
@ -37,6 +33,7 @@ static void testSimplifyTrianglesMain(PathOpsThreadState* data) {
|
|||||||
if ((ex - dx) * (fy - dy) == (ey - dy) * (fx - dx)) {
|
if ((ex - dx) * (fy - dy) == (ey - dy) * (fx - dx)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
SkString pathStr;
|
||||||
SkPath path, out;
|
SkPath path, out;
|
||||||
path.setFillType(SkPath::kWinding_FillType);
|
path.setFillType(SkPath::kWinding_FillType);
|
||||||
path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
|
path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay));
|
||||||
@ -47,26 +44,25 @@ static void testSimplifyTrianglesMain(PathOpsThreadState* data) {
|
|||||||
path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey));
|
path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey));
|
||||||
path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
|
path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy));
|
||||||
path.close();
|
path.close();
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
char* str = pathStr;
|
pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay);
|
||||||
str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", bx, by);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", cx, cy);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy);
|
pathStr.appendf(" path.close();\n");
|
||||||
str += sprintf(str, " path.close();\n");
|
pathStr.appendf(" path.moveTo(%d, %d);\n", dx, dy);
|
||||||
str += sprintf(str, " path.moveTo(%d, %d);\n", dx, dy);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", ex, ey);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", ex, ey);
|
pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy);
|
||||||
str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy);
|
pathStr.appendf(" path.close();\n");
|
||||||
str += sprintf(str, " path.close();\n");
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kWinding_FillType);
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType);
|
|
||||||
}
|
}
|
||||||
ShowTestName(&state, d, e, f, 0);
|
ShowTestName(&state, d, e, f, 0);
|
||||||
testSimplify(path, false, out, state, pathStr);
|
testSimplify(path, false, out, state, pathStr.c_str());
|
||||||
path.setFillType(SkPath::kEvenOdd_FillType);
|
path.setFillType(SkPath::kEvenOdd_FillType);
|
||||||
if (progress) {
|
if (state.fReporter->verbose()) {
|
||||||
outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType);
|
outputProgress(state.fPathStr, pathStr.c_str(), SkPath::kEvenOdd_FillType);
|
||||||
}
|
}
|
||||||
ShowTestName(&state, d, e, f, 1);
|
ShowTestName(&state, d, e, f, 1);
|
||||||
testSimplify(path, true, out, state, pathStr);
|
testSimplify(path, true, out, state, pathStr.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user