| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 | 9 |
| 10 static int add_point(char* str, SkScalar x, SkScalar y) { | 10 static int add_point(char* str, SkScalar x, SkScalar y) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 SkIntToScalar(b * state.fA + d * (6 - state.fA)) / 6 }; | 46 SkIntToScalar(b * state.fA + d * (6 - state.fA)) / 6 }; |
| 47 SkPoint midB = { SkIntToScalar(a * state.fB + c * (6 - state.fB)) / 6, | 47 SkPoint midB = { SkIntToScalar(a * state.fB + c * (6 - state.fB)) / 6, |
| 48 SkIntToScalar(b * state.fB + d * (6 - state.fB)) / 6 }; | 48 SkIntToScalar(b * state.fB + d * (6 - state.fB)) / 6 }; |
| 49 SkPoint endC = { midA.fX + v.fY * state.fC / 3, | 49 SkPoint endC = { midA.fX + v.fY * state.fC / 3, |
| 50 midA.fY + v.fX * state.fC / 3 }; | 50 midA.fY + v.fX * state.fC / 3 }; |
| 51 SkPoint endD = { midB.fX - v.fY * state.fD / 3, | 51 SkPoint endD = { midB.fX - v.fY * state.fD / 3, |
| 52 midB.fY + v.fX * state.fD / 3 }; | 52 midB.fY + v.fX * state.fD / 3 }; |
| 53 SkPath pathA, pathB; | 53 SkPath pathA, pathB; |
| 54 if (progress) { | 54 if (progress) { |
| 55 char* str = pathStr; | 55 char* str = pathStr; |
| 56 const int loopNo = 7; | 56 const int loopNo = 12; |
| 57 str += sprintf(str, "static void loop%d(skiatest::Reporter* reporter
," | 57 str += sprintf(str, "static void loop%d(skiatest::Reporter* reporter
," |
| 58 " const char* filename) {\n", loopNo); | 58 " const char* filename) {\n", loopNo); |
| 59 str += sprintf(str, " SkPath path, pathB;\n"); | 59 str += sprintf(str, " SkPath path, pathB;\n"); |
| 60 str += sprintf(str, " path.moveTo(%d,%d);\n", a, b); | 60 str += sprintf(str, " path.moveTo(%d,%d);\n", a, b); |
| 61 str += sprintf(str, " path.cubicTo(%d,%d, ", c, d); | 61 str += sprintf(str, " path.cubicTo(%d,%d, ", c, d); |
| 62 str += add_point(str, endC.fX, endC.fY); | 62 str += add_point(str, endC.fX, endC.fY); |
| 63 str += sprintf(str, ", "); | 63 str += sprintf(str, ", "); |
| 64 str += add_point(str, endD.fX, endD.fY); | 64 str += add_point(str, endD.fX, endD.fY); |
| 65 str += sprintf(str, ");\n"); | 65 str += sprintf(str, ");\n"); |
| 66 str += sprintf(str, " path.close();\n"); | 66 str += sprintf(str, " path.close();\n"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 86 outputProgress(state.fPathStr, pathStr, kIntersect_SkPathOp); | 86 outputProgress(state.fPathStr, pathStr, kIntersect_SkPathOp); |
| 87 } | 87 } |
| 88 testThreadedPathOp(state.fReporter, pathA, pathB, kIntersect_SkPathOp, "
loops"); | 88 testThreadedPathOp(state.fReporter, pathA, pathB, kIntersect_SkPathOp, "
loops"); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 DEF_TEST(PathOpsOpLoopsThreaded, reporter) { | 95 DEF_TEST(PathOpsOpLoopsThreaded, reporter) { |
| 96 initializeTests(reporter, "cubicOp"); | 96 initializeTests(reporter, "loopOp"); |
| 97 PathOpsThreadedTestRunner testRunner(reporter); | 97 PathOpsThreadedTestRunner testRunner(reporter); |
| 98 for (int a = 0; a < 6; ++a) { // outermost | 98 for (int a = 0; a < 6; ++a) { // outermost |
| 99 for (int b = a + 1; b < 7; ++b) { | 99 for (int b = a + 1; b < 7; ++b) { |
| 100 for (int c = 0 ; c < 6; ++c) { | 100 for (int c = 0 ; c < 6; ++c) { |
| 101 for (int d = c + 1; d < 7; ++d) { | 101 for (int d = c + 1; d < 7; ++d) { |
| 102 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded
Runnable, | 102 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreaded
Runnable, |
| 103 (&testOpLoopsMain, a, b, c, d, &testRunner)); | 103 (&testOpLoopsMain, a, b, c, d, &testRunner)); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 if (!reporter->allowExtendedTest()) goto finish; | 106 if (!reporter->allowExtendedTest()) goto finish; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 finish: | 109 finish: |
| 110 testRunner.render(); | 110 testRunner.render(); |
| 111 ShowTestArray(); | 111 ShowTestArray("loopOp"); |
| 112 } | 112 } |
| 113 | |
| 114 DEF_TEST(PathOpsOpLoops, reporter) { | |
| 115 initializeTests(reporter, "cubicOp"); | |
| 116 PathOpsThreadState state; | |
| 117 state.fReporter = reporter; | |
| 118 SkBitmap bitmap; | |
| 119 state.fBitmap = &bitmap; | |
| 120 char pathStr[PATH_STR_SIZE]; | |
| 121 state.fPathStr = pathStr; | |
| 122 for (state.fA = 0; state.fA < 6; ++state.fA) { // outermost | |
| 123 for (state.fB = state.fA + 1; state.fB < 7; ++state.fB) { | |
| 124 for (state.fC = 0 ; state.fC < 6; ++state.fC) { | |
| 125 for (state.fD = state.fC + 1; state.fD < 7; ++state.fD) { | |
| 126 testOpLoopsMain(&state); | |
| 127 } | |
| 128 } | |
| 129 if (!reporter->allowExtendedTest()) goto finish; | |
| 130 } | |
| 131 } | |
| 132 finish: | |
| 133 ShowTestArray(); | |
| 134 } | |
| OLD | NEW |