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