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 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor(
15 ui::LatencyInfo
* latency
,
16 LayerTreeHost
* layer_tree_host
,
17 LayerTreeHostImpl
* layer_tree_host_impl
)
18 : SwapPromiseMonitor(layer_tree_host
, layer_tree_host_impl
),
21 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {}
23 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() {
24 if (!latency_
->FindLatency(
25 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT
, 0, 0)) {
26 latency_
->AddLatencyNumber(
27 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT
, 0, 0);
28 scoped_ptr
<SwapPromise
> swap_promise(new LatencyInfoSwapPromise(*latency_
));
29 layer_tree_host_
->QueueSwapPromise(swap_promise
.Pass());
33 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() {
34 if (!latency_
->FindLatency(
35 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT
, 0, 0)) {
36 latency_
->AddLatencyNumber(
37 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT
, 0, 0);
38 scoped_ptr
<SwapPromise
> swap_promise(new LatencyInfoSwapPromise(*latency_
));
39 layer_tree_host_impl_
->active_tree()->QueueSwapPromise(swap_promise
.Pass());