caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 "EdgeWalker_Test.h" |
| 8 | #include "Intersection_Tests.h" |
| 9 | #include "ShapeOps.h" |
| 10 | #include "SkBitmap.h" |
| 11 | #include "SkCanvas.h" |
caryclark@google.com | fa4a6e9 | 2012-07-11 17:52:32 +0000 | [diff] [blame] | 12 | #include "SkStream.h" |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 13 | #include <assert.h> |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 14 | #include <errno.h> |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 15 | #include <pthread.h> |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 16 | #include <unistd.h> |
| 17 | #include <sys/types.h> |
| 18 | #include <sys/sysctl.h> |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 19 | |
| 20 | // four rects, of four sizes |
| 21 | // for 3 smaller sizes, tall, wide |
| 22 | // top upper mid lower bottom aligned (3 bits, 5 values) |
| 23 | // same with x (3 bits, 5 values) |
| 24 | // not included, square, tall, wide (2 bits) |
| 25 | // cw or ccw (1 bit) |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 26 | static const char marker[] = |
| 27 | "</div>\n" |
| 28 | "\n" |
| 29 | "<script type=\"text/javascript\">\n" |
| 30 | "\n" |
| 31 | "var testDivs = [\n"; |
| 32 | static const char testLineStr[] = " testLine"; |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 33 | #if 0 |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 34 | static const char filename[] = "../../experimental/Intersection/debugXX.txt"; |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 35 | #else |
| 36 | static const char filename[] = "/flash/debug/XX.txt"; |
| 37 | #endif |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 38 | static int testNumber; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 39 | |
caryclark@google.com | 2ddff93 | 2012-08-07 21:25:27 +0000 | [diff] [blame] | 40 | #define BETTER_THREADS 01 |
| 41 | #define DEBUG_BETTER_THREADS 0 |
| 42 | |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 43 | static void* testSimplify4x4RectsMain(void* data) |
| 44 | { |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 45 | SkASSERT(data); |
| 46 | State4& state = *(State4*) data; |
caryclark@google.com | 2ddff93 | 2012-08-07 21:25:27 +0000 | [diff] [blame] | 47 | #if BETTER_THREADS |
| 48 | do { |
| 49 | #endif |
| 50 | char pathStr[1024]; // gdb: set print elements 400 |
| 51 | bzero(pathStr, sizeof(pathStr)); |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 52 | state.testsRun = 0; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 53 | int aShape = state.a & 0x03; |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 54 | int aCW = state.a >> 2; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 55 | int bShape = state.b & 0x03; |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 56 | int bCW = state.b >> 2; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 57 | int cShape = state.c & 0x03; |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 58 | int cCW = state.c >> 2; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 59 | int dShape = state.d & 0x03; |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 60 | int dCW = state.d >> 2; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 61 | for (int aXAlign = 0 ; aXAlign < 5; ++aXAlign) { |
| 62 | for (int aYAlign = 0 ; aYAlign < 5; ++aYAlign) { |
| 63 | for (int bXAlign = 0 ; bXAlign < 5; ++bXAlign) { |
| 64 | for (int bYAlign = 0 ; bYAlign < 5; ++bYAlign) { |
| 65 | for (int cXAlign = 0 ; cXAlign < 5; ++cXAlign) { |
| 66 | for (int cYAlign = 0 ; cYAlign < 5; ++cYAlign) { |
| 67 | for (int dXAlign = 0 ; dXAlign < 5; ++dXAlign) { |
| 68 | for (int dYAlign = 0 ; dYAlign < 5; ++dYAlign) { |
| 69 | SkPath path, out; |
| 70 | char* str = pathStr; |
| 71 | path.setFillType(SkPath::kWinding_FillType); |
| 72 | int l, t, r, b; |
| 73 | if (aShape) { |
| 74 | switch (aShape) { |
| 75 | case 1: // square |
| 76 | l = 0; r = 60; |
| 77 | t = 0; b = 60; |
| 78 | aXAlign = 5; |
| 79 | aYAlign = 5; |
| 80 | break; |
| 81 | case 2: |
| 82 | l = aXAlign * 12; |
| 83 | r = l + 30; |
| 84 | t = 0; b = 60; |
| 85 | aYAlign = 5; |
| 86 | break; |
| 87 | case 3: |
| 88 | l = 0; r = 60; |
| 89 | t = aYAlign * 12; |
| 90 | b = l + 30; |
| 91 | aXAlign = 5; |
| 92 | break; |
| 93 | } |
| 94 | path.addRect(l, t, r, b, (SkPath::Direction) aCW); |
| 95 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 96 | " (SkPath::Direction) %d);\n", l, t, r, b, aCW); |
| 97 | } else { |
| 98 | aXAlign = 5; |
| 99 | aYAlign = 5; |
| 100 | } |
| 101 | if (bShape) { |
| 102 | switch (bShape) { |
| 103 | case 1: // square |
| 104 | l = bXAlign * 10; |
| 105 | r = l + 20; |
| 106 | t = bYAlign * 10; |
| 107 | b = l + 20; |
| 108 | break; |
| 109 | case 2: |
| 110 | l = bXAlign * 10; |
| 111 | r = l + 20; |
| 112 | t = 10; b = 40; |
| 113 | bYAlign = 5; |
| 114 | break; |
| 115 | case 3: |
| 116 | l = 10; r = 40; |
| 117 | t = bYAlign * 10; |
| 118 | b = l + 20; |
| 119 | bXAlign = 5; |
| 120 | break; |
| 121 | } |
| 122 | path.addRect(l, t, r, b, (SkPath::Direction) bCW); |
| 123 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 124 | " (SkPath::Direction) %d);\n", l, t, r, b, bCW); |
| 125 | } else { |
| 126 | bXAlign = 5; |
| 127 | bYAlign = 5; |
| 128 | } |
| 129 | if (cShape) { |
| 130 | switch (cShape) { |
| 131 | case 1: // square |
| 132 | l = cXAlign * 6; |
| 133 | r = l + 12; |
| 134 | t = cYAlign * 6; |
| 135 | b = l + 12; |
| 136 | break; |
| 137 | case 2: |
| 138 | l = cXAlign * 6; |
| 139 | r = l + 12; |
| 140 | t = 20; b = 30; |
| 141 | cYAlign = 5; |
| 142 | break; |
| 143 | case 3: |
| 144 | l = 20; r = 30; |
| 145 | t = cYAlign * 6; |
| 146 | b = l + 20; |
| 147 | cXAlign = 5; |
| 148 | break; |
| 149 | } |
| 150 | path.addRect(l, t, r, b, (SkPath::Direction) cCW); |
| 151 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 152 | " (SkPath::Direction) %d);\n", l, t, r, b, cCW); |
| 153 | } else { |
| 154 | cXAlign = 5; |
| 155 | cYAlign = 5; |
| 156 | } |
| 157 | if (dShape) { |
| 158 | switch (dShape) { |
| 159 | case 1: // square |
| 160 | l = dXAlign * 4; |
| 161 | r = l + 9; |
| 162 | t = dYAlign * 4; |
| 163 | b = l + 9; |
| 164 | break; |
| 165 | case 2: |
| 166 | l = dXAlign * 6; |
| 167 | r = l + 9; |
| 168 | t = 32; b = 36; |
| 169 | dYAlign = 5; |
| 170 | break; |
| 171 | case 3: |
| 172 | l = 32; r = 36; |
| 173 | t = dYAlign * 6; |
| 174 | b = l + 9; |
| 175 | dXAlign = 5; |
| 176 | break; |
| 177 | } |
| 178 | path.addRect(l, t, r, b, (SkPath::Direction) dCW); |
| 179 | str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 180 | " (SkPath::Direction) %d);\n", l, t, r, b, dCW); |
| 181 | } else { |
| 182 | dXAlign = 5; |
| 183 | dYAlign = 5; |
| 184 | } |
| 185 | path.close(); |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 186 | if (gRunTestsInOneThread) { |
| 187 | SkDebugf("%s\n", pathStr); |
| 188 | } else { |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 189 | #if 0 |
| 190 | char pwd[1024]; |
| 191 | getcwd(pwd, sizeof(pwd)); |
| 192 | SkDebugf("%s\n", pwd); |
| 193 | #endif |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 194 | #if 1 |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 195 | SkFILEWStream outFile(state.filename); |
caryclark@google.com | fa4a6e9 | 2012-07-11 17:52:32 +0000 | [diff] [blame] | 196 | if (!outFile.isValid()) { |
| 197 | continue; |
| 198 | } |
caryclark@google.com | fa4a6e9 | 2012-07-11 17:52:32 +0000 | [diff] [blame] | 199 | outFile.writeText("<div id=\"testLine"); |
| 200 | outFile.writeDecAsText(testNumber); |
| 201 | outFile.writeText("\">\n"); |
| 202 | outFile.writeText(pathStr); |
| 203 | outFile.writeText("</div>\n\n"); |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 204 | |
caryclark@google.com | fa4a6e9 | 2012-07-11 17:52:32 +0000 | [diff] [blame] | 205 | outFile.writeText(marker); |
| 206 | outFile.writeText(testLineStr); |
| 207 | outFile.writeDecAsText(testNumber); |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 208 | outFile.writeText(",\n\n\n"); |
| 209 | |
| 210 | outFile.writeText("static void testLine"); |
| 211 | outFile.writeDecAsText(testNumber); |
| 212 | outFile.writeText("() {\n SkPath path, simple;\n"); |
| 213 | outFile.writeText(pathStr); |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 214 | outFile.writeText(" testSimplifyx(path);\n}\n\n"); |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 215 | outFile.writeText("static void (*firstTest)() = testLine"); |
| 216 | outFile.writeDecAsText(testNumber); |
| 217 | outFile.writeText(";\n\n"); |
| 218 | |
| 219 | outFile.writeText("static struct {\n"); |
| 220 | outFile.writeText(" void (*fun)();\n"); |
| 221 | outFile.writeText(" const char* str;\n"); |
| 222 | outFile.writeText("} tests[] = {\n"); |
| 223 | outFile.writeText(" TEST(testLine"); |
| 224 | outFile.writeDecAsText(testNumber); |
| 225 | outFile.writeText("),\n"); |
caryclark@google.com | fa4a6e9 | 2012-07-11 17:52:32 +0000 | [diff] [blame] | 226 | outFile.flush(); |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 227 | #endif |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 228 | } |
| 229 | testSimplifyx(path, out, state.bitmap, state.canvas); |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 230 | state.testsRun++; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | } |
caryclark@google.com | 2ddff93 | 2012-08-07 21:25:27 +0000 | [diff] [blame] | 239 | if (gRunTestsInOneThread) { |
| 240 | return NULL; |
| 241 | } |
| 242 | #if BETTER_THREADS |
| 243 | if (DEBUG_BETTER_THREADS) SkDebugf("%s done %d\n", __FUNCTION__, state.index); |
| 244 | pthread_mutex_lock(&State4::addQueue); |
| 245 | if (DEBUG_BETTER_THREADS) SkDebugf("%s lock %d\n", __FUNCTION__, state.index); |
| 246 | state.next = State4::queue ? State4::queue->next : NULL; |
| 247 | state.done = true; |
| 248 | State4::queue = &state; |
| 249 | pthread_cond_signal(&State4::checkQueue); |
| 250 | while (state.done && !state.last) { |
| 251 | if (DEBUG_BETTER_THREADS) SkDebugf("%s wait %d\n", __FUNCTION__, state.index); |
| 252 | pthread_cond_wait(&state.initialized, &State4::addQueue); |
| 253 | if (DEBUG_BETTER_THREADS) SkDebugf("%s wait done %d\n", __FUNCTION__, state.index); |
| 254 | } |
| 255 | pthread_mutex_unlock(&State4::addQueue); |
| 256 | if (DEBUG_BETTER_THREADS) SkDebugf("%s unlock %d\n", __FUNCTION__, state.index); |
| 257 | } while (!state.last); |
| 258 | #endif |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 259 | return NULL; |
| 260 | } |
| 261 | |
caryclark@google.com | 2ddff93 | 2012-08-07 21:25:27 +0000 | [diff] [blame] | 262 | const int maxThreadsAllocated = 64; |
| 263 | |
| 264 | State4* State4::queue = NULL; |
| 265 | pthread_mutex_t State4::addQueue = PTHREAD_MUTEX_INITIALIZER; |
| 266 | pthread_cond_t State4::checkQueue = PTHREAD_COND_INITIALIZER; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 267 | |
| 268 | void Simplify4x4RectsThreaded_Test() |
| 269 | { |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 270 | #ifdef SK_DEBUG |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 271 | gDebugMaxWindSum = 4; |
| 272 | gDebugMaxWindValue = 4; |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 273 | #endif |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 274 | int maxThreads = 1; |
| 275 | if (!gRunTestsInOneThread) { |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 276 | int threads = -1; |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 277 | size_t size = sizeof(threads); |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 278 | sysctlbyname("hw.logicalcpu_max", &threads, &size, NULL, 0); |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 279 | SkDebugf("%s errno=%d size=%d processors=%d\n", __FUNCTION__, |
| 280 | errno, size, threads); |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 281 | if (threads > 0) { |
| 282 | maxThreads = threads; |
| 283 | } else { |
| 284 | maxThreads = 8; |
| 285 | } |
| 286 | SkDebugf("%s maxThreads=%d\n", __FUNCTION__, maxThreads); |
| 287 | } |
| 288 | if (!gRunTestsInOneThread) { |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 289 | SkFILEStream inFile("../../experimental/Intersection/op.htm"); |
| 290 | if (inFile.isValid()) { |
| 291 | SkTDArray<char> inData; |
| 292 | inData.setCount(inFile.getLength()); |
| 293 | size_t inLen = inData.count(); |
| 294 | inFile.read(inData.begin(), inLen); |
| 295 | inFile.setPath(NULL); |
| 296 | char* insert = strstr(inData.begin(), marker); |
| 297 | if (insert) { |
| 298 | insert += sizeof(marker) - 1; |
| 299 | const char* numLoc = insert + sizeof(testLineStr) - 1; |
| 300 | testNumber = atoi(numLoc) + 1; |
| 301 | } |
| 302 | } |
| 303 | } |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 304 | State4 threadState[maxThreadsAllocated]; |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 305 | int threadIndex; |
| 306 | for (threadIndex = 0; threadIndex < maxThreads; ++threadIndex) { |
| 307 | State4* statePtr = &threadState[threadIndex]; |
| 308 | strcpy(statePtr->filename, filename); |
| 309 | SkASSERT(statePtr->filename[sizeof(filename) - 7] == 'X'); |
| 310 | SkASSERT(statePtr->filename[sizeof(filename) - 6] == 'X'); |
| 311 | statePtr->filename[sizeof(filename) - 7] = '0' + threadIndex / 10; |
| 312 | statePtr->filename[sizeof(filename) - 6] = '0' + threadIndex % 10; |
| 313 | } |
| 314 | threadIndex = 0; |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 315 | int testsRun = 0; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 316 | for (int a = 0; a < 8; ++a) { // outermost |
| 317 | for (int b = a ; b < 8; ++b) { |
| 318 | for (int c = b ; c < 8; ++c) { |
| 319 | for (int d = c; d < 8; ++d) { |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 320 | if (!gRunTestsInOneThread) { |
caryclark@google.com | 2ddff93 | 2012-08-07 21:25:27 +0000 | [diff] [blame] | 321 | #if BETTER_THREADS == 0 |
| 322 | State4* statePtr = &threadState[threadIndex]; |
| 323 | statePtr->a = a; |
| 324 | statePtr->b = b; |
| 325 | statePtr->c = c; |
| 326 | statePtr->d = d; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 327 | createThread(statePtr, testSimplify4x4RectsMain); |
| 328 | if (++threadIndex >= maxThreads) { |
| 329 | waitForCompletion(threadState, threadIndex); |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 330 | for (int index = 0; index < maxThreads; ++index) { |
| 331 | testsRun += threadState[index].testsRun; |
| 332 | } |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 333 | } |
caryclark@google.com | 2ddff93 | 2012-08-07 21:25:27 +0000 | [diff] [blame] | 334 | #else |
| 335 | State4* statePtr; |
| 336 | pthread_mutex_lock(&State4::addQueue); |
| 337 | if (threadIndex < maxThreads) { |
| 338 | statePtr = &threadState[threadIndex]; |
| 339 | statePtr->a = a; |
| 340 | statePtr->b = b; |
| 341 | statePtr->c = c; |
| 342 | statePtr->d = d; |
| 343 | statePtr->index = threadIndex; |
| 344 | statePtr->done = false; |
| 345 | statePtr->last = false; |
| 346 | pthread_cond_init(&statePtr->initialized, NULL); |
| 347 | ++threadIndex; |
| 348 | createThread(statePtr, testSimplify4x4RectsMain); |
| 349 | } else { |
| 350 | while (!State4::queue) { |
| 351 | if (DEBUG_BETTER_THREADS) SkDebugf("%s wait\n", __FUNCTION__); |
| 352 | pthread_cond_wait(&State4::checkQueue, &State4::addQueue); |
| 353 | } |
| 354 | statePtr = State4::queue; |
| 355 | testsRun += statePtr->testsRun; |
| 356 | if (DEBUG_BETTER_THREADS) SkDebugf("%s dequeue %d\n", __FUNCTION__, statePtr->index); |
| 357 | statePtr->a = a; |
| 358 | statePtr->b = b; |
| 359 | statePtr->c = c; |
| 360 | statePtr->d = d; |
| 361 | statePtr->done = false; |
| 362 | State4::queue = State4::queue->next; |
| 363 | pthread_cond_signal(&statePtr->initialized); |
| 364 | } |
| 365 | pthread_mutex_unlock(&State4::addQueue); |
| 366 | #endif |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 367 | } else { |
caryclark@google.com | 2ddff93 | 2012-08-07 21:25:27 +0000 | [diff] [blame] | 368 | State4 state; |
| 369 | state.a = a; |
| 370 | state.b = b; |
| 371 | state.c = c; |
| 372 | state.d = d; |
| 373 | testSimplify4x4RectsMain(&state); |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 374 | } |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 375 | if (!gRunTestsInOneThread) SkDebugf("."); |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 376 | } |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 377 | if (!gRunTestsInOneThread) SkDebugf("%d", c); |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 378 | } |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 379 | if (!gRunTestsInOneThread) SkDebugf("\n%d", b); |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 380 | } |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 381 | if (!gRunTestsInOneThread) SkDebugf("\n\n%d", a); |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 382 | } |
caryclark@google.com | 2ddff93 | 2012-08-07 21:25:27 +0000 | [diff] [blame] | 383 | if (!gRunTestsInOneThread) { |
| 384 | pthread_mutex_lock(&State4::addQueue); |
| 385 | int runningThreads = maxThreads; |
| 386 | while (runningThreads > 0) { |
| 387 | while (!State4::queue) { |
| 388 | if (DEBUG_BETTER_THREADS) SkDebugf("%s wait\n", __FUNCTION__); |
| 389 | pthread_cond_wait(&State4::checkQueue, &State4::addQueue); |
| 390 | } |
| 391 | while (State4::queue) { |
| 392 | State4::queue->last = true; |
| 393 | pthread_cond_signal(&State4::queue->initialized); |
| 394 | State4::queue = State4::queue->next; |
| 395 | --runningThreads; |
| 396 | } |
| 397 | } |
| 398 | pthread_mutex_unlock(&State4::addQueue); |
| 399 | for (threadIndex = 0; threadIndex < maxThreads; ++threadIndex) { |
| 400 | pthread_join(threadState[threadIndex].threadID, NULL); |
| 401 | testsRun += threadState[threadIndex].testsRun; |
| 402 | } |
| 403 | SkDebugf("%s total tests run=%d\n", __FUNCTION__, testsRun); |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 404 | } |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 405 | #ifdef SK_DEBUG |
| 406 | gDebugMaxWindSum = SK_MaxS32; |
| 407 | gDebugMaxWindValue = SK_MaxS32; |
| 408 | #endif |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 409 | } |
| 410 | |