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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 : routing_id_(MSG_ROUTING_NONE), | 77 : routing_id_(MSG_ROUTING_NONE), |
78 surface_id_(0), | 78 surface_id_(0), |
79 webwidget_(NULL), | 79 webwidget_(NULL), |
80 opener_id_(MSG_ROUTING_NONE), | 80 opener_id_(MSG_ROUTING_NONE), |
81 host_window_(0), | 81 host_window_(0), |
82 host_window_set_(false), | 82 host_window_set_(false), |
83 current_paint_buf_(NULL), | 83 current_paint_buf_(NULL), |
84 next_paint_flags_(0), | 84 next_paint_flags_(0), |
85 filtered_time_per_frame_(0.0f), | 85 filtered_time_per_frame_(0.0f), |
86 update_reply_pending_(false), | 86 update_reply_pending_(false), |
87 need_update_rect_for_auto_resize_(false), | |
87 using_asynchronous_swapbuffers_(false), | 88 using_asynchronous_swapbuffers_(false), |
88 num_swapbuffers_complete_pending_(0), | 89 num_swapbuffers_complete_pending_(0), |
89 did_show_(false), | 90 did_show_(false), |
90 is_hidden_(false), | 91 is_hidden_(false), |
91 is_fullscreen_(false), | 92 is_fullscreen_(false), |
92 needs_repainting_on_restore_(false), | 93 needs_repainting_on_restore_(false), |
93 has_focus_(false), | 94 has_focus_(false), |
94 handling_input_event_(false), | 95 handling_input_event_(false), |
95 closing_(false), | 96 closing_(false), |
96 is_swapped_out_(swapped_out), | 97 is_swapped_out_(swapped_out), |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
909 DCHECK(!pending_update_params_.get()); | 910 DCHECK(!pending_update_params_.get()); |
910 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params); | 911 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params); |
911 pending_update_params_->dx = update.scroll_delta.x(); | 912 pending_update_params_->dx = update.scroll_delta.x(); |
912 pending_update_params_->dy = update.scroll_delta.y(); | 913 pending_update_params_->dy = update.scroll_delta.y(); |
913 pending_update_params_->scroll_rect = update.scroll_rect; | 914 pending_update_params_->scroll_rect = update.scroll_rect; |
914 pending_update_params_->view_size = size_; | 915 pending_update_params_->view_size = size_; |
915 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_); | 916 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_); |
916 pending_update_params_->flags = next_paint_flags_; | 917 pending_update_params_->flags = next_paint_flags_; |
917 pending_update_params_->scroll_offset = GetScrollOffset(); | 918 pending_update_params_->scroll_offset = GetScrollOffset(); |
918 pending_update_params_->needs_ack = true; | 919 pending_update_params_->needs_ack = true; |
919 next_paint_flags_ = 0; | 920 next_paint_flags_ = 0; |
piman
2012/05/15 00:07:43
I would reset need_update_rect_for_auto_resize_ he
Daniel Erat
2012/05/15 00:29:27
Whoops, nice catch (levin@ pointed this out too).
| |
920 | 921 |
921 if (update.scroll_rect.IsEmpty() && | 922 if (update.scroll_rect.IsEmpty() && |
922 !is_accelerated_compositing_active_ && | 923 !is_accelerated_compositing_active_ && |
923 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, | 924 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, |
924 &optimized_copy_rect)) { | 925 &optimized_copy_rect)) { |
925 // Only update the part of the plugin that actually changed. | 926 // Only update the part of the plugin that actually changed. |
926 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); | 927 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); |
927 pending_update_params_->bitmap = dib->id(); | 928 pending_update_params_->bitmap = dib->id(); |
928 pending_update_params_->bitmap_rect = optimized_copy_location; | 929 pending_update_params_->bitmap_rect = optimized_copy_location; |
929 pending_update_params_->copy_rects.push_back(optimized_copy_rect); | 930 pending_update_params_->copy_rects.push_back(optimized_copy_rect); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1070 // 1) Ensures that we call WebView::Paint without a bunch of other junk | 1071 // 1) Ensures that we call WebView::Paint without a bunch of other junk |
1071 // on the call stack. | 1072 // on the call stack. |
1072 // 2) Allows us to collect more damage rects before painting to help coalesce | 1073 // 2) Allows us to collect more damage rects before painting to help coalesce |
1073 // the work that we will need to do. | 1074 // the work that we will need to do. |
1074 invalidation_task_posted_ = true; | 1075 invalidation_task_posted_ = true; |
1075 MessageLoop::current()->PostTask( | 1076 MessageLoop::current()->PostTask( |
1076 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); | 1077 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); |
1077 } | 1078 } |
1078 | 1079 |
1079 void RenderWidget::didAutoResize(const WebSize& new_size) { | 1080 void RenderWidget::didAutoResize(const WebSize& new_size) { |
1080 size_ = new_size; | 1081 if (size_.width() != new_size.width || size_.height() != new_size.height) { |
1082 size_ = new_size; | |
1083 need_update_rect_for_auto_resize_ = true; | |
1084 } | |
1081 } | 1085 } |
1082 | 1086 |
1083 void RenderWidget::didActivateCompositor(int input_handler_identifier) { | 1087 void RenderWidget::didActivateCompositor(int input_handler_identifier) { |
1084 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); | 1088 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); |
1085 | 1089 |
1086 #if !defined(OS_MACOSX) | 1090 #if !defined(OS_MACOSX) |
1087 if (!is_accelerated_compositing_active_) { | 1091 if (!is_accelerated_compositing_active_) { |
1088 // When not in accelerated compositing mode, in certain cases (e.g. waiting | 1092 // When not in accelerated compositing mode, in certain cases (e.g. waiting |
1089 // for a resize or if no backing store) the RenderWidgetHost is blocking the | 1093 // for a resize or if no backing store) the RenderWidgetHost is blocking the |
1090 // browser's UI thread for some time, waiting for an UpdateRect. If we are | 1094 // browser's UI thread for some time, waiting for an UpdateRect. If we are |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1142 // Notify subclasses that we initiated the paint operation. | 1146 // Notify subclasses that we initiated the paint operation. |
1143 DidInitiatePaint(); | 1147 DidInitiatePaint(); |
1144 } | 1148 } |
1145 | 1149 |
1146 void RenderWidget::didCompleteSwapBuffers() { | 1150 void RenderWidget::didCompleteSwapBuffers() { |
1147 DidFlushPaint(); | 1151 DidFlushPaint(); |
1148 | 1152 |
1149 if (update_reply_pending_) | 1153 if (update_reply_pending_) |
1150 return; | 1154 return; |
1151 | 1155 |
1152 if (!next_paint_flags_ && !plugin_window_moves_.size()) | 1156 if (!next_paint_flags_ && |
1157 !need_update_rect_for_auto_resize_ && | |
1158 !plugin_window_moves_.size()) { | |
1153 return; | 1159 return; |
1160 } | |
1154 | 1161 |
1155 ViewHostMsg_UpdateRect_Params params; | 1162 ViewHostMsg_UpdateRect_Params params; |
1156 params.view_size = size_; | 1163 params.view_size = size_; |
1157 params.plugin_window_moves.swap(plugin_window_moves_); | 1164 params.plugin_window_moves.swap(plugin_window_moves_); |
1158 params.flags = next_paint_flags_; | 1165 params.flags = next_paint_flags_; |
1159 params.scroll_offset = GetScrollOffset(); | 1166 params.scroll_offset = GetScrollOffset(); |
1160 params.needs_ack = false; | 1167 params.needs_ack = false; |
1161 | 1168 |
1162 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | 1169 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
1163 next_paint_flags_ = 0; | 1170 next_paint_flags_ = 0; |
1171 need_update_rect_for_auto_resize_ = false; | |
1164 } | 1172 } |
1165 | 1173 |
1166 void RenderWidget::scheduleComposite() { | 1174 void RenderWidget::scheduleComposite() { |
1167 if (WebWidgetHandlesCompositorScheduling()) { | 1175 if (WebWidgetHandlesCompositorScheduling()) { |
1168 webwidget_->composite(false); | 1176 webwidget_->composite(false); |
1169 } else { | 1177 } else { |
1170 // TODO(nduca): replace with something a little less hacky. The reason this | 1178 // TODO(nduca): replace with something a little less hacky. The reason this |
1171 // hack is still used is because the Invalidate-DoDeferredUpdate loop | 1179 // hack is still used is because the Invalidate-DoDeferredUpdate loop |
1172 // contains a lot of host-renderer synchronization logic that is still | 1180 // contains a lot of host-renderer synchronization logic that is still |
1173 // important for the accelerated compositing case. The option of simply | 1181 // important for the accelerated compositing case. The option of simply |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1706 } | 1714 } |
1707 } | 1715 } |
1708 | 1716 |
1709 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1717 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
1710 return false; | 1718 return false; |
1711 } | 1719 } |
1712 | 1720 |
1713 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1721 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1714 return false; | 1722 return false; |
1715 } | 1723 } |
OLD | NEW |