blob: 1462aa225171b34b9c9d2c91fa421afa585214ea [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
Hal Canary6b20a552017-02-07 14:09:38 -050010#include "SkBitmap.h"
caryclark@google.com7eaa53d2013-10-02 14:49:34 +000011#include "SkGraphics.h"
Mike Reedff80c2a2017-01-07 11:16:28 -050012#include "SkPath.h"
Hal Canary6b20a552017-02-07 14:09:38 -050013#include "SkPathOps.h"
Mike Reedff80c2a2017-01-07 11:16:28 -050014#include "SkString.h"
caryclark@google.com66089e42013-04-10 15:55:37 +000015#include "SkTDArray.h"
caryclark@google.com66089e42013-04-10 15:55:37 +000016
17#define PATH_STR_SIZE 512
18
19class PathOpsThreadedRunnable;
caryclark@google.come942bc32013-04-10 18:53:01 +000020
21namespace skiatest {
22class Reporter;
23}
caryclark@google.com66089e42013-04-10 15:55:37 +000024
25struct PathOpsThreadState {
26 unsigned char fA;
27 unsigned char fB;
28 unsigned char fC;
29 unsigned char fD;
Mike Reedff80c2a2017-01-07 11:16:28 -050030 SkString fPathStr;
caryclark@google.com03610322013-04-18 15:58:21 +000031 const char* fKey;
caryclark@google.com7eaa53d2013-10-02 14:49:34 +000032 char fSerialNo[256];
caryclark@google.com66089e42013-04-10 15:55:37 +000033 skiatest::Reporter* fReporter;
34 SkBitmap* fBitmap;
Mike Reedff80c2a2017-01-07 11:16:28 -050035
36 void outputProgress(const char* pathStr, SkPath::FillType);
37 void outputProgress(const char* pathStr, SkPathOp);
caryclark@google.com66089e42013-04-10 15:55:37 +000038};
39
40class PathOpsThreadedTestRunner {
41public:
mtklein406654b2014-09-03 15:34:37 -070042 PathOpsThreadedTestRunner(skiatest::Reporter* reporter) : fReporter(reporter) {}
caryclark@google.com66089e42013-04-10 15:55:37 +000043
44 ~PathOpsThreadedTestRunner();
45
46 void render();
47
48public:
caryclark@google.com66089e42013-04-10 15:55:37 +000049 SkTDArray<PathOpsThreadedRunnable*> fRunnables;
caryclark@google.com66089e42013-04-10 15:55:37 +000050 skiatest::Reporter* fReporter;
51};
52
mtklein048494c2016-02-16 19:06:15 -080053class PathOpsThreadedRunnable {
caryclark@google.com66089e42013-04-10 15:55:37 +000054public:
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.com66089e42013-04-10 15:55:37 +000063 }
64
caryclark@google.com07e97fc2013-07-08 17:17:02 +000065 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.coma2bbc6e2013-11-01 17:36:03 +000073 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
mtklein048494c2016-02-16 19:06:15 -080082 void operator()() {
caryclark@google.com66089e42013-04-10 15:55:37 +000083 SkBitmap bitmap;
84 fState.fBitmap = &bitmap;
caryclark@google.com7eaa53d2013-10-02 14:49:34 +000085 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
caryclark@google.com66089e42013-04-10 15:55:37 +000086 (*fTestFun)(&fState);
caryclark@google.com66089e42013-04-10 15:55:37 +000087 }
88
89private:
90 PathOpsThreadState fState;
91 void (*fTestFun)(PathOpsThreadState*);
caryclark@google.com66089e42013-04-10 15:55:37 +000092};
93
94#endif