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.
5 #include "cc/resources/rasterizer_delegate.h"
7 #include "base/debug/trace_event.h"
11 RasterizerDelegate::RasterizerDelegate(RasterizerClient
* client
,
12 Rasterizer
** rasterizers
,
13 size_t num_rasterizers
)
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) {
19 for (RasterizerVector::iterator it
= rasterizers_
.begin();
20 it
!= rasterizers_
.end();
22 (*it
)->SetClient(this);
25 RasterizerDelegate::~RasterizerDelegate() {}
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
));
36 void RasterizerDelegate::Shutdown() {
37 for (RasterizerVector::iterator it
= rasterizers_
.begin();
38 it
!= rasterizers_
.end();
43 void RasterizerDelegate::ScheduleTasks(RasterTaskQueue
* queue
) {
44 for (size_t i
= 0; i
< rasterizers_
.size(); ++i
)
45 rasterizers_
[i
]->ScheduleTasks(&queue
[i
]);
47 did_finish_running_tasks_pending_count_
= rasterizers_
.size();
48 did_finish_running_tasks_required_for_activation_pending_count_
=
52 void RasterizerDelegate::CheckForCompletedTasks() {
53 for (RasterizerVector::iterator it
= rasterizers_
.begin();
54 it
!= rasterizers_
.end();
56 (*it
)->CheckForCompletedTasks();
59 bool RasterizerDelegate::ShouldForceTasksRequiredForActivationToComplete()
61 return client_
->ShouldForceTasksRequiredForActivationToComplete();
64 void RasterizerDelegate::DidFinishRunningTasks() {
66 "RasterizerDelegate::DidFinishRunningTasks",
68 did_finish_running_tasks_pending_count_
);
70 DCHECK_LT(0u, did_finish_running_tasks_pending_count_
);
71 if (--did_finish_running_tasks_pending_count_
)
73 client_
->DidFinishRunningTasks();
76 void RasterizerDelegate::DidFinishRunningTasksRequiredForActivation() {
78 "RasterizerDelegate::DidFinishRunningTasksRequiredForActivation",
80 did_finish_running_tasks_required_for_activation_pending_count_
);
83 did_finish_running_tasks_required_for_activation_pending_count_
);
84 if (--did_finish_running_tasks_required_for_activation_pending_count_
)
86 client_
->DidFinishRunningTasksRequiredForActivation();