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