OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_RASTER_DEPENDENCY_TASK_H_ | |
6 #define CC_RASTER_DEPENDENCY_TASK_H_ | |
7 | |
8 #include <stddef.h> | |
9 #include <stdint.h> | |
10 | |
11 #include <algorithm> | |
12 #include <map> | |
ericrk
2016/04/01 21:34:31
nit: map/algorithm are not used
| |
13 #include <vector> | |
14 | |
15 #include "base/logging.h" | |
ericrk
2016/04/01 21:34:30
nit: logging is not used.
| |
16 #include "base/memory/ref_counted.h" | |
17 #include "base/memory/scoped_ptr.h" | |
18 #include "cc/base/cc_export.h" | |
19 | |
20 namespace cc { | |
21 | |
22 class Resource; | |
23 class RasterBuffer; | |
24 | |
25 class CC_EXPORT DependencyTaskClient { | |
ericrk
2016/04/01 21:34:30
This does a lot of things other than dependencies,
prashant.n
2016/04/01 23:48:05
I called this as DependencyTask to differetiate fr
| |
26 public: | |
27 virtual scoped_ptr<RasterBuffer> AcquireBufferForRaster( | |
prashant.n
2016/04/01 14:23:39
These methods will be made generic in subsequent p
ericrk
2016/04/01 21:34:30
While I agree that dependencies are a generic conc
prashant.n
2016/04/01 23:48:05
Yes, I agree with you. Scheduling and Completing t
| |
28 const Resource* resource, | |
29 uint64_t resource_content_id, | |
30 uint64_t previous_content_id) = 0; | |
31 virtual void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) = 0; | |
32 | |
33 protected: | |
34 virtual ~DependencyTaskClient() {} | |
35 }; | |
36 | |
37 // A task with or without dependencies which can be run by a TaskGraphRunner. To | |
38 // run a DependencyTask, it should be inserted into a TaskGraph, which can then | |
39 // be scheduled on the TaskGraphRunner. | |
40 class CC_EXPORT DependencyTask | |
41 : public base::RefCountedThreadSafe<DependencyTask> { | |
42 public: | |
43 typedef std::vector<scoped_refptr<DependencyTask>> Vector; | |
44 | |
45 const DependencyTask::Vector& dependencies() const { return dependencies_; } | |
46 | |
47 // Subclasses should implement these methods. RunOnWorkerThread may be called | |
48 // on any thread (origin or worker), ScheduleOnOriginThread and | |
49 // CompleteOnOriginThread must be called on origin thread. The subclasses are | |
50 // responsible for locking and thread safety. | |
51 virtual void RunOnWorkerThread() = 0; | |
52 virtual void ScheduleOnOriginThread(DependencyTaskClient* client) = 0; | |
53 virtual void CompleteOnOriginThread(DependencyTaskClient* client) = 0; | |
54 | |
55 void WillRun(); | |
56 void DidRun(); | |
57 bool HasFinishedRunning() const; | |
58 | |
59 void WillSchedule(); | |
60 void DidSchedule(); | |
61 bool HasBeenScheduled() const; | |
62 | |
63 void WillComplete(); | |
64 void DidComplete(); | |
65 bool HasCompleted() const; | |
66 | |
67 protected: | |
68 friend class base::RefCountedThreadSafe<DependencyTask>; | |
69 | |
70 // For creating task without dependencies. | |
71 DependencyTask(); | |
72 // For creating task with dependencies. | |
73 explicit DependencyTask(DependencyTask::Vector* dependencies); | |
ericrk
2016/04/01 21:34:30
maybe take by value to allow us to std::move the v
| |
74 virtual ~DependencyTask(); | |
75 | |
76 bool will_run_; | |
77 bool did_run_; | |
78 bool did_schedule_; | |
79 bool did_complete_; | |
80 | |
81 DependencyTask::Vector dependencies_; | |
82 }; | |
83 | |
84 } // namespace cc | |
85 | |
86 #endif // CC_RASTER_DEPENDENCY_TASK_H_ | |
OLD | NEW |