blob: 706da6b110078db17f258518e67c495141deea24 [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"
caryclark@google.com66089e42013-04-10 15:55:37 +000014#include "SkTDArray.h"
caryclark@google.com66089e42013-04-10 15:55:37 +000015
Cary Clark389c5572017-04-14 07:46:07 -040016#include <string>
17
caryclark@google.com66089e42013-04-10 15:55:37 +000018#define PATH_STR_SIZE 512
19
20class PathOpsThreadedRunnable;
caryclark@google.come942bc32013-04-10 18:53:01 +000021
22namespace skiatest {
23class Reporter;
24}
caryclark@google.com66089e42013-04-10 15:55:37 +000025
26struct PathOpsThreadState {
27 unsigned char fA;
28 unsigned char fB;
29 unsigned char fC;
30 unsigned char fD;
Cary Clark389c5572017-04-14 07:46:07 -040031 std::string fPathStr;
caryclark@google.com03610322013-04-18 15:58:21 +000032 const char* fKey;
caryclark@google.com7eaa53d2013-10-02 14:49:34 +000033 char fSerialNo[256];
caryclark@google.com66089e42013-04-10 15:55:37 +000034 skiatest::Reporter* fReporter;
35 SkBitmap* fBitmap;
Mike Reedff80c2a2017-01-07 11:16:28 -050036
37 void outputProgress(const char* pathStr, SkPath::FillType);
38 void outputProgress(const char* pathStr, SkPathOp);
caryclark@google.com66089e42013-04-10 15:55:37 +000039};
40
41class PathOpsThreadedTestRunner {
42public:
mtklein406654b2014-09-03 15:34:37 -070043 PathOpsThreadedTestRunner(skiatest::Reporter* reporter) : fReporter(reporter) {}
caryclark@google.com66089e42013-04-10 15:55:37 +000044
45 ~PathOpsThreadedTestRunner();
46
47 void render();
48
49public:
caryclark@google.com66089e42013-04-10 15:55:37 +000050 SkTDArray<PathOpsThreadedRunnable*> fRunnables;
caryclark@google.com66089e42013-04-10 15:55:37 +000051 skiatest::Reporter* fReporter;
52};
53
mtklein048494c2016-02-16 19:06:15 -080054class PathOpsThreadedRunnable {
caryclark@google.com66089e42013-04-10 15:55:37 +000055public:
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.com66089e42013-04-10 15:55:37 +000064 }
65
caryclark@google.com07e97fc2013-07-08 17:17:02 +000066 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.coma2bbc6e2013-11-01 17:36:03 +000074 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
mtklein048494c2016-02-16 19:06:15 -080083 void operator()() {
caryclark@google.com66089e42013-04-10 15:55:37 +000084 SkBitmap bitmap;
85 fState.fBitmap = &bitmap;
caryclark@google.com7eaa53d2013-10-02 14:49:34 +000086 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
caryclark@google.com66089e42013-04-10 15:55:37 +000087 (*fTestFun)(&fState);
caryclark@google.com66089e42013-04-10 15:55:37 +000088 }
89
90private:
91 PathOpsThreadState fState;
92 void (*fTestFun)(PathOpsThreadState*);
caryclark@google.com66089e42013-04-10 15:55:37 +000093};
94
95#endif