blob: 54586d95cca2f4c7763ef88d49217361ef251c4b [file] [log] [blame]
caryclark@google.com66089e42013-04-10 15:55:37 +00001/*
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.com7eaa53d2013-10-02 14:49:34 +000010#include "SkGraphics.h"
caryclark@google.com66089e42013-04-10 15:55:37 +000011#include "SkTDArray.h"
caryclark@google.com66089e42013-04-10 15:55:37 +000012
13#define PATH_STR_SIZE 512
14
15class PathOpsThreadedRunnable;
caryclark@google.come942bc32013-04-10 18:53:01 +000016
17namespace skiatest {
18class Reporter;
19}
caryclark@google.com66089e42013-04-10 15:55:37 +000020
21struct PathOpsThreadState {
22 unsigned char fA;
23 unsigned char fB;
24 unsigned char fC;
25 unsigned char fD;
26 char* fPathStr;
caryclark@google.com03610322013-04-18 15:58:21 +000027 const char* fKey;
caryclark@google.com7eaa53d2013-10-02 14:49:34 +000028 char fSerialNo[256];
caryclark@google.com66089e42013-04-10 15:55:37 +000029 skiatest::Reporter* fReporter;
30 SkBitmap* fBitmap;
31};
32
33class PathOpsThreadedTestRunner {
34public:
mtklein406654b2014-09-03 15:34:37 -070035 PathOpsThreadedTestRunner(skiatest::Reporter* reporter) : fReporter(reporter) {}
caryclark@google.com66089e42013-04-10 15:55:37 +000036
37 ~PathOpsThreadedTestRunner();
38
39 void render();
40
41public:
caryclark@google.com66089e42013-04-10 15:55:37 +000042 SkTDArray<PathOpsThreadedRunnable*> fRunnables;
caryclark@google.com66089e42013-04-10 15:55:37 +000043 skiatest::Reporter* fReporter;
44};
45
mtklein048494c2016-02-16 19:06:15 -080046class PathOpsThreadedRunnable {
caryclark@google.com66089e42013-04-10 15:55:37 +000047public:
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.com66089e42013-04-10 15:55:37 +000056 }
57
caryclark@google.com07e97fc2013-07-08 17:17:02 +000058 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.coma2bbc6e2013-11-01 17:36:03 +000066 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
mtklein048494c2016-02-16 19:06:15 -080075 void operator()() {
caryclark@google.com66089e42013-04-10 15:55:37 +000076 SkBitmap bitmap;
77 fState.fBitmap = &bitmap;
78 char pathStr[PATH_STR_SIZE];
79 fState.fPathStr = pathStr;
caryclark@google.com7eaa53d2013-10-02 14:49:34 +000080 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
caryclark@google.com66089e42013-04-10 15:55:37 +000081 (*fTestFun)(&fState);
caryclark@google.com66089e42013-04-10 15:55:37 +000082 }
83
84private:
85 PathOpsThreadState fState;
86 void (*fTestFun)(PathOpsThreadState*);
caryclark@google.com66089e42013-04-10 15:55:37 +000087};
88
89#endif