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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { | 1993 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { |
1994 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); | 1994 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); |
1995 return false; | 1995 return false; |
1996 } | 1996 } |
1997 | 1997 |
1998 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); | 1998 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); |
1999 return true; | 1999 return true; |
2000 } | 2000 } |
2001 | 2001 |
2002 // static | 2002 // static |
2003 void RenderWidgetHostImpl::SendSwapCompositorFrameAck( | |
2004 int32_t route_id, | |
2005 uint32_t output_surface_id, | |
2006 int renderer_host_id, | |
2007 const cc::CompositorFrameAck& ack) { | |
2008 RenderProcessHost* host = RenderProcessHost::FromID(renderer_host_id); | |
2009 if (!host) | |
2010 return; | |
2011 host->Send(new ViewMsg_SwapCompositorFrameAck( | |
2012 route_id, output_surface_id, ack)); | |
2013 } | |
2014 | |
2015 // static | |
2016 void RenderWidgetHostImpl::SendReclaimCompositorResources( | 2003 void RenderWidgetHostImpl::SendReclaimCompositorResources( |
2017 int32_t route_id, | 2004 int32_t route_id, |
2018 uint32_t output_surface_id, | 2005 uint32_t output_surface_id, |
2019 int renderer_host_id, | 2006 int renderer_host_id, |
2020 const cc::CompositorFrameAck& ack) { | 2007 bool is_swap_ack, |
| 2008 const cc::ReturnedResourceArray& resources) { |
2021 RenderProcessHost* host = RenderProcessHost::FromID(renderer_host_id); | 2009 RenderProcessHost* host = RenderProcessHost::FromID(renderer_host_id); |
2022 if (!host) | 2010 if (!host) |
2023 return; | 2011 return; |
2024 host->Send( | 2012 host->Send(new ViewMsg_ReclaimCompositorResources(route_id, output_surface_id, |
2025 new ViewMsg_ReclaimCompositorResources(route_id, output_surface_id, ack)); | 2013 is_swap_ack, resources)); |
2026 } | 2014 } |
2027 | 2015 |
2028 void RenderWidgetHostImpl::DelayedAutoResized() { | 2016 void RenderWidgetHostImpl::DelayedAutoResized() { |
2029 gfx::Size new_size = new_auto_size_; | 2017 gfx::Size new_size = new_auto_size_; |
2030 // Clear the new_auto_size_ since the empty value is used as a flag to | 2018 // Clear the new_auto_size_ since the empty value is used as a flag to |
2031 // indicate that no callback is in progress (i.e. without this line | 2019 // indicate that no callback is in progress (i.e. without this line |
2032 // DelayedAutoResized will not get called again). | 2020 // DelayedAutoResized will not get called again). |
2033 new_auto_size_.SetSize(0, 0); | 2021 new_auto_size_.SetSize(0, 0); |
2034 if (!auto_resize_enabled_) | 2022 if (!auto_resize_enabled_) |
2035 return; | 2023 return; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2152 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2140 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
2153 } | 2141 } |
2154 | 2142 |
2155 BrowserAccessibilityManager* | 2143 BrowserAccessibilityManager* |
2156 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2144 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2157 return delegate_ ? | 2145 return delegate_ ? |
2158 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2146 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
2159 } | 2147 } |
2160 | 2148 |
2161 } // namespace content | 2149 } // namespace content |
OLD | NEW |