OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 using blink::WebKeyboardEvent; | 82 using blink::WebKeyboardEvent; |
83 using blink::WebMouseEvent; | 83 using blink::WebMouseEvent; |
84 using blink::WebMouseWheelEvent; | 84 using blink::WebMouseWheelEvent; |
85 using blink::WebTextDirection; | 85 using blink::WebTextDirection; |
86 | 86 |
87 namespace content { | 87 namespace content { |
88 namespace { | 88 namespace { |
89 | 89 |
90 bool g_check_for_pending_resize_ack = true; | 90 bool g_check_for_pending_resize_ack = true; |
91 | 91 |
92 const size_t kBrowserCompositeLatencyHistorySize = 60; | |
93 const double kBrowserCompositeLatencyEstimationPercentile = 90.0; | |
94 | |
92 typedef std::pair<int32, int32> RenderWidgetHostID; | 95 typedef std::pair<int32, int32> RenderWidgetHostID; |
93 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> | 96 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> |
94 RoutingIDWidgetMap; | 97 RoutingIDWidgetMap; |
95 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = | 98 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = |
96 LAZY_INSTANCE_INITIALIZER; | 99 LAZY_INSTANCE_INITIALIZER; |
97 | 100 |
98 int GetInputRouterViewFlagsFromCompositorFrameMetadata( | 101 int GetInputRouterViewFlagsFromCompositorFrameMetadata( |
99 const cc::CompositorFrameMetadata metadata) { | 102 const cc::CompositorFrameMetadata metadata) { |
100 int view_flags = InputRouter::VIEW_FLAGS_NONE; | 103 int view_flags = InputRouter::VIEW_FLAGS_NONE; |
101 | 104 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 input_method_active_(false), | 182 input_method_active_(false), |
180 text_direction_updated_(false), | 183 text_direction_updated_(false), |
181 text_direction_(blink::WebTextDirectionLeftToRight), | 184 text_direction_(blink::WebTextDirectionLeftToRight), |
182 text_direction_canceled_(false), | 185 text_direction_canceled_(false), |
183 suppress_next_char_events_(false), | 186 suppress_next_char_events_(false), |
184 pending_mouse_lock_request_(false), | 187 pending_mouse_lock_request_(false), |
185 allow_privileged_mouse_lock_(false), | 188 allow_privileged_mouse_lock_(false), |
186 has_touch_handler_(false), | 189 has_touch_handler_(false), |
187 weak_factory_(this), | 190 weak_factory_(this), |
188 last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32), | 191 last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32), |
189 next_browser_snapshot_id_(1) { | 192 next_browser_snapshot_id_(1), |
193 browser_composite_latency_history_(kBrowserCompositeLatencyHistorySize) { | |
190 CHECK(delegate_); | 194 CHECK(delegate_); |
191 if (routing_id_ == MSG_ROUTING_NONE) { | 195 if (routing_id_ == MSG_ROUTING_NONE) { |
192 routing_id_ = process_->GetNextRoutingID(); | 196 routing_id_ = process_->GetNextRoutingID(); |
193 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( | 197 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( |
194 process_->GetID(), | 198 process_->GetID(), |
195 routing_id_); | 199 routing_id_); |
196 } else { | 200 } else { |
197 // TODO(piman): This is a O(N) lookup, where we could forward the | 201 // TODO(piman): This is a O(N) lookup, where we could forward the |
198 // information from the RenderWidgetHelper. The problem is that doing so | 202 // information from the RenderWidgetHelper. The problem is that doing so |
199 // currently leaks outside of content all the way to chrome classes, and | 203 // currently leaks outside of content all the way to chrome classes, and |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1444 param.b.AssignTo(frame.get()); | 1448 param.b.AssignTo(frame.get()); |
1445 std::vector<IPC::Message> messages_to_deliver_with_frame; | 1449 std::vector<IPC::Message> messages_to_deliver_with_frame; |
1446 messages_to_deliver_with_frame.swap(param.c); | 1450 messages_to_deliver_with_frame.swap(param.c); |
1447 | 1451 |
1448 for (size_t i = 0; i < frame->metadata.latency_info.size(); i++) | 1452 for (size_t i = 0; i < frame->metadata.latency_info.size(); i++) |
1449 AddLatencyInfoComponentIds(&frame->metadata.latency_info[i]); | 1453 AddLatencyInfoComponentIds(&frame->metadata.latency_info[i]); |
1450 | 1454 |
1451 input_router_->OnViewUpdated( | 1455 input_router_->OnViewUpdated( |
1452 GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata)); | 1456 GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata)); |
1453 | 1457 |
1458 for (size_t i = 0; i < frame->metadata.latency_info.size(); ++i) { | |
1459 frame->metadata.latency_info[i].AddLatencyNumber( | |
1460 ui::INPUT_EVENT_BROWSER_COMPOSITE_COMPONENT, 0, 0); | |
brianderson
2014/09/18 23:26:15
If the Browser is swap or commit throttled, there
jbauman
2014/09/19 20:40:29
This should specify GetLatencyComponentId() as the
orglofch
2014/09/19 22:40:26
@brian I've renamed the event.
orglofch
2014/09/19 22:40:26
Done.
| |
1461 } | |
1462 | |
1454 if (view_) { | 1463 if (view_) { |
1455 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass()); | 1464 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass()); |
1456 view_->DidReceiveRendererFrame(); | 1465 view_->DidReceiveRendererFrame(); |
1457 } else { | 1466 } else { |
1458 cc::CompositorFrameAck ack; | 1467 cc::CompositorFrameAck ack; |
1459 if (frame->gl_frame_data) { | 1468 if (frame->gl_frame_data) { |
1460 ack.gl_frame_data = frame->gl_frame_data.Pass(); | 1469 ack.gl_frame_data = frame->gl_frame_data.Pass(); |
1461 ack.gl_frame_data->sync_point = 0; | 1470 ack.gl_frame_data->sync_point = 0; |
1462 } else if (frame->delegated_frame_data) { | 1471 } else if (frame->delegated_frame_data) { |
1463 cc::TransferableResource::ReturnResources( | 1472 cc::TransferableResource::ReturnResources( |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2135 swap_component.event_time - original_component.event_time; | 2144 swap_component.event_time - original_component.event_time; |
2136 for (size_t i = 0; i < original_component.event_count; i++) { | 2145 for (size_t i = 0; i < original_component.event_count; i++) { |
2137 UMA_HISTOGRAM_CUSTOM_COUNTS( | 2146 UMA_HISTOGRAM_CUSTOM_COUNTS( |
2138 "Event.Latency.TouchToScrollUpdateSwap", | 2147 "Event.Latency.TouchToScrollUpdateSwap", |
2139 delta.InMicroseconds(), | 2148 delta.InMicroseconds(), |
2140 1, | 2149 1, |
2141 1000000, | 2150 1000000, |
2142 100); | 2151 100); |
2143 } | 2152 } |
2144 } | 2153 } |
2154 | |
2155 ui::LatencyInfo::LatencyComponent gpu_swap_component; | |
2156 if (!latency_info.FindLatency( | |
2157 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, &gpu_swap_component)) { | |
2158 return; | |
2159 } | |
2160 | |
2161 ui::LatencyInfo::LatencyComponent composite_component; | |
2162 if (latency_info.FindLatency(ui::INPUT_EVENT_BROWSER_COMPOSITE_COMPONENT, | |
jbauman
2014/09/19 20:40:29
This should instead find the component with GetLat
orglofch
2014/09/19 22:40:26
Done.
| |
2163 0, | |
2164 &composite_component)) { | |
2165 base::TimeDelta delta = | |
2166 gpu_swap_component.event_time - composite_component.event_time; | |
2167 browser_composite_latency_history_.InsertSample(delta); | |
2168 } | |
2145 } | 2169 } |
2146 | 2170 |
2147 void RenderWidgetHostImpl::DidReceiveRendererFrame() { | 2171 void RenderWidgetHostImpl::DidReceiveRendererFrame() { |
2148 view_->DidReceiveRendererFrame(); | 2172 view_->DidReceiveRendererFrame(); |
2149 } | 2173 } |
2150 | 2174 |
2151 void RenderWidgetHostImpl::WindowSnapshotAsyncCallback( | 2175 void RenderWidgetHostImpl::WindowSnapshotAsyncCallback( |
2152 int routing_id, | 2176 int routing_id, |
2153 int snapshot_id, | 2177 int snapshot_id, |
2154 gfx::Size snapshot_size, | 2178 gfx::Size snapshot_size, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2308 RenderWidgetHostImpl::GetRootBrowserAccessibilityManager() { | 2332 RenderWidgetHostImpl::GetRootBrowserAccessibilityManager() { |
2309 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2333 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
2310 } | 2334 } |
2311 | 2335 |
2312 BrowserAccessibilityManager* | 2336 BrowserAccessibilityManager* |
2313 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2337 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2314 return delegate_ ? | 2338 return delegate_ ? |
2315 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2339 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
2316 } | 2340 } |
2317 | 2341 |
2342 base::TimeDelta RenderWidgetHostImpl::GetEstimatedBrowserCompositeTime() { | |
2343 if (browser_composite_latency_history_.SampleCount() > 0) { | |
2344 return browser_composite_latency_history_.Percentile( | |
2345 kBrowserCompositeLatencyEstimationPercentile); | |
2346 } else { | |
2347 return base::TimeDelta::FromMicroseconds( | |
2348 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60)); | |
2349 } | |
2350 } | |
2351 | |
2318 #if defined(OS_WIN) | 2352 #if defined(OS_WIN) |
2319 gfx::NativeViewAccessible | 2353 gfx::NativeViewAccessible |
2320 RenderWidgetHostImpl::GetParentNativeViewAccessible() { | 2354 RenderWidgetHostImpl::GetParentNativeViewAccessible() { |
2321 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; | 2355 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; |
2322 } | 2356 } |
2323 #endif | 2357 #endif |
2324 | 2358 |
2325 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2359 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
2326 if (view_) | 2360 if (view_) |
2327 return view_->PreferredReadbackFormat(); | 2361 return view_->PreferredReadbackFormat(); |
2328 return kN32_SkColorType; | 2362 return kN32_SkColorType; |
2329 } | 2363 } |
2330 | 2364 |
2331 } // namespace content | 2365 } // namespace content |
OLD | NEW |