Chromium Code Reviews| 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 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1499 } | 1499 } |
| 1500 | 1500 |
| 1501 void RenderWidgetHostImpl::GetSnapshotFromBrowser( | 1501 void RenderWidgetHostImpl::GetSnapshotFromBrowser( |
| 1502 const GetSnapshotFromBrowserCallback& callback, | 1502 const GetSnapshotFromBrowserCallback& callback, |
| 1503 bool from_surface) { | 1503 bool from_surface) { |
| 1504 int id = next_browser_snapshot_id_++; | 1504 int id = next_browser_snapshot_id_++; |
| 1505 if (from_surface) { | 1505 if (from_surface) { |
| 1506 pending_surface_browser_snapshots_.insert(std::make_pair(id, callback)); | 1506 pending_surface_browser_snapshots_.insert(std::make_pair(id, callback)); |
| 1507 ui::LatencyInfo latency_info; | 1507 ui::LatencyInfo latency_info; |
| 1508 latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, | 1508 latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| 1509 0, id); | 1509 id); |
| 1510 Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); | 1510 Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); |
| 1511 return; | 1511 return; |
| 1512 } | 1512 } |
| 1513 | 1513 |
| 1514 #if defined(OS_MACOSX) | 1514 #if defined(OS_MACOSX) |
| 1515 // MacOS version of underlying GrabViewSnapshot() blocks while | 1515 // MacOS version of underlying GrabViewSnapshot() blocks while |
| 1516 // display/GPU are in a power-saving mode, so make sure display | 1516 // display/GPU are in a power-saving mode, so make sure display |
| 1517 // does not go to sleep for the duration of reading a snapshot. | 1517 // does not go to sleep for the duration of reading a snapshot. |
| 1518 if (pending_browser_snapshots_.empty()) | 1518 if (pending_browser_snapshots_.empty()) |
| 1519 GetWakeLock()->RequestWakeLock(); | 1519 GetWakeLock()->RequestWakeLock(); |
| 1520 #endif | 1520 #endif |
| 1521 pending_browser_snapshots_.insert(std::make_pair(id, callback)); | 1521 pending_browser_snapshots_.insert(std::make_pair(id, callback)); |
| 1522 ui::LatencyInfo latency_info; | 1522 ui::LatencyInfo latency_info; |
| 1523 latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, 0, | 1523 latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| 1524 id); | 1524 id); |
| 1525 Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); | 1525 Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info)); |
| 1526 } | 1526 } |
| 1527 | 1527 |
| 1528 const NativeWebKeyboardEvent* | 1528 const NativeWebKeyboardEvent* |
| 1529 RenderWidgetHostImpl::GetLastKeyboardEvent() const { | 1529 RenderWidgetHostImpl::GetLastKeyboardEvent() const { |
| 1530 return input_router_->GetLastKeyboardEvent(); | 1530 return input_router_->GetLastKeyboardEvent(); |
| 1531 } | 1531 } |
| 1532 | 1532 |
| 1533 void RenderWidgetHostImpl::SelectionChanged(const base::string16& text, | 1533 void RenderWidgetHostImpl::SelectionChanged(const base::string16& text, |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1829 if (view_) | 1829 if (view_) |
| 1830 view_->ClearCompositorFrame(); | 1830 view_->ClearCompositorFrame(); |
| 1831 } | 1831 } |
| 1832 | 1832 |
| 1833 void RenderWidgetHostImpl::OnGpuSwapBuffersCompletedInternal( | 1833 void RenderWidgetHostImpl::OnGpuSwapBuffersCompletedInternal( |
| 1834 const ui::LatencyInfo& latency_info) { | 1834 const ui::LatencyInfo& latency_info) { |
| 1835 ui::LatencyInfo::LatencyComponent window_snapshot_component; | 1835 ui::LatencyInfo::LatencyComponent window_snapshot_component; |
| 1836 if (latency_info.FindLatency(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, | 1836 if (latency_info.FindLatency(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| 1837 GetLatencyComponentId(), | 1837 GetLatencyComponentId(), |
| 1838 &window_snapshot_component)) { | 1838 &window_snapshot_component)) { |
| 1839 int sequence_number = | 1839 static int snapshot_id = 0; |
| 1840 static_cast<int>(window_snapshot_component.sequence_number); | 1840 ++snapshot_id; |
|
tdresser
2017/06/08 18:36:44
Actual change.
| |
| 1841 #if defined(OS_MACOSX) || defined(OS_WIN) | 1841 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 1842 // On Mac, when using CoreAnimation, or Win32 when using GDI, there is a | 1842 // On Mac, when using CoreAnimation, or Win32 when using GDI, there is a |
| 1843 // delay between when content is drawn to the screen, and when the | 1843 // delay between when content is drawn to the screen, and when the |
| 1844 // snapshot will actually pick up that content. Insert a manual delay of | 1844 // snapshot will actually pick up that content. Insert a manual delay of |
| 1845 // 1/6th of a second (to simulate 10 frames at 60 fps) before actually | 1845 // 1/6th of a second (to simulate 10 frames at 60 fps) before actually |
| 1846 // taking the snapshot. | 1846 // taking the snapshot. |
| 1847 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1847 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1848 FROM_HERE, | 1848 FROM_HERE, |
| 1849 base::Bind(&RenderWidgetHostImpl::WindowSnapshotReachedScreen, | 1849 base::Bind(&RenderWidgetHostImpl::WindowSnapshotReachedScreen, |
| 1850 weak_factory_.GetWeakPtr(), sequence_number), | 1850 weak_factory_.GetWeakPtr(), snapshot_id), |
| 1851 base::TimeDelta::FromSecondsD(1. / 6)); | 1851 base::TimeDelta::FromSecondsD(1. / 6)); |
| 1852 #else | 1852 #else |
| 1853 WindowSnapshotReachedScreen(sequence_number); | 1853 WindowSnapshotReachedScreen(snapshot_id); |
| 1854 #endif | 1854 #endif |
| 1855 } | 1855 } |
| 1856 | 1856 |
| 1857 latency_tracker_.OnGpuSwapBuffersCompleted(latency_info); | 1857 latency_tracker_.OnGpuSwapBuffersCompleted(latency_info); |
| 1858 } | 1858 } |
| 1859 | 1859 |
| 1860 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { | 1860 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { |
| 1861 // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case | 1861 // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case |
| 1862 // it handles destruction. | 1862 // it handles destruction. |
| 1863 if (!owned_by_render_frame_host_) { | 1863 if (!owned_by_render_frame_host_) { |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2669 device::mojom::WakeLockType::PreventDisplaySleep, | 2669 device::mojom::WakeLockType::PreventDisplaySleep, |
| 2670 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", | 2670 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", |
| 2671 std::move(request)); | 2671 std::move(request)); |
| 2672 } | 2672 } |
| 2673 } | 2673 } |
| 2674 return wake_lock_.get(); | 2674 return wake_lock_.get(); |
| 2675 } | 2675 } |
| 2676 #endif | 2676 #endif |
| 2677 | 2677 |
| 2678 } // namespace content | 2678 } // namespace content |
| OLD | NEW |