Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: cc/trees/latency_info_swap_promise_monitor.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/latency_info_swap_promise_monitor.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/trees/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/output/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 bool on_main) { 16 bool on_main) {
17 ui::LatencyComponentType type = on_main ? 17 ui::LatencyComponentType type =
18 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT : 18 on_main ? ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT
19 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT; 19 : ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT;
20 if (latency_info->FindLatency(type, 0, nullptr)) 20 if (latency_info->FindLatency(type, 0, nullptr))
21 return false; 21 return false;
22 latency_info->AddLatencyNumber(type, 0, 0); 22 latency_info->AddLatencyNumber(type, 0, 0);
23 return true; 23 return true;
24 } 24 }
25 25
26 bool AddForwardingScrollUpdateToMainComponent(ui::LatencyInfo* latency_info) { 26 bool AddForwardingScrollUpdateToMainComponent(ui::LatencyInfo* latency_info) {
27 if (latency_info->FindLatency( 27 if (latency_info->FindLatency(
28 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, 28 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, 0,
29 0,
30 nullptr)) 29 nullptr))
31 return false; 30 return false;
32 latency_info->AddLatencyNumber( 31 latency_info->AddLatencyNumber(
33 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, 32 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT, 0,
34 0,
35 latency_info->trace_id); 33 latency_info->trace_id);
36 return true; 34 return true;
37 } 35 }
38 36
39 } // namespace 37 } // namespace
40 38
41 namespace cc { 39 namespace cc {
42 40
43 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( 41 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor(
44 ui::LatencyInfo* latency, 42 ui::LatencyInfo* latency,
45 LayerTreeHost* layer_tree_host, 43 LayerTreeHost* layer_tree_host,
46 LayerTreeHostImpl* layer_tree_host_impl) 44 LayerTreeHostImpl* layer_tree_host_impl)
47 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), 45 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
48 latency_(latency) {} 46 latency_(latency) {
47 }
49 48
50 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {} 49 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {
50 }
51 51
52 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { 52 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() {
53 if (AddRenderingScheduledComponent(latency_, true /* on_main */)) { 53 if (AddRenderingScheduledComponent(latency_, true /* on_main */)) {
54 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); 54 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
55 layer_tree_host_->QueueSwapPromise(swap_promise.Pass()); 55 layer_tree_host_->QueueSwapPromise(swap_promise.Pass());
56 } 56 }
57 } 57 }
58 58
59 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { 59 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() {
60 if (AddRenderingScheduledComponent(latency_, false /* on_main */)) { 60 if (AddRenderingScheduledComponent(latency_, false /* on_main */)) {
61 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); 61 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
62 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); 62 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
63 } 63 }
64 } 64 }
65 65
66 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() { 66 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() {
67 if (AddForwardingScrollUpdateToMainComponent(latency_)) { 67 if (AddForwardingScrollUpdateToMainComponent(latency_)) {
68 int64 new_sequence_number = 0; 68 int64 new_sequence_number = 0;
69 for (ui::LatencyInfo::LatencyMap::const_iterator it = 69 for (ui::LatencyInfo::LatencyMap::const_iterator it =
70 latency_->latency_components.begin(); 70 latency_->latency_components.begin();
71 it != latency_->latency_components.end(); 71 it != latency_->latency_components.end(); ++it) {
72 ++it) {
73 if (it->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT) { 72 if (it->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT) {
74 new_sequence_number = 73 new_sequence_number =
75 (static_cast<int64>(base::PlatformThread::CurrentId()) << 32) | 74 (static_cast<int64>(base::PlatformThread::CurrentId()) << 32) |
76 (it->second.sequence_number & 0xffffffff); 75 (it->second.sequence_number & 0xffffffff);
77 DCHECK(new_sequence_number != it->second.sequence_number); 76 DCHECK(new_sequence_number != it->second.sequence_number);
78 break; 77 break;
79 } 78 }
80 } 79 }
81 if (!new_sequence_number) 80 if (!new_sequence_number)
82 return; 81 return;
83 ui::LatencyInfo new_latency; 82 ui::LatencyInfo new_latency;
84 new_latency.AddLatencyNumber( 83 new_latency.AddLatencyNumber(
85 ui::INPUT_EVENT_LATENCY_BEGIN_SCROLL_UPDATE_MAIN_COMPONENT, 84 ui::INPUT_EVENT_LATENCY_BEGIN_SCROLL_UPDATE_MAIN_COMPONENT, 0,
86 0,
87 new_sequence_number); 85 new_sequence_number);
88 new_latency.TraceEventType("ScrollUpdate"); 86 new_latency.TraceEventType("ScrollUpdate");
89 new_latency.CopyLatencyFrom( 87 new_latency.CopyLatencyFrom(
90 *latency_, 88 *latency_,
91 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT); 89 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT);
92 scoped_ptr<SwapPromise> swap_promise( 90 scoped_ptr<SwapPromise> swap_promise(
93 new LatencyInfoSwapPromise(new_latency)); 91 new LatencyInfoSwapPromise(new_latency));
94 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( 92 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(
95 swap_promise.Pass()); 93 swap_promise.Pass());
96 } 94 }
97 } 95 }
98 96
99 } // namespace cc 97 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/latency_info_swap_promise_monitor.h ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698