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/trees/latency_info_swap_promise_monitor.h" | 5 #include "cc/trees/latency_info_swap_promise_monitor.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "cc/output/latency_info_swap_promise.h" | 10 #include "cc/output/latency_info_swap_promise.h" |
11 #include "cc/trees/layer_tree_host.h" | |
12 #include "cc/trees/layer_tree_host_impl.h" | 11 #include "cc/trees/layer_tree_host_impl.h" |
13 #include "cc/trees/layer_tree_impl.h" | 12 #include "cc/trees/layer_tree_impl.h" |
| 13 #include "cc/trees/swap_promise_manager.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 bool AddRenderingScheduledComponent(ui::LatencyInfo* latency_info, | 17 bool AddRenderingScheduledComponent(ui::LatencyInfo* latency_info, |
18 bool on_main) { | 18 bool on_main) { |
19 ui::LatencyComponentType type = | 19 ui::LatencyComponentType type = |
20 on_main ? ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT | 20 on_main ? ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT |
21 : ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT; | 21 : ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT; |
22 if (latency_info->FindLatency(type, 0, nullptr)) | 22 if (latency_info->FindLatency(type, 0, nullptr)) |
23 return false; | 23 return false; |
(...skipping 11 matching lines...) Expand all Loading... |
35 latency_info->trace_id()); | 35 latency_info->trace_id()); |
36 return true; | 36 return true; |
37 } | 37 } |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 namespace cc { | 41 namespace cc { |
42 | 42 |
43 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( | 43 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( |
44 ui::LatencyInfo* latency, | 44 ui::LatencyInfo* latency, |
45 LayerTreeHostInterface* layer_tree_host, | 45 SwapPromiseManager* swap_promise_manager, |
46 LayerTreeHostImpl* layer_tree_host_impl) | 46 LayerTreeHostImpl* layer_tree_host_impl) |
47 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), | 47 : SwapPromiseMonitor(swap_promise_manager, layer_tree_host_impl), |
48 latency_(latency) {} | 48 latency_(latency) {} |
49 | 49 |
50 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() { | 50 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() { |
51 } | 51 } |
52 | 52 |
53 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { | 53 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { |
54 if (AddRenderingScheduledComponent(latency_, true /* on_main */)) { | 54 if (AddRenderingScheduledComponent(latency_, true /* on_main */)) { |
55 std::unique_ptr<SwapPromise> swap_promise( | 55 std::unique_ptr<SwapPromise> swap_promise( |
56 new LatencyInfoSwapPromise(*latency_)); | 56 new LatencyInfoSwapPromise(*latency_)); |
57 layer_tree_host_->QueueSwapPromise(std::move(swap_promise)); | 57 swap_promise_manager_->QueueSwapPromise(std::move(swap_promise)); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { | 61 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { |
62 if (AddRenderingScheduledComponent(latency_, false /* on_main */)) { | 62 if (AddRenderingScheduledComponent(latency_, false /* on_main */)) { |
63 std::unique_ptr<SwapPromise> swap_promise( | 63 std::unique_ptr<SwapPromise> swap_promise( |
64 new LatencyInfoSwapPromise(*latency_)); | 64 new LatencyInfoSwapPromise(*latency_)); |
65 // Queue a pinned swap promise on the active tree. This will allow | 65 // Queue a pinned swap promise on the active tree. This will allow |
66 // measurement of the time to the next SwapBuffers(). The swap | 66 // measurement of the time to the next SwapBuffers(). The swap |
67 // promise is pinned so that it is not interrupted by new incoming | 67 // promise is pinned so that it is not interrupted by new incoming |
(...skipping 29 matching lines...) Expand all Loading... |
97 *latency_, | 97 *latency_, |
98 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); | 98 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); |
99 std::unique_ptr<SwapPromise> swap_promise( | 99 std::unique_ptr<SwapPromise> swap_promise( |
100 new LatencyInfoSwapPromise(new_latency)); | 100 new LatencyInfoSwapPromise(new_latency)); |
101 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( | 101 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( |
102 std::move(swap_promise)); | 102 std::move(swap_promise)); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 } // namespace cc | 106 } // namespace cc |
OLD | NEW |