Chromium Code Reviews| 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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 DoDeferredUpdateAndSendInputAck(); | 818 DoDeferredUpdateAndSendInputAck(); | 
| 819 } | 819 } | 
| 820 | 820 | 
| 821 void RenderWidget::DoDeferredUpdateAndSendInputAck() { | 821 void RenderWidget::DoDeferredUpdateAndSendInputAck() { | 
| 822 DoDeferredUpdate(); | 822 DoDeferredUpdate(); | 
| 823 | 823 | 
| 824 if (pending_input_event_ack_.get()) | 824 if (pending_input_event_ack_.get()) | 
| 825 Send(pending_input_event_ack_.release()); | 825 Send(pending_input_event_ack_.release()); | 
| 826 } | 826 } | 
| 827 | 827 | 
| 828 bool RenderWidget::CanDoDeferredUpdate() const { | |
| 829 if (!webwidget_) { | |
| 830 TRACE_EVENT0("renderer", "EarlyOut_NoWebWidget"); | |
| 831 return false; | |
| 832 } | |
| 833 if (!host_window_set_) { | |
| 834 TRACE_EVENT0("renderer", "EarlyOut_NoHostWindow"); | |
| 835 return false; | |
| 836 } | |
| 837 if (update_reply_pending_) { | |
| 838 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending"); | |
| 839 return false; | |
| 840 } | |
| 841 if (is_accelerated_compositing_active_ && | |
| 842 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) { | |
| 843 TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending"); | |
| 844 return false; | |
| 845 } | |
| 846 return true; | |
| 847 } | |
| 848 | |
| 849 bool RenderWidget::ShouldSuppressDeferredUpdates() const { | |
| 850 return is_hidden_ || size_.IsEmpty(); | |
| 851 } | |
| 852 | |
| 828 void RenderWidget::DoDeferredUpdate() { | 853 void RenderWidget::DoDeferredUpdate() { | 
| 829 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate"); | 854 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate"); | 
| 830 | 855 | 
| 831 if (!webwidget_) | 856 if (!CanDoDeferredUpdate()) | 
| 832 return; | 857 return; | 
| 833 | 858 | 
| 834 if (!host_window_set_) { | |
| 835 TRACE_EVENT0("renderer", "EarlyOut_NoHostWindow"); | |
| 836 return; | |
| 837 } | |
| 838 if (update_reply_pending_) { | |
| 839 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending"); | |
| 840 return; | |
| 841 } | |
| 842 if (is_accelerated_compositing_active_ && | |
| 843 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) { | |
| 844 TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending"); | |
| 845 return; | |
| 846 } | |
| 847 | |
| 848 // Suppress updating when we are hidden. | 859 // Suppress updating when we are hidden. | 
| 849 if (is_hidden_ || size_.IsEmpty()) { | 860 if (ShouldSuppressDeferredUpdates()) { | 
| 850 paint_aggregator_.ClearPendingUpdate(); | 861 paint_aggregator_.ClearPendingUpdate(); | 
| 851 needs_repainting_on_restore_ = true; | 862 needs_repainting_on_restore_ = true; | 
| 852 TRACE_EVENT0("renderer", "EarlyOut_NotVisible"); | 863 TRACE_EVENT0("renderer", "EarlyOut_NotVisible"); | 
| 853 return; | 864 return; | 
| 854 } | 865 } | 
| 855 | 866 | 
| 856 if (is_accelerated_compositing_active_) | 867 if (is_accelerated_compositing_active_) | 
| 857 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); | 868 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); | 
| 858 | 869 | 
| 859 // Tracking of frame rate jitter | 870 // Tracking of frame rate jitter | 
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 params.view_size = size_; | 1188 params.view_size = size_; | 
| 1178 params.plugin_window_moves.swap(plugin_window_moves_); | 1189 params.plugin_window_moves.swap(plugin_window_moves_); | 
| 1179 params.flags = next_paint_flags_; | 1190 params.flags = next_paint_flags_; | 
| 1180 params.scroll_offset = GetScrollOffset(); | 1191 params.scroll_offset = GetScrollOffset(); | 
| 1181 params.needs_ack = false; | 1192 params.needs_ack = false; | 
| 1182 | 1193 | 
| 1183 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | 1194 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | 
| 1184 next_paint_flags_ = 0; | 1195 next_paint_flags_ = 0; | 
| 1185 } | 1196 } | 
| 1186 | 1197 | 
| 1187 void RenderWidget::scheduleComposite() { | 1198 #if defined(WEBWIDGETCLIENT_SCHEDULECOMPOSITE_RETURNS_BOOL) | 
| 1199 #define SC_RETURN_TYPE bool | |
| 1200 #else | |
| 1201 #define SC_RETURN_TYPE void | |
| 1202 #endif | |
| 1203 | |
| 1204 SC_RETURN_TYPE RenderWidget::scheduleComposite() { | |
| 1188 if (WebWidgetHandlesCompositorScheduling()) { | 1205 if (WebWidgetHandlesCompositorScheduling()) { | 
| 1189 webwidget_->composite(false); | 1206 webwidget_->composite(false); | 
| 1207 #if defined(WEBWIDGETCLIENT_SCHEDULECOMPOSITE_RETURNS_BOOL) | |
| 1208 return true; | |
| 1209 #endif | |
| 1190 } else { | 1210 } else { | 
| 1191 // TODO(nduca): replace with something a little less hacky. The reason this | 1211 // TODO(nduca): replace with something a little less hacky. The reason this | 
| 1192 // hack is still used is because the Invalidate-DoDeferredUpdate loop | 1212 // hack is still used is because the Invalidate-DoDeferredUpdate loop | 
| 1193 // contains a lot of host-renderer synchronization logic that is still | 1213 // contains a lot of host-renderer synchronization logic that is still | 
| 1194 // important for the accelerated compositing case. The option of simply | 1214 // important for the accelerated compositing case. The option of simply | 
| 1195 // duplicating all that code is less desirable than "faking out" the | 1215 // duplicating all that code is less desirable than "faking out" the | 
| 1196 // invalidation path using a magical damage rect. | 1216 // invalidation path using a magical damage rect. | 
| 1197 didInvalidateRect(WebRect(0, 0, 1, 1)); | 1217 didInvalidateRect(WebRect(0, 0, 1, 1)); | 
| 1218 #if defined(WEBWIDGETCLIENT_SCHEDULECOMPOSITE_RETURNS_BOOL) | |
| 1219 return CanDoDeferredUpdate() && !ShouldSuppressDeferredUpdates(); | |
| 
 
jamesr
2012/05/08 23:42:40
what happens if ShouldSuppress...() is false, but
 
 | |
| 1220 #endif | |
| 1198 } | 1221 } | 
| 1199 } | 1222 } | 
| 1200 | 1223 | 
| 1201 void RenderWidget::scheduleAnimation() { | 1224 void RenderWidget::scheduleAnimation() { | 
| 1202 if (animation_update_pending_) | 1225 if (animation_update_pending_) | 
| 1203 return; | 1226 return; | 
| 1204 | 1227 | 
| 1205 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); | 1228 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); | 
| 1206 animation_update_pending_ = true; | 1229 animation_update_pending_ = true; | 
| 1207 if (!animation_timer_.IsRunning()) { | 1230 if (!animation_timer_.IsRunning()) { | 
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1719 } | 1742 } | 
| 1720 } | 1743 } | 
| 1721 | 1744 | 
| 1722 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1745 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 
| 1723 return false; | 1746 return false; | 
| 1724 } | 1747 } | 
| 1725 | 1748 | 
| 1726 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1749 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 
| 1727 return false; | 1750 return false; | 
| 1728 } | 1751 } | 
| OLD | NEW |