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 "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
8 #include "cc/base/latency_info_swap_promise.h" | 8 #include "cc/base/latency_info_swap_promise.h" |
9 #include "cc/trees/layer_tree_host.h" | 9 #include "cc/trees/layer_tree_host.h" |
10 #include "cc/trees/layer_tree_host_impl.h" | 10 #include "cc/trees/layer_tree_host_impl.h" |
11 #include "cc/trees/layer_tree_impl.h" | 11 #include "cc/trees/layer_tree_impl.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 bool AddRenderingScheduledComponent(ui::LatencyInfo* latency_info) { | 15 bool AddRenderingScheduledComponent(ui::LatencyInfo* latency_info, |
16 if (latency_info->FindLatency( | 16 bool on_main) { |
17 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, nullptr)) | 17 ui::LatencyComponentType type = on_main ? |
| 18 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT : |
| 19 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT; |
| 20 if (latency_info->FindLatency(type, 0, nullptr)) |
18 return false; | 21 return false; |
19 latency_info->AddLatencyNumber( | 22 latency_info->AddLatencyNumber(type, 0, 0); |
20 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0); | |
21 return true; | 23 return true; |
22 } | 24 } |
23 | 25 |
24 bool AddForwardingScrollUpdateToMainComponent(ui::LatencyInfo* latency_info) { | 26 bool AddForwardingScrollUpdateToMainComponent(ui::LatencyInfo* latency_info) { |
25 if (latency_info->FindLatency( | 27 if (latency_info->FindLatency( |
26 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, | 28 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, |
27 0, | 29 0, |
28 nullptr)) | 30 nullptr)) |
29 return false; | 31 return false; |
30 latency_info->AddLatencyNumber( | 32 latency_info->AddLatencyNumber( |
(...skipping 10 matching lines...) Expand all Loading... |
41 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( | 43 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( |
42 ui::LatencyInfo* latency, | 44 ui::LatencyInfo* latency, |
43 LayerTreeHost* layer_tree_host, | 45 LayerTreeHost* layer_tree_host, |
44 LayerTreeHostImpl* layer_tree_host_impl) | 46 LayerTreeHostImpl* layer_tree_host_impl) |
45 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), | 47 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), |
46 latency_(latency) {} | 48 latency_(latency) {} |
47 | 49 |
48 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {} | 50 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {} |
49 | 51 |
50 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { | 52 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { |
51 if (AddRenderingScheduledComponent(latency_)) { | 53 if (AddRenderingScheduledComponent(latency_, true /* on_main */)) { |
52 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); | 54 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); |
53 layer_tree_host_->QueueSwapPromise(swap_promise.Pass()); | 55 layer_tree_host_->QueueSwapPromise(swap_promise.Pass()); |
54 } | 56 } |
55 } | 57 } |
56 | 58 |
57 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { | 59 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { |
58 if (AddRenderingScheduledComponent(latency_)) { | 60 if (AddRenderingScheduledComponent(latency_, false /* on_main */)) { |
59 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); | 61 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); |
60 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); | 62 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); |
61 } | 63 } |
62 } | 64 } |
63 | 65 |
64 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() { | 66 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() { |
65 if (AddForwardingScrollUpdateToMainComponent(latency_)) { | 67 if (AddForwardingScrollUpdateToMainComponent(latency_)) { |
66 int64 new_sequence_number = 0; | 68 int64 new_sequence_number = 0; |
67 for (ui::LatencyInfo::LatencyMap::const_iterator it = | 69 for (ui::LatencyInfo::LatencyMap::const_iterator it = |
68 latency_->latency_components.begin(); | 70 latency_->latency_components.begin(); |
(...skipping 19 matching lines...) Expand all Loading... |
88 *latency_, | 90 *latency_, |
89 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); | 91 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); |
90 scoped_ptr<SwapPromise> swap_promise( | 92 scoped_ptr<SwapPromise> swap_promise( |
91 new LatencyInfoSwapPromise(new_latency)); | 93 new LatencyInfoSwapPromise(new_latency)); |
92 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( | 94 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( |
93 swap_promise.Pass()); | 95 swap_promise.Pass()); |
94 } | 96 } |
95 } | 97 } |
96 | 98 |
97 } // namespace cc | 99 } // namespace cc |
OLD | NEW |