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

Unified Diff: tests/PathOpsOpLoopThreadedTest.cpp

Issue 239563004: fix minor skp-found bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix mac-detected errors Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/PathOpsExtendedTest.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathOpsOpLoopThreadedTest.cpp
diff --git a/tests/PathOpsOpLoopThreadedTest.cpp b/tests/PathOpsOpLoopThreadedTest.cpp
new file mode 100755
index 0000000000000000000000000000000000000000..71efff3edc3a111fcc1e6cc2b569f50c64bc2f9f
--- /dev/null
+++ b/tests/PathOpsOpLoopThreadedTest.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "PathOpsExtendedTest.h"
+#include "PathOpsThreadedCommon.h"
+
+static void testOpLoopsMain(PathOpsThreadState* data) {
+#if DEBUG_SHOW_TEST_NAME
+ strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
+#endif
+ SkASSERT(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));
+ }
+ for (int a = 0 ; a < 6; ++a) {
+ for (int b = a + 1 ; b < 7; ++b) {
+ for (int c = 0 ; c < 6; ++c) {
+ for (int d = c + 1 ; d < 7; ++d) {
+ // define 4 points that form two lines that often cross; one line is (a, b) (c, d)
+ SkVector v = {SkIntToScalar(a - c), SkIntToScalar(b - d)};
+ SkPoint midA = { SkIntToScalar(a * state.fA + c * (6 - state.fA)) / 6,
+ SkIntToScalar(b * state.fA + d * (6 - state.fA)) / 6 };
+ SkPoint midB = { SkIntToScalar(a * state.fB + c * (6 - state.fB)) / 6,
+ SkIntToScalar(b * state.fB + d * (6 - state.fB)) / 6 };
+ SkPoint endC = { midA.fX + v.fY * state.fC / 3,
+ midA.fY + v.fX * state.fC / 3 };
+ SkPoint endD = { midB.fX - v.fY * state.fD / 3,
+ midB.fY + v.fX * state.fD / 3 };
+ SkPath pathA, pathB;
+ if (progress) {
+ char* str = pathStr;
+ str += sprintf(str, " path.moveTo(%d,%d);\n", a, b);
+ str += sprintf(str, " path.cubicTo(%d,%d, %1.9gf,%1.9gf, %1.9gf,%1.9gf);\n",
+ c, d, endC.fX, endC.fY, endD.fX, endD.fY);
+ str += sprintf(str, " path.close();\n");
+ str += sprintf(str, " pathB.moveTo(%d,%d);\n", c, d);
+ str += sprintf(str, " pathB.cubicTo(%1.9gf,%1.9gf, %1.9gf,%1.9gf, %d,%d);\n",
+ endC.fX, endC.fY, endD.fX, endD.fY, a, b);
+ str += sprintf(str, " pathB.close();\n");
+ }
+ pathA.moveTo(SkIntToScalar(a), SkIntToScalar(b));
+ pathA.cubicTo(SkIntToScalar(c), SkIntToScalar(d), endC.fX, endC.fY, endD.fX, endD.fY);
+ pathA.close();
+ pathB.moveTo(SkIntToScalar(c), SkIntToScalar(d));
+ pathB.cubicTo(endC.fX, endC.fY, endD.fX, endD.fY, SkIntToScalar(a), SkIntToScalar(b));
+ pathB.close();
+// SkDebugf("%s\n", pathStr);
+ if (progress) {
+ outputProgress(state.fPathStr, pathStr, kIntersect_PathOp);
+ }
+ testThreadedPathOp(state.fReporter, pathA, pathB, kIntersect_PathOp, "loops");
+ }
+ }
+ }
+ }
+}
+
+DEF_TEST(PathOpsOpLoopsThreaded, reporter) {
+ int threadCount = initializeTests(reporter, "cubicOp");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
+ for (int a = 0; a < 6; ++a) { // outermost
+ for (int b = a + 1; b < 7; ++b) {
+ for (int c = 0 ; c < 6; ++c) {
+ for (int d = c + 1; d < 7; ++d) {
+ *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
+ (&testOpLoopsMain, a, b, c, d, &testRunner));
+ }
+ }
+ if (!reporter->allowExtendedTest()) goto finish;
+ }
+ }
+finish:
+ testRunner.render();
+ ShowTestArray();
+}
+
+DEF_TEST(PathOpsOpLoops, reporter) {
+ (void) initializeTests(reporter, "cubicOp");
+ PathOpsThreadState state;
+ state.fReporter = reporter;
+ SkBitmap bitmap;
+ state.fBitmap = &bitmap;
+ char pathStr[PATH_STR_SIZE];
+ state.fPathStr = pathStr;
+ for (state.fA = 0; state.fA < 6; ++state.fA) { // outermost
+ for (state.fB = state.fA + 1; state.fB < 7; ++state.fB) {
+ for (state.fC = 0 ; state.fC < 6; ++state.fC) {
+ for (state.fD = state.fC + 1; state.fD < 7; ++state.fD) {
+ testOpLoopsMain(&state);
+ }
+ }
+ if (!reporter->allowExtendedTest()) goto finish;
+ }
+ }
+finish:
+ ShowTestArray();
+}
« no previous file with comments | « tests/PathOpsExtendedTest.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698