Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2728183002: RendererCompositorFrameSink should handle local surface id allocation (Closed)
Patch Set: notreached Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 1816
1817 bool RenderWidgetHostImpl::OnSwapCompositorFrame( 1817 bool RenderWidgetHostImpl::OnSwapCompositorFrame(
1818 const IPC::Message& message) { 1818 const IPC::Message& message) {
1819 // This trace event is used in 1819 // This trace event is used in
1820 // chrome/browser/extensions/api/cast_streaming/performance_test.cc 1820 // chrome/browser/extensions/api/cast_streaming/performance_test.cc
1821 TRACE_EVENT0("test_fps,benchmark", "OnSwapCompositorFrame"); 1821 TRACE_EVENT0("test_fps,benchmark", "OnSwapCompositorFrame");
1822 1822
1823 ViewHostMsg_SwapCompositorFrame::Param param; 1823 ViewHostMsg_SwapCompositorFrame::Param param;
1824 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param)) 1824 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param))
1825 return false; 1825 return false;
1826 cc::CompositorFrame frame(std::move(std::get<1>(param)));
1827 uint32_t compositor_frame_sink_id = std::get<0>(param); 1826 uint32_t compositor_frame_sink_id = std::get<0>(param);
1827 cc::LocalSurfaceId local_surface_id = std::get<1>(param);
1828 cc::CompositorFrame frame(std::move(std::get<2>(param)));
1828 std::vector<IPC::Message> messages_to_deliver_with_frame; 1829 std::vector<IPC::Message> messages_to_deliver_with_frame;
1829 messages_to_deliver_with_frame.swap(std::get<2>(param)); 1830 messages_to_deliver_with_frame.swap(std::get<3>(param));
1831
1832 // The renderer should not send empty frames.
1833 if (frame.render_pass_list.empty()) {
1834 NOTREACHED();
piman 2017/03/20 22:51:45 nit: not NOTREACHED because it can be reached from
Saman Sami 2017/03/21 16:33:38 Done.
1835 return false;
1836 }
1837
1838 // The renderer must allocate a new LocalSurfaceId if frame size or device
1839 // scale factor changes.
1840 float device_scale_factor = frame.metadata.device_scale_factor;
1841 const gfx::Size& frame_size =
1842 frame.render_pass_list.back()->output_rect.size();
1843 if (local_surface_id == last_local_surface_id_ &&
1844 (frame_size != last_frame_size_ ||
1845 device_scale_factor != last_device_scale_factor_)) {
1846 NOTREACHED();
piman 2017/03/20 22:51:45 nit: ditto
Saman Sami 2017/03/21 16:33:38 Done.
1847 return false;
1848 }
1849 last_local_surface_id_ = local_surface_id;
piman 2017/03/20 22:51:45 To confirm: is checking the last local_surface_id
Saman Sami 2017/03/21 02:10:25 Good question. If the renderer alternates between
Saman Sami 2017/03/21 16:33:38 I guess my point is that we cared about two consec
1850 last_frame_size_ = frame_size;
1851 last_device_scale_factor_ = device_scale_factor;
1830 1852
1831 if (frame.metadata.begin_frame_ack.sequence_number < 1853 if (frame.metadata.begin_frame_ack.sequence_number <
1832 cc::BeginFrameArgs::kStartingFrameNumber) { 1854 cc::BeginFrameArgs::kStartingFrameNumber) {
1833 // Received an invalid ack, renderer misbehaved. 1855 // Received an invalid ack, renderer misbehaved.
1834 bad_message::ReceivedBadMessage( 1856 bad_message::ReceivedBadMessage(
1835 GetProcess(), 1857 GetProcess(),
1836 bad_message::RWH_INVALID_BEGIN_FRAME_ACK_COMPOSITOR_FRAME); 1858 bad_message::RWH_INVALID_BEGIN_FRAME_ACK_COMPOSITOR_FRAME);
1837 return false; 1859 return false;
1838 } 1860 }
1839 // |has_damage| and |remaining_frames| are not transmitted. 1861 // |has_damage| and |remaining_frames| are not transmitted.
(...skipping 12 matching lines...) Expand all
1852 if (touch_emulator_) 1874 if (touch_emulator_)
1853 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); 1875 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized);
1854 1876
1855 // Ignore this frame if its content has already been unloaded. Source ID 1877 // Ignore this frame if its content has already been unloaded. Source ID
1856 // is always zero for an OOPIF because we are only concerned with displaying 1878 // is always zero for an OOPIF because we are only concerned with displaying
1857 // stale graphics on top-level frames. We accept frames that have a source ID 1879 // stale graphics on top-level frames. We accept frames that have a source ID
1858 // greater than |current_content_source_id_| because in some cases the first 1880 // greater than |current_content_source_id_| because in some cases the first
1859 // compositor frame can arrive before the navigation commit message that 1881 // compositor frame can arrive before the navigation commit message that
1860 // updates that value. 1882 // updates that value.
1861 if (view_ && frame.metadata.content_source_id >= current_content_source_id_) { 1883 if (view_ && frame.metadata.content_source_id >= current_content_source_id_) {
1862 view_->OnSwapCompositorFrame(compositor_frame_sink_id, std::move(frame)); 1884 view_->OnSwapCompositorFrame(compositor_frame_sink_id, local_surface_id,
1885 std::move(frame));
1863 view_->DidReceiveRendererFrame(); 1886 view_->DidReceiveRendererFrame();
1864 } else { 1887 } else {
1865 cc::ReturnedResourceArray resources; 1888 cc::ReturnedResourceArray resources;
1866 cc::TransferableResource::ReturnResources(frame.resource_list, &resources); 1889 cc::TransferableResource::ReturnResources(frame.resource_list, &resources);
1867 SendReclaimCompositorResources(routing_id_, compositor_frame_sink_id, 1890 SendReclaimCompositorResources(routing_id_, compositor_frame_sink_id,
1868 process_->GetID(), true /* is_swap_ack */, 1891 process_->GetID(), true /* is_swap_ack */,
1869 resources); 1892 resources);
1870 } 1893 }
1871 1894
1872 RenderProcessHost* rph = GetProcess(); 1895 RenderProcessHost* rph = GetProcess();
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
2591 // different from the receiver's. 2614 // different from the receiver's.
2592 file_system_file.url = 2615 file_system_file.url =
2593 GURL(storage::GetIsolatedFileSystemRootURIString( 2616 GURL(storage::GetIsolatedFileSystemRootURIString(
2594 file_system_url.origin(), filesystem_id, std::string()) 2617 file_system_url.origin(), filesystem_id, std::string())
2595 .append(register_name)); 2618 .append(register_name));
2596 file_system_file.filesystem_id = filesystem_id; 2619 file_system_file.filesystem_id = filesystem_id;
2597 } 2620 }
2598 } 2621 }
2599 2622
2600 } // namespace content 2623 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698