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

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: rebase 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 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 1813
1814 bool RenderWidgetHostImpl::OnSwapCompositorFrame( 1814 bool RenderWidgetHostImpl::OnSwapCompositorFrame(
1815 const IPC::Message& message) { 1815 const IPC::Message& message) {
1816 // This trace event is used in 1816 // This trace event is used in
1817 // chrome/browser/extensions/api/cast_streaming/performance_test.cc 1817 // chrome/browser/extensions/api/cast_streaming/performance_test.cc
1818 TRACE_EVENT0("test_fps,benchmark", "OnSwapCompositorFrame"); 1818 TRACE_EVENT0("test_fps,benchmark", "OnSwapCompositorFrame");
1819 1819
1820 ViewHostMsg_SwapCompositorFrame::Param param; 1820 ViewHostMsg_SwapCompositorFrame::Param param;
1821 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param)) 1821 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, &param))
1822 return false; 1822 return false;
1823 cc::CompositorFrame frame(std::move(std::get<1>(param)));
1824 uint32_t compositor_frame_sink_id = std::get<0>(param); 1823 uint32_t compositor_frame_sink_id = std::get<0>(param);
1824 cc::LocalSurfaceId local_surface_id = std::get<1>(param);
1825 cc::CompositorFrame frame(std::move(std::get<2>(param)));
1825 std::vector<IPC::Message> messages_to_deliver_with_frame; 1826 std::vector<IPC::Message> messages_to_deliver_with_frame;
1826 messages_to_deliver_with_frame.swap(std::get<2>(param)); 1827 messages_to_deliver_with_frame.swap(std::get<3>(param));
1828
1829 // The renderer should not send empty frames.
1830 if (frame.render_pass_list.empty()) {
1831 DLOG(ERROR) << "Renderer sent an empty frame.";
1832 return false;
1833 }
1834
1835 // The renderer must allocate a new LocalSurfaceId if frame size or device
1836 // scale factor changes.
1837 float device_scale_factor = frame.metadata.device_scale_factor;
1838 const gfx::Size& frame_size =
1839 frame.render_pass_list.back()->output_rect.size();
1840 if (local_surface_id == last_local_surface_id_ &&
1841 (frame_size != last_frame_size_ ||
1842 device_scale_factor != last_device_scale_factor_)) {
1843 DLOG(ERROR) << "Renderer submitted frame of wrong size to its surface."
1844 << " Expected: size=" << last_frame_size_.ToString()
1845 << ",scale=" << last_device_scale_factor_
1846 << " Received: size=" << frame_size.ToString()
1847 << ",scale=" << device_scale_factor;
1848 return false;
1849 }
1850 last_local_surface_id_ = local_surface_id;
1851 last_frame_size_ = frame_size;
1852 last_device_scale_factor_ = device_scale_factor;
1827 1853
1828 if (frame.metadata.begin_frame_ack.sequence_number < 1854 if (frame.metadata.begin_frame_ack.sequence_number <
1829 cc::BeginFrameArgs::kStartingFrameNumber) { 1855 cc::BeginFrameArgs::kStartingFrameNumber) {
1830 // Received an invalid ack, renderer misbehaved. 1856 // Received an invalid ack, renderer misbehaved.
1831 bad_message::ReceivedBadMessage( 1857 bad_message::ReceivedBadMessage(
1832 GetProcess(), 1858 GetProcess(),
1833 bad_message::RWH_INVALID_BEGIN_FRAME_ACK_COMPOSITOR_FRAME); 1859 bad_message::RWH_INVALID_BEGIN_FRAME_ACK_COMPOSITOR_FRAME);
1834 return false; 1860 return false;
1835 } 1861 }
1836 // |has_damage| and |remaining_frames| are not transmitted. 1862 // |has_damage| and |remaining_frames| are not transmitted.
(...skipping 12 matching lines...) Expand all
1849 if (touch_emulator_) 1875 if (touch_emulator_)
1850 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized); 1876 touch_emulator_->SetDoubleTapSupportForPageEnabled(!is_mobile_optimized);
1851 1877
1852 // Ignore this frame if its content has already been unloaded. Source ID 1878 // Ignore this frame if its content has already been unloaded. Source ID
1853 // is always zero for an OOPIF because we are only concerned with displaying 1879 // is always zero for an OOPIF because we are only concerned with displaying
1854 // stale graphics on top-level frames. We accept frames that have a source ID 1880 // stale graphics on top-level frames. We accept frames that have a source ID
1855 // greater than |current_content_source_id_| because in some cases the first 1881 // greater than |current_content_source_id_| because in some cases the first
1856 // compositor frame can arrive before the navigation commit message that 1882 // compositor frame can arrive before the navigation commit message that
1857 // updates that value. 1883 // updates that value.
1858 if (view_ && frame.metadata.content_source_id >= current_content_source_id_) { 1884 if (view_ && frame.metadata.content_source_id >= current_content_source_id_) {
1859 view_->OnSwapCompositorFrame(compositor_frame_sink_id, std::move(frame)); 1885 view_->OnSwapCompositorFrame(compositor_frame_sink_id, local_surface_id,
1886 std::move(frame));
1860 view_->DidReceiveRendererFrame(); 1887 view_->DidReceiveRendererFrame();
1861 } else { 1888 } else {
1862 cc::ReturnedResourceArray resources; 1889 cc::ReturnedResourceArray resources;
1863 cc::TransferableResource::ReturnResources(frame.resource_list, &resources); 1890 cc::TransferableResource::ReturnResources(frame.resource_list, &resources);
1864 SendReclaimCompositorResources(routing_id_, compositor_frame_sink_id, 1891 SendReclaimCompositorResources(routing_id_, compositor_frame_sink_id,
1865 process_->GetID(), true /* is_swap_ack */, 1892 process_->GetID(), true /* is_swap_ack */,
1866 resources); 1893 resources);
1867 } 1894 }
1868 1895
1869 RenderProcessHost* rph = GetProcess(); 1896 RenderProcessHost* rph = GetProcess();
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
2588 // different from the receiver's. 2615 // different from the receiver's.
2589 file_system_file.url = 2616 file_system_file.url =
2590 GURL(storage::GetIsolatedFileSystemRootURIString( 2617 GURL(storage::GetIsolatedFileSystemRootURIString(
2591 file_system_url.origin(), filesystem_id, std::string()) 2618 file_system_url.origin(), filesystem_id, std::string())
2592 .append(register_name)); 2619 .append(register_name));
2593 file_system_file.filesystem_id = filesystem_id; 2620 file_system_file.filesystem_id = filesystem_id;
2594 } 2621 }
2595 } 2622 }
2596 2623
2597 } // namespace content 2624 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698