Chromium Code Reviews| 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_impl.h" | 11 #include "cc/trees/layer_tree_host_impl.h" |
| 12 #include "cc/trees/layer_tree_impl.h" | 12 #include "cc/trees/layer_tree_impl.h" |
| 13 #include "cc/trees/swap_promise_manager.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; |
| 24 latency_info->AddLatencyNumber(type, 0, 0); | 24 latency_info->AddLatencyNumber(type, 0); |
| 25 return true; | 25 return true; |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool AddForwardingScrollUpdateToMainComponent(ui::LatencyInfo* latency_info) { | 28 bool AddForwardingScrollUpdateToMainComponent(ui::LatencyInfo* latency_info) { |
| 29 if (latency_info->FindLatency( | 29 if (latency_info->FindLatency( |
| 30 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, 0, | 30 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, 0, |
| 31 nullptr)) | 31 nullptr)) |
| 32 return false; | 32 return false; |
| 33 latency_info->AddLatencyNumber( | 33 latency_info->AddLatencyNumber( |
| 34 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, 0, | 34 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, |
| 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, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 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 |
| 68 // activations (which would otherwise break the swap promise). | 68 // activations (which would otherwise break the swap promise). |
| 69 layer_tree_host_impl_->active_tree()->QueuePinnedSwapPromise( | 69 layer_tree_host_impl_->active_tree()->QueuePinnedSwapPromise( |
| 70 std::move(swap_promise)); | 70 std::move(swap_promise)); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() { | 74 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() { |
| 75 if (AddForwardingScrollUpdateToMainComponent(latency_)) { | 75 if (AddForwardingScrollUpdateToMainComponent(latency_)) { |
| 76 int64_t new_sequence_number = 0; | |
| 77 for (ui::LatencyInfo::LatencyMap::const_iterator it = | |
| 78 latency_->latency_components().begin(); | |
| 79 it != latency_->latency_components().end(); ++it) { | |
| 80 if (it->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT) { | |
| 81 new_sequence_number = | |
| 82 ((static_cast<int64_t>(base::PlatformThread::CurrentId()) << 32) ^ | |
| 83 (reinterpret_cast<uint64_t>(this) << 32)) | | |
| 84 (it->second.sequence_number & 0xffffffff); | |
| 85 if (new_sequence_number == it->second.sequence_number) | |
| 86 return; | |
| 87 break; | |
| 88 } | |
| 89 } | |
| 90 if (!new_sequence_number) | |
| 91 return; | |
|
tdresser
2017/06/08 18:36:44
This is a material change.
I think what's happen
| |
| 92 ui::LatencyInfo new_latency; | 76 ui::LatencyInfo new_latency; |
| 93 new_latency.AddLatencyNumberWithTraceName( | 77 new_latency.AddLatencyNumberWithTraceName( |
| 94 ui::LATENCY_BEGIN_SCROLL_LISTENER_UPDATE_MAIN_COMPONENT, 0, | 78 ui::LATENCY_BEGIN_SCROLL_LISTENER_UPDATE_MAIN_COMPONENT, 0, |
| 95 new_sequence_number, "ScrollUpdate"); | 79 "ScrollUpdate"); |
| 96 new_latency.CopyLatencyFrom( | 80 new_latency.CopyLatencyFrom( |
| 97 *latency_, | 81 *latency_, |
| 98 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); | 82 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); |
| 99 std::unique_ptr<SwapPromise> swap_promise( | 83 std::unique_ptr<SwapPromise> swap_promise( |
| 100 new LatencyInfoSwapPromise(new_latency)); | 84 new LatencyInfoSwapPromise(new_latency)); |
| 101 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( | 85 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( |
| 102 std::move(swap_promise)); | 86 std::move(swap_promise)); |
| 103 } | 87 } |
| 104 } | 88 } |
| 105 | 89 |
| 106 } // namespace cc | 90 } // namespace cc |
| OLD | NEW |