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

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

Issue 9225050: Defer render_widget draw until host window is available (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: aura sets host_window_ to NULL, so check for set-ness instead of null-ness Created 8 years, 10 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') | no next file » | 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 using WebKit::WebVector; 67 using WebKit::WebVector;
68 using WebKit::WebWidget; 68 using WebKit::WebWidget;
69 using content::RenderThread; 69 using content::RenderThread;
70 70
71 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type) 71 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type)
72 : routing_id_(MSG_ROUTING_NONE), 72 : routing_id_(MSG_ROUTING_NONE),
73 surface_id_(0), 73 surface_id_(0),
74 webwidget_(NULL), 74 webwidget_(NULL),
75 opener_id_(MSG_ROUTING_NONE), 75 opener_id_(MSG_ROUTING_NONE),
76 host_window_(0), 76 host_window_(0),
77 host_window_set_(false),
77 current_paint_buf_(NULL), 78 current_paint_buf_(NULL),
78 next_paint_flags_(0), 79 next_paint_flags_(0),
79 filtered_time_per_frame_(0.0f), 80 filtered_time_per_frame_(0.0f),
80 update_reply_pending_(false), 81 update_reply_pending_(false),
81 using_asynchronous_swapbuffers_(false), 82 using_asynchronous_swapbuffers_(false),
82 num_swapbuffers_complete_pending_(0), 83 num_swapbuffers_complete_pending_(0),
83 did_show_(false), 84 did_show_(false),
84 is_hidden_(false), 85 is_hidden_(false),
85 is_fullscreen_(false), 86 is_fullscreen_(false),
86 needs_repainting_on_restore_(false), 87 needs_repainting_on_restore_(false),
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 168 }
168 } 169 }
169 170
170 // This is used to complete pending inits and non-pending inits. For non- 171 // 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 172 // pending cases, the parent will be the same as the current parent. This
172 // indicates we do not need to reparent or anything. 173 // indicates we do not need to reparent or anything.
173 void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) { 174 void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) {
174 DCHECK(routing_id_ != MSG_ROUTING_NONE); 175 DCHECK(routing_id_ != MSG_ROUTING_NONE);
175 176
176 host_window_ = parent_hwnd; 177 host_window_ = parent_hwnd;
178 host_window_set_ = true;
179
180 DoDeferredUpdate();
177 181
178 Send(new ViewHostMsg_RenderViewReady(routing_id_)); 182 Send(new ViewHostMsg_RenderViewReady(routing_id_));
179 } 183 }
180 184
181 void RenderWidget::SetSwappedOut(bool is_swapped_out) { 185 void RenderWidget::SetSwappedOut(bool is_swapped_out) {
182 // We should only toggle between states. 186 // We should only toggle between states.
183 DCHECK(is_swapped_out_ != is_swapped_out); 187 DCHECK(is_swapped_out_ != is_swapped_out);
184 is_swapped_out_ = is_swapped_out; 188 is_swapped_out_ = is_swapped_out;
185 189
186 // If we are swapping out, we will call ReleaseProcess, allowing the process 190 // If we are swapping out, we will call ReleaseProcess, allowing the process
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 737
734 if (pending_input_event_ack_.get()) 738 if (pending_input_event_ack_.get())
735 Send(pending_input_event_ack_.release()); 739 Send(pending_input_event_ack_.release());
736 } 740 }
737 741
738 void RenderWidget::DoDeferredUpdate() { 742 void RenderWidget::DoDeferredUpdate() {
739 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate"); 743 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate");
740 744
741 if (!webwidget_) 745 if (!webwidget_)
742 return; 746 return;
747
748 if (!host_window_set_) {
749 TRACE_EVENT0("renderer", "EarlyOut_NoHostWindow");
750 return;
751 }
743 if (update_reply_pending_) { 752 if (update_reply_pending_) {
744 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending"); 753 TRACE_EVENT0("renderer", "EarlyOut_UpdateReplyPending");
745 return; 754 return;
746 } 755 }
747 if (is_accelerated_compositing_active_ && 756 if (is_accelerated_compositing_active_ &&
748 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) { 757 num_swapbuffers_complete_pending_ >= kMaxSwapBuffersPending) {
749 TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending"); 758 TRACE_EVENT0("renderer", "EarlyOut_MaxSwapBuffersPending");
750 return; 759 return;
751 } 760 }
752 761
753 // Suppress updating when we are hidden. 762 // Suppress updating when we are hidden.
754 if (is_hidden_ || size_.IsEmpty()) { 763 if (is_hidden_ || size_.IsEmpty()) {
755 paint_aggregator_.ClearPendingUpdate(); 764 paint_aggregator_.ClearPendingUpdate();
756 needs_repainting_on_restore_ = true; 765 needs_repainting_on_restore_ = true;
757 TRACE_EVENT0("renderer", "EarlyOut_NotVisible"); 766 TRACE_EVENT0("renderer", "EarlyOut_NotVisible");
758 return; 767 return;
759 } 768 }
760 769
770 if (is_accelerated_compositing_active_)
771 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers();
772
761 // Tracking of frame rate jitter 773 // Tracking of frame rate jitter
762 base::TimeTicks frame_begin_ticks = base::TimeTicks::Now(); 774 base::TimeTicks frame_begin_ticks = base::TimeTicks::Now();
763 AnimateIfNeeded(); 775 AnimateIfNeeded();
764 776
765 // Layout may generate more invalidation. It may also enable the 777 // Layout may generate more invalidation. It may also enable the
766 // GPU acceleration, so make sure to run layout before we send the 778 // GPU acceleration, so make sure to run layout before we send the
767 // GpuRenderingActivated message. 779 // GpuRenderingActivated message.
768 webwidget_->layout(); 780 webwidget_->layout();
769 781
770 // Suppress painting if nothing is dirty. This has to be done after updating 782 // Suppress painting if nothing is dirty. This has to be done after updating
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 // round-trips to the browser's UI thread before finishing the frame, 1022 // round-trips to the browser's UI thread before finishing the frame,
1011 // causing deadlocks if we delay the UpdateRect until we receive the 1023 // causing deadlocks if we delay the UpdateRect until we receive the
1012 // OnSwapBuffersComplete. So send a dummy message that will unblock the 1024 // OnSwapBuffersComplete. So send a dummy message that will unblock the
1013 // browser's UI thread. 1025 // browser's UI thread.
1014 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_)); 1026 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_));
1015 } 1027 }
1016 1028
1017 is_accelerated_compositing_active_ = true; 1029 is_accelerated_compositing_active_ = true;
1018 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( 1030 Send(new ViewHostMsg_DidActivateAcceleratedCompositing(
1019 routing_id_, is_accelerated_compositing_active_)); 1031 routing_id_, is_accelerated_compositing_active_));
1020
1021 // Note: asynchronous swapbuffer support currently only matters if
1022 // compositing scheduling happens on the RenderWidget.
1023 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers();
1024 } 1032 }
1025 1033
1026 void RenderWidget::didDeactivateCompositor() { 1034 void RenderWidget::didDeactivateCompositor() {
1027 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); 1035 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor");
1028 1036
1029 is_accelerated_compositing_active_ = false; 1037 is_accelerated_compositing_active_ = false;
1030 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( 1038 Send(new ViewHostMsg_DidActivateAcceleratedCompositing(
1031 routing_id_, is_accelerated_compositing_active_)); 1039 routing_id_, is_accelerated_compositing_active_));
1032 1040
1033 if (using_asynchronous_swapbuffers_) 1041 if (using_asynchronous_swapbuffers_)
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 } 1512 }
1505 return ui::TEXT_INPUT_TYPE_NONE; 1513 return ui::TEXT_INPUT_TYPE_NONE;
1506 } 1514 }
1507 1515
1508 bool RenderWidget::CanComposeInline() { 1516 bool RenderWidget::CanComposeInline() {
1509 return true; 1517 return true;
1510 } 1518 }
1511 1519
1512 WebScreenInfo RenderWidget::screenInfo() { 1520 WebScreenInfo RenderWidget::screenInfo() {
1513 WebScreenInfo results; 1521 WebScreenInfo results;
1514 if (host_window_) 1522 if (host_window_set_)
1515 Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results)); 1523 Send(new ViewHostMsg_GetScreenInfo(routing_id_, host_window_, &results));
1516 else { 1524 else {
1517 DLOG(WARNING) << "Unable to retrieve screen information, no host window"; 1525 DLOG(WARNING) << "Unable to retrieve screen information, no host window";
1518 #if defined(USE_AURA) 1526 #if defined(USE_AURA)
1519 // TODO(backer): Remove this a temporary workaround for crbug.com/111929 1527 // TODO(backer): Remove this a temporary workaround for crbug.com/111929
1520 // once we get a proper fix. 1528 // once we get a proper fix.
1521 results.availableRect.width = 1000; 1529 results.availableRect.width = 1000;
1522 results.availableRect.height = 1000; 1530 results.availableRect.height = 1000;
1523 #endif 1531 #endif
1524 } 1532 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 } 1584 }
1577 } 1585 }
1578 1586
1579 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { 1587 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) {
1580 return false; 1588 return false;
1581 } 1589 }
1582 1590
1583 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { 1591 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1584 return false; 1592 return false;
1585 } 1593 }
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698