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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 } | 168 } |
| 169 | 169 |
| 170 // This is used to complete pending inits and non-pending inits. For non- | 170 // This is used to complete pending inits and non-pending inits. For non- |
| 171 // pending cases, the parent will be the same as the current parent. This | 171 // pending cases, the parent will be the same as the current parent. This |
| 172 // indicates we do not need to reparent or anything. | 172 // indicates we do not need to reparent or anything. |
| 173 void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) { | 173 void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) { |
| 174 DCHECK(routing_id_ != MSG_ROUTING_NONE); | 174 DCHECK(routing_id_ != MSG_ROUTING_NONE); |
| 175 | 175 |
| 176 host_window_ = parent_hwnd; | 176 host_window_ = parent_hwnd; |
| 177 | 177 |
| 178 DoDeferredUpdate(); | |
| 179 | |
| 178 Send(new ViewHostMsg_RenderViewReady(routing_id_)); | 180 Send(new ViewHostMsg_RenderViewReady(routing_id_)); |
| 179 } | 181 } |
| 180 | 182 |
| 181 void RenderWidget::SetSwappedOut(bool is_swapped_out) { | 183 void RenderWidget::SetSwappedOut(bool is_swapped_out) { |
| 182 // We should only toggle between states. | 184 // We should only toggle between states. |
| 183 DCHECK(is_swapped_out_ != is_swapped_out); | 185 DCHECK(is_swapped_out_ != is_swapped_out); |
| 184 is_swapped_out_ = is_swapped_out; | 186 is_swapped_out_ = is_swapped_out; |
| 185 | 187 |
| 186 // If we are swapping out, we will call ReleaseProcess, allowing the process | 188 // If we are swapping out, we will call ReleaseProcess, allowing the process |
| 187 // to exit if all of its RenderViews are swapped out. We wait until the | 189 // to exit if all of its RenderViews are swapped out. We wait until the |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 | 732 |
| 731 if (pending_input_event_ack_.get()) | 733 if (pending_input_event_ack_.get()) |
| 732 Send(pending_input_event_ack_.release()); | 734 Send(pending_input_event_ack_.release()); |
| 733 } | 735 } |
| 734 | 736 |
| 735 void RenderWidget::DoDeferredUpdate() { | 737 void RenderWidget::DoDeferredUpdate() { |
| 736 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate"); | 738 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate"); |
| 737 | 739 |
| 738 if (!webwidget_) | 740 if (!webwidget_) |
| 739 return; | 741 return; |
| 742 | |
| 743 if (!host_window_) { | |
| 744 TRACE_EVENT0("renderer", "EarlyOut_NoHostWindow"); | |
| 745 return; | |
| 746 } | |
| 740 if (update_reply_pending_) { | 747 if (update_reply_pending_) { |
| 741 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending"); | 748 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending"); |
| 742 return; | 749 return; |
| 743 } | 750 } |
| 744 if (is_accelerated_compositing_active_ && | 751 if (is_accelerated_compositing_active_ && |
| 745 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) { | 752 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) { |
| 746 TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending"); | 753 TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending"); |
| 747 return; | 754 return; |
| 748 } | 755 } |
| 749 | 756 |
| 750 // Suppress updating when we are hidden. | 757 // Suppress updating when we are hidden. |
| 751 if (is_hidden_ || size_.IsEmpty()) { | 758 if (is_hidden_ || size_.IsEmpty()) { |
| 752 paint_aggregator_.ClearPendingUpdate(); | 759 paint_aggregator_.ClearPendingUpdate(); |
| 753 needs_repainting_on_restore_ = true; | 760 needs_repainting_on_restore_ = true; |
| 754 TRACE_EVENT0("renderer", "EarlyOut_NotVisible"); | 761 TRACE_EVENT0("renderer", "EarlyOut_NotVisible"); |
| 755 return; | 762 return; |
| 756 } | 763 } |
| 757 | 764 |
| 765 if (is_accelerated_compositing_active_) | |
|
piman
2012/01/30 18:10:23
is_accelerated_compositing_active_ can change valu
| |
| 766 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); | |
| 767 | |
| 758 // Tracking of frame rate jitter | 768 // Tracking of frame rate jitter |
| 759 base::TimeTicks frame_begin_ticks = base::TimeTicks::Now(); | 769 base::TimeTicks frame_begin_ticks = base::TimeTicks::Now(); |
| 760 AnimateIfNeeded(); | 770 AnimateIfNeeded(); |
| 761 | 771 |
| 762 // Layout may generate more invalidation. It may also enable the | 772 // Layout may generate more invalidation. It may also enable the |
| 763 // GPU acceleration, so make sure to run layout before we send the | 773 // GPU acceleration, so make sure to run layout before we send the |
| 764 // GpuRenderingActivated message. | 774 // GpuRenderingActivated message. |
| 765 webwidget_->layout(); | 775 webwidget_->layout(); |
| 766 | 776 |
| 767 // Suppress painting if nothing is dirty. This has to be done after updating | 777 // Suppress painting if nothing is dirty. This has to be done after updating |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1003 // round-trips to the browser's UI thread before finishing the frame, | 1013 // round-trips to the browser's UI thread before finishing the frame, |
| 1004 // causing deadlocks if we delay the UpdateRect until we receive the | 1014 // causing deadlocks if we delay the UpdateRect until we receive the |
| 1005 // OnSwapBuffersComplete. So send a dummy message that will unblock the | 1015 // OnSwapBuffersComplete. So send a dummy message that will unblock the |
| 1006 // browser's UI thread. | 1016 // browser's UI thread. |
| 1007 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_)); | 1017 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_)); |
| 1008 } | 1018 } |
| 1009 | 1019 |
| 1010 is_accelerated_compositing_active_ = true; | 1020 is_accelerated_compositing_active_ = true; |
| 1011 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( | 1021 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
| 1012 routing_id_, is_accelerated_compositing_active_)); | 1022 routing_id_, is_accelerated_compositing_active_)); |
| 1013 | |
| 1014 // Note: asynchronous swapbuffer support currently only matters if | |
| 1015 // compositing scheduling happens on the RenderWidget. | |
| 1016 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); | |
| 1017 } | 1023 } |
| 1018 | 1024 |
| 1019 void RenderWidget::didDeactivateCompositor() { | 1025 void RenderWidget::didDeactivateCompositor() { |
| 1020 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); | 1026 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); |
| 1021 | 1027 |
| 1022 is_accelerated_compositing_active_ = false; | 1028 is_accelerated_compositing_active_ = false; |
| 1023 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( | 1029 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
| 1024 routing_id_, is_accelerated_compositing_active_)); | 1030 routing_id_, is_accelerated_compositing_active_)); |
| 1025 | 1031 |
| 1026 if (using_asynchronous_swapbuffers_) | 1032 if (using_asynchronous_swapbuffers_) |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1559 } | 1565 } |
| 1560 } | 1566 } |
| 1561 | 1567 |
| 1562 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1568 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1563 return false; | 1569 return false; |
| 1564 } | 1570 } |
| 1565 | 1571 |
| 1566 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1572 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
| 1567 return false; | 1573 return false; |
| 1568 } | 1574 } |
| OLD | NEW |