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

Side by Side Diff: dm/DMTask.h

Issue 179233005: DM: make GPU tasks multithreaded again. Big refactor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: default 1 GPU thread Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « dm/DMSerializeTask.cpp ('k') | dm/DMTask.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifndef DMTask_DEFINED 1 #ifndef DMTask_DEFINED
2 #define DMTask_DEFINED 2 #define DMTask_DEFINED
3 3
4 #include "DMReporter.h" 4 #include "DMReporter.h"
5 #include "GrContextFactory.h" 5 #include "GrContextFactory.h"
6 #include "SkRunnable.h" 6 #include "SkRunnable.h"
7 #include "SkThreadPool.h"
8 7
9 // DM will run() these tasks on one of two threadpools, depending on the result 8 // DM will run() these tasks on one of two threadpools.
10 // of usesGpu(). The subclasses can call fail() to mark this task as failed, 9 // Subclasses can call fail() to mark this task as failed, or make any number of spawnChild() calls
11 // or make any number of spawnChild() calls to kick off dependent tasks. 10 // to kick off dependent tasks.
12 // 11 //
13 // Task deletes itself when run. 12 // Tasks delete themselves when run.
14 13
15 namespace DM { 14 namespace DM {
16 15
17 class TaskRunner; 16 class TaskRunner;
18 17
19 class Task : public SkRunnable { 18 class CpuTask;
19
20 class Task {
20 public: 21 public:
21 Task(Reporter* reporter, TaskRunner* taskRunner);
22 Task(const Task& parent);
23 virtual ~Task();
24
25 void run() SK_OVERRIDE;
26
27 virtual void draw() = 0;
28 virtual bool usesGpu() const = 0;
29 virtual bool shouldSkip() const = 0; 22 virtual bool shouldSkip() const = 0;
30 virtual SkString name() const = 0; 23 virtual SkString name() const = 0;
31 24
32 // Returns the number of parents above this task. 25 // Returns the number of parents above this task.
33 // Top-level tasks return 0, their children 1, and so on. 26 // Top-level tasks return 0, their children 1, and so on.
34 int depth() const { return fDepth; } 27 int depth() const { return fDepth; }
35 28
36 protected: 29 protected:
37 void spawnChild(Task* task); 30 Task(Reporter* reporter, TaskRunner* taskRunner);
31 Task(const Task& parent);
32 virtual ~Task() {}
33
38 void fail(const char* msg = NULL); 34 void fail(const char* msg = NULL);
39 35 void finish();
40 // This can only be safely called from a GPU task's draw() method. 36 void spawnChild(CpuTask* task); // For now we don't allow GPU child tasks.
41 GrContextFactory* getGrContextFactory() const;
42 37
43 private: 38 private:
44 // Both unowned. 39 Reporter* fReporter; // Unowned.
45 Reporter* fReporter; 40 TaskRunner* fTaskRunner; // Unowned.
46 TaskRunner* fTaskRunner;
47 int fDepth; 41 int fDepth;
42 };
48 43
49 typedef SkRunnable INHERITED; 44 class CpuTask : public Task, public SkRunnable {
45 public:
46 CpuTask(Reporter* reporter, TaskRunner* taskRunner);
47 CpuTask(const Task& parent);
48 virtual ~CpuTask() {}
49
50 void run() SK_OVERRIDE;
51 virtual void draw() = 0;
52 };
53
54 class GpuTask : public Task, public SkTRunnable<GrContextFactory> {
55 public:
56 GpuTask(Reporter* reporter, TaskRunner* taskRunner);
57 virtual ~GpuTask() {}
58
59 void run(GrContextFactory&) SK_OVERRIDE;
60 virtual void draw(GrContextFactory*) = 0;
50 }; 61 };
51 62
52 } // namespace DM 63 } // namespace DM
53 64
54 #endif // DMTask_DEFINED 65 #endif // DMTask_DEFINED
OLDNEW
« no previous file with comments | « dm/DMSerializeTask.cpp ('k') | dm/DMTask.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698