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/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } | 267 } |
268 | 268 |
269 void RenderWidgetHostImpl::CompositingSurfaceUpdated() { | 269 void RenderWidgetHostImpl::CompositingSurfaceUpdated() { |
270 GpuSurfaceTracker::Get()->SetSurfaceHandle( | 270 GpuSurfaceTracker::Get()->SetSurfaceHandle( |
271 surface_id_, GetCompositingSurface()); | 271 surface_id_, GetCompositingSurface()); |
272 process_->SurfaceUpdated(surface_id_); | 272 process_->SurfaceUpdated(surface_id_); |
273 } | 273 } |
274 | 274 |
275 void RenderWidgetHostImpl::ResetSizeAndRepaintPendingFlags() { | 275 void RenderWidgetHostImpl::ResetSizeAndRepaintPendingFlags() { |
276 resize_ack_pending_ = false; | 276 resize_ack_pending_ = false; |
| 277 if (repaint_ack_pending_) { |
| 278 TRACE_EVENT_ASYNC_END0( |
| 279 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
| 280 } |
277 repaint_ack_pending_ = false; | 281 repaint_ack_pending_ = false; |
278 in_flight_size_.SetSize(0, 0); | 282 in_flight_size_.SetSize(0, 0); |
279 } | 283 } |
280 | 284 |
281 void RenderWidgetHostImpl::SendScreenRects() { | 285 void RenderWidgetHostImpl::SendScreenRects() { |
282 if (!renderer_initialized_ || waiting_for_screen_rects_ack_) | 286 if (!renderer_initialized_ || waiting_for_screen_rects_ack_) |
283 return; | 287 return; |
284 | 288 |
285 if (is_hidden_) { | 289 if (is_hidden_) { |
286 // On GTK, this comes in for backgrounded tabs. Ignore, to match what | 290 // On GTK, this comes in for backgrounded tabs. Ignore, to match what |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 // We might have a cached backing store that we can reuse! | 696 // We might have a cached backing store that we can reuse! |
693 BackingStore* backing_store = NULL; | 697 BackingStore* backing_store = NULL; |
694 if (TryGetBackingStore(view_size, &backing_store) || !force_create) | 698 if (TryGetBackingStore(view_size, &backing_store) || !force_create) |
695 return backing_store; | 699 return backing_store; |
696 | 700 |
697 // We do not have a suitable backing store in the cache, so send out a | 701 // We do not have a suitable backing store in the cache, so send out a |
698 // request to the renderer to paint the view if required. | 702 // request to the renderer to paint the view if required. |
699 if (!repaint_ack_pending_ && !resize_ack_pending_ && !view_being_painted_) { | 703 if (!repaint_ack_pending_ && !resize_ack_pending_ && !view_being_painted_) { |
700 repaint_start_time_ = TimeTicks::Now(); | 704 repaint_start_time_ = TimeTicks::Now(); |
701 repaint_ack_pending_ = true; | 705 repaint_ack_pending_ = true; |
| 706 TRACE_EVENT_ASYNC_BEGIN0( |
| 707 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
702 Send(new ViewMsg_Repaint(routing_id_, view_size)); | 708 Send(new ViewMsg_Repaint(routing_id_, view_size)); |
703 } | 709 } |
704 | 710 |
705 TimeDelta max_delay = TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS); | 711 TimeDelta max_delay = TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS); |
706 TimeTicks end_time = TimeTicks::Now() + max_delay; | 712 TimeTicks end_time = TimeTicks::Now() + max_delay; |
707 do { | 713 do { |
708 TRACE_EVENT0("renderer_host", "GetBackingStore::WaitForUpdate"); | 714 TRACE_EVENT0("renderer_host", "GetBackingStore::WaitForUpdate"); |
709 | 715 |
710 #if defined(OS_MACOSX) | 716 #if defined(OS_MACOSX) |
711 view_->AboutToWaitForBackingStoreMsg(); | 717 view_->AboutToWaitForBackingStoreMsg(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 if (!view_) | 759 if (!view_) |
754 return NULL; | 760 return NULL; |
755 return view_->AllocBackingStore(size); | 761 return view_->AllocBackingStore(size); |
756 } | 762 } |
757 | 763 |
758 void RenderWidgetHostImpl::DonePaintingToBackingStore() { | 764 void RenderWidgetHostImpl::DonePaintingToBackingStore() { |
759 Send(new ViewMsg_UpdateRect_ACK(GetRoutingID())); | 765 Send(new ViewMsg_UpdateRect_ACK(GetRoutingID())); |
760 } | 766 } |
761 | 767 |
762 void RenderWidgetHostImpl::ScheduleComposite() { | 768 void RenderWidgetHostImpl::ScheduleComposite() { |
763 if (is_hidden_ || !is_accelerated_compositing_active_) { | 769 if (is_hidden_ || !is_accelerated_compositing_active_ || |
| 770 current_size_.IsEmpty()) { |
764 return; | 771 return; |
765 } | 772 } |
766 | 773 |
767 // Send out a request to the renderer to paint the view if required. | 774 // Send out a request to the renderer to paint the view if required. |
768 if (!repaint_ack_pending_ && !resize_ack_pending_ && !view_being_painted_) { | 775 if (!repaint_ack_pending_ && !resize_ack_pending_ && !view_being_painted_) { |
769 repaint_start_time_ = TimeTicks::Now(); | 776 repaint_start_time_ = TimeTicks::Now(); |
770 repaint_ack_pending_ = true; | 777 repaint_ack_pending_ = true; |
| 778 TRACE_EVENT_ASYNC_BEGIN0( |
| 779 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
771 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 780 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
772 } | 781 } |
773 } | 782 } |
774 | 783 |
775 void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { | 784 void RenderWidgetHostImpl::StartHangMonitorTimeout(TimeDelta delay) { |
776 if (!GetProcess()->IsGuest() && CommandLine::ForCurrentProcess()->HasSwitch( | 785 if (!GetProcess()->IsGuest() && CommandLine::ForCurrentProcess()->HasSwitch( |
777 switches::kDisableHangMonitor)) { | 786 switches::kDisableHangMonitor)) { |
778 return; | 787 return; |
779 } | 788 } |
780 | 789 |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 // that will end up reaching GetBackingStore. | 1653 // that will end up reaching GetBackingStore. |
1645 if (is_resize_ack) { | 1654 if (is_resize_ack) { |
1646 DCHECK(resize_ack_pending_); | 1655 DCHECK(resize_ack_pending_); |
1647 resize_ack_pending_ = false; | 1656 resize_ack_pending_ = false; |
1648 in_flight_size_.SetSize(0, 0); | 1657 in_flight_size_.SetSize(0, 0); |
1649 } | 1658 } |
1650 | 1659 |
1651 bool is_repaint_ack = | 1660 bool is_repaint_ack = |
1652 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags); | 1661 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags); |
1653 if (is_repaint_ack) { | 1662 if (is_repaint_ack) { |
| 1663 DCHECK(repaint_ack_pending_); |
| 1664 TRACE_EVENT_ASYNC_END0( |
| 1665 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
1654 repaint_ack_pending_ = false; | 1666 repaint_ack_pending_ = false; |
1655 TimeDelta delta = TimeTicks::Now() - repaint_start_time_; | 1667 TimeDelta delta = TimeTicks::Now() - repaint_start_time_; |
1656 UMA_HISTOGRAM_TIMES("MPArch.RWH_RepaintDelta", delta); | 1668 UMA_HISTOGRAM_TIMES("MPArch.RWH_RepaintDelta", delta); |
1657 } | 1669 } |
1658 | 1670 |
1659 DCHECK(!params.view_size.IsEmpty()); | 1671 DCHECK(!params.view_size.IsEmpty()); |
1660 | 1672 |
1661 bool was_async = false; | 1673 bool was_async = false; |
1662 | 1674 |
1663 // If this is a GPU UpdateRect, params.bitmap is invalid and dib will be NULL. | 1675 // If this is a GPU UpdateRect, params.bitmap is invalid and dib will be NULL. |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2152 | 2164 |
2153 bool needs_full_paint = false; | 2165 bool needs_full_paint = false; |
2154 bool scheduled_completion_callback = false; | 2166 bool scheduled_completion_callback = false; |
2155 BackingStoreManager::PrepareBackingStore(this, view_size, bitmap, bitmap_rect, | 2167 BackingStoreManager::PrepareBackingStore(this, view_size, bitmap, bitmap_rect, |
2156 copy_rects, scale_factor, | 2168 copy_rects, scale_factor, |
2157 completion_callback, | 2169 completion_callback, |
2158 &needs_full_paint, | 2170 &needs_full_paint, |
2159 &scheduled_completion_callback); | 2171 &scheduled_completion_callback); |
2160 if (needs_full_paint) { | 2172 if (needs_full_paint) { |
2161 repaint_start_time_ = TimeTicks::Now(); | 2173 repaint_start_time_ = TimeTicks::Now(); |
| 2174 DCHECK(!repaint_ack_pending_); |
2162 repaint_ack_pending_ = true; | 2175 repaint_ack_pending_ = true; |
| 2176 TRACE_EVENT_ASYNC_BEGIN0( |
| 2177 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
2163 Send(new ViewMsg_Repaint(routing_id_, view_size)); | 2178 Send(new ViewMsg_Repaint(routing_id_, view_size)); |
2164 } | 2179 } |
2165 | 2180 |
2166 return scheduled_completion_callback; | 2181 return scheduled_completion_callback; |
2167 } | 2182 } |
2168 | 2183 |
2169 void RenderWidgetHostImpl::ScrollBackingStoreRect(const gfx::Vector2d& delta, | 2184 void RenderWidgetHostImpl::ScrollBackingStoreRect(const gfx::Vector2d& delta, |
2170 const gfx::Rect& clip_rect, | 2185 const gfx::Rect& clip_rect, |
2171 const gfx::Size& view_size) { | 2186 const gfx::Size& view_size) { |
2172 if (is_hidden_) { | 2187 if (is_hidden_) { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2465 return; | 2480 return; |
2466 | 2481 |
2467 OnRenderAutoResized(new_size); | 2482 OnRenderAutoResized(new_size); |
2468 } | 2483 } |
2469 | 2484 |
2470 void RenderWidgetHostImpl::DetachDelegate() { | 2485 void RenderWidgetHostImpl::DetachDelegate() { |
2471 delegate_ = NULL; | 2486 delegate_ = NULL; |
2472 } | 2487 } |
2473 | 2488 |
2474 } // namespace content | 2489 } // namespace content |
OLD | NEW |