caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +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 | #ifndef PathOpsThreadedCommon_DEFINED |
| 8 | #define PathOpsThreadedCommon_DEFINED |
| 9 | |
caryclark@google.com | 7eaa53d | 2013-10-02 14:49:34 +0000 | [diff] [blame] | 10 | #include "SkGraphics.h" |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 11 | #include "SkRunnable.h" |
| 12 | #include "SkTDArray.h" |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 13 | |
| 14 | #define PATH_STR_SIZE 512 |
| 15 | |
| 16 | class PathOpsThreadedRunnable; |
caryclark@google.com | e942bc3 | 2013-04-10 18:53:01 +0000 | [diff] [blame] | 17 | |
| 18 | namespace skiatest { |
| 19 | class Reporter; |
| 20 | } |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 21 | |
| 22 | struct PathOpsThreadState { |
| 23 | unsigned char fA; |
| 24 | unsigned char fB; |
| 25 | unsigned char fC; |
| 26 | unsigned char fD; |
| 27 | char* fPathStr; |
caryclark@google.com | 0361032 | 2013-04-18 15:58:21 +0000 | [diff] [blame] | 28 | const char* fKey; |
caryclark@google.com | 7eaa53d | 2013-10-02 14:49:34 +0000 | [diff] [blame] | 29 | char fSerialNo[256]; |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 30 | skiatest::Reporter* fReporter; |
| 31 | SkBitmap* fBitmap; |
| 32 | }; |
| 33 | |
| 34 | class PathOpsThreadedTestRunner { |
| 35 | public: |
mtklein | 406654b | 2014-09-03 15:34:37 -0700 | [diff] [blame] | 36 | PathOpsThreadedTestRunner(skiatest::Reporter* reporter) : fReporter(reporter) {} |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 37 | |
| 38 | ~PathOpsThreadedTestRunner(); |
| 39 | |
| 40 | void render(); |
| 41 | |
| 42 | public: |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 43 | SkTDArray<PathOpsThreadedRunnable*> fRunnables; |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 44 | skiatest::Reporter* fReporter; |
| 45 | }; |
| 46 | |
| 47 | class PathOpsThreadedRunnable : public SkRunnable { |
| 48 | public: |
| 49 | PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), int a, int b, int c, int d, |
| 50 | PathOpsThreadedTestRunner* runner) { |
| 51 | fState.fA = a; |
| 52 | fState.fB = b; |
| 53 | fState.fC = c; |
| 54 | fState.fD = d; |
| 55 | fState.fReporter = runner->fReporter; |
| 56 | fTestFun = testFun; |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 57 | } |
| 58 | |
caryclark@google.com | 07e97fc | 2013-07-08 17:17:02 +0000 | [diff] [blame] | 59 | PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), const char* str, |
| 60 | PathOpsThreadedTestRunner* runner) { |
| 61 | SkASSERT(strlen(str) < sizeof(fState.fSerialNo) - 1); |
| 62 | strcpy(fState.fSerialNo, str); |
| 63 | fState.fReporter = runner->fReporter; |
| 64 | fTestFun = testFun; |
| 65 | } |
| 66 | |
caryclark@google.com | a2bbc6e | 2013-11-01 17:36:03 +0000 | [diff] [blame] | 67 | PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), int dirNo, const char* str, |
| 68 | PathOpsThreadedTestRunner* runner) { |
| 69 | SkASSERT(strlen(str) < sizeof(fState.fSerialNo) - 1); |
| 70 | fState.fA = dirNo; |
| 71 | strcpy(fState.fSerialNo, str); |
| 72 | fState.fReporter = runner->fReporter; |
| 73 | fTestFun = testFun; |
| 74 | } |
| 75 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 76 | void run() override { |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 77 | SkBitmap bitmap; |
| 78 | fState.fBitmap = &bitmap; |
| 79 | char pathStr[PATH_STR_SIZE]; |
| 80 | fState.fPathStr = pathStr; |
caryclark@google.com | 7eaa53d | 2013-10-02 14:49:34 +0000 | [diff] [blame] | 81 | SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 82 | (*fTestFun)(&fState); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | private: |
| 86 | PathOpsThreadState fState; |
| 87 | void (*fTestFun)(PathOpsThreadState*); |
caryclark@google.com | 66089e4 | 2013-04-10 15:55:37 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | #endif |