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

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

Issue 2144733005: [WIP] cc: Plumb SurfaceId from clients Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure only SurfaceFactoy and tests can update hierarchy Created 4 years, 5 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_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <tuple> 10 #include <tuple>
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), 1638 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
1639 gfx::Rect()); 1639 gfx::Rect());
1640 view_->SetSize(view_size); 1640 view_->SetSize(view_size);
1641 view_->Show(); 1641 view_->Show();
1642 sink_->ClearMessages(); 1642 sink_->ClearMessages();
1643 1643
1644 view_->ResetCompositor(); 1644 view_->ResetCompositor();
1645 1645
1646 // Swapping a frame should trigger a swap ACK IPC because we have reset the 1646 // Swapping a frame should trigger a swap ACK IPC because we have reset the
1647 // compositor. 1647 // compositor.
1648 view_->OnSwapCompositorFrame(0, 1648 view_->OnSwapCompositorFrame(0, cc::SurfaceId(1, 1, 1),
1649 MakeDelegatedFrame(1.f, view_size, view_rect)); 1649 MakeDelegatedFrame(1.f, view_size, view_rect));
1650 EXPECT_EQ(1u, sink_->message_count()); 1650 EXPECT_EQ(1u, sink_->message_count());
1651 { 1651 {
1652 const IPC::Message* msg = sink_->GetMessageAt(0); 1652 const IPC::Message* msg = sink_->GetMessageAt(0);
1653 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type()); 1653 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type());
1654 ViewMsg_ReclaimCompositorResources::Param params; 1654 ViewMsg_ReclaimCompositorResources::Param params;
1655 ViewMsg_ReclaimCompositorResources::Read(msg, &params); 1655 ViewMsg_ReclaimCompositorResources::Read(msg, &params);
1656 EXPECT_EQ(0u, std::get<0>(params)); // output_surface_id 1656 EXPECT_EQ(0u, std::get<0>(params)); // output_surface_id
1657 EXPECT_TRUE(std::get<1>(params)); // is_swap_ack 1657 EXPECT_TRUE(std::get<1>(params)); // is_swap_ack
1658 } 1658 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 } 1690 }
1691 1691
1692 // This test verifies that when the output_surface_id changes, then 1692 // This test verifies that when the output_surface_id changes, then
1693 // DelegateFrameHost returns compositor resources without a swap ack. 1693 // DelegateFrameHost returns compositor resources without a swap ack.
1694 TEST_F(RenderWidgetHostViewAuraTest, TwoOutputSurfaces) { 1694 TEST_F(RenderWidgetHostViewAuraTest, TwoOutputSurfaces) {
1695 FakeSurfaceDamageObserver damage_observer; 1695 FakeSurfaceDamageObserver damage_observer;
1696 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1696 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1697 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1697 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1698 manager->AddObserver(&damage_observer); 1698 manager->AddObserver(&damage_observer);
1699 1699
1700 // Wait for the ui::Compositor to get an OutputSurface and a SurfaceFactory.
1701 // The surfaces system will then be able to install a destruction dependency
1702 // between the child client and the ui::Compositor ensuring that calling
1703 // SurfaceFactory::Destroy on a child surface does not immediately destroy
1704 // the surface.
1705 aura::Window* root_window = aura_test_helper_->root_window();
1706 ui::DrawWaiterForTest::WaitForCompositingInitialized(
1707 root_window->GetHost()->compositor());
1708
1700 gfx::Size view_size(100, 100); 1709 gfx::Size view_size(100, 100);
1701 gfx::Rect view_rect(view_size); 1710 gfx::Rect view_rect(view_size);
1702 1711
1703 view_->InitAsChild(nullptr); 1712 view_->InitAsChild(nullptr);
1704 aura::client::ParentWindowWithContext( 1713 aura::client::ParentWindowWithContext(
1705 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), 1714 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
1706 gfx::Rect()); 1715 gfx::Rect());
1707 view_->SetSize(view_size); 1716 view_->SetSize(view_size);
1708 view_->Show(); 1717 view_->Show();
1709 sink_->ClearMessages(); 1718 sink_->ClearMessages();
1710 1719
1711 view_->OnSwapCompositorFrame(0, 1720 view_->OnSwapCompositorFrame(0, cc::SurfaceId(1, 1, 1),
1712 MakeDelegatedFrame(1.f, view_size, view_rect)); 1721 MakeDelegatedFrame(1.f, view_size, view_rect));
1713 1722
1714 // Accumulate some returned resources. This should not trigger an IPC. 1723 // Accumulate some returned resources. This should not trigger an IPC.
1715 cc::ReturnedResourceArray resources; 1724 cc::ReturnedResourceArray resources;
1716 cc::ReturnedResource resource; 1725 cc::ReturnedResource resource;
1717 resource.id = 1; 1726 resource.id = 1;
1718 resources.push_back(resource); 1727 resources.push_back(resource);
1719 view_->ReturnResources(resources); 1728 view_->ReturnResources(resources);
1720 EXPECT_EQ(0u, sink_->message_count()); 1729 EXPECT_EQ(0u, sink_->message_count());
1721 1730
1722 // Swap another CompositorFrame but this time from another output_surface_id. 1731 // Swap another CompositorFrame but this time from another output_surface_id.
1723 // This should trigger a non-ACK ReclaimCompositorResources IPC. 1732 // This should trigger a non-ACK ReclaimCompositorResources IPC.
1724 view_->OnSwapCompositorFrame(1, 1733 view_->OnSwapCompositorFrame(1, cc::SurfaceId(1, 2, 1),
1725 MakeDelegatedFrame(1.f, view_size, view_rect)); 1734 MakeDelegatedFrame(1.f, view_size, view_rect));
1726 EXPECT_EQ(1u, sink_->message_count()); 1735 EXPECT_EQ(1u, sink_->message_count());
1727 { 1736 {
1728 const IPC::Message* msg = sink_->GetMessageAt(0); 1737 const IPC::Message* msg = sink_->GetMessageAt(0);
1729 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type()); 1738 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, msg->type());
1730 ViewMsg_ReclaimCompositorResources::Param params; 1739 ViewMsg_ReclaimCompositorResources::Param params;
1731 ViewMsg_ReclaimCompositorResources::Read(msg, &params); 1740 ViewMsg_ReclaimCompositorResources::Read(msg, &params);
1732 EXPECT_EQ(0u, std::get<0>(params)); // output_surface_id 1741 EXPECT_EQ(0u, std::get<0>(params)); // output_surface_id
1733 EXPECT_FALSE(std::get<1>(params)); // is_swap_ack 1742 EXPECT_FALSE(std::get<1>(params)); // is_swap_ack
1734 } 1743 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); 1778 EXPECT_EQ(ViewMsg_Resize::ID, msg->type());
1770 ViewMsg_Resize::Param params; 1779 ViewMsg_Resize::Param params;
1771 ViewMsg_Resize::Read(msg, &params); 1780 ViewMsg_Resize::Read(msg, &params);
1772 EXPECT_EQ( 1781 EXPECT_EQ(
1773 "0,0 800x600", 1782 "0,0 800x600",
1774 gfx::Rect(std::get<0>(params).screen_info.availableRect).ToString()); 1783 gfx::Rect(std::get<0>(params).screen_info.availableRect).ToString());
1775 EXPECT_EQ("800x600", std::get<0>(params).new_size.ToString()); 1784 EXPECT_EQ("800x600", std::get<0>(params).new_size.ToString());
1776 // Resizes are blocked until we swapped a frame of the correct size, and 1785 // Resizes are blocked until we swapped a frame of the correct size, and
1777 // we've committed it. 1786 // we've committed it.
1778 view_->OnSwapCompositorFrame( 1787 view_->OnSwapCompositorFrame(
1779 0, MakeDelegatedFrame(1.f, std::get<0>(params).new_size, 1788 0, cc::SurfaceId(1, 1, 1),
1780 gfx::Rect(std::get<0>(params).new_size))); 1789 MakeDelegatedFrame(1.f, std::get<0>(params).new_size,
1790 gfx::Rect(std::get<0>(params).new_size)));
1781 ui::DrawWaiterForTest::WaitForCommit( 1791 ui::DrawWaiterForTest::WaitForCommit(
1782 root_window->GetHost()->compositor()); 1792 root_window->GetHost()->compositor());
1783 } 1793 }
1784 1794
1785 widget_host_->ResetSizeAndRepaintPendingFlags(); 1795 widget_host_->ResetSizeAndRepaintPendingFlags();
1786 sink_->ClearMessages(); 1796 sink_->ClearMessages();
1787 1797
1788 // Make sure the corrent screen size is set along in the resize 1798 // Make sure the corrent screen size is set along in the resize
1789 // request when the screen size has changed. 1799 // request when the screen size has changed.
1790 aura_test_helper_->test_screen()->SetUIScale(0.5); 1800 aura_test_helper_->test_screen()->SetUIScale(0.5);
1791 EXPECT_EQ(1u, sink_->message_count()); 1801 EXPECT_EQ(1u, sink_->message_count());
1792 { 1802 {
1793 const IPC::Message* msg = sink_->GetMessageAt(0); 1803 const IPC::Message* msg = sink_->GetMessageAt(0);
1794 EXPECT_EQ(ViewMsg_Resize::ID, msg->type()); 1804 EXPECT_EQ(ViewMsg_Resize::ID, msg->type());
1795 ViewMsg_Resize::Param params; 1805 ViewMsg_Resize::Param params;
1796 ViewMsg_Resize::Read(msg, &params); 1806 ViewMsg_Resize::Read(msg, &params);
1797 EXPECT_EQ( 1807 EXPECT_EQ(
1798 "0,0 1600x1200", 1808 "0,0 1600x1200",
1799 gfx::Rect(std::get<0>(params).screen_info.availableRect).ToString()); 1809 gfx::Rect(std::get<0>(params).screen_info.availableRect).ToString());
1800 EXPECT_EQ("1600x1200", std::get<0>(params).new_size.ToString()); 1810 EXPECT_EQ("1600x1200", std::get<0>(params).new_size.ToString());
1801 view_->OnSwapCompositorFrame( 1811 view_->OnSwapCompositorFrame(
1802 0, MakeDelegatedFrame(1.f, std::get<0>(params).new_size, 1812 0, cc::SurfaceId(1, 2, 1),
1803 gfx::Rect(std::get<0>(params).new_size))); 1813 MakeDelegatedFrame(1.f, std::get<0>(params).new_size,
1814 gfx::Rect(std::get<0>(params).new_size)));
1804 ui::DrawWaiterForTest::WaitForCommit( 1815 ui::DrawWaiterForTest::WaitForCommit(
1805 root_window->GetHost()->compositor()); 1816 root_window->GetHost()->compositor());
1806 } 1817 }
1807 } 1818 }
1808 1819
1809 // Swapping a frame should notify the window. 1820 // Swapping a frame should notify the window.
1810 TEST_F(RenderWidgetHostViewAuraTest, SwapNotifiesWindow) { 1821 TEST_F(RenderWidgetHostViewAuraTest, SwapNotifiesWindow) {
1811 gfx::Size view_size(100, 100); 1822 gfx::Size view_size(100, 100);
1812 gfx::Rect view_rect(view_size); 1823 gfx::Rect view_rect(view_size);
1813 1824
1814 view_->InitAsChild(nullptr); 1825 view_->InitAsChild(nullptr);
1815 aura::client::ParentWindowWithContext( 1826 aura::client::ParentWindowWithContext(
1816 view_->GetNativeView(), 1827 view_->GetNativeView(),
1817 parent_view_->GetNativeView()->GetRootWindow(), 1828 parent_view_->GetNativeView()->GetRootWindow(),
1818 gfx::Rect()); 1829 gfx::Rect());
1819 view_->SetSize(view_size); 1830 view_->SetSize(view_size);
1820 view_->Show(); 1831 view_->Show();
1821 1832
1822 MockWindowObserver observer; 1833 MockWindowObserver observer;
1823 view_->window_->AddObserver(&observer); 1834 view_->window_->AddObserver(&observer);
1824 1835
1825 // Delegated renderer path 1836 // Delegated renderer path
1826 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect)); 1837 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect));
1827 view_->OnSwapCompositorFrame( 1838 view_->OnSwapCompositorFrame(0, cc::SurfaceId(1, 1, 1),
1828 0, MakeDelegatedFrame(1.f, view_size, view_rect)); 1839 MakeDelegatedFrame(1.f, view_size, view_rect));
1829 testing::Mock::VerifyAndClearExpectations(&observer); 1840 testing::Mock::VerifyAndClearExpectations(&observer);
1830 1841
1831 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, 1842 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_,
1832 gfx::Rect(5, 5, 5, 5))); 1843 gfx::Rect(5, 5, 5, 5)));
1833 view_->OnSwapCompositorFrame( 1844 view_->OnSwapCompositorFrame(
1834 0, MakeDelegatedFrame(1.f, view_size, gfx::Rect(5, 5, 5, 5))); 1845 0, cc::SurfaceId(1, 1, 1),
1846 MakeDelegatedFrame(1.f, view_size, gfx::Rect(5, 5, 5, 5)));
1835 testing::Mock::VerifyAndClearExpectations(&observer); 1847 testing::Mock::VerifyAndClearExpectations(&observer);
1836 1848
1837 view_->window_->RemoveObserver(&observer); 1849 view_->window_->RemoveObserver(&observer);
1838 } 1850 }
1839 1851
1840 // Recreating the layers for a window should cause Surface destruction to 1852 // Recreating the layers for a window should cause Surface destruction to
1841 // depend on both layers. 1853 // depend on both layers.
1842 TEST_F(RenderWidgetHostViewAuraTest, RecreateLayers) { 1854 TEST_F(RenderWidgetHostViewAuraTest, RecreateLayers) {
1843 gfx::Size view_size(100, 100); 1855 gfx::Size view_size(100, 100);
1844 gfx::Rect view_rect(view_size); 1856 gfx::Rect view_rect(view_size);
1845 1857
1846 view_->InitAsChild(nullptr); 1858 view_->InitAsChild(nullptr);
1847 aura::client::ParentWindowWithContext( 1859 aura::client::ParentWindowWithContext(
1848 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), 1860 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
1849 gfx::Rect()); 1861 gfx::Rect());
1850 view_->SetSize(view_size); 1862 view_->SetSize(view_size);
1851 view_->Show(); 1863 view_->Show();
1852 1864
1853 view_->OnSwapCompositorFrame(0, 1865 view_->OnSwapCompositorFrame(0, cc::SurfaceId(1, 1, 1),
1854 MakeDelegatedFrame(1.f, view_size, view_rect)); 1866 MakeDelegatedFrame(1.f, view_size, view_rect));
1855 std::unique_ptr<ui::LayerTreeOwner> cloned_owner( 1867 std::unique_ptr<ui::LayerTreeOwner> cloned_owner(
1856 wm::RecreateLayers(view_->GetNativeView(), nullptr)); 1868 wm::RecreateLayers(view_->GetNativeView(), nullptr));
1857 1869
1858 cc::SurfaceId id = view_->GetDelegatedFrameHost()->SurfaceIdForTesting(); 1870 cc::SurfaceId id = view_->GetDelegatedFrameHost()->SurfaceIdForTesting();
1859 if (!id.is_null()) { 1871 if (!id.is_null()) {
1860 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1872 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1861 cc::SurfaceManager* manager = factory->GetSurfaceManager(); 1873 cc::SurfaceManager* manager = factory->GetSurfaceManager();
1862 cc::Surface* surface = manager->GetSurfaceForId(id); 1874 cc::Surface* surface = manager->GetSurfaceForId(id);
1863 EXPECT_TRUE(surface); 1875 EXPECT_TRUE(surface);
(...skipping 14 matching lines...) Expand all
1878 1890
1879 view_->InitAsChild(nullptr); 1891 view_->InitAsChild(nullptr);
1880 aura::client::ParentWindowWithContext( 1892 aura::client::ParentWindowWithContext(
1881 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(), 1893 view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
1882 gfx::Rect()); 1894 gfx::Rect());
1883 view_->SetSize(large_size); 1895 view_->SetSize(large_size);
1884 view_->Show(); 1896 view_->Show();
1885 cc::CompositorFrame frame = 1897 cc::CompositorFrame frame =
1886 MakeDelegatedFrame(1.f, small_size, gfx::Rect(small_size)); 1898 MakeDelegatedFrame(1.f, small_size, gfx::Rect(small_size));
1887 frame.metadata.root_background_color = SK_ColorRED; 1899 frame.metadata.root_background_color = SK_ColorRED;
1888 view_->OnSwapCompositorFrame(0, std::move(frame)); 1900 view_->OnSwapCompositorFrame(0, cc::SurfaceId(1, 1, 1), std::move(frame));
1889 1901
1890 ui::Layer* parent_layer = view_->GetNativeView()->layer(); 1902 ui::Layer* parent_layer = view_->GetNativeView()->layer();
1891 1903
1892 ASSERT_EQ(2u, parent_layer->children().size()); 1904 ASSERT_EQ(2u, parent_layer->children().size());
1893 EXPECT_EQ(gfx::Rect(40, 0, 60, 100), parent_layer->children()[0]->bounds()); 1905 EXPECT_EQ(gfx::Rect(40, 0, 60, 100), parent_layer->children()[0]->bounds());
1894 EXPECT_EQ(SK_ColorRED, parent_layer->children()[0]->background_color()); 1906 EXPECT_EQ(SK_ColorRED, parent_layer->children()[0]->background_color());
1895 EXPECT_EQ(gfx::Rect(0, 45, 40, 55), parent_layer->children()[1]->bounds()); 1907 EXPECT_EQ(gfx::Rect(0, 45, 40, 55), parent_layer->children()[1]->bounds());
1896 EXPECT_EQ(SK_ColorRED, parent_layer->children()[1]->background_color()); 1908 EXPECT_EQ(SK_ColorRED, parent_layer->children()[1]->background_color());
1897 1909
1898 delegates_.back()->set_is_fullscreen(true); 1910 delegates_.back()->set_is_fullscreen(true);
1899 view_->SetSize(medium_size); 1911 view_->SetSize(medium_size);
1900 1912
1901 // Right gutter is unnecessary. 1913 // Right gutter is unnecessary.
1902 ASSERT_EQ(1u, parent_layer->children().size()); 1914 ASSERT_EQ(1u, parent_layer->children().size());
1903 EXPECT_EQ(gfx::Rect(0, 45, 40, 50), parent_layer->children()[0]->bounds()); 1915 EXPECT_EQ(gfx::Rect(0, 45, 40, 50), parent_layer->children()[0]->bounds());
1904 1916
1905 // RWH is fullscreen, so gutters should be black. 1917 // RWH is fullscreen, so gutters should be black.
1906 EXPECT_EQ(SK_ColorBLACK, parent_layer->children()[0]->background_color()); 1918 EXPECT_EQ(SK_ColorBLACK, parent_layer->children()[0]->background_color());
1907 1919
1908 frame = MakeDelegatedFrame(1.f, medium_size, gfx::Rect(medium_size)); 1920 frame = MakeDelegatedFrame(1.f, medium_size, gfx::Rect(medium_size));
1909 view_->OnSwapCompositorFrame(0, std::move(frame)); 1921 view_->OnSwapCompositorFrame(0, cc::SurfaceId(1, 1, 1), std::move(frame));
1910 EXPECT_EQ(0u, parent_layer->children().size()); 1922 EXPECT_EQ(0u, parent_layer->children().size());
1911 1923
1912 view_->SetSize(large_size); 1924 view_->SetSize(large_size);
1913 ASSERT_EQ(2u, parent_layer->children().size()); 1925 ASSERT_EQ(2u, parent_layer->children().size());
1914 1926
1915 // This should evict the frame and remove the gutter layers. 1927 // This should evict the frame and remove the gutter layers.
1916 view_->Hide(); 1928 view_->Hide();
1917 view_->SetSize(small_size); 1929 view_->SetSize(small_size);
1918 ASSERT_EQ(0u, parent_layer->children().size()); 1930 ASSERT_EQ(0u, parent_layer->children().size());
1919 } 1931 }
1920 1932
1921 TEST_F(RenderWidgetHostViewAuraTest, Resize) { 1933 TEST_F(RenderWidgetHostViewAuraTest, Resize) {
1922 gfx::Size size1(100, 100); 1934 gfx::Size size1(100, 100);
1923 gfx::Size size2(200, 200); 1935 gfx::Size size2(200, 200);
1924 gfx::Size size3(300, 300); 1936 gfx::Size size3(300, 300);
1925 1937
1926 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow(); 1938 aura::Window* root_window = parent_view_->GetNativeView()->GetRootWindow();
1927 view_->InitAsChild(nullptr); 1939 view_->InitAsChild(nullptr);
1928 aura::client::ParentWindowWithContext( 1940 aura::client::ParentWindowWithContext(
1929 view_->GetNativeView(), root_window, gfx::Rect(size1)); 1941 view_->GetNativeView(), root_window, gfx::Rect(size1));
1930 view_->Show(); 1942 view_->Show();
1931 view_->SetSize(size1); 1943 view_->SetSize(size1);
1932 view_->OnSwapCompositorFrame( 1944 view_->OnSwapCompositorFrame(
1933 0, MakeDelegatedFrame(1.f, size1, gfx::Rect(size1))); 1945 0, cc::SurfaceId(1, 1, 1),
1946 MakeDelegatedFrame(1.f, size1, gfx::Rect(size1)));
1934 ui::DrawWaiterForTest::WaitForCommit( 1947 ui::DrawWaiterForTest::WaitForCommit(
1935 root_window->GetHost()->compositor()); 1948 root_window->GetHost()->compositor());
1936 ViewHostMsg_UpdateRect_Params update_params; 1949 ViewHostMsg_UpdateRect_Params update_params;
1937 update_params.view_size = size1; 1950 update_params.view_size = size1;
1938 update_params.flags = ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; 1951 update_params.flags = ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK;
1939 widget_host_->OnMessageReceived( 1952 widget_host_->OnMessageReceived(
1940 ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params)); 1953 ViewHostMsg_UpdateRect(widget_host_->GetRoutingID(), update_params));
1941 sink_->ClearMessages(); 1954 sink_->ClearMessages();
1942 // Resize logic is idle (no pending resize, no pending commit). 1955 // Resize logic is idle (no pending resize, no pending commit).
1943 EXPECT_EQ(size1.ToString(), view_->GetRequestedRendererSize().ToString()); 1956 EXPECT_EQ(size1.ToString(), view_->GetRequestedRendererSize().ToString());
(...skipping 17 matching lines...) Expand all
1961 1974
1962 // Resize renderer again, before receiving a frame. Should not produce a 1975 // Resize renderer again, before receiving a frame. Should not produce a
1963 // Resize message. 1976 // Resize message.
1964 view_->SetSize(size3); 1977 view_->SetSize(size3);
1965 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString()); 1978 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString());
1966 EXPECT_EQ(0u, sink_->message_count()); 1979 EXPECT_EQ(0u, sink_->message_count());
1967 1980
1968 // Receive a frame of the new size, should be skipped and not produce a Resize 1981 // Receive a frame of the new size, should be skipped and not produce a Resize
1969 // message. 1982 // message.
1970 view_->OnSwapCompositorFrame( 1983 view_->OnSwapCompositorFrame(
1971 0, MakeDelegatedFrame(1.f, size3, gfx::Rect(size3))); 1984 0, cc::SurfaceId(1, 1, 1),
1985 MakeDelegatedFrame(1.f, size3, gfx::Rect(size3)));
1972 // Expect the frame ack; 1986 // Expect the frame ack;
1973 EXPECT_EQ(1u, sink_->message_count()); 1987 EXPECT_EQ(1u, sink_->message_count());
1974 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID, 1988 EXPECT_EQ(ViewMsg_ReclaimCompositorResources::ID,
1975 sink_->GetMessageAt(0)->type()); 1989 sink_->GetMessageAt(0)->type());
1976 sink_->ClearMessages(); 1990 sink_->ClearMessages();
1977 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString()); 1991 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString());
1978 1992
1979 // Receive a frame of the correct size, should not be skipped and, and should 1993 // Receive a frame of the correct size, should not be skipped and, and should
1980 // produce a Resize message after the commit. 1994 // produce a Resize message after the commit.
1981 view_->OnSwapCompositorFrame( 1995 view_->OnSwapCompositorFrame(
1982 0, MakeDelegatedFrame(1.f, size2, gfx::Rect(size2))); 1996 0, cc::SurfaceId(1, 1, 1),
1997 MakeDelegatedFrame(1.f, size2, gfx::Rect(size2)));
1983 cc::SurfaceId surface_id = view_->surface_id(); 1998 cc::SurfaceId surface_id = view_->surface_id();
1984 if (surface_id.is_null()) { 1999 if (surface_id.is_null()) {
1985 // No frame ack yet. 2000 // No frame ack yet.
1986 EXPECT_EQ(0u, sink_->message_count()); 2001 EXPECT_EQ(0u, sink_->message_count());
1987 } else { 2002 } else {
1988 // Frame isn't desired size, so early ack. 2003 // Frame isn't desired size, so early ack.
1989 EXPECT_EQ(1u, sink_->message_count()); 2004 EXPECT_EQ(1u, sink_->message_count());
1990 } 2005 }
1991 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString()); 2006 EXPECT_EQ(size2.ToString(), view_->GetRequestedRendererSize().ToString());
1992 2007
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 view_->GetNativeView(), 2058 view_->GetNativeView(),
2044 parent_view_->GetNativeView()->GetRootWindow(), 2059 parent_view_->GetNativeView()->GetRootWindow(),
2045 gfx::Rect()); 2060 gfx::Rect());
2046 view_->SetSize(view_rect.size()); 2061 view_->SetSize(view_rect.size());
2047 2062
2048 MockWindowObserver observer; 2063 MockWindowObserver observer;
2049 view_->window_->AddObserver(&observer); 2064 view_->window_->AddObserver(&observer);
2050 2065
2051 // A full frame of damage. 2066 // A full frame of damage.
2052 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect)); 2067 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect));
2053 view_->OnSwapCompositorFrame( 2068 view_->OnSwapCompositorFrame(0, cc::SurfaceId(1, 1, 1),
2054 0, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2069 MakeDelegatedFrame(1.f, frame_size, view_rect));
2055 testing::Mock::VerifyAndClearExpectations(&observer); 2070 testing::Mock::VerifyAndClearExpectations(&observer);
2056 view_->RunOnCompositingDidCommit(); 2071 view_->RunOnCompositingDidCommit();
2057 2072
2058 // A partial damage frame. 2073 // A partial damage frame.
2059 gfx::Rect partial_view_rect(30, 30, 20, 20); 2074 gfx::Rect partial_view_rect(30, 30, 20, 20);
2060 EXPECT_CALL(observer, 2075 EXPECT_CALL(observer,
2061 OnDelegatedFrameDamage(view_->window_, partial_view_rect)); 2076 OnDelegatedFrameDamage(view_->window_, partial_view_rect));
2062 view_->OnSwapCompositorFrame( 2077 view_->OnSwapCompositorFrame(
2063 0, MakeDelegatedFrame(1.f, frame_size, partial_view_rect)); 2078 0, cc::SurfaceId(1, 1, 1),
2079 MakeDelegatedFrame(1.f, frame_size, partial_view_rect));
2064 testing::Mock::VerifyAndClearExpectations(&observer); 2080 testing::Mock::VerifyAndClearExpectations(&observer);
2065 view_->RunOnCompositingDidCommit(); 2081 view_->RunOnCompositingDidCommit();
2066 2082
2067 // Lock the compositor. Now we should drop frames. 2083 // Lock the compositor. Now we should drop frames.
2068 view_rect = gfx::Rect(150, 150); 2084 view_rect = gfx::Rect(150, 150);
2069 view_->SetSize(view_rect.size()); 2085 view_->SetSize(view_rect.size());
2070 2086
2071 // This frame is dropped. 2087 // This frame is dropped.
2072 gfx::Rect dropped_damage_rect_1(10, 20, 30, 40); 2088 gfx::Rect dropped_damage_rect_1(10, 20, 30, 40);
2073 EXPECT_CALL(observer, OnDelegatedFrameDamage(_, _)).Times(0); 2089 EXPECT_CALL(observer, OnDelegatedFrameDamage(_, _)).Times(0);
2074 view_->OnSwapCompositorFrame( 2090 view_->OnSwapCompositorFrame(
2075 0, MakeDelegatedFrame(1.f, frame_size, dropped_damage_rect_1)); 2091 0, cc::SurfaceId(1, 1, 1),
2092 MakeDelegatedFrame(1.f, frame_size, dropped_damage_rect_1));
2076 testing::Mock::VerifyAndClearExpectations(&observer); 2093 testing::Mock::VerifyAndClearExpectations(&observer);
2077 view_->RunOnCompositingDidCommit(); 2094 view_->RunOnCompositingDidCommit();
2078 2095
2079 gfx::Rect dropped_damage_rect_2(40, 50, 10, 20); 2096 gfx::Rect dropped_damage_rect_2(40, 50, 10, 20);
2080 EXPECT_CALL(observer, OnDelegatedFrameDamage(_, _)).Times(0); 2097 EXPECT_CALL(observer, OnDelegatedFrameDamage(_, _)).Times(0);
2081 view_->OnSwapCompositorFrame( 2098 view_->OnSwapCompositorFrame(
2082 0, MakeDelegatedFrame(1.f, frame_size, dropped_damage_rect_2)); 2099 0, cc::SurfaceId(1, 1, 1),
2100 MakeDelegatedFrame(1.f, frame_size, dropped_damage_rect_2));
2083 testing::Mock::VerifyAndClearExpectations(&observer); 2101 testing::Mock::VerifyAndClearExpectations(&observer);
2084 view_->RunOnCompositingDidCommit(); 2102 view_->RunOnCompositingDidCommit();
2085 2103
2086 // Unlock the compositor. This frame should damage everything. 2104 // Unlock the compositor. This frame should damage everything.
2087 frame_size = view_rect.size(); 2105 frame_size = view_rect.size();
2088 2106
2089 gfx::Rect new_damage_rect(5, 6, 10, 10); 2107 gfx::Rect new_damage_rect(5, 6, 10, 10);
2090 EXPECT_CALL(observer, 2108 EXPECT_CALL(observer,
2091 OnDelegatedFrameDamage(view_->window_, view_rect)); 2109 OnDelegatedFrameDamage(view_->window_, view_rect));
2092 view_->OnSwapCompositorFrame( 2110 view_->OnSwapCompositorFrame(
2093 0, MakeDelegatedFrame(1.f, frame_size, new_damage_rect)); 2111 0, cc::SurfaceId(1, 1, 1),
2112 MakeDelegatedFrame(1.f, frame_size, new_damage_rect));
2094 testing::Mock::VerifyAndClearExpectations(&observer); 2113 testing::Mock::VerifyAndClearExpectations(&observer);
2095 view_->RunOnCompositingDidCommit(); 2114 view_->RunOnCompositingDidCommit();
2096 2115
2097 // A partial damage frame, this should not be dropped. 2116 // A partial damage frame, this should not be dropped.
2098 EXPECT_CALL(observer, 2117 EXPECT_CALL(observer,
2099 OnDelegatedFrameDamage(view_->window_, partial_view_rect)); 2118 OnDelegatedFrameDamage(view_->window_, partial_view_rect));
2100 view_->OnSwapCompositorFrame( 2119 view_->OnSwapCompositorFrame(
2101 0, MakeDelegatedFrame(1.f, frame_size, partial_view_rect)); 2120 0, cc::SurfaceId(1, 1, 1),
2121 MakeDelegatedFrame(1.f, frame_size, partial_view_rect));
2102 testing::Mock::VerifyAndClearExpectations(&observer); 2122 testing::Mock::VerifyAndClearExpectations(&observer);
2103 view_->RunOnCompositingDidCommit(); 2123 view_->RunOnCompositingDidCommit();
2104 2124
2105 2125
2106 // Resize to something empty. 2126 // Resize to something empty.
2107 view_rect = gfx::Rect(100, 0); 2127 view_rect = gfx::Rect(100, 0);
2108 view_->SetSize(view_rect.size()); 2128 view_->SetSize(view_rect.size());
2109 2129
2110 // We're never expecting empty frames, resize to something non-empty. 2130 // We're never expecting empty frames, resize to something non-empty.
2111 view_rect = gfx::Rect(100, 100); 2131 view_rect = gfx::Rect(100, 100);
2112 view_->SetSize(view_rect.size()); 2132 view_->SetSize(view_rect.size());
2113 2133
2114 // This frame should not be dropped. 2134 // This frame should not be dropped.
2115 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect)); 2135 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect));
2116 view_->OnSwapCompositorFrame( 2136 view_->OnSwapCompositorFrame(
2117 0, MakeDelegatedFrame(1.f, view_rect.size(), view_rect)); 2137 0, cc::SurfaceId(1, 1, 1),
2138 MakeDelegatedFrame(1.f, view_rect.size(), view_rect));
2118 testing::Mock::VerifyAndClearExpectations(&observer); 2139 testing::Mock::VerifyAndClearExpectations(&observer);
2119 view_->RunOnCompositingDidCommit(); 2140 view_->RunOnCompositingDidCommit();
2120 2141
2121 view_->window_->RemoveObserver(&observer); 2142 view_->window_->RemoveObserver(&observer);
2122 } 2143 }
2123 2144
2124 TEST_F(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange) { 2145 TEST_F(RenderWidgetHostViewAuraTest, OutputSurfaceIdChange) {
2125 gfx::Rect view_rect(100, 100); 2146 gfx::Rect view_rect(100, 100);
2126 gfx::Size frame_size = view_rect.size(); 2147 gfx::Size frame_size = view_rect.size();
2127 2148
2128 view_->InitAsChild(nullptr); 2149 view_->InitAsChild(nullptr);
2129 aura::client::ParentWindowWithContext( 2150 aura::client::ParentWindowWithContext(
2130 view_->GetNativeView(), 2151 view_->GetNativeView(),
2131 parent_view_->GetNativeView()->GetRootWindow(), 2152 parent_view_->GetNativeView()->GetRootWindow(),
2132 gfx::Rect()); 2153 gfx::Rect());
2133 view_->SetSize(view_rect.size()); 2154 view_->SetSize(view_rect.size());
2134 2155
2135 MockWindowObserver observer; 2156 MockWindowObserver observer;
2136 view_->window_->AddObserver(&observer); 2157 view_->window_->AddObserver(&observer);
2137 2158
2138 // Swap a frame. 2159 // Swap a frame.
2139 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect)); 2160 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect));
2140 view_->OnSwapCompositorFrame( 2161 view_->OnSwapCompositorFrame(0, cc::SurfaceId(1, 1, 1),
2141 0, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2162 MakeDelegatedFrame(1.f, frame_size, view_rect));
2142 testing::Mock::VerifyAndClearExpectations(&observer); 2163 testing::Mock::VerifyAndClearExpectations(&observer);
2143 view_->RunOnCompositingDidCommit(); 2164 view_->RunOnCompositingDidCommit();
2144 2165
2145 // Swap a frame with a different surface id. 2166 // Swap a frame with a different surface id.
2146 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect)); 2167 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect));
2147 view_->OnSwapCompositorFrame( 2168 view_->OnSwapCompositorFrame(1, cc::SurfaceId(1, 2, 1),
2148 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2169 MakeDelegatedFrame(1.f, frame_size, view_rect));
2149 testing::Mock::VerifyAndClearExpectations(&observer); 2170 testing::Mock::VerifyAndClearExpectations(&observer);
2150 view_->RunOnCompositingDidCommit(); 2171 view_->RunOnCompositingDidCommit();
2151 2172
2152 // Swap an empty frame, with a different surface id. 2173 // Swap an empty frame, with a different surface id.
2153 view_->OnSwapCompositorFrame( 2174 view_->OnSwapCompositorFrame(
2154 2, MakeDelegatedFrame(1.f, gfx::Size(), gfx::Rect())); 2175 2, cc::SurfaceId(1, 3, 1),
2176 MakeDelegatedFrame(1.f, gfx::Size(), gfx::Rect()));
2155 testing::Mock::VerifyAndClearExpectations(&observer); 2177 testing::Mock::VerifyAndClearExpectations(&observer);
2156 view_->RunOnCompositingDidCommit(); 2178 view_->RunOnCompositingDidCommit();
2157 2179
2158 // Swap another frame, with a different surface id. 2180 // Swap another frame, with a different surface id.
2159 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect)); 2181 EXPECT_CALL(observer, OnDelegatedFrameDamage(view_->window_, view_rect));
2160 view_->OnSwapCompositorFrame(3, 2182 view_->OnSwapCompositorFrame(3, cc::SurfaceId(1, 4, 1),
2161 MakeDelegatedFrame(1.f, frame_size, view_rect)); 2183 MakeDelegatedFrame(1.f, frame_size, view_rect));
2162 testing::Mock::VerifyAndClearExpectations(&observer); 2184 testing::Mock::VerifyAndClearExpectations(&observer);
2163 view_->RunOnCompositingDidCommit(); 2185 view_->RunOnCompositingDidCommit();
2164 2186
2165 view_->window_->RemoveObserver(&observer); 2187 view_->window_->RemoveObserver(&observer);
2166 } 2188 }
2167 2189
2168 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) { 2190 TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFrames) {
2169 view_->InitAsChild(nullptr); 2191 view_->InitAsChild(nullptr);
2170 2192
(...skipping 24 matching lines...) Expand all
2195 views[i]->GetNativeView(), 2217 views[i]->GetNativeView(),
2196 parent_view_->GetNativeView()->GetRootWindow(), 2218 parent_view_->GetNativeView()->GetRootWindow(),
2197 gfx::Rect()); 2219 gfx::Rect());
2198 views[i]->SetSize(view_rect.size()); 2220 views[i]->SetSize(view_rect.size());
2199 } 2221 }
2200 2222
2201 // Make each renderer visible, and swap a frame on it, then make it invisible. 2223 // Make each renderer visible, and swap a frame on it, then make it invisible.
2202 for (size_t i = 0; i < renderer_count; ++i) { 2224 for (size_t i = 0; i < renderer_count; ++i) {
2203 views[i]->Show(); 2225 views[i]->Show();
2204 views[i]->OnSwapCompositorFrame( 2226 views[i]->OnSwapCompositorFrame(
2205 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2227 1, cc::SurfaceId(1 + i, 1, 1),
2228 MakeDelegatedFrame(1.f, frame_size, view_rect));
2206 EXPECT_TRUE(views[i]->HasFrameData()); 2229 EXPECT_TRUE(views[i]->HasFrameData());
2207 views[i]->Hide(); 2230 views[i]->Hide();
2208 } 2231 }
2209 2232
2210 // There should be max_renderer_frames with a frame in it, and one without it. 2233 // There should be max_renderer_frames with a frame in it, and one without it.
2211 // Since the logic is LRU eviction, the first one should be without. 2234 // Since the logic is LRU eviction, the first one should be without.
2212 EXPECT_FALSE(views[0]->HasFrameData()); 2235 EXPECT_FALSE(views[0]->HasFrameData());
2213 for (size_t i = 1; i < renderer_count; ++i) 2236 for (size_t i = 1; i < renderer_count; ++i)
2214 EXPECT_TRUE(views[i]->HasFrameData()); 2237 EXPECT_TRUE(views[i]->HasFrameData());
2215 2238
2216 // LRU renderer is [0], make it visible, it shouldn't evict anything yet. 2239 // LRU renderer is [0], make it visible, it shouldn't evict anything yet.
2217 views[0]->Show(); 2240 views[0]->Show();
2218 EXPECT_FALSE(views[0]->HasFrameData()); 2241 EXPECT_FALSE(views[0]->HasFrameData());
2219 EXPECT_TRUE(views[1]->HasFrameData()); 2242 EXPECT_TRUE(views[1]->HasFrameData());
2220 // Since [0] doesn't have a frame, it should be waiting for the renderer to 2243 // Since [0] doesn't have a frame, it should be waiting for the renderer to
2221 // give it one. 2244 // give it one.
2222 EXPECT_TRUE(views[0]->released_front_lock_active()); 2245 EXPECT_TRUE(views[0]->released_front_lock_active());
2223 2246
2224 // Swap a frame on it, it should evict the next LRU [1]. 2247 // Swap a frame on it, it should evict the next LRU [1].
2225 views[0]->OnSwapCompositorFrame( 2248 views[0]->OnSwapCompositorFrame(
2226 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2249 1, cc::SurfaceId(1, 2, 1),
2250 MakeDelegatedFrame(1.f, frame_size, view_rect));
2227 EXPECT_TRUE(views[0]->HasFrameData()); 2251 EXPECT_TRUE(views[0]->HasFrameData());
2228 EXPECT_FALSE(views[1]->HasFrameData()); 2252 EXPECT_FALSE(views[1]->HasFrameData());
2229 // Now that [0] got a frame, it shouldn't be waiting any more. 2253 // Now that [0] got a frame, it shouldn't be waiting any more.
2230 EXPECT_FALSE(views[0]->released_front_lock_active()); 2254 EXPECT_FALSE(views[0]->released_front_lock_active());
2231 views[0]->Hide(); 2255 views[0]->Hide();
2232 2256
2233 // LRU renderer is [1], still hidden. Swap a frame on it, it should evict 2257 // LRU renderer is [1], still hidden. Swap a frame on it, it should evict
2234 // the next LRU [2]. 2258 // the next LRU [2].
2235 views[1]->OnSwapCompositorFrame( 2259 views[1]->OnSwapCompositorFrame(
2236 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2260 1, cc::SurfaceId(2, 2, 1),
2261 MakeDelegatedFrame(1.f, frame_size, view_rect));
2237 EXPECT_TRUE(views[0]->HasFrameData()); 2262 EXPECT_TRUE(views[0]->HasFrameData());
2238 EXPECT_TRUE(views[1]->HasFrameData()); 2263 EXPECT_TRUE(views[1]->HasFrameData());
2239 EXPECT_FALSE(views[2]->HasFrameData()); 2264 EXPECT_FALSE(views[2]->HasFrameData());
2240 for (size_t i = 3; i < renderer_count; ++i) 2265 for (size_t i = 3; i < renderer_count; ++i)
2241 EXPECT_TRUE(views[i]->HasFrameData()); 2266 EXPECT_TRUE(views[i]->HasFrameData());
2242 2267
2243 // Make all renderers but [0] visible and swap a frame on them, keep [0] 2268 // Make all renderers but [0] visible and swap a frame on them, keep [0]
2244 // hidden, it becomes the LRU. 2269 // hidden, it becomes the LRU.
2245 for (size_t i = 1; i < renderer_count; ++i) { 2270 for (size_t i = 1; i < renderer_count; ++i) {
2246 views[i]->Show(); 2271 views[i]->Show();
2247 // The renderers who don't have a frame should be waiting. The ones that 2272 // The renderers who don't have a frame should be waiting. The ones that
2248 // have a frame should not. 2273 // have a frame should not.
2249 // In practice, [1] has a frame, but anything after has its frame evicted. 2274 // In practice, [1] has a frame, but anything after has its frame evicted.
2250 EXPECT_EQ(!views[i]->HasFrameData(), 2275 EXPECT_EQ(!views[i]->HasFrameData(),
2251 views[i]->released_front_lock_active()); 2276 views[i]->released_front_lock_active());
2252 views[i]->OnSwapCompositorFrame( 2277 views[i]->OnSwapCompositorFrame(
2253 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2278 1, cc::SurfaceId(1 + i, 1, 1),
2279 MakeDelegatedFrame(1.f, frame_size, view_rect));
2254 // Now everyone has a frame. 2280 // Now everyone has a frame.
2255 EXPECT_FALSE(views[i]->released_front_lock_active()); 2281 EXPECT_FALSE(views[i]->released_front_lock_active());
2256 EXPECT_TRUE(views[i]->HasFrameData()); 2282 EXPECT_TRUE(views[i]->HasFrameData());
2257 } 2283 }
2258 EXPECT_FALSE(views[0]->HasFrameData()); 2284 EXPECT_FALSE(views[0]->HasFrameData());
2259 2285
2260 // Swap a frame on [0], it should be evicted immediately. 2286 // Swap a frame on [0], it should be evicted immediately.
2261 views[0]->OnSwapCompositorFrame( 2287 views[0]->OnSwapCompositorFrame(
2262 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2288 1, cc::SurfaceId(1, 1, 1),
2289 MakeDelegatedFrame(1.f, frame_size, view_rect));
2263 EXPECT_FALSE(views[0]->HasFrameData()); 2290 EXPECT_FALSE(views[0]->HasFrameData());
2264 2291
2265 // Make [0] visible, and swap a frame on it. Nothing should be evicted 2292 // Make [0] visible, and swap a frame on it. Nothing should be evicted
2266 // although we're above the limit. 2293 // although we're above the limit.
2267 views[0]->Show(); 2294 views[0]->Show();
2268 // We don't have a frame, wait. 2295 // We don't have a frame, wait.
2269 EXPECT_TRUE(views[0]->released_front_lock_active()); 2296 EXPECT_TRUE(views[0]->released_front_lock_active());
2270 views[0]->OnSwapCompositorFrame( 2297 views[0]->OnSwapCompositorFrame(
2271 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2298 1, cc::SurfaceId(1, 1, 1),
2299 MakeDelegatedFrame(1.f, frame_size, view_rect));
2272 EXPECT_FALSE(views[0]->released_front_lock_active()); 2300 EXPECT_FALSE(views[0]->released_front_lock_active());
2273 for (size_t i = 0; i < renderer_count; ++i) 2301 for (size_t i = 0; i < renderer_count; ++i)
2274 EXPECT_TRUE(views[i]->HasFrameData()); 2302 EXPECT_TRUE(views[i]->HasFrameData());
2275 2303
2276 // Make [0] hidden, it should evict its frame. 2304 // Make [0] hidden, it should evict its frame.
2277 views[0]->Hide(); 2305 views[0]->Hide();
2278 EXPECT_FALSE(views[0]->HasFrameData()); 2306 EXPECT_FALSE(views[0]->HasFrameData());
2279 2307
2280 // Make [0] visible, don't give it a frame, it should be waiting. 2308 // Make [0] visible, don't give it a frame, it should be waiting.
2281 views[0]->Show(); 2309 views[0]->Show();
2282 EXPECT_TRUE(views[0]->released_front_lock_active()); 2310 EXPECT_TRUE(views[0]->released_front_lock_active());
2283 // Make [0] hidden, it should stop waiting. 2311 // Make [0] hidden, it should stop waiting.
2284 views[0]->Hide(); 2312 views[0]->Hide();
2285 EXPECT_FALSE(views[0]->released_front_lock_active()); 2313 EXPECT_FALSE(views[0]->released_front_lock_active());
2286 2314
2287 // Make [1] hidden, resize it. It should drop its frame. 2315 // Make [1] hidden, resize it. It should drop its frame.
2288 views[1]->Hide(); 2316 views[1]->Hide();
2289 EXPECT_TRUE(views[1]->HasFrameData()); 2317 EXPECT_TRUE(views[1]->HasFrameData());
2290 gfx::Size size2(200, 200); 2318 gfx::Size size2(200, 200);
2291 views[1]->SetSize(size2); 2319 views[1]->SetSize(size2);
2292 EXPECT_FALSE(views[1]->HasFrameData()); 2320 EXPECT_FALSE(views[1]->HasFrameData());
2293 // Show it, it should block until we give it a frame. 2321 // Show it, it should block until we give it a frame.
2294 views[1]->Show(); 2322 views[1]->Show();
2295 EXPECT_TRUE(views[1]->released_front_lock_active()); 2323 EXPECT_TRUE(views[1]->released_front_lock_active());
2296 views[1]->OnSwapCompositorFrame( 2324 views[1]->OnSwapCompositorFrame(
2297 1, MakeDelegatedFrame(1.f, size2, gfx::Rect(size2))); 2325 1, cc::SurfaceId(2, 1, 1),
2326 MakeDelegatedFrame(1.f, size2, gfx::Rect(size2)));
2298 EXPECT_FALSE(views[1]->released_front_lock_active()); 2327 EXPECT_FALSE(views[1]->released_front_lock_active());
2299 2328
2300 for (size_t i = 0; i < renderer_count - 1; ++i) 2329 for (size_t i = 0; i < renderer_count - 1; ++i)
2301 views[i]->Hide(); 2330 views[i]->Hide();
2302 2331
2303 // Allocate enough bitmaps so that two frames (proportionally) would be 2332 // Allocate enough bitmaps so that two frames (proportionally) would be
2304 // enough hit the handle limit. 2333 // enough hit the handle limit.
2305 int handles_per_frame = 5; 2334 int handles_per_frame = 5;
2306 RendererFrameManager::GetInstance()->set_max_handles(handles_per_frame * 2); 2335 RendererFrameManager::GetInstance()->set_max_handles(handles_per_frame * 2);
2307 2336
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2361 parent_view_->GetNativeView()->GetRootWindow(), 2390 parent_view_->GetNativeView()->GetRootWindow(),
2362 gfx::Rect()); 2391 gfx::Rect());
2363 views[i]->SetSize(view_rect.size()); 2392 views[i]->SetSize(view_rect.size());
2364 } 2393 }
2365 2394
2366 // Make each renderer visible and swap a frame on it. No eviction should 2395 // Make each renderer visible and swap a frame on it. No eviction should
2367 // occur because all frames are visible. 2396 // occur because all frames are visible.
2368 for (size_t i = 0; i < renderer_count; ++i) { 2397 for (size_t i = 0; i < renderer_count; ++i) {
2369 views[i]->Show(); 2398 views[i]->Show();
2370 views[i]->OnSwapCompositorFrame( 2399 views[i]->OnSwapCompositorFrame(
2371 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2400 1, cc::SurfaceId(i + 1, 1, 1),
2401 MakeDelegatedFrame(1.f, frame_size, view_rect));
2372 EXPECT_TRUE(views[i]->HasFrameData()); 2402 EXPECT_TRUE(views[i]->HasFrameData());
2373 } 2403 }
2374 2404
2375 // If we hide [0], then [0] should be evicted. 2405 // If we hide [0], then [0] should be evicted.
2376 views[0]->Hide(); 2406 views[0]->Hide();
2377 EXPECT_FALSE(views[0]->HasFrameData()); 2407 EXPECT_FALSE(views[0]->HasFrameData());
2378 2408
2379 // If we lock [0] before hiding it, then [0] should not be evicted. 2409 // If we lock [0] before hiding it, then [0] should not be evicted.
2380 views[0]->Show(); 2410 views[0]->Show();
2381 views[0]->OnSwapCompositorFrame( 2411 views[0]->OnSwapCompositorFrame(
2382 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2412 1, cc::SurfaceId(1, 1, 1),
2413 MakeDelegatedFrame(1.f, frame_size, view_rect));
2383 EXPECT_TRUE(views[0]->HasFrameData()); 2414 EXPECT_TRUE(views[0]->HasFrameData());
2384 views[0]->GetDelegatedFrameHost()->LockResources(); 2415 views[0]->GetDelegatedFrameHost()->LockResources();
2385 views[0]->Hide(); 2416 views[0]->Hide();
2386 EXPECT_TRUE(views[0]->HasFrameData()); 2417 EXPECT_TRUE(views[0]->HasFrameData());
2387 2418
2388 // If we unlock [0] now, then [0] should be evicted. 2419 // If we unlock [0] now, then [0] should be evicted.
2389 views[0]->GetDelegatedFrameHost()->UnlockResources(); 2420 views[0]->GetDelegatedFrameHost()->UnlockResources();
2390 EXPECT_FALSE(views[0]->HasFrameData()); 2421 EXPECT_FALSE(views[0]->HasFrameData());
2391 2422
2392 for (size_t i = 0; i < renderer_count; ++i) { 2423 for (size_t i = 0; i < renderer_count; ++i) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 parent_view_->GetNativeView()->GetRootWindow(), 2463 parent_view_->GetNativeView()->GetRootWindow(),
2433 gfx::Rect()); 2464 gfx::Rect());
2434 views[i]->SetSize(view_rect.size()); 2465 views[i]->SetSize(view_rect.size());
2435 } 2466 }
2436 2467
2437 // Make each renderer visible and swap a frame on it. No eviction should 2468 // Make each renderer visible and swap a frame on it. No eviction should
2438 // occur because all frames are visible. 2469 // occur because all frames are visible.
2439 for (size_t i = 0; i < renderer_count; ++i) { 2470 for (size_t i = 0; i < renderer_count; ++i) {
2440 views[i]->Show(); 2471 views[i]->Show();
2441 views[i]->OnSwapCompositorFrame( 2472 views[i]->OnSwapCompositorFrame(
2442 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2473 1, cc::SurfaceId(1, 1, 1),
2474 MakeDelegatedFrame(1.f, frame_size, view_rect));
2443 EXPECT_TRUE(views[i]->HasFrameData()); 2475 EXPECT_TRUE(views[i]->HasFrameData());
2444 } 2476 }
2445 2477
2446 // If we hide one, it should not get evicted. 2478 // If we hide one, it should not get evicted.
2447 views[0]->Hide(); 2479 views[0]->Hide();
2448 message_loop_.RunUntilIdle(); 2480 message_loop_.RunUntilIdle();
2449 EXPECT_TRUE(views[0]->HasFrameData()); 2481 EXPECT_TRUE(views[0]->HasFrameData());
2450 // Using a lesser memory pressure event however, should evict. 2482 // Using a lesser memory pressure event however, should evict.
2451 SimulateMemoryPressure( 2483 SimulateMemoryPressure(
2452 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE); 2484 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE);
(...skipping 22 matching lines...) Expand all
2475 view_->InitAsChild(nullptr); 2507 view_->InitAsChild(nullptr);
2476 aura::client::ParentWindowWithContext( 2508 aura::client::ParentWindowWithContext(
2477 view_->GetNativeView(), 2509 view_->GetNativeView(),
2478 parent_view_->GetNativeView()->GetRootWindow(), 2510 parent_view_->GetNativeView()->GetRootWindow(),
2479 gfx::Rect()); 2511 gfx::Rect());
2480 view_->SetSize(view_rect.size()); 2512 view_->SetSize(view_rect.size());
2481 view_->Show(); 2513 view_->Show();
2482 2514
2483 // With a 1x DPI UI and 1x DPI Renderer. 2515 // With a 1x DPI UI and 1x DPI Renderer.
2484 view_->OnSwapCompositorFrame( 2516 view_->OnSwapCompositorFrame(
2485 1, MakeDelegatedFrame(1.f, frame_size, gfx::Rect(frame_size))); 2517 1, cc::SurfaceId(1, 1, 1),
2518 MakeDelegatedFrame(1.f, frame_size, gfx::Rect(frame_size)));
2486 2519
2487 cc::SurfaceId surface_id = view_->surface_id(); 2520 cc::SurfaceId surface_id = view_->surface_id();
2488 2521
2489 // This frame will have the same number of physical pixels, but has a new 2522 // This frame will have the same number of physical pixels, but has a new
2490 // scale on it. 2523 // scale on it.
2491 view_->OnSwapCompositorFrame( 2524 view_->OnSwapCompositorFrame(
2492 1, MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size))); 2525 1, cc::SurfaceId(1, 2, 1),
2526 MakeDelegatedFrame(2.f, frame_size, gfx::Rect(frame_size)));
2493 2527
2494 // When we get a new frame with the same frame size in physical pixels, but 2528 // When we get a new frame with the same frame size in physical pixels, but
2495 // a different scale, we should generate a surface, as the final result will 2529 // a different scale, we should generate a surface, as the final result will
2496 // need to be scaled differently to the screen. 2530 // need to be scaled differently to the screen.
2497 EXPECT_NE(surface_id, view_->surface_id()); 2531 EXPECT_NE(surface_id, view_->surface_id());
2498 } 2532 }
2499 2533
2500 class RenderWidgetHostViewAuraCopyRequestTest 2534 class RenderWidgetHostViewAuraCopyRequestTest
2501 : public RenderWidgetHostViewAuraShutdownTest { 2535 : public RenderWidgetHostViewAuraShutdownTest {
2502 public: 2536 public:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 } 2577 }
2544 2578
2545 void InstallFakeTickClock() { 2579 void InstallFakeTickClock() {
2546 // Create a fake tick clock and transfer ownership to the frame host. 2580 // Create a fake tick clock and transfer ownership to the frame host.
2547 tick_clock_ = new base::SimpleTestTickClock(); 2581 tick_clock_ = new base::SimpleTestTickClock();
2548 view_->GetDelegatedFrameHost()->tick_clock_ = base::WrapUnique(tick_clock_); 2582 view_->GetDelegatedFrameHost()->tick_clock_ = base::WrapUnique(tick_clock_);
2549 } 2583 }
2550 2584
2551 void OnSwapCompositorFrame() { 2585 void OnSwapCompositorFrame() {
2552 view_->OnSwapCompositorFrame( 2586 view_->OnSwapCompositorFrame(
2553 1, MakeDelegatedFrame(1.f, view_rect_.size(), view_rect_)); 2587 1, cc::SurfaceId(1, 1, 1),
2588 MakeDelegatedFrame(1.f, view_rect_.size(), view_rect_));
2554 cc::SurfaceId surface_id = 2589 cc::SurfaceId surface_id =
2555 view_->GetDelegatedFrameHost()->SurfaceIdForTesting(); 2590 view_->GetDelegatedFrameHost()->SurfaceIdForTesting();
2556 if (!surface_id.is_null()) 2591 if (!surface_id.is_null())
2557 view_->GetDelegatedFrameHost()->WillDrawSurface(surface_id, view_rect_); 2592 view_->GetDelegatedFrameHost()->WillDrawSurface(surface_id, view_rect_);
2558 ASSERT_TRUE(view_->last_copy_request_); 2593 ASSERT_TRUE(view_->last_copy_request_);
2559 } 2594 }
2560 2595
2561 void ReleaseSwappedFrame() { 2596 void ReleaseSwappedFrame() {
2562 std::unique_ptr<cc::CopyOutputRequest> request = 2597 std::unique_ptr<cc::CopyOutputRequest> request =
2563 std::move(view_->last_copy_request_); 2598 std::move(view_->last_copy_request_);
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
4017 gfx::Size size(5, 5); 4052 gfx::Size size(5, 5);
4018 4053
4019 const IPC::Message* msg = 4054 const IPC::Message* msg =
4020 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceClientId::ID); 4055 sink_->GetUniqueMessageMatching(ViewMsg_SetSurfaceClientId::ID);
4021 EXPECT_TRUE(msg); 4056 EXPECT_TRUE(msg);
4022 ViewMsg_SetSurfaceClientId::Param params; 4057 ViewMsg_SetSurfaceClientId::Param params;
4023 ViewMsg_SetSurfaceClientId::Read(msg, &params); 4058 ViewMsg_SetSurfaceClientId::Read(msg, &params);
4024 view_->InitAsChild(nullptr); 4059 view_->InitAsChild(nullptr);
4025 view_->Show(); 4060 view_->Show();
4026 view_->SetSize(size); 4061 view_->SetSize(size);
4027 view_->OnSwapCompositorFrame(0, 4062 view_->OnSwapCompositorFrame(0, cc::SurfaceId(1, 1, 1),
4028 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); 4063 MakeDelegatedFrame(1.f, size, gfx::Rect(size)));
4029 EXPECT_EQ(view_->GetSurfaceClientId(), std::get<0>(params)); 4064 EXPECT_EQ(view_->GetSurfaceClientId(), std::get<0>(params));
4030 } 4065 }
4031 4066
4032 // This class provides functionality to test a RenderWidgetHostViewAura 4067 // This class provides functionality to test a RenderWidgetHostViewAura
4033 // instance which has been hooked up to a test RenderViewHost instance and 4068 // instance which has been hooked up to a test RenderViewHost instance and
4034 // a WebContents instance. 4069 // a WebContents instance.
4035 class RenderWidgetHostViewAuraWithViewHarnessTest 4070 class RenderWidgetHostViewAuraWithViewHarnessTest
4036 : public RenderViewHostImplTestHarness { 4071 : public RenderViewHostImplTestHarness {
4037 public: 4072 public:
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4466 // No bounds at index 1. 4501 // No bounds at index 1.
4467 EXPECT_FALSE(text_input_client()->GetCompositionCharacterBounds(1, &bound)); 4502 EXPECT_FALSE(text_input_client()->GetCompositionCharacterBounds(1, &bound));
4468 4503
4469 // Valid bound at index 0. 4504 // Valid bound at index 0.
4470 EXPECT_TRUE(text_input_client()->GetCompositionCharacterBounds(0, &bound)); 4505 EXPECT_TRUE(text_input_client()->GetCompositionCharacterBounds(0, &bound));
4471 EXPECT_EQ(4 + (int)index, bound.height()); 4506 EXPECT_EQ(4 + (int)index, bound.height());
4472 } 4507 }
4473 } 4508 }
4474 4509
4475 } // namespace content 4510 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698