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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 popup_type_(popup_type), | 104 popup_type_(popup_type), |
105 pending_window_rect_count_(0), | 105 pending_window_rect_count_(0), |
106 suppress_next_char_events_(false), | 106 suppress_next_char_events_(false), |
107 is_accelerated_compositing_active_(false), | 107 is_accelerated_compositing_active_(false), |
108 animation_update_pending_(false), | 108 animation_update_pending_(false), |
109 invalidation_task_posted_(false), | 109 invalidation_task_posted_(false), |
110 screen_info_(screen_info), | 110 screen_info_(screen_info), |
111 device_scale_factor_(screen_info_.deviceScaleFactor), | 111 device_scale_factor_(screen_info_.deviceScaleFactor), |
112 throttle_input_events_(true), | 112 throttle_input_events_(true), |
113 next_smooth_scroll_gesture_id_(0), | 113 next_smooth_scroll_gesture_id_(0), |
114 is_threaded_compositing_enabled_(false) { | 114 is_threaded_compositing_enabled_(false), |
| 115 started_frame_(false), |
| 116 got_input_(false) { |
115 if (!swapped_out) | 117 if (!swapped_out) |
116 RenderProcess::current()->AddRefProcess(); | 118 RenderProcess::current()->AddRefProcess(); |
117 DCHECK(RenderThread::Get()); | 119 DCHECK(RenderThread::Get()); |
118 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 120 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
119 switches::kDisableGpuVsync); | 121 switches::kDisableGpuVsync); |
120 is_threaded_compositing_enabled_ = | 122 is_threaded_compositing_enabled_ = |
121 CommandLine::ForCurrentProcess()->HasSwitch( | 123 CommandLine::ForCurrentProcess()->HasSwitch( |
122 switches::kEnableThreadedCompositing); | 124 switches::kEnableThreadedCompositing); |
123 } | 125 } |
124 | 126 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 233 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
232 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) | 234 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) |
233 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) | 235 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) |
234 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) | 236 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) |
235 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) | 237 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
236 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) | 238 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) |
237 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut) | 239 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut) |
238 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck) | 240 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck) |
239 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete) | 241 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete) |
240 IPC_MESSAGE_HANDLER(ViewMsg_HandleInputEvent, OnHandleInputEvent) | 242 IPC_MESSAGE_HANDLER(ViewMsg_HandleInputEvent, OnHandleInputEvent) |
| 243 IPC_MESSAGE_HANDLER(ViewMsg_StartFrame, OnStartFrame) |
241 IPC_MESSAGE_HANDLER(ViewMsg_MouseCaptureLost, OnMouseCaptureLost) | 244 IPC_MESSAGE_HANDLER(ViewMsg_MouseCaptureLost, OnMouseCaptureLost) |
242 IPC_MESSAGE_HANDLER(ViewMsg_SetFocus, OnSetFocus) | 245 IPC_MESSAGE_HANDLER(ViewMsg_SetFocus, OnSetFocus) |
243 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) | 246 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) |
244 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) | 247 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) |
245 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition) | 248 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition) |
246 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnMsgPaintAtSize) | 249 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnMsgPaintAtSize) |
247 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnMsgRepaint) | 250 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnMsgRepaint) |
248 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, | 251 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, |
249 OnMsgSmoothScrollCompleted) | 252 OnMsgSmoothScrollCompleted) |
250 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) | 253 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 // generated it. | 542 // generated it. |
540 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) { | 543 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) { |
541 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); | 544 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); |
542 return; | 545 return; |
543 } | 546 } |
544 | 547 |
545 // Continue painting if necessary... | 548 // Continue painting if necessary... |
546 DoDeferredUpdateAndSendInputAck(); | 549 DoDeferredUpdateAndSendInputAck(); |
547 } | 550 } |
548 | 551 |
549 void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event, | 552 void RenderWidget::OnHandleInputEvent(int64 input_number, |
| 553 const WebKit::WebInputEvent* input_event, |
550 bool is_keyboard_shortcut) { | 554 bool is_keyboard_shortcut) { |
551 TRACE_EVENT0("renderer", "RenderWidget::OnHandleInputEvent"); | 555 TRACE_EVENT0("renderer", "RenderWidget::OnHandleInputEvent"); |
552 | 556 |
553 handling_input_event_ = true; | 557 handling_input_event_ = true; |
554 if (!input_event) { | 558 if (!input_event) { |
555 handling_input_event_ = false; | 559 handling_input_event_ = false; |
556 return; | 560 return; |
557 } | 561 } |
558 | 562 |
| 563 OnStartFrame(input_number); |
| 564 |
559 bool prevent_default = false; | 565 bool prevent_default = false; |
560 if (WebInputEvent::isMouseEventType(input_event->type)) { | 566 if (WebInputEvent::isMouseEventType(input_event->type)) { |
561 const WebMouseEvent& mouse_event = | 567 const WebMouseEvent& mouse_event = |
562 *static_cast<const WebMouseEvent*>(input_event); | 568 *static_cast<const WebMouseEvent*>(input_event); |
563 TRACE_EVENT2("renderer", "HandleMouseMove", | 569 TRACE_EVENT2("renderer", "HandleMouseMove", |
564 "x", mouse_event.x, "y", mouse_event.y); | 570 "x", mouse_event.x, "y", mouse_event.y); |
565 prevent_default = WillHandleMouseEvent(mouse_event); | 571 prevent_default = WillHandleMouseEvent(mouse_event); |
566 } | 572 } |
567 | 573 |
568 if (WebInputEvent::isGestureEventType(input_event->type)) { | 574 if (WebInputEvent::isGestureEventType(input_event->type)) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 if (!prevent_default) { | 638 if (!prevent_default) { |
633 if (WebInputEvent::isKeyboardEventType(input_event->type)) | 639 if (WebInputEvent::isKeyboardEventType(input_event->type)) |
634 DidHandleKeyEvent(); | 640 DidHandleKeyEvent(); |
635 if (WebInputEvent::isMouseEventType(input_event->type)) | 641 if (WebInputEvent::isMouseEventType(input_event->type)) |
636 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); | 642 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); |
637 if (WebInputEvent::isTouchEventType(input_event->type)) | 643 if (WebInputEvent::isTouchEventType(input_event->type)) |
638 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event))); | 644 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event))); |
639 } | 645 } |
640 } | 646 } |
641 | 647 |
| 648 void RenderWidget::OnStartFrame(int64 input_number) { |
| 649 latency_info_.inputNumber = std::max(input_number, latency_info_.inputNumber); |
| 650 if (!got_input_) { |
| 651 TRACE_EVENT_ASYNC_BEGIN1("frame", "Input handling", this, |
| 652 "input_number", input_number); |
| 653 got_input_ = true; |
| 654 } |
| 655 } |
| 656 |
| 657 void RenderWidget::StartingFrame() { |
| 658 if (got_input_) { |
| 659 TRACE_EVENT_ASYNC_END1("frame", "Input handling", this, |
| 660 "input_number", latency_info_.inputNumber); |
| 661 got_input_ = false; |
| 662 } |
| 663 |
| 664 if (!started_frame_) { |
| 665 started_frame_ = true; |
| 666 latency_info_.rendererMainFrameNumber++; |
| 667 TRACE_EVENT_ASYNC_BEGIN2("frame", "Frame", this, |
| 668 "frame_number", |
| 669 latency_info_.rendererMainFrameNumber, |
| 670 "input_number", latency_info_.inputNumber); |
| 671 } |
| 672 webwidget_->setLatencyInfo(latency_info_); |
| 673 } |
| 674 |
642 void RenderWidget::OnMouseCaptureLost() { | 675 void RenderWidget::OnMouseCaptureLost() { |
643 if (webwidget_) | 676 if (webwidget_) |
644 webwidget_->mouseCaptureLost(); | 677 webwidget_->mouseCaptureLost(); |
645 } | 678 } |
646 | 679 |
647 void RenderWidget::OnSetFocus(bool enable) { | 680 void RenderWidget::OnSetFocus(bool enable) { |
648 has_focus_ = enable; | 681 has_focus_ = enable; |
649 if (webwidget_) | 682 if (webwidget_) |
650 webwidget_->setFocus(enable); | 683 webwidget_->setFocus(enable); |
651 } | 684 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1); | 830 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1); |
798 canvas->drawIRect(irect, paint); | 831 canvas->drawIRect(irect, paint); |
799 } | 832 } |
800 | 833 |
801 void RenderWidget::AnimationCallback() { | 834 void RenderWidget::AnimationCallback() { |
802 TRACE_EVENT0("renderer", "RenderWidget::AnimationCallback"); | 835 TRACE_EVENT0("renderer", "RenderWidget::AnimationCallback"); |
803 if (!animation_update_pending_) { | 836 if (!animation_update_pending_) { |
804 TRACE_EVENT0("renderer", "EarlyOut_NoAnimationUpdatePending"); | 837 TRACE_EVENT0("renderer", "EarlyOut_NoAnimationUpdatePending"); |
805 return; | 838 return; |
806 } | 839 } |
| 840 StartingFrame(); |
807 if (!animation_floor_time_.is_null() && IsRenderingVSynced()) { | 841 if (!animation_floor_time_.is_null() && IsRenderingVSynced()) { |
808 // Record when we fired (according to base::Time::Now()) relative to when | 842 // Record when we fired (according to base::Time::Now()) relative to when |
809 // we posted the task to quantify how much the base::Time/base::TimeTicks | 843 // we posted the task to quantify how much the base::Time/base::TimeTicks |
810 // skew is affecting animations. | 844 // skew is affecting animations. |
811 base::TimeDelta animation_callback_delay = base::Time::Now() - | 845 base::TimeDelta animation_callback_delay = base::Time::Now() - |
812 (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16)); | 846 (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16)); |
813 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime", | 847 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime", |
814 animation_callback_delay, | 848 animation_callback_delay, |
815 base::TimeDelta::FromMilliseconds(0), | 849 base::TimeDelta::FromMilliseconds(0), |
816 base::TimeDelta::FromMilliseconds(30), | 850 base::TimeDelta::FromMilliseconds(30), |
(...skipping 10 matching lines...) Expand all Loading... |
827 base::TimeDelta animationInterval = IsRenderingVSynced() ? | 861 base::TimeDelta animationInterval = IsRenderingVSynced() ? |
828 base::TimeDelta::FromMilliseconds(16) : base::TimeDelta(); | 862 base::TimeDelta::FromMilliseconds(16) : base::TimeDelta(); |
829 | 863 |
830 base::Time now = base::Time::Now(); | 864 base::Time now = base::Time::Now(); |
831 | 865 |
832 // animation_floor_time_ is the earliest time that we should animate when | 866 // animation_floor_time_ is the earliest time that we should animate when |
833 // using the dead reckoning software scheduler. If we're using swapbuffers | 867 // using the dead reckoning software scheduler. If we're using swapbuffers |
834 // complete callbacks to rate limit, we can ignore this floor. | 868 // complete callbacks to rate limit, we can ignore this floor. |
835 if (now >= animation_floor_time_ || num_swapbuffers_complete_pending_ > 0) { | 869 if (now >= animation_floor_time_ || num_swapbuffers_complete_pending_ > 0) { |
836 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") | 870 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") |
| 871 StartingFrame(); |
837 animation_floor_time_ = now + animationInterval; | 872 animation_floor_time_ = now + animationInterval; |
838 // Set a timer to call us back after animationInterval before | 873 // Set a timer to call us back after animationInterval before |
839 // running animation callbacks so that if a callback requests another | 874 // running animation callbacks so that if a callback requests another |
840 // we'll be sure to run it at the proper time. | 875 // we'll be sure to run it at the proper time. |
841 animation_timer_.Stop(); | 876 animation_timer_.Stop(); |
842 animation_timer_.Start(FROM_HERE, animationInterval, this, | 877 animation_timer_.Start(FROM_HERE, animationInterval, this, |
843 &RenderWidget::AnimationCallback); | 878 &RenderWidget::AnimationCallback); |
844 animation_update_pending_ = false; | 879 animation_update_pending_ = false; |
845 webwidget_->animate(0.0); | 880 webwidget_->animate(0.0); |
846 return; | 881 return; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 UpdateSelectionBounds(); | 965 UpdateSelectionBounds(); |
931 | 966 |
932 // Suppress painting if nothing is dirty. This has to be done after updating | 967 // Suppress painting if nothing is dirty. This has to be done after updating |
933 // animations running layout as these may generate further invalidations. | 968 // animations running layout as these may generate further invalidations. |
934 if (!paint_aggregator_.HasPendingUpdate()) { | 969 if (!paint_aggregator_.HasPendingUpdate()) { |
935 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); | 970 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); |
936 webwidget_->instrumentCancelFrame(); | 971 webwidget_->instrumentCancelFrame(); |
937 return; | 972 return; |
938 } | 973 } |
939 | 974 |
| 975 StartingFrame(); |
| 976 |
940 if (!is_accelerated_compositing_active_ && | 977 if (!is_accelerated_compositing_active_ && |
941 !is_threaded_compositing_enabled_ && | 978 !is_threaded_compositing_enabled_ && |
942 ForceCompositingModeEnabled()) { | 979 ForceCompositingModeEnabled()) { |
943 webwidget_->enterForceCompositingMode(true); | 980 webwidget_->enterForceCompositingMode(true); |
944 } | 981 } |
945 | 982 |
946 if (!last_do_deferred_update_time_.is_null()) { | 983 if (!last_do_deferred_update_time_.is_null()) { |
947 base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_; | 984 base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_; |
948 if (is_accelerated_compositing_active_) { | 985 if (is_accelerated_compositing_active_) { |
949 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay", | 986 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay", |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 DCHECK(!pending_update_params_.get()); | 1036 DCHECK(!pending_update_params_.get()); |
1000 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params); | 1037 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params); |
1001 pending_update_params_->scroll_delta = update.scroll_delta; | 1038 pending_update_params_->scroll_delta = update.scroll_delta; |
1002 pending_update_params_->scroll_rect = update.scroll_rect; | 1039 pending_update_params_->scroll_rect = update.scroll_rect; |
1003 pending_update_params_->view_size = size_; | 1040 pending_update_params_->view_size = size_; |
1004 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_); | 1041 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_); |
1005 pending_update_params_->flags = next_paint_flags_; | 1042 pending_update_params_->flags = next_paint_flags_; |
1006 pending_update_params_->scroll_offset = GetScrollOffset(); | 1043 pending_update_params_->scroll_offset = GetScrollOffset(); |
1007 pending_update_params_->needs_ack = true; | 1044 pending_update_params_->needs_ack = true; |
1008 pending_update_params_->scale_factor = device_scale_factor_; | 1045 pending_update_params_->scale_factor = device_scale_factor_; |
| 1046 pending_update_params_->latency_info = latency_info_; |
1009 next_paint_flags_ = 0; | 1047 next_paint_flags_ = 0; |
1010 need_update_rect_for_auto_resize_ = false; | 1048 need_update_rect_for_auto_resize_ = false; |
1011 | 1049 |
1012 if (update.scroll_rect.IsEmpty() && | 1050 if (update.scroll_rect.IsEmpty() && |
1013 !is_accelerated_compositing_active_ && | 1051 !is_accelerated_compositing_active_ && |
1014 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, | 1052 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, |
1015 &optimized_copy_rect, | 1053 &optimized_copy_rect, |
1016 &dib_scale_factor)) { | 1054 &dib_scale_factor)) { |
1017 // Only update the part of the plugin that actually changed. | 1055 // Only update the part of the plugin that actually changed. |
1018 optimized_copy_rect.Intersect(bounds); | 1056 optimized_copy_rect.Intersect(bounds); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 Send(pending_input_event_ack_.release()); | 1118 Send(pending_input_event_ack_.release()); |
1081 | 1119 |
1082 // If composite() called SwapBuffers, pending_update_params_ will be reset (in | 1120 // If composite() called SwapBuffers, pending_update_params_ will be reset (in |
1083 // OnSwapBuffersPosted), meaning a message has been added to the | 1121 // OnSwapBuffersPosted), meaning a message has been added to the |
1084 // updates_pending_swap_ queue, that will be sent later. Otherwise, we send | 1122 // updates_pending_swap_ queue, that will be sent later. Otherwise, we send |
1085 // the message now. | 1123 // the message now. |
1086 if (pending_update_params_.get()) { | 1124 if (pending_update_params_.get()) { |
1087 // sending an ack to browser process that the paint is complete... | 1125 // sending an ack to browser process that the paint is complete... |
1088 update_reply_pending_ = pending_update_params_->needs_ack; | 1126 update_reply_pending_ = pending_update_params_->needs_ack; |
1089 Send(new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_)); | 1127 Send(new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_)); |
| 1128 didBeginCompositorFrame(); |
1090 pending_update_params_.reset(); | 1129 pending_update_params_.reset(); |
1091 } | 1130 } |
1092 | 1131 |
1093 // If we're software rendering then we're done initiating the paint. | 1132 // If we're software rendering then we're done initiating the paint. |
1094 if (!is_accelerated_compositing_active_) | 1133 if (!is_accelerated_compositing_active_) |
1095 DidInitiatePaint(); | 1134 DidInitiatePaint(); |
1096 } | 1135 } |
1097 | 1136 |
1098 /////////////////////////////////////////////////////////////////////////////// | 1137 /////////////////////////////////////////////////////////////////////////////// |
1099 // WebWidgetClient | 1138 // WebWidgetClient |
1100 | 1139 |
1101 void RenderWidget::didInvalidateRect(const WebRect& rect) { | 1140 void RenderWidget::didInvalidateRect(const WebRect& rect) { |
1102 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", | 1141 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", |
1103 "width", rect.width, "height", rect.height); | 1142 "width", rect.width, "height", rect.height); |
| 1143 StartingFrame(); |
1104 // The invalidated rect might be outside the bounds of the view. | 1144 // The invalidated rect might be outside the bounds of the view. |
1105 gfx::Rect view_rect(size_); | 1145 gfx::Rect view_rect(size_); |
1106 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect); | 1146 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect); |
1107 if (damaged_rect.IsEmpty()) | 1147 if (damaged_rect.IsEmpty()) |
1108 return; | 1148 return; |
1109 | 1149 |
1110 paint_aggregator_.InvalidateRect(damaged_rect); | 1150 paint_aggregator_.InvalidateRect(damaged_rect); |
1111 | 1151 |
1112 // We may not need to schedule another call to DoDeferredUpdate. | 1152 // We may not need to schedule another call to DoDeferredUpdate. |
1113 if (invalidation_task_posted_) | 1153 if (invalidation_task_posted_) |
(...skipping 27 matching lines...) Expand all Loading... |
1141 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place. | 1181 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place. |
1142 if (is_accelerated_compositing_active_) | 1182 if (is_accelerated_compositing_active_) |
1143 return; | 1183 return; |
1144 | 1184 |
1145 // The scrolled rect might be outside the bounds of the view. | 1185 // The scrolled rect might be outside the bounds of the view. |
1146 gfx::Rect view_rect(size_); | 1186 gfx::Rect view_rect(size_); |
1147 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect); | 1187 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect); |
1148 if (damaged_rect.IsEmpty()) | 1188 if (damaged_rect.IsEmpty()) |
1149 return; | 1189 return; |
1150 | 1190 |
| 1191 StartingFrame(); |
1151 paint_aggregator_.ScrollRect(gfx::Vector2d(dx, dy), damaged_rect); | 1192 paint_aggregator_.ScrollRect(gfx::Vector2d(dx, dy), damaged_rect); |
1152 | 1193 |
1153 // We may not need to schedule another call to DoDeferredUpdate. | 1194 // We may not need to schedule another call to DoDeferredUpdate. |
1154 if (invalidation_task_posted_) | 1195 if (invalidation_task_posted_) |
1155 return; | 1196 return; |
1156 if (!paint_aggregator_.HasPendingUpdate()) | 1197 if (!paint_aggregator_.HasPendingUpdate()) |
1157 return; | 1198 return; |
1158 if (update_reply_pending_ || | 1199 if (update_reply_pending_ || |
1159 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) | 1200 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) |
1160 return; | 1201 return; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 // In single-threaded mode, we exit force compositing mode and re-enter in | 1265 // In single-threaded mode, we exit force compositing mode and re-enter in |
1225 // DoDeferredUpdate() if appropriate. In threaded compositing mode, | 1266 // DoDeferredUpdate() if appropriate. In threaded compositing mode, |
1226 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and | 1267 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and |
1227 // entering force compositing mode at the appropriate times. | 1268 // entering force compositing mode at the appropriate times. |
1228 if (!is_threaded_compositing_enabled_) | 1269 if (!is_threaded_compositing_enabled_) |
1229 webwidget_->enterForceCompositingMode(false); | 1270 webwidget_->enterForceCompositingMode(false); |
1230 } | 1271 } |
1231 | 1272 |
1232 void RenderWidget::willBeginCompositorFrame() { | 1273 void RenderWidget::willBeginCompositorFrame() { |
1233 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1274 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
| 1275 StartingFrame(); |
1234 | 1276 |
1235 DCHECK(RenderThreadImpl::current()->compositor_thread()); | 1277 DCHECK(RenderThreadImpl::current()->compositor_thread()); |
1236 | 1278 |
1237 // The following two can result in further layout and possibly | 1279 // The following two can result in further layout and possibly |
1238 // enable GPU acceleration so they need to be called before any painting | 1280 // enable GPU acceleration so they need to be called before any painting |
1239 // is done. | 1281 // is done. |
1240 UpdateTextInputState(DO_NOT_SHOW_IME); | 1282 UpdateTextInputState(DO_NOT_SHOW_IME); |
1241 UpdateSelectionBounds(); | 1283 UpdateSelectionBounds(); |
| 1284 WillInitiatePaint(); |
| 1285 } |
1242 | 1286 |
1243 WillInitiatePaint(); | 1287 void RenderWidget::didBeginCompositorFrame() { |
| 1288 if (started_frame_) { |
| 1289 TRACE_EVENT_ASYNC_END2("frame", "Frame", this, |
| 1290 "frameNumber", latency_info_.rendererMainFrameNumber, |
| 1291 "inputNumber", latency_info_.inputNumber); |
| 1292 started_frame_ = false; |
| 1293 } |
1244 } | 1294 } |
1245 | 1295 |
1246 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1296 void RenderWidget::didBecomeReadyForAdditionalInput() { |
1247 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1297 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
1248 if (pending_input_event_ack_.get()) | 1298 if (pending_input_event_ack_.get()) |
1249 Send(pending_input_event_ack_.release()); | 1299 Send(pending_input_event_ack_.release()); |
1250 } | 1300 } |
1251 | 1301 |
1252 void RenderWidget::didCommitAndDrawCompositorFrame() { | 1302 void RenderWidget::didCommitAndDrawCompositorFrame() { |
1253 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame"); | 1303 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame"); |
(...skipping 27 matching lines...) Expand all Loading... |
1281 params.needs_ack = false; | 1331 params.needs_ack = false; |
1282 params.scale_factor = device_scale_factor_; | 1332 params.scale_factor = device_scale_factor_; |
1283 | 1333 |
1284 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | 1334 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
1285 next_paint_flags_ = 0; | 1335 next_paint_flags_ = 0; |
1286 need_update_rect_for_auto_resize_ = false; | 1336 need_update_rect_for_auto_resize_ = false; |
1287 } | 1337 } |
1288 | 1338 |
1289 void RenderWidget::scheduleComposite() { | 1339 void RenderWidget::scheduleComposite() { |
1290 TRACE_EVENT0("gpu", "RenderWidget::scheduleComposite"); | 1340 TRACE_EVENT0("gpu", "RenderWidget::scheduleComposite"); |
| 1341 StartingFrame(); |
1291 if (WebWidgetHandlesCompositorScheduling()) { | 1342 if (WebWidgetHandlesCompositorScheduling()) { |
1292 webwidget_->composite(false); | 1343 webwidget_->composite(false); |
1293 } else { | 1344 } else { |
1294 // TODO(nduca): replace with something a little less hacky. The reason this | 1345 // TODO(nduca): replace with something a little less hacky. The reason this |
1295 // hack is still used is because the Invalidate-DoDeferredUpdate loop | 1346 // hack is still used is because the Invalidate-DoDeferredUpdate loop |
1296 // contains a lot of host-renderer synchronization logic that is still | 1347 // contains a lot of host-renderer synchronization logic that is still |
1297 // important for the accelerated compositing case. The option of simply | 1348 // important for the accelerated compositing case. The option of simply |
1298 // duplicating all that code is less desirable than "faking out" the | 1349 // duplicating all that code is less desirable than "faking out" the |
1299 // invalidation path using a magical damage rect. | 1350 // invalidation path using a magical damage rect. |
1300 didInvalidateRect(WebRect(0, 0, 1, 1)); | 1351 didInvalidateRect(WebRect(0, 0, 1, 1)); |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 | 2020 |
1970 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 2021 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1971 return false; | 2022 return false; |
1972 } | 2023 } |
1973 | 2024 |
1974 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2025 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
1975 return true; | 2026 return true; |
1976 } | 2027 } |
1977 | 2028 |
1978 } // namespace content | 2029 } // namespace content |
OLD | NEW |