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
3 // found in the LICENSE file.
5 #include "cc/base/latency_info_swap_promise_monitor.h"
7 #include "cc/base/latency_info_swap_promise.h"
8 #include "cc/trees/layer_tree_host.h"
9 #include "cc/trees/layer_tree_host_impl.h"
10 #include "cc/trees/layer_tree_impl.h"
14 bool AddRenderingScheduledComponent(ui::LatencyInfo
* latency_info
) {
15 if (latency_info
->FindLatency(
16 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT
, 0, 0))
18 latency_info
->AddLatencyNumber(
19 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT
, 0, 0);
27 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor(
28 ui::LatencyInfo
* latency
,
29 LayerTreeHost
* layer_tree_host
,
30 LayerTreeHostImpl
* layer_tree_host_impl
)
31 : SwapPromiseMonitor(layer_tree_host
, layer_tree_host_impl
),
34 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {}
36 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() {
37 if (AddRenderingScheduledComponent(latency_
)) {
38 scoped_ptr
<SwapPromise
> swap_promise(new LatencyInfoSwapPromise(*latency_
));
39 layer_tree_host_
->QueueSwapPromise(swap_promise
.Pass());
43 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() {
44 if (AddRenderingScheduledComponent(latency_
)) {
45 scoped_ptr
<SwapPromise
> swap_promise(new LatencyInfoSwapPromise(*latency_
));
46 layer_tree_host_impl_
->active_tree()->QueueSwapPromise(swap_promise
.Pass());
50 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() {
51 if (AddRenderingScheduledComponent(latency_
)) {
52 scoped_ptr
<SwapPromise
> swap_promise(new LatencyInfoSwapPromise(*latency_
));
53 layer_tree_host_impl_
->QueueSwapPromiseForMainThreadScrollUpdate(