OLD | NEW |
(Empty) | |
| 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 #ifndef PathOpsThreadedCommon_DEFINED |
| 8 #define PathOpsThreadedCommon_DEFINED |
| 9 |
| 10 #include "SkCountdown.h" |
| 11 #include "SkRunnable.h" |
| 12 #include "SkTDArray.h" |
| 13 #include "SkThreadPool.h" |
| 14 |
| 15 #define PATH_STR_SIZE 512 |
| 16 |
| 17 class PathOpsThreadedRunnable; |
| 18 class skiatest::Reporter; |
| 19 |
| 20 struct PathOpsThreadState { |
| 21 unsigned char fA; |
| 22 unsigned char fB; |
| 23 unsigned char fC; |
| 24 unsigned char fD; |
| 25 char* fPathStr; |
| 26 skiatest::Reporter* fReporter; |
| 27 SkBitmap* fBitmap; |
| 28 }; |
| 29 |
| 30 class PathOpsThreadedTestRunner { |
| 31 public: |
| 32 PathOpsThreadedTestRunner(skiatest::Reporter* reporter, int threadCount) |
| 33 : fNumThreads(threadCount) |
| 34 , fThreadPool(threadCount) |
| 35 , fCountdown(threadCount) |
| 36 , fReporter(reporter) { |
| 37 } |
| 38 |
| 39 ~PathOpsThreadedTestRunner(); |
| 40 |
| 41 void render(); |
| 42 |
| 43 public: |
| 44 int fNumThreads; |
| 45 SkTDArray<PathOpsThreadedRunnable*> fRunnables; |
| 46 SkThreadPool fThreadPool; |
| 47 SkCountdown fCountdown; |
| 48 skiatest::Reporter* fReporter; |
| 49 }; |
| 50 |
| 51 class PathOpsThreadedRunnable : public SkRunnable { |
| 52 public: |
| 53 PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), int a, int b,
int c, int d, |
| 54 PathOpsThreadedTestRunner* runner) { |
| 55 fState.fA = a; |
| 56 fState.fB = b; |
| 57 fState.fC = c; |
| 58 fState.fD = d; |
| 59 fState.fReporter = runner->fReporter; |
| 60 fTestFun = testFun; |
| 61 fDone = &runner->fCountdown; |
| 62 } |
| 63 |
| 64 virtual void run() SK_OVERRIDE { |
| 65 SkBitmap bitmap; |
| 66 fState.fBitmap = &bitmap; |
| 67 char pathStr[PATH_STR_SIZE]; |
| 68 fState.fPathStr = pathStr; |
| 69 (*fTestFun)(&fState); |
| 70 fDone->run(); |
| 71 } |
| 72 |
| 73 private: |
| 74 PathOpsThreadState fState; |
| 75 void (*fTestFun)(PathOpsThreadState*); |
| 76 SkRunnable* fDone; |
| 77 }; |
| 78 |
| 79 #endif |
OLD | NEW |