 Chromium Code Reviews
 Chromium Code Reviews Issue 2391133005:
  remove sprintf  (Closed)
    
  
    Issue 2391133005:
  remove sprintf  (Closed) 
  | OLD | NEW | 
|---|---|
| 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 "SkString.h" | |
| 10 | |
| 11 static int loopNo = 1; | |
| 
scroggo
2016/10/06 14:42:00
nit: gLoopNo
 | |
| 9 | 12 | 
| 10 static void testSimplifyQuadralateralsMain(PathOpsThreadState* data) | 13 static void testSimplifyQuadralateralsMain(PathOpsThreadState* data) | 
| 11 { | 14 { | 
| 12 SkASSERT(data); | 15 SkASSERT(data); | 
| 13 PathOpsThreadState& state = *data; | 16 PathOpsThreadState& state = *data; | 
| 14 char pathStr[1024]; | 17 SkString pathStr; | 
| 15 bool progress = state.fReporter->verbose(); // FIXME: break out into its own parameter? | |
| 16 if (progress) { | |
| 17 sk_bzero(pathStr, sizeof(pathStr)); | |
| 18 } | |
| 19 int ax = state.fA & 0x03; | 18 int ax = state.fA & 0x03; | 
| 20 int ay = state.fA >> 2; | 19 int ay = state.fA >> 2; | 
| 21 int bx = state.fB & 0x03; | 20 int bx = state.fB & 0x03; | 
| 22 int by = state.fB >> 2; | 21 int by = state.fB >> 2; | 
| 23 int cx = state.fC & 0x03; | 22 int cx = state.fC & 0x03; | 
| 24 int cy = state.fC >> 2; | 23 int cy = state.fC >> 2; | 
| 25 int dx = state.fD & 0x03; | 24 int dx = state.fD & 0x03; | 
| 26 int dy = state.fD >> 2; | 25 int dy = state.fD >> 2; | 
| 27 for (int e = 0 ; e < 16; ++e) { | 26 for (int e = 0 ; e < 16; ++e) { | 
| 28 int ex = e & 0x03; | 27 int ex = e & 0x03; | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 41 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); | 40 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); | 
| 42 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); | 41 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); | 
| 43 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); | 42 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); | 
| 44 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy)); | 43 path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy)); | 
| 45 path.close(); | 44 path.close(); | 
| 46 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey)); | 45 path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey)); | 
| 47 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); | 46 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); | 
| 48 path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy)); | 47 path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy)); | 
| 49 path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy)); | 48 path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy)); | 
| 50 path.close(); | 49 path.close(); | 
| 51 if (progress) { | 50 if (state.fReporter->verbose()) { | 
| 52 // gdb: set print elements 400 | 51 pathStr.printf("static void quadralateralSimplify%d(skia test::Reporter*" | 
| 53 char* str = pathStr; | 52 "reporter, const char* filename) {\n", loopNo); | 
| 54 str += sprintf(str, " path.moveTo(%d, %d);\n", ax, ay ); | 53 pathStr.appendf(" SkPath path;\n"); | 
| 55 str += sprintf(str, " path.lineTo(%d, %d);\n", bx, by ); | 54 pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay); | 
| 56 str += sprintf(str, " path.lineTo(%d, %d);\n", cx, cy ); | 55 pathStr.appendf(" path.lineTo(%d, %d);\n", bx, by); | 
| 57 str += sprintf(str, " path.lineTo(%d, %d);\n", dx, dy ); | 56 pathStr.appendf(" path.lineTo(%d, %d);\n", cx, cy); | 
| 58 str += sprintf(str, " path.close();\n"); | 57 pathStr.appendf(" path.lineTo(%d, %d);\n", dx, dy); | 
| 59 str += sprintf(str, " path.moveTo(%d, %d);\n", ex, ey ); | 58 pathStr.appendf(" path.close();\n"); | 
| 60 str += sprintf(str, " path.lineTo(%d, %d);\n", fx, fy ); | 59 pathStr.appendf(" path.moveTo(%d, %d);\n", ex, ey); | 
| 61 str += sprintf(str, " path.lineTo(%d, %d);\n", gx, gy ); | 60 pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy); | 
| 62 str += sprintf(str, " path.lineTo(%d, %d);\n", hx, hy ); | 61 pathStr.appendf(" path.lineTo(%d, %d);\n", gx, gy); | 
| 63 str += sprintf(str, " path.close();\n"); | 62 pathStr.appendf(" path.lineTo(%d, %d);\n", hx, hy); | 
| 64 outputProgress(state.fPathStr, pathStr, SkPath::kWinding _FillType); | 63 pathStr.appendf(" path.close();\n"); | 
| 64 pathStr.appendf(" testPathSimplify(reporter, path, fi lename);\n"); | |
| 65 pathStr.appendf("}\n"); | |
| 66 outputProgress(state.fPathStr, pathStr.c_str(), SkPath:: kWinding_FillType); | |
| 65 } | 67 } | 
| 66 testSimplify(path, false, out, state, pathStr); | 68 testSimplify(path, false, out, state, pathStr.c_str()); | 
| 67 path.setFillType(SkPath::kEvenOdd_FillType); | 69 path.setFillType(SkPath::kEvenOdd_FillType); | 
| 68 if (progress) { | 70 if (state.fReporter->verbose()) { | 
| 69 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd _FillType); | 71 outputProgress(state.fPathStr, pathStr.c_str(), SkPath:: kEvenOdd_FillType); | 
| 70 } | 72 } | 
| 71 testSimplify(path, true, out, state, pathStr); | 73 testSimplify(path, true, out, state, pathStr.c_str()); | 
| 72 } | 74 } | 
| 73 } | 75 } | 
| 74 } | 76 } | 
| 75 } | 77 } | 
| 76 } | 78 } | 
| 77 | 79 | 
| 78 DEF_TEST(PathOpsSimplifyQuadralateralsThreaded, reporter) { | 80 DEF_TEST(PathOpsSimplifyQuadralateralsThreaded, reporter) { | 
| 79 initializeTests(reporter, "testQuadralaterals"); | 81 initializeTests(reporter, "testQuadralaterals"); | 
| 80 PathOpsThreadedTestRunner testRunner(reporter); | 82 PathOpsThreadedTestRunner testRunner(reporter); | 
| 81 for (int a = 0; a < 16; ++a) { | 83 for (int a = 0; a < 16; ++a) { | 
| 82 for (int b = a ; b < 16; ++b) { | 84 for (int b = a ; b < 16; ++b) { | 
| 83 for (int c = b ; c < 16; ++c) { | 85 for (int c = b ; c < 16; ++c) { | 
| 84 for (int d = c; d < 16; ++d) { | 86 for (int d = c; d < 16; ++d) { | 
| 85 *testRunner.fRunnables.append() = new PathOpsThreadedRunnabl e( | 87 *testRunner.fRunnables.append() = new PathOpsThreadedRunnabl e( | 
| 86 &testSimplifyQuadralateralsMain, a, b, c, d, &testRu nner); | 88 &testSimplifyQuadralateralsMain, a, b, c, d, &testRu nner); | 
| 87 } | 89 } | 
| 88 if (!reporter->allowExtendedTest()) goto finish; | 90 if (!reporter->allowExtendedTest()) goto finish; | 
| 89 } | 91 } | 
| 90 } | 92 } | 
| 91 } | 93 } | 
| 92 finish: | 94 finish: | 
| 93 testRunner.render(); | 95 testRunner.render(); | 
| 94 } | 96 } | 
| OLD | NEW |