Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: dm/DMTaskRunner.cpp

Issue 178273002: Let DM run unit tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dm/DMTaskRunner.h ('k') | dm/DMTestTask.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMTaskRunner.cpp
diff --git a/dm/DMTaskRunner.cpp b/dm/DMTaskRunner.cpp
index 22269a4d7046739a1689d1b08d33987f3ddafcc6..bd53ce615a61134271a1751add333c4eec480ff6 100644
--- a/dm/DMTaskRunner.cpp
+++ b/dm/DMTaskRunner.cpp
@@ -3,10 +3,21 @@
namespace DM {
-TaskRunner::TaskRunner(int cputhreads, int gpuThreads)
+
+TaskRunner::TaskRunner(int cputhreads)
: fMain(cputhreads)
- , fGpu(gpuThreads)
- {}
+ , 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()) {
@@ -17,6 +28,17 @@ void TaskRunner::add(Task* 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
« no previous file with comments | « dm/DMTaskRunner.h ('k') | dm/DMTestTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698