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

Side by Side Diff: content/renderer/render_widget.cc

Issue 11293121: Add latency measurement system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: create cc::LatencyInfo Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_widget.h ('k') | ui/aura/bench/bench_main.cc » ('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 (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
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
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, OnPaintAtSize) 249 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize)
247 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 250 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
248 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, OnSmoothScrollCompleted) 251 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, OnSmoothScrollCompleted)
249 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 252 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
250 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 253 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // generated it. 541 // generated it.
539 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) { 542 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) {
540 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); 543 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate");
541 return; 544 return;
542 } 545 }
543 546
544 // Continue painting if necessary... 547 // Continue painting if necessary...
545 DoDeferredUpdateAndSendInputAck(); 548 DoDeferredUpdateAndSendInputAck();
546 } 549 }
547 550
548 void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event, 551 void RenderWidget::OnHandleInputEvent(int64 input_number,
552 const WebKit::WebInputEvent* input_event,
549 bool is_keyboard_shortcut) { 553 bool is_keyboard_shortcut) {
550 TRACE_EVENT0("renderer", "RenderWidget::OnHandleInputEvent"); 554 TRACE_EVENT0("renderer", "RenderWidget::OnHandleInputEvent");
551 555
552 handling_input_event_ = true; 556 handling_input_event_ = true;
553 if (!input_event) { 557 if (!input_event) {
554 handling_input_event_ = false; 558 handling_input_event_ = false;
555 return; 559 return;
556 } 560 }
557 561
562 OnStartFrame(input_number);
563
558 bool prevent_default = false; 564 bool prevent_default = false;
559 if (WebInputEvent::isMouseEventType(input_event->type)) { 565 if (WebInputEvent::isMouseEventType(input_event->type)) {
560 const WebMouseEvent& mouse_event = 566 const WebMouseEvent& mouse_event =
561 *static_cast<const WebMouseEvent*>(input_event); 567 *static_cast<const WebMouseEvent*>(input_event);
562 TRACE_EVENT2("renderer", "HandleMouseMove", 568 TRACE_EVENT2("renderer", "HandleMouseMove",
563 "x", mouse_event.x, "y", mouse_event.y); 569 "x", mouse_event.x, "y", mouse_event.y);
564 prevent_default = WillHandleMouseEvent(mouse_event); 570 prevent_default = WillHandleMouseEvent(mouse_event);
565 } 571 }
566 572
567 if (WebInputEvent::isGestureEventType(input_event->type)) { 573 if (WebInputEvent::isGestureEventType(input_event->type)) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 if (!prevent_default) { 637 if (!prevent_default) {
632 if (WebInputEvent::isKeyboardEventType(input_event->type)) 638 if (WebInputEvent::isKeyboardEventType(input_event->type))
633 DidHandleKeyEvent(); 639 DidHandleKeyEvent();
634 if (WebInputEvent::isMouseEventType(input_event->type)) 640 if (WebInputEvent::isMouseEventType(input_event->type))
635 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); 641 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event)));
636 if (WebInputEvent::isTouchEventType(input_event->type)) 642 if (WebInputEvent::isTouchEventType(input_event->type))
637 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event))); 643 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event)));
638 } 644 }
639 } 645 }
640 646
647 void RenderWidget::OnStartFrame(int64 input_number) {
648 latency_info_.inputNumber = std::max(input_number, latency_info_.inputNumber);
649 if (!got_input_) {
650 TRACE_EVENT_ASYNC_BEGIN1("frame", "Input handling", this,
651 "input_number", input_number);
652 got_input_ = true;
653 }
654 }
655
656 void RenderWidget::StartingFrame() {
657 if (got_input_) {
658 TRACE_EVENT_ASYNC_END1("frame", "Input handling", this,
659 "input_number", latency_info_.inputNumber);
660 got_input_ = false;
661 }
662
663 if (!started_frame_) {
664 started_frame_ = true;
665 latency_info_.rendererMainFrameNumber++;
666 TRACE_EVENT_ASYNC_BEGIN2("frame", "Frame", this,
667 "frame_number",
668 latency_info_.rendererMainFrameNumber,
669 "input_number", latency_info_.inputNumber);
670 }
671 WebKit::WebLatencyInfoImpl latency_info;
672 latency_info.latency_info = latency_info_;
673 webwidget_->setLatencyInfo(latency_info);
674 }
675
641 void RenderWidget::OnMouseCaptureLost() { 676 void RenderWidget::OnMouseCaptureLost() {
642 if (webwidget_) 677 if (webwidget_)
643 webwidget_->mouseCaptureLost(); 678 webwidget_->mouseCaptureLost();
644 } 679 }
645 680
646 void RenderWidget::OnSetFocus(bool enable) { 681 void RenderWidget::OnSetFocus(bool enable) {
647 has_focus_ = enable; 682 has_focus_ = enable;
648 if (webwidget_) 683 if (webwidget_)
649 webwidget_->setFocus(enable); 684 webwidget_->setFocus(enable);
650 } 685 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1); 831 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1);
797 canvas->drawIRect(irect, paint); 832 canvas->drawIRect(irect, paint);
798 } 833 }
799 834
800 void RenderWidget::AnimationCallback() { 835 void RenderWidget::AnimationCallback() {
801 TRACE_EVENT0("renderer", "RenderWidget::AnimationCallback"); 836 TRACE_EVENT0("renderer", "RenderWidget::AnimationCallback");
802 if (!animation_update_pending_) { 837 if (!animation_update_pending_) {
803 TRACE_EVENT0("renderer", "EarlyOut_NoAnimationUpdatePending"); 838 TRACE_EVENT0("renderer", "EarlyOut_NoAnimationUpdatePending");
804 return; 839 return;
805 } 840 }
841 StartingFrame();
806 if (!animation_floor_time_.is_null() && IsRenderingVSynced()) { 842 if (!animation_floor_time_.is_null() && IsRenderingVSynced()) {
807 // Record when we fired (according to base::Time::Now()) relative to when 843 // Record when we fired (according to base::Time::Now()) relative to when
808 // we posted the task to quantify how much the base::Time/base::TimeTicks 844 // we posted the task to quantify how much the base::Time/base::TimeTicks
809 // skew is affecting animations. 845 // skew is affecting animations.
810 base::TimeDelta animation_callback_delay = base::Time::Now() - 846 base::TimeDelta animation_callback_delay = base::Time::Now() -
811 (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16)); 847 (animation_floor_time_ - base::TimeDelta::FromMilliseconds(16));
812 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime", 848 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AnimationCallbackDelayTime",
813 animation_callback_delay, 849 animation_callback_delay,
814 base::TimeDelta::FromMilliseconds(0), 850 base::TimeDelta::FromMilliseconds(0),
815 base::TimeDelta::FromMilliseconds(30), 851 base::TimeDelta::FromMilliseconds(30),
(...skipping 10 matching lines...) Expand all
826 base::TimeDelta animationInterval = IsRenderingVSynced() ? 862 base::TimeDelta animationInterval = IsRenderingVSynced() ?
827 base::TimeDelta::FromMilliseconds(16) : base::TimeDelta(); 863 base::TimeDelta::FromMilliseconds(16) : base::TimeDelta();
828 864
829 base::Time now = base::Time::Now(); 865 base::Time now = base::Time::Now();
830 866
831 // animation_floor_time_ is the earliest time that we should animate when 867 // animation_floor_time_ is the earliest time that we should animate when
832 // using the dead reckoning software scheduler. If we're using swapbuffers 868 // using the dead reckoning software scheduler. If we're using swapbuffers
833 // complete callbacks to rate limit, we can ignore this floor. 869 // complete callbacks to rate limit, we can ignore this floor.
834 if (now >= animation_floor_time_ || num_swapbuffers_complete_pending_ > 0) { 870 if (now >= animation_floor_time_ || num_swapbuffers_complete_pending_ > 0) {
835 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") 871 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded")
872 StartingFrame();
836 animation_floor_time_ = now + animationInterval; 873 animation_floor_time_ = now + animationInterval;
837 // Set a timer to call us back after animationInterval before 874 // Set a timer to call us back after animationInterval before
838 // running animation callbacks so that if a callback requests another 875 // running animation callbacks so that if a callback requests another
839 // we'll be sure to run it at the proper time. 876 // we'll be sure to run it at the proper time.
840 animation_timer_.Stop(); 877 animation_timer_.Stop();
841 animation_timer_.Start(FROM_HERE, animationInterval, this, 878 animation_timer_.Start(FROM_HERE, animationInterval, this,
842 &RenderWidget::AnimationCallback); 879 &RenderWidget::AnimationCallback);
843 animation_update_pending_ = false; 880 animation_update_pending_ = false;
844 webwidget_->animate(0.0); 881 webwidget_->animate(0.0);
845 return; 882 return;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 UpdateSelectionBounds(); 966 UpdateSelectionBounds();
930 967
931 // Suppress painting if nothing is dirty. This has to be done after updating 968 // Suppress painting if nothing is dirty. This has to be done after updating
932 // animations running layout as these may generate further invalidations. 969 // animations running layout as these may generate further invalidations.
933 if (!paint_aggregator_.HasPendingUpdate()) { 970 if (!paint_aggregator_.HasPendingUpdate()) {
934 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); 971 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate");
935 webwidget_->instrumentCancelFrame(); 972 webwidget_->instrumentCancelFrame();
936 return; 973 return;
937 } 974 }
938 975
976 StartingFrame();
977
939 if (!is_accelerated_compositing_active_ && 978 if (!is_accelerated_compositing_active_ &&
940 !is_threaded_compositing_enabled_ && 979 !is_threaded_compositing_enabled_ &&
941 ForceCompositingModeEnabled()) { 980 ForceCompositingModeEnabled()) {
942 webwidget_->enterForceCompositingMode(true); 981 webwidget_->enterForceCompositingMode(true);
943 } 982 }
944 983
945 if (!last_do_deferred_update_time_.is_null()) { 984 if (!last_do_deferred_update_time_.is_null()) {
946 base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_; 985 base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_;
947 if (is_accelerated_compositing_active_) { 986 if (is_accelerated_compositing_active_) {
948 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay", 987 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay",
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 DCHECK(!pending_update_params_.get()); 1037 DCHECK(!pending_update_params_.get());
999 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params); 1038 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params);
1000 pending_update_params_->scroll_delta = update.scroll_delta; 1039 pending_update_params_->scroll_delta = update.scroll_delta;
1001 pending_update_params_->scroll_rect = update.scroll_rect; 1040 pending_update_params_->scroll_rect = update.scroll_rect;
1002 pending_update_params_->view_size = size_; 1041 pending_update_params_->view_size = size_;
1003 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_); 1042 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_);
1004 pending_update_params_->flags = next_paint_flags_; 1043 pending_update_params_->flags = next_paint_flags_;
1005 pending_update_params_->scroll_offset = GetScrollOffset(); 1044 pending_update_params_->scroll_offset = GetScrollOffset();
1006 pending_update_params_->needs_ack = true; 1045 pending_update_params_->needs_ack = true;
1007 pending_update_params_->scale_factor = device_scale_factor_; 1046 pending_update_params_->scale_factor = device_scale_factor_;
1047 pending_update_params_->latency_info = latency_info_;
1008 next_paint_flags_ = 0; 1048 next_paint_flags_ = 0;
1009 need_update_rect_for_auto_resize_ = false; 1049 need_update_rect_for_auto_resize_ = false;
1010 1050
1011 if (update.scroll_rect.IsEmpty() && 1051 if (update.scroll_rect.IsEmpty() &&
1012 !is_accelerated_compositing_active_ && 1052 !is_accelerated_compositing_active_ &&
1013 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, 1053 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location,
1014 &optimized_copy_rect, 1054 &optimized_copy_rect,
1015 &dib_scale_factor)) { 1055 &dib_scale_factor)) {
1016 // Only update the part of the plugin that actually changed. 1056 // Only update the part of the plugin that actually changed.
1017 optimized_copy_rect.Intersect(bounds); 1057 optimized_copy_rect.Intersect(bounds);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 Send(pending_input_event_ack_.release()); 1119 Send(pending_input_event_ack_.release());
1080 1120
1081 // If composite() called SwapBuffers, pending_update_params_ will be reset (in 1121 // If composite() called SwapBuffers, pending_update_params_ will be reset (in
1082 // OnSwapBuffersPosted), meaning a message has been added to the 1122 // OnSwapBuffersPosted), meaning a message has been added to the
1083 // updates_pending_swap_ queue, that will be sent later. Otherwise, we send 1123 // updates_pending_swap_ queue, that will be sent later. Otherwise, we send
1084 // the message now. 1124 // the message now.
1085 if (pending_update_params_.get()) { 1125 if (pending_update_params_.get()) {
1086 // sending an ack to browser process that the paint is complete... 1126 // sending an ack to browser process that the paint is complete...
1087 update_reply_pending_ = pending_update_params_->needs_ack; 1127 update_reply_pending_ = pending_update_params_->needs_ack;
1088 Send(new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_)); 1128 Send(new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_));
1129 didBeginCompositorFrame();
1089 pending_update_params_.reset(); 1130 pending_update_params_.reset();
1090 } 1131 }
1091 1132
1092 // If we're software rendering then we're done initiating the paint. 1133 // If we're software rendering then we're done initiating the paint.
1093 if (!is_accelerated_compositing_active_) 1134 if (!is_accelerated_compositing_active_)
1094 DidInitiatePaint(); 1135 DidInitiatePaint();
1095 } 1136 }
1096 1137
1097 /////////////////////////////////////////////////////////////////////////////// 1138 ///////////////////////////////////////////////////////////////////////////////
1098 // WebWidgetClient 1139 // WebWidgetClient
1099 1140
1100 void RenderWidget::didInvalidateRect(const WebRect& rect) { 1141 void RenderWidget::didInvalidateRect(const WebRect& rect) {
1101 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", 1142 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect",
1102 "width", rect.width, "height", rect.height); 1143 "width", rect.width, "height", rect.height);
1144 StartingFrame();
1103 // The invalidated rect might be outside the bounds of the view. 1145 // The invalidated rect might be outside the bounds of the view.
1104 gfx::Rect view_rect(size_); 1146 gfx::Rect view_rect(size_);
1105 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect); 1147 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect);
1106 if (damaged_rect.IsEmpty()) 1148 if (damaged_rect.IsEmpty())
1107 return; 1149 return;
1108 1150
1109 paint_aggregator_.InvalidateRect(damaged_rect); 1151 paint_aggregator_.InvalidateRect(damaged_rect);
1110 1152
1111 // We may not need to schedule another call to DoDeferredUpdate. 1153 // We may not need to schedule another call to DoDeferredUpdate.
1112 if (invalidation_task_posted_) 1154 if (invalidation_task_posted_)
(...skipping 27 matching lines...) Expand all
1140 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place. 1182 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place.
1141 if (is_accelerated_compositing_active_) 1183 if (is_accelerated_compositing_active_)
1142 return; 1184 return;
1143 1185
1144 // The scrolled rect might be outside the bounds of the view. 1186 // The scrolled rect might be outside the bounds of the view.
1145 gfx::Rect view_rect(size_); 1187 gfx::Rect view_rect(size_);
1146 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect); 1188 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect);
1147 if (damaged_rect.IsEmpty()) 1189 if (damaged_rect.IsEmpty())
1148 return; 1190 return;
1149 1191
1192 StartingFrame();
1150 paint_aggregator_.ScrollRect(gfx::Vector2d(dx, dy), damaged_rect); 1193 paint_aggregator_.ScrollRect(gfx::Vector2d(dx, dy), damaged_rect);
1151 1194
1152 // We may not need to schedule another call to DoDeferredUpdate. 1195 // We may not need to schedule another call to DoDeferredUpdate.
1153 if (invalidation_task_posted_) 1196 if (invalidation_task_posted_)
1154 return; 1197 return;
1155 if (!paint_aggregator_.HasPendingUpdate()) 1198 if (!paint_aggregator_.HasPendingUpdate())
1156 return; 1199 return;
1157 if (update_reply_pending_ || 1200 if (update_reply_pending_ ||
1158 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) 1201 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending)
1159 return; 1202 return;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 // In single-threaded mode, we exit force compositing mode and re-enter in 1266 // In single-threaded mode, we exit force compositing mode and re-enter in
1224 // DoDeferredUpdate() if appropriate. In threaded compositing mode, 1267 // DoDeferredUpdate() if appropriate. In threaded compositing mode,
1225 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and 1268 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and
1226 // entering force compositing mode at the appropriate times. 1269 // entering force compositing mode at the appropriate times.
1227 if (!is_threaded_compositing_enabled_) 1270 if (!is_threaded_compositing_enabled_)
1228 webwidget_->enterForceCompositingMode(false); 1271 webwidget_->enterForceCompositingMode(false);
1229 } 1272 }
1230 1273
1231 void RenderWidget::willBeginCompositorFrame() { 1274 void RenderWidget::willBeginCompositorFrame() {
1232 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); 1275 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
1276 StartingFrame();
1233 1277
1234 DCHECK(RenderThreadImpl::current()->compositor_thread()); 1278 DCHECK(RenderThreadImpl::current()->compositor_thread());
1235 1279
1236 // The following two can result in further layout and possibly 1280 // The following two can result in further layout and possibly
1237 // enable GPU acceleration so they need to be called before any painting 1281 // enable GPU acceleration so they need to be called before any painting
1238 // is done. 1282 // is done.
1239 UpdateTextInputState(DO_NOT_SHOW_IME); 1283 UpdateTextInputState(DO_NOT_SHOW_IME);
1240 UpdateSelectionBounds(); 1284 UpdateSelectionBounds();
1285 WillInitiatePaint();
1286 }
1241 1287
1242 WillInitiatePaint(); 1288 void RenderWidget::didBeginCompositorFrame() {
1289 if (started_frame_) {
1290 TRACE_EVENT_ASYNC_END2("frame", "Frame", this,
1291 "frameNumber", latency_info_.rendererMainFrameNumber,
1292 "inputNumber", latency_info_.inputNumber);
1293 started_frame_ = false;
1294 }
1243 } 1295 }
1244 1296
1245 void RenderWidget::didBecomeReadyForAdditionalInput() { 1297 void RenderWidget::didBecomeReadyForAdditionalInput() {
1246 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); 1298 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput");
1247 if (pending_input_event_ack_.get()) 1299 if (pending_input_event_ack_.get())
1248 Send(pending_input_event_ack_.release()); 1300 Send(pending_input_event_ack_.release());
1249 } 1301 }
1250 1302
1251 void RenderWidget::didCommitAndDrawCompositorFrame() { 1303 void RenderWidget::didCommitAndDrawCompositorFrame() {
1252 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame"); 1304 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame");
(...skipping 27 matching lines...) Expand all
1280 params.needs_ack = false; 1332 params.needs_ack = false;
1281 params.scale_factor = device_scale_factor_; 1333 params.scale_factor = device_scale_factor_;
1282 1334
1283 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); 1335 Send(new ViewHostMsg_UpdateRect(routing_id_, params));
1284 next_paint_flags_ = 0; 1336 next_paint_flags_ = 0;
1285 need_update_rect_for_auto_resize_ = false; 1337 need_update_rect_for_auto_resize_ = false;
1286 } 1338 }
1287 1339
1288 void RenderWidget::scheduleComposite() { 1340 void RenderWidget::scheduleComposite() {
1289 TRACE_EVENT0("gpu", "RenderWidget::scheduleComposite"); 1341 TRACE_EVENT0("gpu", "RenderWidget::scheduleComposite");
1342 StartingFrame();
1290 if (WebWidgetHandlesCompositorScheduling()) { 1343 if (WebWidgetHandlesCompositorScheduling()) {
1291 webwidget_->composite(false); 1344 webwidget_->composite(false);
1292 } else { 1345 } else {
1293 // TODO(nduca): replace with something a little less hacky. The reason this 1346 // TODO(nduca): replace with something a little less hacky. The reason this
1294 // hack is still used is because the Invalidate-DoDeferredUpdate loop 1347 // hack is still used is because the Invalidate-DoDeferredUpdate loop
1295 // contains a lot of host-renderer synchronization logic that is still 1348 // contains a lot of host-renderer synchronization logic that is still
1296 // important for the accelerated compositing case. The option of simply 1349 // important for the accelerated compositing case. The option of simply
1297 // duplicating all that code is less desirable than "faking out" the 1350 // duplicating all that code is less desirable than "faking out" the
1298 // invalidation path using a magical damage rect. 1351 // invalidation path using a magical damage rect.
1299 didInvalidateRect(WebRect(0, 0, 1, 1)); 1352 didInvalidateRect(WebRect(0, 0, 1, 1));
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 2034
1982 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { 2035 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1983 return false; 2036 return false;
1984 } 2037 }
1985 2038
1986 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { 2039 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
1987 return true; 2040 return true;
1988 } 2041 }
1989 2042
1990 } // namespace content 2043 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | ui/aura/bench/bench_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698