| 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  |   9  | 
|  10 static void testSimplifyDegeneratesMain(PathOpsThreadState* data) { |  10 static void testSimplifyDegeneratesMain(PathOpsThreadState* data) { | 
|  11     SkASSERT(data); |  11     SkASSERT(data); | 
|  12     PathOpsThreadState& state = *data; |  12     PathOpsThreadState& state = *data; | 
|  13     char pathStr[1024]; |  13     char pathStr[1024]; | 
|  14     sk_bzero(pathStr, sizeof(pathStr)); |  14     bool progress = state.fReporter->verbose(); // FIXME: break out into its own
     parameter? | 
 |  15     if (progress) { | 
 |  16         sk_bzero(pathStr, sizeof(pathStr)); | 
 |  17     } | 
|  15     int ax = state.fA & 0x03; |  18     int ax = state.fA & 0x03; | 
|  16     int ay = state.fA >> 2; |  19     int ay = state.fA >> 2; | 
|  17     int bx = state.fB & 0x03; |  20     int bx = state.fB & 0x03; | 
|  18     int by = state.fB >> 2; |  21     int by = state.fB >> 2; | 
|  19     int cx = state.fC & 0x03; |  22     int cx = state.fC & 0x03; | 
|  20     int cy = state.fC >> 2; |  23     int cy = state.fC >> 2; | 
|  21     for (int d = 0; d < 16; ++d) { |  24     for (int d = 0; d < 16; ++d) { | 
|  22         int dx = d & 0x03; |  25         int dx = d & 0x03; | 
|  23         int dy = d >> 2; |  26         int dy = d >> 2; | 
|  24         for (int e = d ; e < 16; ++e) { |  27         for (int e = d ; e < 16; ++e) { | 
|  25             int ex = e & 0x03; |  28             int ex = e & 0x03; | 
|  26             int ey = e >> 2; |  29             int ey = e >> 2; | 
|  27             for (int f = d ; f < 16; ++f) { |  30             for (int f = d ; f < 16; ++f) { | 
|  28                 int fx = f & 0x03; |  31                 int fx = f & 0x03; | 
|  29                 int fy = f >> 2; |  32                 int fy = f >> 2; | 
|  30                 if (state.fD && (ex - dx) * (fy - dy) |  33                 if (state.fD && (ex - dx) * (fy - dy) | 
|  31                         != (ey - dy) * (fx - dx)) { |  34                         != (ey - dy) * (fx - dx)) { | 
|  32                     continue; |  35                     continue; | 
|  33                 } |  36                 } | 
|  34                 SkPath path, out; |  37                 SkPath path, out; | 
|  35                 path.setFillType(SkPath::kWinding_FillType); |  38                 path.setFillType(SkPath::kWinding_FillType); | 
|  36                 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); |  39                 path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); | 
|  37                 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); |  40                 path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); | 
|  38                 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); |  41                 path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); | 
|  39                 path.close(); |  42                 path.close(); | 
|  40                 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); |  43                 path.moveTo(SkIntToScalar(dx), SkIntToScalar(dy)); | 
|  41                 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); |  44                 path.lineTo(SkIntToScalar(ex), SkIntToScalar(ey)); | 
|  42                 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); |  45                 path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); | 
|  43                 path.close(); |  46                 path.close(); | 
|  44                 char* str = pathStr; |  47                 if (progress) { | 
|  45                 str += sprintf(str, "    path.moveTo(%d, %d);\n", ax, ay); |  48                     char* str = pathStr; | 
|  46                 str += sprintf(str, "    path.lineTo(%d, %d);\n", bx, by); |  49                     str += sprintf(str, "    path.moveTo(%d, %d);\n", ax, ay); | 
|  47                 str += sprintf(str, "    path.lineTo(%d, %d);\n", cx, cy); |  50                     str += sprintf(str, "    path.lineTo(%d, %d);\n", bx, by); | 
|  48                 str += sprintf(str, "    path.close();\n"); |  51                     str += sprintf(str, "    path.lineTo(%d, %d);\n", cx, cy); | 
|  49                 str += sprintf(str, "    path.moveTo(%d, %d);\n", dx, dy); |  52                     str += sprintf(str, "    path.close();\n"); | 
|  50                 str += sprintf(str, "    path.lineTo(%d, %d);\n", ex, ey); |  53                     str += sprintf(str, "    path.moveTo(%d, %d);\n", dx, dy); | 
|  51                 str += sprintf(str, "    path.lineTo(%d, %d);\n", fx, fy); |  54                     str += sprintf(str, "    path.lineTo(%d, %d);\n", ex, ey); | 
|  52                 str += sprintf(str, "    path.close();\n"); |  55                     str += sprintf(str, "    path.lineTo(%d, %d);\n", fx, fy); | 
|  53                 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillTyp
    e); |  56                     str += sprintf(str, "    path.close();\n"); | 
 |  57                     outputProgress(state.fPathStr, pathStr, SkPath::kWinding_Fil
    lType); | 
 |  58                 } | 
|  54                 testSimplify(path, false, out, state, pathStr); |  59                 testSimplify(path, false, out, state, pathStr); | 
|  55                 path.setFillType(SkPath::kEvenOdd_FillType); |  60                 path.setFillType(SkPath::kEvenOdd_FillType); | 
|  56                 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillTyp
    e); |  61                 if (progress) { | 
 |  62                     outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_Fil
    lType); | 
 |  63                 } | 
|  57                 testSimplify(path, true, out, state, pathStr); |  64                 testSimplify(path, true, out, state, pathStr); | 
|  58             } |  65             } | 
|  59         } |  66         } | 
|  60     } |  67     } | 
|  61 } |  68 } | 
|  62  |  69  | 
|  63 static void PathOpsSimplifyDegeneratesThreadedTest(skiatest::Reporter* reporter)
     { |  70 static void PathOpsSimplifyDegeneratesThreadedTest(skiatest::Reporter* reporter)
     { | 
|  64     int threadCount = initializeTests(reporter, "testDegenerates"); |  71     int threadCount = initializeTests(reporter, "testDegenerates"); | 
|  65     PathOpsThreadedTestRunner testRunner(reporter, threadCount); |  72     PathOpsThreadedTestRunner testRunner(reporter, threadCount); | 
|  66     for (int a = 0; a < 16; ++a) { |  73     for (int a = 0; a < 16; ++a) { | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  79             } |  86             } | 
|  80             if (!reporter->allowExtendedTest()) goto finish; |  87             if (!reporter->allowExtendedTest()) goto finish; | 
|  81         } |  88         } | 
|  82     } |  89     } | 
|  83 finish: |  90 finish: | 
|  84     testRunner.render(); |  91     testRunner.render(); | 
|  85 } |  92 } | 
|  86  |  93  | 
|  87 #include "TestClassDef.h" |  94 #include "TestClassDef.h" | 
|  88 DEFINE_TESTCLASS_SHORT(PathOpsSimplifyDegeneratesThreadedTest) |  95 DEFINE_TESTCLASS_SHORT(PathOpsSimplifyDegeneratesThreadedTest) | 
| OLD | NEW |