| 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/base/latency_info_swap_promise_monitor.h" | 5 #include "cc/base/latency_info_swap_promise_monitor.h" |
| 6 | 6 |
| 7 #include "cc/base/latency_info_swap_promise.h" | 7 #include "cc/base/latency_info_swap_promise.h" |
| 8 #include "cc/trees/layer_tree_host.h" | 8 #include "cc/trees/layer_tree_host.h" |
| 9 #include "cc/trees/layer_tree_host_impl.h" | 9 #include "cc/trees/layer_tree_host_impl.h" |
| 10 #include "cc/trees/layer_tree_impl.h" | 10 #include "cc/trees/layer_tree_impl.h" |
| 11 | 11 |
| 12 namespace { |
| 13 |
| 14 bool AddRenderingScheduledComponent(ui::LatencyInfo* latency_info) { |
| 15 if (latency_info->FindLatency( |
| 16 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0)) |
| 17 return false; |
| 18 latency_info->AddLatencyNumber( |
| 19 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0); |
| 20 return true; |
| 21 } |
| 22 |
| 23 } // namespace |
| 24 |
| 12 namespace cc { | 25 namespace cc { |
| 13 | 26 |
| 14 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( | 27 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( |
| 15 ui::LatencyInfo* latency, | 28 ui::LatencyInfo* latency, |
| 16 LayerTreeHost* layer_tree_host, | 29 LayerTreeHost* layer_tree_host, |
| 17 LayerTreeHostImpl* layer_tree_host_impl) | 30 LayerTreeHostImpl* layer_tree_host_impl) |
| 18 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), | 31 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), |
| 19 latency_(latency) {} | 32 latency_(latency) {} |
| 20 | 33 |
| 21 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {} | 34 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {} |
| 22 | 35 |
| 23 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { | 36 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { |
| 24 if (!latency_->FindLatency( | 37 if (AddRenderingScheduledComponent(latency_)) { |
| 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_)); | 38 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); |
| 29 layer_tree_host_->QueueSwapPromise(swap_promise.Pass()); | 39 layer_tree_host_->QueueSwapPromise(swap_promise.Pass()); |
| 30 } | 40 } |
| 31 } | 41 } |
| 32 | 42 |
| 33 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { | 43 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { |
| 34 if (!latency_->FindLatency( | 44 if (AddRenderingScheduledComponent(latency_)) { |
| 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_)); | 45 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); |
| 39 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); | 46 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); |
| 40 } | 47 } |
| 41 } | 48 } |
| 42 | 49 |
| 50 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() { |
| 51 if (AddRenderingScheduledComponent(latency_)) |
| 52 layer_tree_host_impl_->QueueScrollUpdateLatencyInfo(*latency_); |
| 53 } |
| 54 |
| 43 } // namespace cc | 55 } // namespace cc |
| OLD | NEW |