OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_RESOURCES_IMAGE_COPY_RASTER_WORKER_POOL_H_ | 5 #ifndef CC_RESOURCES_IMAGE_COPY_RASTER_WORKER_POOL_H_ |
6 #define CC_RESOURCES_IMAGE_COPY_RASTER_WORKER_POOL_H_ | 6 #define CC_RESOURCES_IMAGE_COPY_RASTER_WORKER_POOL_H_ |
7 | 7 |
8 #include <vector> | |
9 | |
10 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
11 #include "base/values.h" | 9 #include "base/values.h" |
12 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
13 #include "cc/resources/raster_worker_pool.h" | 11 #include "cc/resources/raster_worker_pool.h" |
14 #include "cc/resources/rasterizer.h" | 12 #include "cc/resources/rasterizer.h" |
15 | 13 |
16 namespace base { | 14 namespace base { |
17 namespace debug { | 15 namespace debug { |
18 class ConvertableToTraceFormat; | 16 class ConvertableToTraceFormat; |
19 class TracedValue; | 17 class TracedValue; |
(...skipping 21 matching lines...) Expand all Loading... |
41 // Overridden from RasterWorkerPool: | 39 // Overridden from RasterWorkerPool: |
42 virtual Rasterizer* AsRasterizer() OVERRIDE; | 40 virtual Rasterizer* AsRasterizer() OVERRIDE; |
43 | 41 |
44 // Overridden from Rasterizer: | 42 // Overridden from Rasterizer: |
45 virtual void SetClient(RasterizerClient* client) OVERRIDE; | 43 virtual void SetClient(RasterizerClient* client) OVERRIDE; |
46 virtual void Shutdown() OVERRIDE; | 44 virtual void Shutdown() OVERRIDE; |
47 virtual void ScheduleTasks(RasterTaskQueue* queue) OVERRIDE; | 45 virtual void ScheduleTasks(RasterTaskQueue* queue) OVERRIDE; |
48 virtual void CheckForCompletedTasks() OVERRIDE; | 46 virtual void CheckForCompletedTasks() OVERRIDE; |
49 | 47 |
50 // Overridden from RasterizerTaskClient: | 48 // Overridden from RasterizerTaskClient: |
51 virtual RasterBuffer* AcquireBufferForRaster(RasterTask* task) OVERRIDE; | 49 virtual scoped_ptr<RasterBuffer> AcquireBufferForRaster( |
52 virtual void ReleaseBufferForRaster(RasterTask* task) OVERRIDE; | 50 const Resource* resource) OVERRIDE; |
| 51 virtual void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) OVERRIDE; |
53 | 52 |
54 protected: | 53 protected: |
55 ImageCopyRasterWorkerPool(base::SequencedTaskRunner* task_runner, | 54 ImageCopyRasterWorkerPool(base::SequencedTaskRunner* task_runner, |
56 TaskGraphRunner* task_graph_runner, | 55 TaskGraphRunner* task_graph_runner, |
57 ContextProvider* context_provider, | 56 ContextProvider* context_provider, |
58 ResourceProvider* resource_provider, | 57 ResourceProvider* resource_provider, |
59 ResourcePool* resource_pool); | 58 ResourcePool* resource_pool); |
60 | 59 |
61 private: | 60 private: |
62 struct RasterTaskState { | |
63 class TaskComparator { | |
64 public: | |
65 explicit TaskComparator(const RasterTask* task) : task_(task) {} | |
66 | |
67 bool operator()(const RasterTaskState& state) const { | |
68 return state.task == task_; | |
69 } | |
70 | |
71 private: | |
72 const RasterTask* task_; | |
73 }; | |
74 | |
75 typedef std::vector<RasterTaskState> Vector; | |
76 | |
77 RasterTaskState(const RasterTask* task, ScopedResource* resource) | |
78 : task(task), resource(resource) {} | |
79 | |
80 const RasterTask* task; | |
81 ScopedResource* resource; | |
82 }; | |
83 | |
84 void OnRasterFinished(TaskSet task_set); | 61 void OnRasterFinished(TaskSet task_set); |
85 void FlushCopies(); | |
86 scoped_refptr<base::debug::ConvertableToTraceFormat> StateAsValue() const; | 62 scoped_refptr<base::debug::ConvertableToTraceFormat> StateAsValue() const; |
87 void StagingStateAsValueInto(base::debug::TracedValue* staging_state) const; | 63 void StagingStateAsValueInto(base::debug::TracedValue* staging_state) const; |
88 | 64 |
89 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 65 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
90 TaskGraphRunner* task_graph_runner_; | 66 TaskGraphRunner* task_graph_runner_; |
91 const NamespaceToken namespace_token_; | 67 const NamespaceToken namespace_token_; |
92 RasterizerClient* client_; | 68 RasterizerClient* client_; |
93 ContextProvider* context_provider_; | 69 ContextProvider* context_provider_; |
94 ResourceProvider* resource_provider_; | 70 ResourceProvider* resource_provider_; |
95 ResourcePool* resource_pool_; | 71 ResourcePool* resource_pool_; |
96 | |
97 RasterTaskState::Vector raster_task_states_; | |
98 | |
99 bool has_performed_copy_since_last_flush_; | |
100 | |
101 TaskSetCollection raster_pending_; | 72 TaskSetCollection raster_pending_; |
102 | |
103 scoped_refptr<RasterizerTask> raster_finished_tasks_[kNumberOfTaskSets]; | 73 scoped_refptr<RasterizerTask> raster_finished_tasks_[kNumberOfTaskSets]; |
104 | 74 |
105 // Task graph used when scheduling tasks and vector used to gather | 75 // Task graph used when scheduling tasks and vector used to gather |
106 // completed tasks. | 76 // completed tasks. |
107 TaskGraph graph_; | 77 TaskGraph graph_; |
108 Task::Vector completed_tasks_; | 78 Task::Vector completed_tasks_; |
109 | 79 |
110 base::WeakPtrFactory<ImageCopyRasterWorkerPool> | 80 base::WeakPtrFactory<ImageCopyRasterWorkerPool> |
111 raster_finished_weak_ptr_factory_; | 81 raster_finished_weak_ptr_factory_; |
112 | 82 |
113 DISALLOW_COPY_AND_ASSIGN(ImageCopyRasterWorkerPool); | 83 DISALLOW_COPY_AND_ASSIGN(ImageCopyRasterWorkerPool); |
114 }; | 84 }; |
115 | 85 |
116 } // namespace cc | 86 } // namespace cc |
117 | 87 |
118 #endif // CC_RESOURCES_IMAGE_COPY_RASTER_WORKER_POOL_H_ | 88 #endif // CC_RESOURCES_IMAGE_COPY_RASTER_WORKER_POOL_H_ |
OLD | NEW |