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

Unified Diff: cc/resources/raster_worker_pool.cc

Issue 154003006: cc: Switch to vector based TaskGraph implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix 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 | « cc/resources/raster_worker_pool.h ('k') | cc/resources/raster_worker_pool_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/raster_worker_pool.cc
diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc
index 09b65bc06b84fa04f8eea4f6bbc17572b7851bce..29aa0f2b71133e6c4f82ae575f80a077e3f305ce 100644
--- a/cc/resources/raster_worker_pool.cc
+++ b/cc/resources/raster_worker_pool.cc
@@ -21,7 +21,6 @@
#include "third_party/skia/include/gpu/SkGpuDevice.h"
namespace cc {
-
namespace {
// Subclass of Allocator that takes a suitably allocated pointer and uses
@@ -228,7 +227,7 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask {
}
protected:
- virtual ~RasterWorkerPoolTaskImpl() {}
+ virtual ~RasterWorkerPoolTaskImpl() { DCHECK(!buffer_); }
private:
scoped_ptr<base::Value> DataAsValue() const {
@@ -537,6 +536,13 @@ void RasterWorkerPool::RasterTask::Reset() { internal_ = NULL; }
RasterWorkerPool::RasterTask::~RasterTask() {}
+// Task priorities that make sure raster finished tasks run before any
+// remaining raster tasks.
+unsigned RasterWorkerPool::kRasterFinishedTaskPriority = 1u;
+unsigned RasterWorkerPool::kRasterRequiredForActivationFinishedTaskPriority =
+ 0u;
+unsigned RasterWorkerPool::kRasterTaskPriorityBase = 2u;
+
RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider,
ContextProvider* context_provider)
: namespace_token_(g_task_graph_runner.Pointer()->GetNamespaceToken()),
@@ -611,7 +617,7 @@ void RasterWorkerPool::Shutdown() {
TRACE_EVENT0("cc", "RasterWorkerPool::Shutdown");
raster_tasks_.clear();
- TaskGraph empty;
+ internal::TaskGraph empty;
SetTaskGraph(&empty);
g_task_graph_runner.Pointer()->WaitForTasksToFinishRunning(namespace_token_);
weak_ptr_factory_.InvalidateWeakPtrs();
@@ -629,15 +635,15 @@ bool RasterWorkerPool::IsRasterTaskRequiredForActivation(
raster_tasks_required_for_activation_.end();
}
-void RasterWorkerPool::SetTaskGraph(TaskGraph* graph) {
- TRACE_EVENT1(
- "cc", "RasterWorkerPool::SetTaskGraph", "num_tasks", graph->size());
+void RasterWorkerPool::SetTaskGraph(internal::TaskGraph* graph) {
+ TRACE_EVENT0("cc", "RasterWorkerPool::SetTaskGraph");
- for (internal::GraphNode::Map::iterator it = graph->begin();
- it != graph->end();
+ for (internal::TaskGraph::Node::Vector::iterator it = graph->nodes.begin();
+ it != graph->nodes.end();
++it) {
+ internal::TaskGraph::Node& node = *it;
internal::WorkerPoolTask* task =
- static_cast<internal::WorkerPoolTask*>(it->first);
+ static_cast<internal::WorkerPoolTask*>(node.task);
if (!task->HasBeenScheduled()) {
task->WillSchedule();
@@ -748,24 +754,25 @@ scoped_ptr<base::Value> RasterWorkerPool::ScheduledStateAsValue() const {
}
// static
-internal::GraphNode* RasterWorkerPool::CreateGraphNodeForTask(
- internal::WorkerPoolTask* task,
- unsigned priority,
- TaskGraph* graph) {
- internal::GraphNode* node = new internal::GraphNode(task, priority);
- DCHECK(graph->find(task) == graph->end());
- graph->set(task, make_scoped_ptr(node));
- return node;
+void RasterWorkerPool::InsertNodeForTask(internal::TaskGraph* graph,
+ internal::WorkerPoolTask* task,
+ unsigned priority,
+ size_t dependencies) {
+ DCHECK(std::find_if(graph->nodes.begin(),
+ graph->nodes.end(),
+ internal::TaskGraph::Node::TaskComparator(task)) ==
+ graph->nodes.end());
+ graph->nodes.push_back(
+ internal::TaskGraph::Node(task, priority, dependencies));
}
// static
-internal::GraphNode* RasterWorkerPool::CreateGraphNodeForRasterTask(
+void RasterWorkerPool::InsertNodeForRasterTask(
+ internal::TaskGraph* graph,
internal::WorkerPoolTask* raster_task,
const internal::Task::Vector& decode_tasks,
- unsigned priority,
- TaskGraph* graph) {
- internal::GraphNode* raster_node =
- CreateGraphNodeForTask(raster_task, priority, graph);
+ unsigned priority) {
+ size_t dependencies = 0u;
// Insert image decode tasks.
for (internal::Task::Vector::const_iterator it = decode_tasks.begin();
@@ -778,22 +785,20 @@ internal::GraphNode* RasterWorkerPool::CreateGraphNodeForRasterTask(
if (decode_task->HasCompleted())
continue;
- raster_node->add_dependency();
+ dependencies++;
- // Check if decode task already exists in graph.
- internal::GraphNode::Map::iterator decode_it = graph->find(decode_task);
- if (decode_it != graph->end()) {
- internal::GraphNode* decode_node = decode_it->second;
- decode_node->add_dependent(raster_node);
- continue;
- }
+ // Add decode task if it doesn't already exists in graph.
+ internal::TaskGraph::Node::Vector::iterator decode_it =
+ std::find_if(graph->nodes.begin(),
+ graph->nodes.end(),
+ internal::TaskGraph::Node::TaskComparator(decode_task));
+ if (decode_it == graph->nodes.end())
+ InsertNodeForTask(graph, decode_task, priority, 0u);
- internal::GraphNode* decode_node =
- CreateGraphNodeForTask(decode_task, priority, graph);
- decode_node->add_dependent(raster_node);
+ graph->edges.push_back(internal::TaskGraph::Edge(decode_task, raster_task));
}
- return raster_node;
+ InsertNodeForTask(graph, raster_task, priority, dependencies);
}
} // namespace cc
« no previous file with comments | « cc/resources/raster_worker_pool.h ('k') | cc/resources/raster_worker_pool_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698