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 <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 using WebKit::WebGestureEvent; | 78 using WebKit::WebGestureEvent; |
79 using WebKit::WebInputEvent; | 79 using WebKit::WebInputEvent; |
80 using WebKit::WebKeyboardEvent; | 80 using WebKit::WebKeyboardEvent; |
81 using WebKit::WebMouseEvent; | 81 using WebKit::WebMouseEvent; |
82 using WebKit::WebMouseWheelEvent; | 82 using WebKit::WebMouseWheelEvent; |
83 using WebKit::WebTextDirection; | 83 using WebKit::WebTextDirection; |
84 | 84 |
85 namespace content { | 85 namespace content { |
86 namespace { | 86 namespace { |
87 | 87 |
88 bool g_check_for_pending_resize_ack = true; | |
89 | |
90 // How long to (synchronously) wait for the renderer to respond with a | 88 // How long to (synchronously) wait for the renderer to respond with a |
91 // PaintRect message, when our backing-store is invalid, before giving up and | 89 // PaintRect message, when our backing-store is invalid, before giving up and |
92 // returning a null or incorrectly sized backing-store from GetBackingStore. | 90 // returning a null or incorrectly sized backing-store from GetBackingStore. |
93 // This timeout impacts the "choppiness" of our window resize perf. | 91 // This timeout impacts the "choppiness" of our window resize perf. |
94 const int kPaintMsgTimeoutMS = 50; | 92 const int kPaintMsgTimeoutMS = 50; |
95 | 93 |
96 // Returns |true| if the two wheel events should be coalesced. | 94 // Returns |true| if the two wheel events should be coalesced. |
97 bool ShouldCoalesceMouseWheelEvents(const WebMouseWheelEvent& last_event, | 95 bool ShouldCoalesceMouseWheelEvents(const WebMouseWheelEvent& last_event, |
98 const WebMouseWheelEvent& new_event) { | 96 const WebMouseWheelEvent& new_event) { |
99 return last_event.modifiers == new_event.modifiers && | 97 return last_event.modifiers == new_event.modifiers && |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 } | 1208 } |
1211 | 1209 |
1212 void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) { | 1210 void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) { |
1213 Send(new InputMsg_CursorVisibilityChange(GetRoutingID(), is_visible)); | 1211 Send(new InputMsg_CursorVisibilityChange(GetRoutingID(), is_visible)); |
1214 } | 1212 } |
1215 | 1213 |
1216 int64 RenderWidgetHostImpl::GetLatencyComponentId() { | 1214 int64 RenderWidgetHostImpl::GetLatencyComponentId() { |
1217 return GetRoutingID() | (static_cast<int64>(GetProcess()->GetID()) << 32); | 1215 return GetRoutingID() | (static_cast<int64>(GetProcess()->GetID()) << 32); |
1218 } | 1216 } |
1219 | 1217 |
1220 // static | |
1221 void RenderWidgetHostImpl::DisableResizeAckCheckForTesting() { | |
1222 g_check_for_pending_resize_ack = false; | |
1223 } | |
1224 | |
1225 ui::LatencyInfo RenderWidgetHostImpl::NewInputLatencyInfo() { | 1218 ui::LatencyInfo RenderWidgetHostImpl::NewInputLatencyInfo() { |
1226 ui::LatencyInfo info; | 1219 ui::LatencyInfo info; |
1227 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_COMPONENT, | 1220 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_COMPONENT, |
1228 GetLatencyComponentId(), | 1221 GetLatencyComponentId(), |
1229 ++last_input_number_); | 1222 ++last_input_number_); |
1230 return info; | 1223 return info; |
1231 } | 1224 } |
1232 | 1225 |
1233 void RenderWidgetHostImpl::SendInputEvent(const WebInputEvent& input_event, | 1226 void RenderWidgetHostImpl::SendInputEvent(const WebInputEvent& input_event, |
1234 int event_size, | 1227 int event_size, |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 current_size_ = params.view_size; | 1730 current_size_ = params.view_size; |
1738 // Update our knowledge of the RenderWidget's scroll offset. | 1731 // Update our knowledge of the RenderWidget's scroll offset. |
1739 last_scroll_offset_ = params.scroll_offset; | 1732 last_scroll_offset_ = params.scroll_offset; |
1740 | 1733 |
1741 bool is_resize_ack = | 1734 bool is_resize_ack = |
1742 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags); | 1735 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags); |
1743 | 1736 |
1744 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since | 1737 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since |
1745 // that will end up reaching GetBackingStore. | 1738 // that will end up reaching GetBackingStore. |
1746 if (is_resize_ack) { | 1739 if (is_resize_ack) { |
1747 DCHECK(!g_check_for_pending_resize_ack || resize_ack_pending_); | 1740 DCHECK(resize_ack_pending_); |
1748 resize_ack_pending_ = false; | 1741 resize_ack_pending_ = false; |
1749 in_flight_size_.SetSize(0, 0); | 1742 in_flight_size_.SetSize(0, 0); |
1750 } | 1743 } |
1751 | 1744 |
1752 bool is_repaint_ack = | 1745 bool is_repaint_ack = |
1753 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags); | 1746 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags); |
1754 if (is_repaint_ack) { | 1747 if (is_repaint_ack) { |
1755 DCHECK(repaint_ack_pending_); | 1748 DCHECK(repaint_ack_pending_); |
1756 TRACE_EVENT_ASYNC_END0( | 1749 TRACE_EVENT_ASYNC_END0( |
1757 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); | 1750 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 rendering_stats_.total_input_latency += | 2517 rendering_stats_.total_input_latency += |
2525 l->second.event_count * | 2518 l->second.event_count * |
2526 (latency_info.swap_timestamp - l->second.event_time); | 2519 (latency_info.swap_timestamp - l->second.event_time); |
2527 | 2520 |
2528 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2521 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2529 switches::kEnableGpuBenchmarking)) | 2522 switches::kEnableGpuBenchmarking)) |
2530 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); | 2523 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); |
2531 } | 2524 } |
2532 | 2525 |
2533 } // namespace content | 2526 } // namespace content |
OLD | NEW |