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 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/metrics/field_trial.h" | 22 #include "base/metrics/field_trial.h" |
23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
24 #include "base/single_thread_task_runner.h" | 24 #include "base/single_thread_task_runner.h" |
25 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
27 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
28 #include "base/trace_event/trace_event.h" | 28 #include "base/trace_event/trace_event.h" |
29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
30 #include "cc/base/switches.h" | 30 #include "cc/base/switches.h" |
31 #include "cc/output/compositor_frame.h" | 31 #include "cc/output/compositor_frame.h" |
32 #include "cc/output/compositor_frame_ack.h" | |
33 #include "content/browser/accessibility/accessibility_mode_helper.h" | 32 #include "content/browser/accessibility/accessibility_mode_helper.h" |
34 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 33 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
35 #include "content/browser/bad_message.h" | 34 #include "content/browser/bad_message.h" |
36 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 35 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
37 #include "content/browser/gpu/compositor_util.h" | 36 #include "content/browser/gpu/compositor_util.h" |
38 #include "content/browser/renderer_host/dip_util.h" | 37 #include "content/browser/renderer_host/dip_util.h" |
39 #include "content/browser/renderer_host/frame_metadata_util.h" | 38 #include "content/browser/renderer_host/frame_metadata_util.h" |
40 #include "content/browser/renderer_host/input/input_router_config_helper.h" | 39 #include "content/browser/renderer_host/input/input_router_config_helper.h" |
41 #include "content/browser/renderer_host/input/input_router_impl.h" | 40 #include "content/browser/renderer_host/input/input_router_impl.h" |
42 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 41 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 | 1559 |
1561 bool is_mobile_optimized = IsMobileOptimizedFrame(frame.metadata); | 1560 bool is_mobile_optimized = IsMobileOptimizedFrame(frame.metadata); |
1562 input_router_->NotifySiteIsMobileOptimized(is_mobile_optimized); | 1561 input_router_->NotifySiteIsMobileOptimized(is_mobile_optimized); |
1563 if (touch_emulator_) | 1562 if (touch_emulator_) |
1564 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); | 1563 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); |
1565 | 1564 |
1566 if (view_) { | 1565 if (view_) { |
1567 view_->OnSwapCompositorFrame(output_surface_id, std::move(frame)); | 1566 view_->OnSwapCompositorFrame(output_surface_id, std::move(frame)); |
1568 view_->DidReceiveRendererFrame(); | 1567 view_->DidReceiveRendererFrame(); |
1569 } else { | 1568 } else { |
1570 cc::CompositorFrameAck ack; | 1569 cc::ReturnedResourceArray resources; |
1571 if (frame.delegated_frame_data) { | 1570 if (frame.delegated_frame_data) { |
1572 cc::TransferableResource::ReturnResources( | 1571 cc::TransferableResource::ReturnResources( |
1573 frame.delegated_frame_data->resource_list, &ack.resources); | 1572 frame.delegated_frame_data->resource_list, &resources); |
1574 } | 1573 } |
1575 SendSwapCompositorFrameAck(routing_id_, output_surface_id, | 1574 SendReclaimCompositorResources(routing_id_, output_surface_id, |
1576 process_->GetID(), ack); | 1575 process_->GetID(), true /* is_swap_ack */, |
| 1576 resources); |
1577 } | 1577 } |
1578 | 1578 |
1579 RenderProcessHost* rph = GetProcess(); | 1579 RenderProcessHost* rph = GetProcess(); |
1580 for (std::vector<IPC::Message>::const_iterator i = | 1580 for (std::vector<IPC::Message>::const_iterator i = |
1581 messages_to_deliver_with_frame.begin(); | 1581 messages_to_deliver_with_frame.begin(); |
1582 i != messages_to_deliver_with_frame.end(); | 1582 i != messages_to_deliver_with_frame.end(); |
1583 ++i) { | 1583 ++i) { |
1584 rph->OnMessageReceived(*i); | 1584 rph->OnMessageReceived(*i); |
1585 if (i->dispatch_error()) | 1585 if (i->dispatch_error()) |
1586 rph->OnBadMessageReceived(*i); | 1586 rph->OnBadMessageReceived(*i); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { | 1994 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { |
1995 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); | 1995 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); |
1996 return false; | 1996 return false; |
1997 } | 1997 } |
1998 | 1998 |
1999 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); | 1999 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); |
2000 return true; | 2000 return true; |
2001 } | 2001 } |
2002 | 2002 |
2003 // static | 2003 // static |
2004 void RenderWidgetHostImpl::SendSwapCompositorFrameAck( | |
2005 int32_t route_id, | |
2006 uint32_t output_surface_id, | |
2007 int renderer_host_id, | |
2008 const cc::CompositorFrameAck& ack) { | |
2009 RenderProcessHost* host = RenderProcessHost::FromID(renderer_host_id); | |
2010 if (!host) | |
2011 return; | |
2012 host->Send(new ViewMsg_SwapCompositorFrameAck( | |
2013 route_id, output_surface_id, ack)); | |
2014 } | |
2015 | |
2016 // static | |
2017 void RenderWidgetHostImpl::SendReclaimCompositorResources( | 2004 void RenderWidgetHostImpl::SendReclaimCompositorResources( |
2018 int32_t route_id, | 2005 int32_t route_id, |
2019 uint32_t output_surface_id, | 2006 uint32_t output_surface_id, |
2020 int renderer_host_id, | 2007 int renderer_host_id, |
2021 const cc::CompositorFrameAck& ack) { | 2008 bool is_swap_ack, |
| 2009 const cc::ReturnedResourceArray& resources) { |
2022 RenderProcessHost* host = RenderProcessHost::FromID(renderer_host_id); | 2010 RenderProcessHost* host = RenderProcessHost::FromID(renderer_host_id); |
2023 if (!host) | 2011 if (!host) |
2024 return; | 2012 return; |
2025 host->Send( | 2013 host->Send(new ViewMsg_ReclaimCompositorResources(route_id, output_surface_id, |
2026 new ViewMsg_ReclaimCompositorResources(route_id, output_surface_id, ack)); | 2014 is_swap_ack, resources)); |
2027 } | 2015 } |
2028 | 2016 |
2029 void RenderWidgetHostImpl::DelayedAutoResized() { | 2017 void RenderWidgetHostImpl::DelayedAutoResized() { |
2030 gfx::Size new_size = new_auto_size_; | 2018 gfx::Size new_size = new_auto_size_; |
2031 // Clear the new_auto_size_ since the empty value is used as a flag to | 2019 // Clear the new_auto_size_ since the empty value is used as a flag to |
2032 // indicate that no callback is in progress (i.e. without this line | 2020 // indicate that no callback is in progress (i.e. without this line |
2033 // DelayedAutoResized will not get called again). | 2021 // DelayedAutoResized will not get called again). |
2034 new_auto_size_.SetSize(0, 0); | 2022 new_auto_size_.SetSize(0, 0); |
2035 if (!auto_resize_enabled_) | 2023 if (!auto_resize_enabled_) |
2036 return; | 2024 return; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2141 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
2154 } | 2142 } |
2155 | 2143 |
2156 BrowserAccessibilityManager* | 2144 BrowserAccessibilityManager* |
2157 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2145 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2158 return delegate_ ? | 2146 return delegate_ ? |
2159 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2147 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
2160 } | 2148 } |
2161 | 2149 |
2162 } // namespace content | 2150 } // namespace content |
OLD | NEW |