diff options
author | caryclark <caryclark@google.com> | 2016-10-06 11:46:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-06 11:46:25 -0700 |
commit | 8f1864386734cfa7650a5576ba453745a407ade2 (patch) | |
tree | 413e5df77a872a26e02dc4b64ef191e6df4948f1 /tests/PathOpsOpCubicThreadedTest.cpp | |
parent | 33cbfd75afdd383770bb6253c06ba819a2481a35 (diff) |
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
Diffstat (limited to 'tests/PathOpsOpCubicThreadedTest.cpp')
-rw-r--r-- | tests/PathOpsOpCubicThreadedTest.cpp | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/tests/PathOpsOpCubicThreadedTest.cpp b/tests/PathOpsOpCubicThreadedTest.cpp index 2c0c3d372d..e76eb06477 100644 --- a/tests/PathOpsOpCubicThreadedTest.cpp +++ b/tests/PathOpsOpCubicThreadedTest.cpp @@ -6,6 +6,7 @@ */ #include "PathOpsExtendedTest.h" #include "PathOpsThreadedCommon.h" +#include "SkString.h" static int loopNo = 158; @@ -15,11 +16,7 @@ static void testOpCubicsMain(PathOpsThreadState* data) { #endif SkASSERT(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)); - } + SkString pathStr; for (int a = 0 ; a < 6; ++a) { for (int b = a + 1 ; b < 7; ++b) { 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)); pathB.close(); for (int op = 0 ; op <= kXOR_SkPathOp; ++op) { - if (progress) { - outputProgress(state.fPathStr, pathStr, (SkPathOp) op); - } - if (progress) { - char* str = pathStr; - str += sprintf(str, "static void cubicOp%d(skiatest::Reporter* reporter," + if (state.fReporter->verbose()) { + pathStr.printf("static void cubicOp%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", + 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"); - str += sprintf(str, " 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.moveTo(%d,%d);\n", state.fA, state.fB); + pathStr.appendf(" path.cubicTo(%d,%d, %d,%d, %d,%d);\n", state.fC, state.fD, b, a, d, c); - str += sprintf(str, " path.close();\n"); - str += sprintf(str, " pathB.setFillType(SkPath::k%s_FillType);\n", + pathStr.appendf(" path.close();\n"); + pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n", f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType ? "EvenOdd" : "?UNDEFINED"); - str += sprintf(str, " pathB.moveTo(%d,%d);\n", a, b); - str += sprintf(str, " pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d, + pathStr.appendf(" pathB.moveTo(%d,%d);\n", a, b); + pathStr.appendf(" pathB.cubicTo(%d,%d, %d,%d, %d,%d);\n", c, d, state.fB, state.fA, state.fD, state.fC); - str += sprintf(str, " pathB.close();\n"); - str += sprintf(str, " testPathOp(reporter, path, pathB, %s, filename);\n", + pathStr.appendf(" pathB.close();\n"); + pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n", 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 (progress) { + if (state.fReporter->verbose()) { ++loopNo; goto skipToNext; } |