PathOpsOpCircleThreadedTest.cpp 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright 2015 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "include/core/SkString.h"
  8. #include "tests/PathOpsDebug.h"
  9. #include "tests/PathOpsExtendedTest.h"
  10. #include "tests/PathOpsThreadedCommon.h"
  11. #include <atomic>
  12. static int loopNo = 4;
  13. static std::atomic<int> gCirclesTestNo{0};
  14. static void testOpCirclesMain(PathOpsThreadState* data) {
  15. SkASSERT(data);
  16. PathOpsThreadState& state = *data;
  17. SkString pathStr;
  18. for (int a = 0 ; a < 6; ++a) {
  19. for (int b = a + 1 ; b < 7; ++b) {
  20. for (int c = 0 ; c < 6; ++c) {
  21. for (int d = c + 1 ; d < 7; ++d) {
  22. for (int e = SkPath::kWinding_FillType ; e <= SkPath::kEvenOdd_FillType; ++e) {
  23. for (int f = SkPath::kWinding_FillType ; f <= SkPath::kEvenOdd_FillType; ++f) {
  24. SkPath pathA, pathB;
  25. pathA.setFillType((SkPath::FillType) e);
  26. pathA.addCircle(SkIntToScalar(state.fA), SkIntToScalar(state.fB), SkIntToScalar(state.fC),
  27. state.fD ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
  28. pathB.setFillType((SkPath::FillType) f);
  29. pathB.addCircle(SkIntToScalar(a), SkIntToScalar(b), SkIntToScalar(c),
  30. d ? SkPath::kCW_Direction : SkPath::kCCW_Direction);
  31. for (int op = 0 ; op <= kXOR_SkPathOp; ++op) {
  32. if (state.fReporter->verbose()) {
  33. pathStr.printf("static void circlesOp%d(skiatest::Reporter* reporter,"
  34. " const char* filename) {\n", loopNo);
  35. pathStr.appendf(" SkPath path, pathB;\n");
  36. pathStr.appendf(" path.setFillType(SkPath::k%s_FillType);\n",
  37. e == SkPath::kWinding_FillType ? "Winding" : e == SkPath::kEvenOdd_FillType
  38. ? "EvenOdd" : "?UNDEFINED");
  39. pathStr.appendf(" path.addCircle(%d, %d, %d, %s);\n", state.fA, state.fB,
  40. state.fC, state.fD ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
  41. pathStr.appendf(" pathB.setFillType(SkPath::k%s_FillType);\n",
  42. f == SkPath::kWinding_FillType ? "Winding" : f == SkPath::kEvenOdd_FillType
  43. ? "EvenOdd" : "?UNDEFINED");
  44. pathStr.appendf(" pathB.addCircle(%d, %d, %d, %s);\n", a, b,
  45. c, d ? "SkPath::kCW_Direction" : "SkPath::kCCW_Direction");
  46. pathStr.appendf(" testPathOp(reporter, path, pathB, %s, filename);\n",
  47. SkPathOpsDebug::OpStr((SkPathOp) op));
  48. pathStr.appendf("}\n");
  49. state.outputProgress(pathStr.c_str(), (SkPathOp) op);
  50. }
  51. SkString testName;
  52. testName.printf("thread_circles%d", ++gCirclesTestNo);
  53. if (!testPathOp(state.fReporter, pathA, pathB, (SkPathOp) op, testName.c_str())) {
  54. if (state.fReporter->verbose()) {
  55. ++loopNo;
  56. goto skipToNext;
  57. }
  58. }
  59. if (PathOpsDebug::gCheckForDuplicateNames) return;
  60. }
  61. }
  62. }
  63. skipToNext: ;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. DEF_TEST(PathOpsOpCircleThreaded, reporter) {
  70. initializeTests(reporter, "circleOp");
  71. PathOpsThreadedTestRunner testRunner(reporter);
  72. for (int a = 0; a < 6; ++a) { // outermost
  73. for (int b = a + 1; b < 7; ++b) {
  74. for (int c = 0 ; c < 6; ++c) {
  75. for (int d = 0; d < 2; ++d) {
  76. *testRunner.fRunnables.append() = new PathOpsThreadedRunnable(
  77. &testOpCirclesMain, a, b, c, d, &testRunner);
  78. }
  79. }
  80. if (!reporter->allowExtendedTest()) goto finish;
  81. }
  82. }
  83. finish:
  84. testRunner.render();
  85. }