| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/resources/rasterizer_delegate.h" | |
| 6 | |
| 7 #include "base/debug/trace_event.h" | |
| 8 | |
| 9 namespace cc { | |
| 10 | |
| 11 RasterizerDelegate::RasterizerDelegate(RasterizerClient* client, | |
| 12 Rasterizer** rasterizers, | |
| 13 size_t num_rasterizers) | |
| 14 : client_(client), | |
| 15 rasterizers_(rasterizers, rasterizers + num_rasterizers), | |
| 16 did_finish_running_tasks_pending_count_(0u), | |
| 17 did_finish_running_tasks_required_for_activation_pending_count_(0u) { | |
| 18 DCHECK(client_); | |
| 19 for (RasterizerVector::iterator it = rasterizers_.begin(); | |
| 20 it != rasterizers_.end(); | |
| 21 ++it) | |
| 22 (*it)->SetClient(this); | |
| 23 } | |
| 24 | |
| 25 RasterizerDelegate::~RasterizerDelegate() {} | |
| 26 | |
| 27 // static | |
| 28 scoped_ptr<RasterizerDelegate> RasterizerDelegate::Create( | |
| 29 RasterizerClient* client, | |
| 30 Rasterizer** rasterizers, | |
| 31 size_t num_rasterizers) { | |
| 32 return make_scoped_ptr( | |
| 33 new RasterizerDelegate(client, rasterizers, num_rasterizers)); | |
| 34 } | |
| 35 | |
| 36 void RasterizerDelegate::Shutdown() { | |
| 37 for (RasterizerVector::iterator it = rasterizers_.begin(); | |
| 38 it != rasterizers_.end(); | |
| 39 ++it) | |
| 40 (*it)->Shutdown(); | |
| 41 } | |
| 42 | |
| 43 void RasterizerDelegate::ScheduleTasks(RasterTaskQueue* queue) { | |
| 44 for (size_t i = 0; i < rasterizers_.size(); ++i) | |
| 45 rasterizers_[i]->ScheduleTasks(&queue[i]); | |
| 46 | |
| 47 did_finish_running_tasks_pending_count_ = rasterizers_.size(); | |
| 48 did_finish_running_tasks_required_for_activation_pending_count_ = | |
| 49 rasterizers_.size(); | |
| 50 } | |
| 51 | |
| 52 void RasterizerDelegate::CheckForCompletedTasks() { | |
| 53 for (RasterizerVector::iterator it = rasterizers_.begin(); | |
| 54 it != rasterizers_.end(); | |
| 55 ++it) | |
| 56 (*it)->CheckForCompletedTasks(); | |
| 57 } | |
| 58 | |
| 59 bool RasterizerDelegate::ShouldForceTasksRequiredForActivationToComplete() | |
| 60 const { | |
| 61 return client_->ShouldForceTasksRequiredForActivationToComplete(); | |
| 62 } | |
| 63 | |
| 64 void RasterizerDelegate::DidFinishRunningTasks() { | |
| 65 TRACE_EVENT1("cc", | |
| 66 "RasterizerDelegate::DidFinishRunningTasks", | |
| 67 "pending_count", | |
| 68 did_finish_running_tasks_pending_count_); | |
| 69 | |
| 70 DCHECK_LT(0u, did_finish_running_tasks_pending_count_); | |
| 71 if (--did_finish_running_tasks_pending_count_) | |
| 72 return; | |
| 73 client_->DidFinishRunningTasks(); | |
| 74 } | |
| 75 | |
| 76 void RasterizerDelegate::DidFinishRunningTasksRequiredForActivation() { | |
| 77 TRACE_EVENT1("cc", | |
| 78 "RasterizerDelegate::DidFinishRunningTasksRequiredForActivation", | |
| 79 "pending_count", | |
| 80 did_finish_running_tasks_required_for_activation_pending_count_); | |
| 81 | |
| 82 DCHECK_LT(0u, | |
| 83 did_finish_running_tasks_required_for_activation_pending_count_); | |
| 84 if (--did_finish_running_tasks_required_for_activation_pending_count_) | |
| 85 return; | |
| 86 client_->DidFinishRunningTasksRequiredForActivation(); | |
| 87 } | |
| 88 | |
| 89 } // namespace cc | |
| OLD | NEW |