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 <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 : view_(NULL), | 164 : view_(NULL), |
165 renderer_initialized_(false), | 165 renderer_initialized_(false), |
166 hung_renderer_delay_ms_(kHungRendererDelayMs), | 166 hung_renderer_delay_ms_(kHungRendererDelayMs), |
167 delegate_(delegate), | 167 delegate_(delegate), |
168 process_(process), | 168 process_(process), |
169 routing_id_(routing_id), | 169 routing_id_(routing_id), |
170 surface_id_(0), | 170 surface_id_(0), |
171 is_loading_(false), | 171 is_loading_(false), |
172 is_hidden_(hidden), | 172 is_hidden_(hidden), |
173 is_fullscreen_(false), | 173 is_fullscreen_(false), |
174 is_accelerated_compositing_active_(false), | |
175 repaint_ack_pending_(false), | 174 repaint_ack_pending_(false), |
176 resize_ack_pending_(false), | 175 resize_ack_pending_(false), |
177 screen_info_out_of_date_(false), | 176 screen_info_out_of_date_(false), |
178 overdraw_bottom_height_(0.f), | 177 overdraw_bottom_height_(0.f), |
179 should_auto_resize_(false), | 178 should_auto_resize_(false), |
180 waiting_for_screen_rects_ack_(false), | 179 waiting_for_screen_rects_ack_(false), |
181 accessibility_mode_(AccessibilityModeOff), | 180 accessibility_mode_(AccessibilityModeOff), |
182 needs_repainting_on_restore_(false), | 181 needs_repainting_on_restore_(false), |
183 is_unresponsive_(false), | 182 is_unresponsive_(false), |
184 in_flight_event_count_(0), | 183 in_flight_event_count_(0), |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnUpdateIsDelayed) | 469 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnUpdateIsDelayed) |
471 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) | 470 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) |
472 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) | 471 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) |
473 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) | 472 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) |
474 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTouchEventEmulationEnabled, | 473 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTouchEventEmulationEnabled, |
475 OnSetTouchEventEmulationEnabled) | 474 OnSetTouchEventEmulationEnabled) |
476 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, | 475 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, |
477 OnTextInputTypeChanged) | 476 OnTextInputTypeChanged) |
478 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, | 477 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, |
479 OnImeCancelComposition) | 478 OnImeCancelComposition) |
480 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing, | |
481 OnDidActivateAcceleratedCompositing) | |
482 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) | 479 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) |
483 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) | 480 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) |
484 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, | 481 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, |
485 OnShowDisambiguationPopup) | 482 OnShowDisambiguationPopup) |
486 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) | 483 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) |
487 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, | 484 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, |
488 OnSelectionBoundsChanged) | 485 OnSelectionBoundsChanged) |
489 #if defined(OS_WIN) | 486 #if defined(OS_WIN) |
490 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, | 487 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, |
491 OnWindowlessPluginDummyWindowCreated) | 488 OnWindowlessPluginDummyWindowCreated) |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
698 if (!view_) | 695 if (!view_) |
699 return; | 696 return; |
700 view_->SetIsLoading(is_loading); | 697 view_->SetIsLoading(is_loading); |
701 } | 698 } |
702 | 699 |
703 void RenderWidgetHostImpl::CopyFromBackingStore( | 700 void RenderWidgetHostImpl::CopyFromBackingStore( |
704 const gfx::Rect& src_subrect, | 701 const gfx::Rect& src_subrect, |
705 const gfx::Size& accelerated_dst_size, | 702 const gfx::Size& accelerated_dst_size, |
706 const base::Callback<void(bool, const SkBitmap&)>& callback, | 703 const base::Callback<void(bool, const SkBitmap&)>& callback, |
707 const SkBitmap::Config& bitmap_config) { | 704 const SkBitmap::Config& bitmap_config) { |
708 if (view_ && is_accelerated_compositing_active_) { | 705 if (view_) { |
709 TRACE_EVENT0("browser", | 706 TRACE_EVENT0("browser", |
710 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); | 707 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); |
711 gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ? | 708 gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ? |
712 gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | 709 gfx::Rect(view_->GetViewBounds().size()) : src_subrect; |
713 view_->CopyFromCompositingSurface( | 710 view_->CopyFromCompositingSurface( |
714 accelerated_copy_rect, accelerated_dst_size, callback, bitmap_config); | 711 accelerated_copy_rect, accelerated_dst_size, callback, bitmap_config); |
715 return; | 712 return; |
716 } | 713 } |
717 | 714 |
718 callback.Run(false, SkBitmap()); | 715 callback.Run(false, SkBitmap()); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
839 | 836 |
840 // Loop if we still have time left and haven't gotten a properly sized | 837 // Loop if we still have time left and haven't gotten a properly sized |
841 // BackingStore yet. This is necessary to support the GPU path which | 838 // BackingStore yet. This is necessary to support the GPU path which |
842 // typically has multiple frames pipelined -- we may need to skip one or two | 839 // typically has multiple frames pipelined -- we may need to skip one or two |
843 // BackingStore messages to get to the latest. | 840 // BackingStore messages to get to the latest. |
844 max_delay = end_time - TimeTicks::Now(); | 841 max_delay = end_time - TimeTicks::Now(); |
845 } while (max_delay > TimeDelta::FromSeconds(0)); | 842 } while (max_delay > TimeDelta::FromSeconds(0)); |
846 } | 843 } |
847 | 844 |
848 bool RenderWidgetHostImpl::ScheduleComposite() { | 845 bool RenderWidgetHostImpl::ScheduleComposite() { |
849 if (is_hidden_ || !is_accelerated_compositing_active_ || | 846 if (is_hidden_ || current_size_.IsEmpty() || repaint_ack_pending_ || |
850 current_size_.IsEmpty() || repaint_ack_pending_ || | |
851 resize_ack_pending_ || view_being_painted_) { | 847 resize_ack_pending_ || view_being_painted_) { |
852 return false; | 848 return false; |
853 } | 849 } |
854 | 850 |
855 // Send out a request to the renderer to paint the view if required. | 851 // Send out a request to the renderer to paint the view if required. |
856 repaint_start_time_ = TimeTicks::Now(); | 852 repaint_start_time_ = TimeTicks::Now(); |
857 repaint_ack_pending_ = true; | 853 repaint_ack_pending_ = true; |
858 TRACE_EVENT_ASYNC_BEGIN0( | 854 TRACE_EVENT_ASYNC_BEGIN0( |
859 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); | 855 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
860 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 856 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1226 if (overscroll_controller_) | 1222 if (overscroll_controller_) |
1227 overscroll_controller_->Reset(); | 1223 overscroll_controller_->Reset(); |
1228 | 1224 |
1229 // Must reset these to ensure that keyboard events work with a new renderer. | 1225 // Must reset these to ensure that keyboard events work with a new renderer. |
1230 suppress_next_char_events_ = false; | 1226 suppress_next_char_events_ = false; |
1231 | 1227 |
1232 // Reset some fields in preparation for recovering from a crash. | 1228 // Reset some fields in preparation for recovering from a crash. |
1233 ResetSizeAndRepaintPendingFlags(); | 1229 ResetSizeAndRepaintPendingFlags(); |
1234 current_size_.SetSize(0, 0); | 1230 current_size_.SetSize(0, 0); |
1235 is_hidden_ = false; | 1231 is_hidden_ = false; |
1236 is_accelerated_compositing_active_ = false; | |
danakj
2014/05/12 17:37:58
Should we be dropping the frame on the RWHV here t
piman
2014/05/13 20:25:40
RenderProcessGone below will destroy the RWHV anyw
| |
1237 | 1232 |
1238 // Reset this to ensure the hung renderer mechanism is working properly. | 1233 // Reset this to ensure the hung renderer mechanism is working properly. |
1239 in_flight_event_count_ = 0; | 1234 in_flight_event_count_ = 0; |
1240 | 1235 |
1241 if (view_) { | 1236 if (view_) { |
1242 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, | 1237 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, |
1243 gfx::GLSurfaceHandle()); | 1238 gfx::GLSurfaceHandle()); |
1244 view_->RenderProcessGone(status, exit_code); | 1239 view_->RenderProcessGone(status, exit_code); |
1245 view_ = NULL; // The View should be deleted by RenderProcessGone. | 1240 view_ = NULL; // The View should be deleted by RenderProcessGone. |
1246 } | 1241 } |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1675 if (view_) | 1670 if (view_) |
1676 view_->ImeCompositionRangeChanged(range, character_bounds); | 1671 view_->ImeCompositionRangeChanged(range, character_bounds); |
1677 } | 1672 } |
1678 #endif | 1673 #endif |
1679 | 1674 |
1680 void RenderWidgetHostImpl::OnImeCancelComposition() { | 1675 void RenderWidgetHostImpl::OnImeCancelComposition() { |
1681 if (view_) | 1676 if (view_) |
1682 view_->ImeCancelComposition(); | 1677 view_->ImeCancelComposition(); |
1683 } | 1678 } |
1684 | 1679 |
1685 void RenderWidgetHostImpl::OnDidActivateAcceleratedCompositing(bool activated) { | |
1686 TRACE_EVENT1("renderer_host", | |
1687 "RenderWidgetHostImpl::OnDidActivateAcceleratedCompositing", | |
1688 "activated", activated); | |
1689 is_accelerated_compositing_active_ = activated; | |
1690 if (view_) | |
1691 view_->OnAcceleratedCompositingStateChange(); | |
1692 } | |
1693 | |
1694 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture, | 1680 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture, |
1695 bool last_unlocked_by_target, | 1681 bool last_unlocked_by_target, |
1696 bool privileged) { | 1682 bool privileged) { |
1697 | 1683 |
1698 if (pending_mouse_lock_request_) { | 1684 if (pending_mouse_lock_request_) { |
1699 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); | 1685 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); |
1700 return; | 1686 return; |
1701 } else if (IsMouseLocked()) { | 1687 } else if (IsMouseLocked()) { |
1702 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); | 1688 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); |
1703 return; | 1689 return; |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2345 } | 2331 } |
2346 } | 2332 } |
2347 | 2333 |
2348 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { | 2334 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { |
2349 if (view_) | 2335 if (view_) |
2350 return view_->PreferredReadbackFormat(); | 2336 return view_->PreferredReadbackFormat(); |
2351 return SkBitmap::kARGB_8888_Config; | 2337 return SkBitmap::kARGB_8888_Config; |
2352 } | 2338 } |
2353 | 2339 |
2354 } // namespace content | 2340 } // namespace content |
OLD | NEW |