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