OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "cc/resources/raster_worker_pool.h" | 5 #include "cc/resources/raster_worker_pool.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "cc/debug/devtools_instrumentation.h" | 10 #include "cc/debug/devtools_instrumentation.h" |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 if (new_graph.empty()) { | 488 if (new_graph.empty()) { |
489 SetTaskGraph(&new_graph); | 489 SetTaskGraph(&new_graph); |
490 raster_finished_task_ = NULL; | 490 raster_finished_task_ = NULL; |
491 return; | 491 return; |
492 } | 492 } |
493 | 493 |
494 ++schedule_raster_tasks_count_; | 494 ++schedule_raster_tasks_count_; |
495 | 495 |
496 scoped_refptr<internal::WorkerPoolTask> new_raster_finished_task( | 496 scoped_refptr<internal::WorkerPoolTask> new_raster_finished_task( |
497 new RasterFinishedWorkerPoolTaskImpl( | 497 new RasterFinishedWorkerPoolTaskImpl( |
498 base::MessageLoopProxy::current(), | 498 base::MessageLoopProxy::current().get(), |
499 base::Bind(&RasterWorkerPool::OnRasterFinished, | 499 base::Bind(&RasterWorkerPool::OnRasterFinished, |
500 weak_ptr_factory_.GetWeakPtr(), | 500 weak_ptr_factory_.GetWeakPtr(), |
501 schedule_raster_tasks_count_))); | 501 schedule_raster_tasks_count_))); |
502 raster_finished_node->set_task(new_raster_finished_task.get()); | 502 raster_finished_node->set_task(new_raster_finished_task.get()); |
503 // Insert "raster finished" task before switching to new graph. | 503 // Insert "raster finished" task before switching to new graph. |
504 new_graph.set(new_raster_finished_task.get(), raster_finished_node.Pass()); | 504 new_graph.set(new_raster_finished_task.get(), raster_finished_node.Pass()); |
505 SetTaskGraph(&new_graph); | 505 SetTaskGraph(&new_graph); |
506 raster_finished_task_.swap(new_raster_finished_task); | 506 raster_finished_task_.swap(new_raster_finished_task); |
507 } | 507 } |
508 | 508 |
509 bool RasterWorkerPool::IsRasterTaskRequiredForActivation( | 509 bool RasterWorkerPool::IsRasterTaskRequiredForActivation( |
510 internal::RasterWorkerPoolTask* task) const { | 510 internal::RasterWorkerPoolTask* task) const { |
511 return | 511 return |
512 raster_tasks_required_for_activation_.find(task) != | 512 raster_tasks_required_for_activation_.find(task) != |
513 raster_tasks_required_for_activation_.end(); | 513 raster_tasks_required_for_activation_.end(); |
514 } | 514 } |
515 | 515 |
516 void RasterWorkerPool::OnRasterFinished(int64 schedule_raster_tasks_count) { | 516 void RasterWorkerPool::OnRasterFinished(int64 schedule_raster_tasks_count) { |
517 TRACE_EVENT1("cc", "RasterWorkerPool::OnRasterFinished", | 517 TRACE_EVENT1("cc", "RasterWorkerPool::OnRasterFinished", |
518 "schedule_raster_tasks_count", schedule_raster_tasks_count); | 518 "schedule_raster_tasks_count", schedule_raster_tasks_count); |
519 DCHECK_GE(schedule_raster_tasks_count_, schedule_raster_tasks_count); | 519 DCHECK_GE(schedule_raster_tasks_count_, schedule_raster_tasks_count); |
520 // Call OnRasterTasksFinished() when we've finished running all raster | 520 // Call OnRasterTasksFinished() when we've finished running all raster |
521 // tasks needed since last time SetRasterTaskGraph() was called. | 521 // tasks needed since last time SetRasterTaskGraph() was called. |
522 if (schedule_raster_tasks_count_ == schedule_raster_tasks_count) | 522 if (schedule_raster_tasks_count_ == schedule_raster_tasks_count) |
523 OnRasterTasksFinished(); | 523 OnRasterTasksFinished(); |
524 } | 524 } |
525 | 525 |
526 } // namespace cc | 526 } // namespace cc |
OLD | NEW |