blob: 6cc0c3f4eed9f13eba7291573341b36d9306d451 [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"
Mike Reedff80c2a2017-01-07 11:16:28 -050011#include "SkPath.h"
12#include "SkString.h"
caryclark@google.com66089e42013-04-10 15:55:37 +000013#include "SkTDArray.h"
caryclark@google.com66089e42013-04-10 15:55:37 +000014
15#define PATH_STR_SIZE 512
16
17class PathOpsThreadedRunnable;
caryclark@google.come942bc32013-04-10 18:53:01 +000018
19namespace skiatest {
20class Reporter;
21}
caryclark@google.com66089e42013-04-10 15:55:37 +000022
23struct PathOpsThreadState {
24 unsigned char fA;
25 unsigned char fB;
26 unsigned char fC;
27 unsigned char fD;
Mike Reedff80c2a2017-01-07 11:16:28 -050028 SkString fPathStr;
caryclark@google.com03610322013-04-18 15:58:21 +000029 const char* fKey;
caryclark@google.com7eaa53d2013-10-02 14:49:34 +000030 char fSerialNo[256];
caryclark@google.com66089e42013-04-10 15:55:37 +000031 skiatest::Reporter* fReporter;
32 SkBitmap* fBitmap;
Mike Reedff80c2a2017-01-07 11:16:28 -050033
34 void outputProgress(const char* pathStr, SkPath::FillType);
35 void outputProgress(const char* pathStr, SkPathOp);
caryclark@google.com66089e42013-04-10 15:55:37 +000036};
37
38class PathOpsThreadedTestRunner {
39public:
mtklein406654b2014-09-03 15:34:37 -070040 PathOpsThreadedTestRunner(skiatest::Reporter* reporter) : fReporter(reporter) {}
caryclark@google.com66089e42013-04-10 15:55:37 +000041
42 ~PathOpsThreadedTestRunner();
43
44 void render();
45
46public:
caryclark@google.com66089e42013-04-10 15:55:37 +000047 SkTDArray<PathOpsThreadedRunnable*> fRunnables;
caryclark@google.com66089e42013-04-10 15:55:37 +000048 skiatest::Reporter* fReporter;
49};
50
mtklein048494c2016-02-16 19:06:15 -080051class PathOpsThreadedRunnable {
caryclark@google.com66089e42013-04-10 15:55:37 +000052public:
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.com66089e42013-04-10 15:55:37 +000061 }
62
caryclark@google.com07e97fc2013-07-08 17:17:02 +000063 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.coma2bbc6e2013-11-01 17:36:03 +000071 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
mtklein048494c2016-02-16 19:06:15 -080080 void operator()() {
caryclark@google.com66089e42013-04-10 15:55:37 +000081 SkBitmap bitmap;
82 fState.fBitmap = &bitmap;
caryclark@google.com7eaa53d2013-10-02 14:49:34 +000083 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024);
caryclark@google.com66089e42013-04-10 15:55:37 +000084 (*fTestFun)(&fState);
caryclark@google.com66089e42013-04-10 15:55:37 +000085 }
86
87private:
88 PathOpsThreadState fState;
89 void (*fTestFun)(PathOpsThreadState*);
caryclark@google.com66089e42013-04-10 15:55:37 +000090};
91
92#endif