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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
| 921 need_update_rect_for_auto_resize_ = false; |
920 | 922 |
921 if (update.scroll_rect.IsEmpty() && | 923 if (update.scroll_rect.IsEmpty() && |
922 !is_accelerated_compositing_active_ && | 924 !is_accelerated_compositing_active_ && |
923 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, | 925 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, |
924 &optimized_copy_rect)) { | 926 &optimized_copy_rect)) { |
925 // Only update the part of the plugin that actually changed. | 927 // Only update the part of the plugin that actually changed. |
926 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); | 928 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); |
927 pending_update_params_->bitmap = dib->id(); | 929 pending_update_params_->bitmap = dib->id(); |
928 pending_update_params_->bitmap_rect = optimized_copy_location; | 930 pending_update_params_->bitmap_rect = optimized_copy_location; |
929 pending_update_params_->copy_rects.push_back(optimized_copy_rect); | 931 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 | 1072 // 1) Ensures that we call WebView::Paint without a bunch of other junk |
1071 // on the call stack. | 1073 // on the call stack. |
1072 // 2) Allows us to collect more damage rects before painting to help coalesce | 1074 // 2) Allows us to collect more damage rects before painting to help coalesce |
1073 // the work that we will need to do. | 1075 // the work that we will need to do. |
1074 invalidation_task_posted_ = true; | 1076 invalidation_task_posted_ = true; |
1075 MessageLoop::current()->PostTask( | 1077 MessageLoop::current()->PostTask( |
1076 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); | 1078 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); |
1077 } | 1079 } |
1078 | 1080 |
1079 void RenderWidget::didAutoResize(const WebSize& new_size) { | 1081 void RenderWidget::didAutoResize(const WebSize& new_size) { |
1080 size_ = new_size; | 1082 if (size_.width() != new_size.width || size_.height() != new_size.height) { |
| 1083 size_ = new_size; |
| 1084 need_update_rect_for_auto_resize_ = true; |
| 1085 } |
1081 } | 1086 } |
1082 | 1087 |
1083 void RenderWidget::didActivateCompositor(int input_handler_identifier) { | 1088 void RenderWidget::didActivateCompositor(int input_handler_identifier) { |
1084 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); | 1089 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); |
1085 | 1090 |
1086 #if !defined(OS_MACOSX) | 1091 #if !defined(OS_MACOSX) |
1087 if (!is_accelerated_compositing_active_) { | 1092 if (!is_accelerated_compositing_active_) { |
1088 // When not in accelerated compositing mode, in certain cases (e.g. waiting | 1093 // 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 | 1094 // 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 | 1095 // 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. | 1147 // Notify subclasses that we initiated the paint operation. |
1143 DidInitiatePaint(); | 1148 DidInitiatePaint(); |
1144 } | 1149 } |
1145 | 1150 |
1146 void RenderWidget::didCompleteSwapBuffers() { | 1151 void RenderWidget::didCompleteSwapBuffers() { |
1147 DidFlushPaint(); | 1152 DidFlushPaint(); |
1148 | 1153 |
1149 if (update_reply_pending_) | 1154 if (update_reply_pending_) |
1150 return; | 1155 return; |
1151 | 1156 |
1152 if (!next_paint_flags_ && !plugin_window_moves_.size()) | 1157 if (!next_paint_flags_ && |
| 1158 !need_update_rect_for_auto_resize_ && |
| 1159 !plugin_window_moves_.size()) { |
1153 return; | 1160 return; |
| 1161 } |
1154 | 1162 |
1155 ViewHostMsg_UpdateRect_Params params; | 1163 ViewHostMsg_UpdateRect_Params params; |
1156 params.view_size = size_; | 1164 params.view_size = size_; |
1157 params.plugin_window_moves.swap(plugin_window_moves_); | 1165 params.plugin_window_moves.swap(plugin_window_moves_); |
1158 params.flags = next_paint_flags_; | 1166 params.flags = next_paint_flags_; |
1159 params.scroll_offset = GetScrollOffset(); | 1167 params.scroll_offset = GetScrollOffset(); |
1160 params.needs_ack = false; | 1168 params.needs_ack = false; |
1161 | 1169 |
1162 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | 1170 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
1163 next_paint_flags_ = 0; | 1171 next_paint_flags_ = 0; |
| 1172 need_update_rect_for_auto_resize_ = false; |
1164 } | 1173 } |
1165 | 1174 |
1166 void RenderWidget::scheduleComposite() { | 1175 void RenderWidget::scheduleComposite() { |
1167 if (WebWidgetHandlesCompositorScheduling()) { | 1176 if (WebWidgetHandlesCompositorScheduling()) { |
1168 webwidget_->composite(false); | 1177 webwidget_->composite(false); |
1169 } else { | 1178 } else { |
1170 // TODO(nduca): replace with something a little less hacky. The reason this | 1179 // TODO(nduca): replace with something a little less hacky. The reason this |
1171 // hack is still used is because the Invalidate-DoDeferredUpdate loop | 1180 // hack is still used is because the Invalidate-DoDeferredUpdate loop |
1172 // contains a lot of host-renderer synchronization logic that is still | 1181 // contains a lot of host-renderer synchronization logic that is still |
1173 // important for the accelerated compositing case. The option of simply | 1182 // important for the accelerated compositing case. The option of simply |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 } | 1715 } |
1707 } | 1716 } |
1708 | 1717 |
1709 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1718 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
1710 return false; | 1719 return false; |
1711 } | 1720 } |
1712 | 1721 |
1713 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1722 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1714 return false; | 1723 return false; |
1715 } | 1724 } |
OLD | NEW |