2013-04-10 15:55:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
#ifndef PathOpsThreadedCommon_DEFINED
|
|
|
|
#define PathOpsThreadedCommon_DEFINED
|
|
|
|
|
2017-02-07 19:09:38 +00:00
|
|
|
#include "SkBitmap.h"
|
2013-10-02 14:49:34 +00:00
|
|
|
#include "SkGraphics.h"
|
2017-01-07 16:16:28 +00:00
|
|
|
#include "SkPath.h"
|
2017-02-07 19:09:38 +00:00
|
|
|
#include "SkPathOps.h"
|
2013-04-10 15:55:37 +00:00
|
|
|
#include "SkTDArray.h"
|
|
|
|
|
2017-04-14 11:46:07 +00:00
|
|
|
#include <string>
|
|
|
|
|
2013-04-10 15:55:37 +00:00
|
|
|
#define PATH_STR_SIZE 512
|
|
|
|
|
|
|
|
class PathOpsThreadedRunnable;
|
2013-04-10 18:53:01 +00:00
|
|
|
|
|
|
|
namespace skiatest {
|
|
|
|
class Reporter;
|
|
|
|
}
|
2013-04-10 15:55:37 +00:00
|
|
|
|
|
|
|
struct PathOpsThreadState {
|
|
|
|
unsigned char fA;
|
|
|
|
unsigned char fB;
|
|
|
|
unsigned char fC;
|
|
|
|
unsigned char fD;
|
2017-04-14 11:46:07 +00:00
|
|
|
std::string fPathStr;
|
2013-04-18 15:58:21 +00:00
|
|
|
const char* fKey;
|
2013-10-02 14:49:34 +00:00
|
|
|
char fSerialNo[256];
|
2013-04-10 15:55:37 +00:00
|
|
|
skiatest::Reporter* fReporter;
|
|
|
|
SkBitmap* fBitmap;
|
2017-01-07 16:16:28 +00:00
|
|
|
|
|
|
|
void outputProgress(const char* pathStr, SkPath::FillType);
|
|
|
|
void outputProgress(const char* pathStr, SkPathOp);
|
2013-04-10 15:55:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PathOpsThreadedTestRunner {
|
|
|
|
public:
|
SkThreadPool ~~> SkTaskGroup
SkTaskGroup is like SkThreadPool except the threads stay in
one global pool. Each SkTaskGroup itself is tiny (4 bytes)
and its wait() method applies only to tasks add()ed to that
instance, not the whole thread pool.
This means we don't need to bring up new thread pools when
tests themselves want to use multithreading (e.g. pathops,
quilt). We just create a new SkTaskGroup and wait for that
to complete. This should be more efficient, and allow us
to expand where we use threads to really latency sensitive
places. E.g. we can probably now use these in nanobench
for CPU .skp rendering.
Now that all threads are sharing the same pool, I think we
can remove most of the custom mechanism pathops tests use
to control threading. They'll just ride on the global pool
with all other tests now.
This (temporarily?) removes the GPU multithreading feature
from DM, which we don't use.
On my desktop, DM runs a little faster (57s -> 55s) in
Debug, and a lot faster in Release (36s -> 24s). The bots
show speedups of similar proportions, cutting more than a
minute off the N4/Release and Win7/Debug runtimes.
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/9c7207b5dc71dc5a96a2eb107d401133333d5b6f
R=caryclark@google.com, bsalomon@google.com, bungeman@google.com, mtklein@google.com, reed@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/531653002
2014-09-03 22:34:37 +00:00
|
|
|
PathOpsThreadedTestRunner(skiatest::Reporter* reporter) : fReporter(reporter) {}
|
2013-04-10 15:55:37 +00:00
|
|
|
|
|
|
|
~PathOpsThreadedTestRunner();
|
|
|
|
|
|
|
|
void render();
|
|
|
|
|
|
|
|
public:
|
|
|
|
SkTDArray<PathOpsThreadedRunnable*> fRunnables;
|
|
|
|
skiatest::Reporter* fReporter;
|
|
|
|
};
|
|
|
|
|
2016-02-17 03:06:15 +00:00
|
|
|
class PathOpsThreadedRunnable {
|
2013-04-10 15:55:37 +00:00
|
|
|
public:
|
|
|
|
PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), int a, int b, int c, int d,
|
|
|
|
PathOpsThreadedTestRunner* runner) {
|
2019-02-04 15:01:53 +00:00
|
|
|
fState.fA = (a & 0xFF);
|
|
|
|
fState.fB = (b & 0xFF);
|
|
|
|
fState.fC = (c & 0xFF);
|
|
|
|
fState.fD = (d & 0xFF);
|
2013-04-10 15:55:37 +00:00
|
|
|
fState.fReporter = runner->fReporter;
|
|
|
|
fTestFun = testFun;
|
|
|
|
}
|
|
|
|
|
2013-07-08 17:17:02 +00:00
|
|
|
PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), const char* str,
|
|
|
|
PathOpsThreadedTestRunner* runner) {
|
|
|
|
SkASSERT(strlen(str) < sizeof(fState.fSerialNo) - 1);
|
|
|
|
strcpy(fState.fSerialNo, str);
|
|
|
|
fState.fReporter = runner->fReporter;
|
|
|
|
fTestFun = testFun;
|
|
|
|
}
|
|
|
|
|
2013-11-01 17:36:03 +00:00
|
|
|
PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), int dirNo, const char* str,
|
|
|
|
PathOpsThreadedTestRunner* runner) {
|
|
|
|
SkASSERT(strlen(str) < sizeof(fState.fSerialNo) - 1);
|
|
|
|
fState.fA = dirNo;
|
|
|
|
strcpy(fState.fSerialNo, str);
|
|
|
|
fState.fReporter = runner->fReporter;
|
|
|
|
fTestFun = testFun;
|
|
|
|
}
|
|
|
|
|
2016-02-17 03:06:15 +00:00
|
|
|
void operator()() {
|
2013-04-10 15:55:37 +00:00
|
|
|
SkBitmap bitmap;
|
|
|
|
fState.fBitmap = &bitmap;
|
|
|
|
(*fTestFun)(&fState);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
PathOpsThreadState fState;
|
|
|
|
void (*fTestFun)(PathOpsThreadState*);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|