Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_impl.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc |
| index 90afecd8290a9633cee6f2b9de069c68d3f5951a..cdebe4d738a8492cf212b52acf2526aa5499af8c 100644 |
| --- a/content/browser/renderer_host/render_widget_host_impl.cc |
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc |
| @@ -1454,8 +1454,8 @@ void RenderWidgetHostImpl::GetSnapshotFromBrowser( |
| if (from_surface) { |
| pending_surface_browser_snapshots_.insert(std::make_pair(id, callback)); |
| ui::LatencyInfo latency_info; |
| - latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, 0, |
| - id); |
| + latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| + 0, id); |
| Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); |
| return; |
| } |
| @@ -1475,7 +1475,7 @@ void RenderWidgetHostImpl::GetSnapshotFromBrowser( |
| #endif |
| pending_browser_snapshots_.insert(std::make_pair(id, callback)); |
| ui::LatencyInfo latency_info; |
| - latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, 0, |
| + latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, 0, |
| id); |
| Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); |
| } |
| @@ -1758,6 +1758,32 @@ void RenderWidgetHostImpl::ClearDisplayedGraphics() { |
| view_->ClearCompositorFrame(); |
| } |
| +void RenderWidgetHostImpl::OnGpuSwapBufersCompletedInternal( |
| + const ui::LatencyInfo& latency_info) { |
| + ui::LatencyInfo::LatencyComponent window_snapshot_component; |
| + if (latency_info.FindLatency(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| + GetLatencyComponentId(), |
| + &window_snapshot_component)) { |
| + int sequence_number = |
| + static_cast<int>(window_snapshot_component.sequence_number); |
| +#if defined(OS_MACOSX) |
| + // On Mac, when using CoreAnmation, there is a delay between when content |
|
tdresser
2017/04/03 15:57:11
CoreAnmation -> CoreAnimation
mfomitchev
2017/04/03 17:31:00
Done.
|
| + // is drawn to the screen, and when the snapshot will actually pick up |
| + // that content. Insert a manual delay of 1/6th of a second (to simulate |
| + // 10 frames at 60 fps) before actually taking the snapshot. |
| + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind(&RenderWidgetHostImpl::WindowSnapshotReachedScreen, |
| + weak_factory_.GetWeakPtr(), sequence_number), |
| + base::TimeDelta::FromSecondsD(1. / 6)); |
| +#else |
| + WindowSnapshotReachedScreen(sequence_number); |
| +#endif |
| + } |
| + |
| + latency_tracker_.OnGpuSwapBufersCompleted(latency_info); |
| +} |
| + |
| void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { |
| // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case |
| // it handles destruction. |
| @@ -2340,31 +2366,6 @@ void RenderWidgetHostImpl::DetachDelegate() { |
| latency_tracker_.SetDelegate(nullptr); |
| } |
| -void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
| - ui::LatencyInfo::LatencyComponent window_snapshot_component; |
| - if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| - GetLatencyComponentId(), |
| - &window_snapshot_component)) { |
| - int sequence_number = static_cast<int>( |
| - window_snapshot_component.sequence_number); |
| -#if defined(OS_MACOSX) |
| - // On Mac, when using CoreAnmation, there is a delay between when content |
| - // is drawn to the screen, and when the snapshot will actually pick up |
| - // that content. Insert a manual delay of 1/6th of a second (to simulate |
| - // 10 frames at 60 fps) before actually taking the snapshot. |
| - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| - FROM_HERE, |
| - base::Bind(&RenderWidgetHostImpl::WindowSnapshotReachedScreen, |
| - weak_factory_.GetWeakPtr(), sequence_number), |
| - base::TimeDelta::FromSecondsD(1. / 6)); |
| -#else |
| - WindowSnapshotReachedScreen(sequence_number); |
| -#endif |
| - } |
| - |
| - latency_tracker_.OnFrameSwapped(latency_info); |
| -} |
| - |
| void RenderWidgetHostImpl::DidReceiveRendererFrame() { |
| view_->DidReceiveRendererFrame(); |
| } |
| @@ -2455,13 +2456,13 @@ void RenderWidgetHostImpl::OnSnapshotReceived(int snapshot_id, |
| } |
| // static |
| -void RenderWidgetHostImpl::CompositorFrameDrawn( |
| +void RenderWidgetHostImpl::OnGpuSwapBufersCompleted( |
| const std::vector<ui::LatencyInfo>& latency_info) { |
| for (size_t i = 0; i < latency_info.size(); i++) { |
| std::set<RenderWidgetHostImpl*> rwhi_set; |
| for (const auto& lc : latency_info[i].latency_components()) { |
| if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || |
| - lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT || |
| + lc.first.first == ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT || |
| lc.first.first == ui::TAB_SHOW_COMPONENT) { |
| // Matches with GetLatencyComponentId |
| int routing_id = lc.first.second & 0xffffffff; |
| @@ -2473,7 +2474,7 @@ void RenderWidgetHostImpl::CompositorFrameDrawn( |
| } |
| RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); |
| if (rwhi_set.insert(rwhi).second) |
| - rwhi->FrameSwapped(latency_info[i]); |
| + rwhi->OnGpuSwapBufersCompletedInternal(latency_info[i]); |
| } |
| } |
| } |