| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | 467 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
| 469 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) | 468 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) |
| 470 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) | 469 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) |
| 471 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) | 470 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) |
| 472 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTouchEventEmulationEnabled, | 471 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTouchEventEmulationEnabled, |
| 473 OnSetTouchEventEmulationEnabled) | 472 OnSetTouchEventEmulationEnabled) |
| 474 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, | 473 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, |
| 475 OnTextInputTypeChanged) | 474 OnTextInputTypeChanged) |
| 476 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, | 475 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, |
| 477 OnImeCancelComposition) | 476 OnImeCancelComposition) |
| 478 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing, | |
| 479 OnDidActivateAcceleratedCompositing) | |
| 480 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) | 477 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) |
| 481 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) | 478 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) |
| 482 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, | 479 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, |
| 483 OnShowDisambiguationPopup) | 480 OnShowDisambiguationPopup) |
| 484 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) | 481 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) |
| 485 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, | 482 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, |
| 486 OnSelectionBoundsChanged) | 483 OnSelectionBoundsChanged) |
| 487 #if defined(OS_WIN) | 484 #if defined(OS_WIN) |
| 488 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, | 485 IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, |
| 489 OnWindowlessPluginDummyWindowCreated) | 486 OnWindowlessPluginDummyWindowCreated) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 if (!view_) | 693 if (!view_) |
| 697 return; | 694 return; |
| 698 view_->SetIsLoading(is_loading); | 695 view_->SetIsLoading(is_loading); |
| 699 } | 696 } |
| 700 | 697 |
| 701 void RenderWidgetHostImpl::CopyFromBackingStore( | 698 void RenderWidgetHostImpl::CopyFromBackingStore( |
| 702 const gfx::Rect& src_subrect, | 699 const gfx::Rect& src_subrect, |
| 703 const gfx::Size& accelerated_dst_size, | 700 const gfx::Size& accelerated_dst_size, |
| 704 const base::Callback<void(bool, const SkBitmap&)>& callback, | 701 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 705 const SkBitmap::Config& bitmap_config) { | 702 const SkBitmap::Config& bitmap_config) { |
| 706 if (view_ && is_accelerated_compositing_active_) { | 703 if (view_) { |
| 707 TRACE_EVENT0("browser", | 704 TRACE_EVENT0("browser", |
| 708 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); | 705 "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); |
| 709 gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ? | 706 gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ? |
| 710 gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | 707 gfx::Rect(view_->GetViewBounds().size()) : src_subrect; |
| 711 view_->CopyFromCompositingSurface( | 708 view_->CopyFromCompositingSurface( |
| 712 accelerated_copy_rect, accelerated_dst_size, callback, bitmap_config); | 709 accelerated_copy_rect, accelerated_dst_size, callback, bitmap_config); |
| 713 return; | 710 return; |
| 714 } | 711 } |
| 715 | 712 |
| 716 callback.Run(false, SkBitmap()); | 713 callback.Run(false, SkBitmap()); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 | 832 |
| 836 // Loop if we still have time left and haven't gotten a properly sized | 833 // Loop if we still have time left and haven't gotten a properly sized |
| 837 // BackingStore yet. This is necessary to support the GPU path which | 834 // BackingStore yet. This is necessary to support the GPU path which |
| 838 // typically has multiple frames pipelined -- we may need to skip one or two | 835 // typically has multiple frames pipelined -- we may need to skip one or two |
| 839 // BackingStore messages to get to the latest. | 836 // BackingStore messages to get to the latest. |
| 840 max_delay = end_time - TimeTicks::Now(); | 837 max_delay = end_time - TimeTicks::Now(); |
| 841 } while (max_delay > TimeDelta::FromSeconds(0)); | 838 } while (max_delay > TimeDelta::FromSeconds(0)); |
| 842 } | 839 } |
| 843 | 840 |
| 844 bool RenderWidgetHostImpl::ScheduleComposite() { | 841 bool RenderWidgetHostImpl::ScheduleComposite() { |
| 845 if (is_hidden_ || !is_accelerated_compositing_active_ || | 842 if (is_hidden_ || current_size_.IsEmpty() || repaint_ack_pending_ || |
| 846 current_size_.IsEmpty() || repaint_ack_pending_ || | |
| 847 resize_ack_pending_ || view_being_painted_) { | 843 resize_ack_pending_ || view_being_painted_) { |
| 848 return false; | 844 return false; |
| 849 } | 845 } |
| 850 | 846 |
| 851 // Send out a request to the renderer to paint the view if required. | 847 // Send out a request to the renderer to paint the view if required. |
| 852 repaint_start_time_ = TimeTicks::Now(); | 848 repaint_start_time_ = TimeTicks::Now(); |
| 853 repaint_ack_pending_ = true; | 849 repaint_ack_pending_ = true; |
| 854 TRACE_EVENT_ASYNC_BEGIN0( | 850 TRACE_EVENT_ASYNC_BEGIN0( |
| 855 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); | 851 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
| 856 Send(new ViewMsg_Repaint(routing_id_, current_size_)); | 852 Send(new ViewMsg_Repaint(routing_id_, current_size_)); |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 if (overscroll_controller_) | 1218 if (overscroll_controller_) |
| 1223 overscroll_controller_->Reset(); | 1219 overscroll_controller_->Reset(); |
| 1224 | 1220 |
| 1225 // Must reset these to ensure that keyboard events work with a new renderer. | 1221 // Must reset these to ensure that keyboard events work with a new renderer. |
| 1226 suppress_next_char_events_ = false; | 1222 suppress_next_char_events_ = false; |
| 1227 | 1223 |
| 1228 // Reset some fields in preparation for recovering from a crash. | 1224 // Reset some fields in preparation for recovering from a crash. |
| 1229 ResetSizeAndRepaintPendingFlags(); | 1225 ResetSizeAndRepaintPendingFlags(); |
| 1230 current_size_.SetSize(0, 0); | 1226 current_size_.SetSize(0, 0); |
| 1231 is_hidden_ = false; | 1227 is_hidden_ = false; |
| 1232 is_accelerated_compositing_active_ = false; | |
| 1233 | 1228 |
| 1234 // Reset this to ensure the hung renderer mechanism is working properly. | 1229 // Reset this to ensure the hung renderer mechanism is working properly. |
| 1235 in_flight_event_count_ = 0; | 1230 in_flight_event_count_ = 0; |
| 1236 | 1231 |
| 1237 if (view_) { | 1232 if (view_) { |
| 1238 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, | 1233 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, |
| 1239 gfx::GLSurfaceHandle()); | 1234 gfx::GLSurfaceHandle()); |
| 1240 view_->RenderProcessGone(status, exit_code); | 1235 view_->RenderProcessGone(status, exit_code); |
| 1241 view_ = NULL; // The View should be deleted by RenderProcessGone. | 1236 view_ = NULL; // The View should be deleted by RenderProcessGone. |
| 1242 } | 1237 } |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 if (view_) | 1661 if (view_) |
| 1667 view_->ImeCompositionRangeChanged(range, character_bounds); | 1662 view_->ImeCompositionRangeChanged(range, character_bounds); |
| 1668 } | 1663 } |
| 1669 #endif | 1664 #endif |
| 1670 | 1665 |
| 1671 void RenderWidgetHostImpl::OnImeCancelComposition() { | 1666 void RenderWidgetHostImpl::OnImeCancelComposition() { |
| 1672 if (view_) | 1667 if (view_) |
| 1673 view_->ImeCancelComposition(); | 1668 view_->ImeCancelComposition(); |
| 1674 } | 1669 } |
| 1675 | 1670 |
| 1676 void RenderWidgetHostImpl::OnDidActivateAcceleratedCompositing(bool activated) { | |
| 1677 TRACE_EVENT1("renderer_host", | |
| 1678 "RenderWidgetHostImpl::OnDidActivateAcceleratedCompositing", | |
| 1679 "activated", activated); | |
| 1680 is_accelerated_compositing_active_ = activated; | |
| 1681 if (view_) | |
| 1682 view_->OnAcceleratedCompositingStateChange(); | |
| 1683 } | |
| 1684 | |
| 1685 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture, | 1671 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture, |
| 1686 bool last_unlocked_by_target, | 1672 bool last_unlocked_by_target, |
| 1687 bool privileged) { | 1673 bool privileged) { |
| 1688 | 1674 |
| 1689 if (pending_mouse_lock_request_) { | 1675 if (pending_mouse_lock_request_) { |
| 1690 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); | 1676 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); |
| 1691 return; | 1677 return; |
| 1692 } else if (IsMouseLocked()) { | 1678 } else if (IsMouseLocked()) { |
| 1693 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); | 1679 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); |
| 1694 return; | 1680 return; |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2336 } | 2322 } |
| 2337 } | 2323 } |
| 2338 | 2324 |
| 2339 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { | 2325 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2340 if (view_) | 2326 if (view_) |
| 2341 return view_->PreferredReadbackFormat(); | 2327 return view_->PreferredReadbackFormat(); |
| 2342 return SkBitmap::kARGB_8888_Config; | 2328 return SkBitmap::kARGB_8888_Config; |
| 2343 } | 2329 } |
| 2344 | 2330 |
| 2345 } // namespace content | 2331 } // namespace content |
| OLD | NEW |