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