0dc5bd149a
- refactor GYPs and a few flags - make GPU tests grab a thread-local GrContextFactory when needed as we do in DM for GMs - add a few more UI features to make DM more like tests I believe this makes the program 'tests' obsolete. It should be somewhat faster to run the two sets together than running the old binaries serially: - serial: tests 20s (3m18s CPU), dm 21s (3m01s CPU) - together: 27s (6m21s CPU) Next up is to incorporate benches. I'm only planning there on a single-pass sanity check, so that won't obsolete the program 'bench' just yet. Tested: out/Debug/tests && out/Debug/dm && echo ok BUG=skia: Committed: http://code.google.com/p/skia/source/detail?r=13586 R=reed@google.com, bsalomon@google.com, mtklein@google.com, tfarina@chromium.org Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/178273002 git-svn-id: http://skia.googlecode.com/svn/trunk@13592 2bbb7eff-a529-9590-31e7-b0007b416f81
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#include "DMTaskRunner.h"
|
|
#include "DMTask.h"
|
|
|
|
namespace DM {
|
|
|
|
|
|
TaskRunner::TaskRunner(int cputhreads)
|
|
: fMain(cputhreads)
|
|
, fGpu(1) {
|
|
// Enqueue a task on the GPU thread to create a GrContextFactory.
|
|
struct Create : public SkRunnable {
|
|
Create(GrContextFactory** ptr) : fPtr(ptr) {}
|
|
void run() SK_OVERRIDE {
|
|
*fPtr = SkNEW(GrContextFactory);
|
|
delete this;
|
|
}
|
|
GrContextFactory** fPtr;
|
|
};
|
|
fGpu.add(SkNEW_ARGS(Create, (&fGrContextFactory)));
|
|
}
|
|
|
|
void TaskRunner::add(Task* task) {
|
|
if (task->usesGpu()) {
|
|
fGpu.add(task);
|
|
} else {
|
|
fMain.add(task);
|
|
}
|
|
}
|
|
|
|
void TaskRunner::wait() {
|
|
// Enqueue a task on the GPU thread to destroy the GrContextFactory.
|
|
struct Delete : public SkRunnable {
|
|
Delete(GrContextFactory* ptr) : fPtr(ptr) {}
|
|
void run() SK_OVERRIDE {
|
|
delete fPtr;
|
|
delete this;
|
|
}
|
|
GrContextFactory* fPtr;
|
|
};
|
|
fGpu.add(SkNEW_ARGS(Delete, (fGrContextFactory)));
|
|
|
|
// These wait calls block until the threadpool is done. We don't allow
|
|
// children to spawn new GPU tasks so we can wait for that first knowing
|
|
// we'll never try to add to it later. Same can't be said of fMain: fGpu
|
|
// and fMain can both add tasks to fMain, so we have to wait for that last.
|
|
fGpu.wait();
|
|
fMain.wait();
|
|
}
|
|
|
|
} // namespace DM
|