| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 layer->SetDrawsContent(true); | 291 layer->SetDrawsContent(true); |
| 292 layer->SetBounds(size); | 292 layer->SetBounds(size); |
| 293 layer->SetContentBounds(size); | 293 layer->SetContentBounds(size); |
| 294 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); | 294 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); |
| 295 return layer.Pass(); | 295 return layer.Pass(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void DrawFrame() { | 298 void DrawFrame() { |
| 299 LayerTreeHostImpl::FrameData frame; | 299 LayerTreeHostImpl::FrameData frame; |
| 300 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 300 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 301 host_impl_->DrawLayers(&frame); | 301 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 302 host_impl_->DidDrawAllLayers(frame); | 302 host_impl_->DidDrawAllLayers(frame); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); | 305 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); |
| 306 void pinch_zoom_pan_viewport_test(float device_scale_factor); | 306 void pinch_zoom_pan_viewport_test(float device_scale_factor); |
| 307 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); | 307 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); |
| 308 void pinch_zoom_pan_viewport_and_scroll_boundary_test( | 308 void pinch_zoom_pan_viewport_and_scroll_boundary_test( |
| 309 float device_scale_factor); | 309 float device_scale_factor); |
| 310 | 310 |
| 311 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) { | 311 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) { |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 1704 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 1705 host_impl_->active_tree()->root_layer()); | 1705 host_impl_->active_tree()->root_layer()); |
| 1706 | 1706 |
| 1707 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 1707 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 1708 DidDrawCheckLayer* layer = | 1708 DidDrawCheckLayer* layer = |
| 1709 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 1709 static_cast<DidDrawCheckLayer*>(root->children()[0]); |
| 1710 | 1710 |
| 1711 { | 1711 { |
| 1712 LayerTreeHostImpl::FrameData frame; | 1712 LayerTreeHostImpl::FrameData frame; |
| 1713 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1713 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1714 host_impl_->DrawLayers(&frame); | 1714 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1715 host_impl_->DidDrawAllLayers(frame); | 1715 host_impl_->DidDrawAllLayers(frame); |
| 1716 | 1716 |
| 1717 EXPECT_TRUE(layer->will_draw_called()); | 1717 EXPECT_TRUE(layer->will_draw_called()); |
| 1718 EXPECT_TRUE(layer->append_quads_called()); | 1718 EXPECT_TRUE(layer->append_quads_called()); |
| 1719 EXPECT_TRUE(layer->did_draw_called()); | 1719 EXPECT_TRUE(layer->did_draw_called()); |
| 1720 } | 1720 } |
| 1721 | 1721 |
| 1722 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); | 1722 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); |
| 1723 | 1723 |
| 1724 { | 1724 { |
| 1725 LayerTreeHostImpl::FrameData frame; | 1725 LayerTreeHostImpl::FrameData frame; |
| 1726 | 1726 |
| 1727 layer->set_will_draw_returns_false(); | 1727 layer->set_will_draw_returns_false(); |
| 1728 layer->ClearDidDrawCheck(); | 1728 layer->ClearDidDrawCheck(); |
| 1729 | 1729 |
| 1730 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1730 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1731 host_impl_->DrawLayers(&frame); | 1731 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1732 host_impl_->DidDrawAllLayers(frame); | 1732 host_impl_->DidDrawAllLayers(frame); |
| 1733 | 1733 |
| 1734 EXPECT_TRUE(layer->will_draw_called()); | 1734 EXPECT_TRUE(layer->will_draw_called()); |
| 1735 EXPECT_FALSE(layer->append_quads_called()); | 1735 EXPECT_FALSE(layer->append_quads_called()); |
| 1736 EXPECT_FALSE(layer->did_draw_called()); | 1736 EXPECT_FALSE(layer->did_draw_called()); |
| 1737 } | 1737 } |
| 1738 } | 1738 } |
| 1739 | 1739 |
| 1740 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 1740 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
| 1741 // The root layer is always drawn, so run this test on a child layer that | 1741 // The root layer is always drawn, so run this test on a child layer that |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1753 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 1753 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 1754 layer->SetBounds(gfx::Size(10, 10)); | 1754 layer->SetBounds(gfx::Size(10, 10)); |
| 1755 layer->SetContentBounds(gfx::Size(10, 10)); | 1755 layer->SetContentBounds(gfx::Size(10, 10)); |
| 1756 | 1756 |
| 1757 LayerTreeHostImpl::FrameData frame; | 1757 LayerTreeHostImpl::FrameData frame; |
| 1758 | 1758 |
| 1759 EXPECT_FALSE(layer->will_draw_called()); | 1759 EXPECT_FALSE(layer->will_draw_called()); |
| 1760 EXPECT_FALSE(layer->did_draw_called()); | 1760 EXPECT_FALSE(layer->did_draw_called()); |
| 1761 | 1761 |
| 1762 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1762 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1763 host_impl_->DrawLayers(&frame); | 1763 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1764 host_impl_->DidDrawAllLayers(frame); | 1764 host_impl_->DidDrawAllLayers(frame); |
| 1765 | 1765 |
| 1766 EXPECT_FALSE(layer->will_draw_called()); | 1766 EXPECT_FALSE(layer->will_draw_called()); |
| 1767 EXPECT_FALSE(layer->did_draw_called()); | 1767 EXPECT_FALSE(layer->did_draw_called()); |
| 1768 | 1768 |
| 1769 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); | 1769 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); |
| 1770 | 1770 |
| 1771 // Ensure visible_content_rect for layer is not empty | 1771 // Ensure visible_content_rect for layer is not empty |
| 1772 layer->SetPosition(gfx::PointF()); | 1772 layer->SetPosition(gfx::PointF()); |
| 1773 | 1773 |
| 1774 EXPECT_FALSE(layer->will_draw_called()); | 1774 EXPECT_FALSE(layer->will_draw_called()); |
| 1775 EXPECT_FALSE(layer->did_draw_called()); | 1775 EXPECT_FALSE(layer->did_draw_called()); |
| 1776 | 1776 |
| 1777 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1777 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1778 host_impl_->DrawLayers(&frame); | 1778 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1779 host_impl_->DidDrawAllLayers(frame); | 1779 host_impl_->DidDrawAllLayers(frame); |
| 1780 | 1780 |
| 1781 EXPECT_TRUE(layer->will_draw_called()); | 1781 EXPECT_TRUE(layer->will_draw_called()); |
| 1782 EXPECT_TRUE(layer->did_draw_called()); | 1782 EXPECT_TRUE(layer->did_draw_called()); |
| 1783 | 1783 |
| 1784 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); | 1784 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); |
| 1785 } | 1785 } |
| 1786 | 1786 |
| 1787 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { | 1787 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { |
| 1788 gfx::Size big_size(1000, 1000); | 1788 gfx::Size big_size(1000, 1000); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1807 top_layer->SetContentsOpaque(true); | 1807 top_layer->SetContentsOpaque(true); |
| 1808 | 1808 |
| 1809 LayerTreeHostImpl::FrameData frame; | 1809 LayerTreeHostImpl::FrameData frame; |
| 1810 | 1810 |
| 1811 EXPECT_FALSE(occluded_layer->will_draw_called()); | 1811 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 1812 EXPECT_FALSE(occluded_layer->did_draw_called()); | 1812 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 1813 EXPECT_FALSE(top_layer->will_draw_called()); | 1813 EXPECT_FALSE(top_layer->will_draw_called()); |
| 1814 EXPECT_FALSE(top_layer->did_draw_called()); | 1814 EXPECT_FALSE(top_layer->did_draw_called()); |
| 1815 | 1815 |
| 1816 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1816 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1817 host_impl_->DrawLayers(&frame); | 1817 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1818 host_impl_->DidDrawAllLayers(frame); | 1818 host_impl_->DidDrawAllLayers(frame); |
| 1819 | 1819 |
| 1820 EXPECT_FALSE(occluded_layer->will_draw_called()); | 1820 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 1821 EXPECT_FALSE(occluded_layer->did_draw_called()); | 1821 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 1822 EXPECT_TRUE(top_layer->will_draw_called()); | 1822 EXPECT_TRUE(top_layer->will_draw_called()); |
| 1823 EXPECT_TRUE(top_layer->did_draw_called()); | 1823 EXPECT_TRUE(top_layer->did_draw_called()); |
| 1824 } | 1824 } |
| 1825 | 1825 |
| 1826 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 1826 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| 1827 host_impl_->active_tree()->SetRootLayer( | 1827 host_impl_->active_tree()->SetRootLayer( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1839 | 1839 |
| 1840 layer1->SetOpacity(0.3f); | 1840 layer1->SetOpacity(0.3f); |
| 1841 layer1->SetShouldFlattenTransform(true); | 1841 layer1->SetShouldFlattenTransform(true); |
| 1842 | 1842 |
| 1843 EXPECT_FALSE(root->did_draw_called()); | 1843 EXPECT_FALSE(root->did_draw_called()); |
| 1844 EXPECT_FALSE(layer1->did_draw_called()); | 1844 EXPECT_FALSE(layer1->did_draw_called()); |
| 1845 EXPECT_FALSE(layer2->did_draw_called()); | 1845 EXPECT_FALSE(layer2->did_draw_called()); |
| 1846 | 1846 |
| 1847 LayerTreeHostImpl::FrameData frame; | 1847 LayerTreeHostImpl::FrameData frame; |
| 1848 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1848 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1849 host_impl_->DrawLayers(&frame); | 1849 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1850 host_impl_->DidDrawAllLayers(frame); | 1850 host_impl_->DidDrawAllLayers(frame); |
| 1851 | 1851 |
| 1852 EXPECT_TRUE(root->did_draw_called()); | 1852 EXPECT_TRUE(root->did_draw_called()); |
| 1853 EXPECT_TRUE(layer1->did_draw_called()); | 1853 EXPECT_TRUE(layer1->did_draw_called()); |
| 1854 EXPECT_TRUE(layer2->did_draw_called()); | 1854 EXPECT_TRUE(layer2->did_draw_called()); |
| 1855 | 1855 |
| 1856 EXPECT_NE(root->render_surface(), layer1->render_surface()); | 1856 EXPECT_NE(root->render_surface(), layer1->render_surface()); |
| 1857 EXPECT_TRUE(!!layer1->render_surface()); | 1857 EXPECT_TRUE(!!layer1->render_surface()); |
| 1858 } | 1858 } |
| 1859 | 1859 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1915 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1915 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1916 2, | 1916 2, |
| 1917 tile_missing, | 1917 tile_missing, |
| 1918 had_incomplete_tile, | 1918 had_incomplete_tile, |
| 1919 is_animating, | 1919 is_animating, |
| 1920 host_impl_->resource_provider())); | 1920 host_impl_->resource_provider())); |
| 1921 | 1921 |
| 1922 LayerTreeHostImpl::FrameData frame; | 1922 LayerTreeHostImpl::FrameData frame; |
| 1923 | 1923 |
| 1924 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1924 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1925 host_impl_->DrawLayers(&frame); | 1925 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1926 host_impl_->DidDrawAllLayers(frame); | 1926 host_impl_->DidDrawAllLayers(frame); |
| 1927 } | 1927 } |
| 1928 | 1928 |
| 1929 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { | 1929 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
| 1930 host_impl_->active_tree()->SetRootLayer( | 1930 host_impl_->active_tree()->SetRootLayer( |
| 1931 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1931 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1932 DidDrawCheckLayer* root = | 1932 DidDrawCheckLayer* root = |
| 1933 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1933 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1934 bool tile_missing = false; | 1934 bool tile_missing = false; |
| 1935 bool had_incomplete_tile = false; | 1935 bool had_incomplete_tile = false; |
| 1936 bool is_animating = true; | 1936 bool is_animating = true; |
| 1937 root->AddChild( | 1937 root->AddChild( |
| 1938 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1938 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1939 2, | 1939 2, |
| 1940 tile_missing, | 1940 tile_missing, |
| 1941 had_incomplete_tile, | 1941 had_incomplete_tile, |
| 1942 is_animating, | 1942 is_animating, |
| 1943 host_impl_->resource_provider())); | 1943 host_impl_->resource_provider())); |
| 1944 | 1944 |
| 1945 LayerTreeHostImpl::FrameData frame; | 1945 LayerTreeHostImpl::FrameData frame; |
| 1946 | 1946 |
| 1947 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1947 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1948 host_impl_->DrawLayers(&frame); | 1948 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1949 host_impl_->DidDrawAllLayers(frame); | 1949 host_impl_->DidDrawAllLayers(frame); |
| 1950 } | 1950 } |
| 1951 | 1951 |
| 1952 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { | 1952 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { |
| 1953 host_impl_->active_tree()->SetRootLayer( | 1953 host_impl_->active_tree()->SetRootLayer( |
| 1954 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1954 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1955 DidDrawCheckLayer* root = | 1955 DidDrawCheckLayer* root = |
| 1956 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1956 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1957 | 1957 |
| 1958 bool tile_missing = true; | 1958 bool tile_missing = true; |
| 1959 bool had_incomplete_tile = false; | 1959 bool had_incomplete_tile = false; |
| 1960 bool is_animating = false; | 1960 bool is_animating = false; |
| 1961 root->AddChild( | 1961 root->AddChild( |
| 1962 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1962 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1963 4, | 1963 4, |
| 1964 tile_missing, | 1964 tile_missing, |
| 1965 had_incomplete_tile, | 1965 had_incomplete_tile, |
| 1966 is_animating, | 1966 is_animating, |
| 1967 host_impl_->resource_provider())); | 1967 host_impl_->resource_provider())); |
| 1968 LayerTreeHostImpl::FrameData frame; | 1968 LayerTreeHostImpl::FrameData frame; |
| 1969 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1969 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1970 host_impl_->DrawLayers(&frame); | 1970 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1971 host_impl_->DidDrawAllLayers(frame); | 1971 host_impl_->DidDrawAllLayers(frame); |
| 1972 } | 1972 } |
| 1973 | 1973 |
| 1974 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { | 1974 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
| 1975 host_impl_->active_tree()->SetRootLayer( | 1975 host_impl_->active_tree()->SetRootLayer( |
| 1976 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1976 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1977 DidDrawCheckLayer* root = | 1977 DidDrawCheckLayer* root = |
| 1978 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1978 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1979 | 1979 |
| 1980 bool tile_missing = false; | 1980 bool tile_missing = false; |
| 1981 bool had_incomplete_tile = true; | 1981 bool had_incomplete_tile = true; |
| 1982 bool is_animating = false; | 1982 bool is_animating = false; |
| 1983 root->AddChild( | 1983 root->AddChild( |
| 1984 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1984 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1985 4, | 1985 4, |
| 1986 tile_missing, | 1986 tile_missing, |
| 1987 had_incomplete_tile, | 1987 had_incomplete_tile, |
| 1988 is_animating, | 1988 is_animating, |
| 1989 host_impl_->resource_provider())); | 1989 host_impl_->resource_provider())); |
| 1990 LayerTreeHostImpl::FrameData frame; | 1990 LayerTreeHostImpl::FrameData frame; |
| 1991 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1991 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1992 host_impl_->DrawLayers(&frame); | 1992 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1993 host_impl_->DidDrawAllLayers(frame); | 1993 host_impl_->DidDrawAllLayers(frame); |
| 1994 } | 1994 } |
| 1995 | 1995 |
| 1996 TEST_F(LayerTreeHostImplTest, | 1996 TEST_F(LayerTreeHostImplTest, |
| 1997 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { | 1997 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { |
| 1998 host_impl_->active_tree()->SetRootLayer( | 1998 host_impl_->active_tree()->SetRootLayer( |
| 1999 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 1999 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 2000 DidDrawCheckLayer* root = | 2000 DidDrawCheckLayer* root = |
| 2001 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2001 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2002 bool tile_missing = true; | 2002 bool tile_missing = true; |
| 2003 bool had_incomplete_tile = false; | 2003 bool had_incomplete_tile = false; |
| 2004 bool is_animating = true; | 2004 bool is_animating = true; |
| 2005 root->AddChild( | 2005 root->AddChild( |
| 2006 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2006 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2007 6, | 2007 6, |
| 2008 tile_missing, | 2008 tile_missing, |
| 2009 had_incomplete_tile, | 2009 had_incomplete_tile, |
| 2010 is_animating, | 2010 is_animating, |
| 2011 host_impl_->resource_provider())); | 2011 host_impl_->resource_provider())); |
| 2012 LayerTreeHostImpl::FrameData frame; | 2012 LayerTreeHostImpl::FrameData frame; |
| 2013 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, | 2013 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, |
| 2014 host_impl_->PrepareToDraw(&frame)); | 2014 host_impl_->PrepareToDraw(&frame)); |
| 2015 host_impl_->DrawLayers(&frame); | 2015 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2016 host_impl_->DidDrawAllLayers(frame); | 2016 host_impl_->DidDrawAllLayers(frame); |
| 2017 } | 2017 } |
| 2018 | 2018 |
| 2019 TEST_F(LayerTreeHostImplTest, | 2019 TEST_F(LayerTreeHostImplTest, |
| 2020 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { | 2020 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { |
| 2021 host_impl_->active_tree()->SetRootLayer( | 2021 host_impl_->active_tree()->SetRootLayer( |
| 2022 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2022 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 2023 DidDrawCheckLayer* root = | 2023 DidDrawCheckLayer* root = |
| 2024 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2024 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2025 bool tile_missing = false; | 2025 bool tile_missing = false; |
| 2026 bool had_incomplete_tile = true; | 2026 bool had_incomplete_tile = true; |
| 2027 bool is_animating = true; | 2027 bool is_animating = true; |
| 2028 root->AddChild( | 2028 root->AddChild( |
| 2029 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2029 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2030 6, | 2030 6, |
| 2031 tile_missing, | 2031 tile_missing, |
| 2032 had_incomplete_tile, | 2032 had_incomplete_tile, |
| 2033 is_animating, | 2033 is_animating, |
| 2034 host_impl_->resource_provider())); | 2034 host_impl_->resource_provider())); |
| 2035 LayerTreeHostImpl::FrameData frame; | 2035 LayerTreeHostImpl::FrameData frame; |
| 2036 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2036 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2037 host_impl_->DrawLayers(&frame); | 2037 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2038 host_impl_->DidDrawAllLayers(frame); | 2038 host_impl_->DidDrawAllLayers(frame); |
| 2039 } | 2039 } |
| 2040 | 2040 |
| 2041 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { | 2041 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { |
| 2042 host_impl_->active_tree()->SetRootLayer( | 2042 host_impl_->active_tree()->SetRootLayer( |
| 2043 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2043 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2044 DidDrawCheckLayer* root = | 2044 DidDrawCheckLayer* root = |
| 2045 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2045 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2046 bool tile_missing = false; | 2046 bool tile_missing = false; |
| 2047 bool had_incomplete_tile = false; | 2047 bool had_incomplete_tile = false; |
| 2048 bool is_animating = false; | 2048 bool is_animating = false; |
| 2049 root->AddChild( | 2049 root->AddChild( |
| 2050 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2050 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2051 8, | 2051 8, |
| 2052 tile_missing, | 2052 tile_missing, |
| 2053 had_incomplete_tile, | 2053 had_incomplete_tile, |
| 2054 is_animating, | 2054 is_animating, |
| 2055 host_impl_->resource_provider())); | 2055 host_impl_->resource_provider())); |
| 2056 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2056 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2057 LayerTreeHostImpl::FrameData frame; | 2057 LayerTreeHostImpl::FrameData frame; |
| 2058 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2058 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2059 host_impl_->DrawLayers(&frame); | 2059 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2060 host_impl_->DidDrawAllLayers(frame); | 2060 host_impl_->DidDrawAllLayers(frame); |
| 2061 } | 2061 } |
| 2062 | 2062 |
| 2063 TEST_F(LayerTreeHostImplTest, | 2063 TEST_F(LayerTreeHostImplTest, |
| 2064 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { | 2064 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { |
| 2065 host_impl_->active_tree()->SetRootLayer( | 2065 host_impl_->active_tree()->SetRootLayer( |
| 2066 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2066 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2067 DidDrawCheckLayer* root = | 2067 DidDrawCheckLayer* root = |
| 2068 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2068 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2069 bool tile_missing = false; | 2069 bool tile_missing = false; |
| 2070 bool had_incomplete_tile = true; | 2070 bool had_incomplete_tile = true; |
| 2071 bool is_animating = false; | 2071 bool is_animating = false; |
| 2072 root->AddChild( | 2072 root->AddChild( |
| 2073 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2073 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2074 8, | 2074 8, |
| 2075 tile_missing, | 2075 tile_missing, |
| 2076 had_incomplete_tile, | 2076 had_incomplete_tile, |
| 2077 is_animating, | 2077 is_animating, |
| 2078 host_impl_->resource_provider())); | 2078 host_impl_->resource_provider())); |
| 2079 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2079 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2080 LayerTreeHostImpl::FrameData frame; | 2080 LayerTreeHostImpl::FrameData frame; |
| 2081 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2081 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
| 2082 host_impl_->PrepareToDraw(&frame)); | 2082 host_impl_->PrepareToDraw(&frame)); |
| 2083 host_impl_->DrawLayers(&frame); | 2083 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2084 host_impl_->DidDrawAllLayers(frame); | 2084 host_impl_->DidDrawAllLayers(frame); |
| 2085 } | 2085 } |
| 2086 | 2086 |
| 2087 TEST_F(LayerTreeHostImplTest, | 2087 TEST_F(LayerTreeHostImplTest, |
| 2088 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { | 2088 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { |
| 2089 host_impl_->active_tree()->SetRootLayer( | 2089 host_impl_->active_tree()->SetRootLayer( |
| 2090 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2090 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2091 DidDrawCheckLayer* root = | 2091 DidDrawCheckLayer* root = |
| 2092 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2092 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2093 bool tile_missing = true; | 2093 bool tile_missing = true; |
| 2094 bool had_incomplete_tile = false; | 2094 bool had_incomplete_tile = false; |
| 2095 bool is_animating = false; | 2095 bool is_animating = false; |
| 2096 root->AddChild( | 2096 root->AddChild( |
| 2097 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2097 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2098 8, | 2098 8, |
| 2099 tile_missing, | 2099 tile_missing, |
| 2100 had_incomplete_tile, | 2100 had_incomplete_tile, |
| 2101 is_animating, | 2101 is_animating, |
| 2102 host_impl_->resource_provider())); | 2102 host_impl_->resource_provider())); |
| 2103 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2103 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2104 LayerTreeHostImpl::FrameData frame; | 2104 LayerTreeHostImpl::FrameData frame; |
| 2105 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2105 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
| 2106 host_impl_->PrepareToDraw(&frame)); | 2106 host_impl_->PrepareToDraw(&frame)); |
| 2107 host_impl_->DrawLayers(&frame); | 2107 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2108 host_impl_->DidDrawAllLayers(frame); | 2108 host_impl_->DidDrawAllLayers(frame); |
| 2109 } | 2109 } |
| 2110 | 2110 |
| 2111 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2111 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 2112 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2112 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2113 root->SetScrollClipLayer(Layer::INVALID_ID); | 2113 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 2114 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2114 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2115 DrawFrame(); | 2115 DrawFrame(); |
| 2116 | 2116 |
| 2117 // Scroll event is ignored because layer is not scrollable. | 2117 // Scroll event is ignored because layer is not scrollable. |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2546 EXPECT_EQ(1.f, scroll->contents_scale_y()); | 2546 EXPECT_EQ(1.f, scroll->contents_scale_y()); |
| 2547 EXPECT_EQ(1.f, child->contents_scale_x()); | 2547 EXPECT_EQ(1.f, child->contents_scale_x()); |
| 2548 EXPECT_EQ(1.f, child->contents_scale_y()); | 2548 EXPECT_EQ(1.f, child->contents_scale_y()); |
| 2549 EXPECT_EQ(1.f, grand_child->contents_scale_x()); | 2549 EXPECT_EQ(1.f, grand_child->contents_scale_x()); |
| 2550 EXPECT_EQ(1.f, grand_child->contents_scale_y()); | 2550 EXPECT_EQ(1.f, grand_child->contents_scale_y()); |
| 2551 | 2551 |
| 2552 // Make sure all the layers are drawn with the page scale delta applied, i.e., | 2552 // Make sure all the layers are drawn with the page scale delta applied, i.e., |
| 2553 // the page scale delta on the root layer is applied hierarchically. | 2553 // the page scale delta on the root layer is applied hierarchically. |
| 2554 LayerTreeHostImpl::FrameData frame; | 2554 LayerTreeHostImpl::FrameData frame; |
| 2555 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2555 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2556 host_impl_->DrawLayers(&frame); | 2556 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2557 host_impl_->DidDrawAllLayers(frame); | 2557 host_impl_->DidDrawAllLayers(frame); |
| 2558 | 2558 |
| 2559 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); | 2559 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); |
| 2560 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); | 2560 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); |
| 2561 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); | 2561 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); |
| 2562 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); | 2562 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); |
| 2563 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); | 2563 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); |
| 2564 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); | 2564 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); |
| 2565 EXPECT_EQ(new_page_scale, | 2565 EXPECT_EQ(new_page_scale, |
| 2566 grand_child->draw_transform().matrix().getDouble(0, 0)); | 2566 grand_child->draw_transform().matrix().getDouble(0, 0)); |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3577 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 3577 static_cast<BlendStateCheckLayer*>(root->children()[0]); |
| 3578 layer1->SetPosition(gfx::PointF(2.f, 2.f)); | 3578 layer1->SetPosition(gfx::PointF(2.f, 2.f)); |
| 3579 | 3579 |
| 3580 LayerTreeHostImpl::FrameData frame; | 3580 LayerTreeHostImpl::FrameData frame; |
| 3581 | 3581 |
| 3582 // Opaque layer, drawn without blending. | 3582 // Opaque layer, drawn without blending. |
| 3583 layer1->SetContentsOpaque(true); | 3583 layer1->SetContentsOpaque(true); |
| 3584 layer1->SetExpectation(false, false); | 3584 layer1->SetExpectation(false, false); |
| 3585 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3585 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3586 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3586 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3587 host_impl_->DrawLayers(&frame); | 3587 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3588 EXPECT_TRUE(layer1->quads_appended()); | 3588 EXPECT_TRUE(layer1->quads_appended()); |
| 3589 host_impl_->DidDrawAllLayers(frame); | 3589 host_impl_->DidDrawAllLayers(frame); |
| 3590 | 3590 |
| 3591 // Layer with translucent content and painting, so drawn with blending. | 3591 // Layer with translucent content and painting, so drawn with blending. |
| 3592 layer1->SetContentsOpaque(false); | 3592 layer1->SetContentsOpaque(false); |
| 3593 layer1->SetExpectation(true, false); | 3593 layer1->SetExpectation(true, false); |
| 3594 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3594 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3595 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3595 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3596 host_impl_->DrawLayers(&frame); | 3596 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3597 EXPECT_TRUE(layer1->quads_appended()); | 3597 EXPECT_TRUE(layer1->quads_appended()); |
| 3598 host_impl_->DidDrawAllLayers(frame); | 3598 host_impl_->DidDrawAllLayers(frame); |
| 3599 | 3599 |
| 3600 // Layer with translucent opacity, drawn with blending. | 3600 // Layer with translucent opacity, drawn with blending. |
| 3601 layer1->SetContentsOpaque(true); | 3601 layer1->SetContentsOpaque(true); |
| 3602 layer1->SetOpacity(0.5f); | 3602 layer1->SetOpacity(0.5f); |
| 3603 layer1->SetExpectation(true, false); | 3603 layer1->SetExpectation(true, false); |
| 3604 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3604 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3605 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3605 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3606 host_impl_->DrawLayers(&frame); | 3606 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3607 EXPECT_TRUE(layer1->quads_appended()); | 3607 EXPECT_TRUE(layer1->quads_appended()); |
| 3608 host_impl_->DidDrawAllLayers(frame); | 3608 host_impl_->DidDrawAllLayers(frame); |
| 3609 | 3609 |
| 3610 // Layer with translucent opacity and painting, drawn with blending. | 3610 // Layer with translucent opacity and painting, drawn with blending. |
| 3611 layer1->SetContentsOpaque(true); | 3611 layer1->SetContentsOpaque(true); |
| 3612 layer1->SetOpacity(0.5f); | 3612 layer1->SetOpacity(0.5f); |
| 3613 layer1->SetExpectation(true, false); | 3613 layer1->SetExpectation(true, false); |
| 3614 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3614 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3615 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3615 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3616 host_impl_->DrawLayers(&frame); | 3616 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3617 EXPECT_TRUE(layer1->quads_appended()); | 3617 EXPECT_TRUE(layer1->quads_appended()); |
| 3618 host_impl_->DidDrawAllLayers(frame); | 3618 host_impl_->DidDrawAllLayers(frame); |
| 3619 | 3619 |
| 3620 layer1->AddChild( | 3620 layer1->AddChild( |
| 3621 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 3621 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 3622 3, | 3622 3, |
| 3623 host_impl_->resource_provider())); | 3623 host_impl_->resource_provider())); |
| 3624 BlendStateCheckLayer* layer2 = | 3624 BlendStateCheckLayer* layer2 = |
| 3625 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); | 3625 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); |
| 3626 layer2->SetPosition(gfx::PointF(4.f, 4.f)); | 3626 layer2->SetPosition(gfx::PointF(4.f, 4.f)); |
| 3627 | 3627 |
| 3628 // 2 opaque layers, drawn without blending. | 3628 // 2 opaque layers, drawn without blending. |
| 3629 layer1->SetContentsOpaque(true); | 3629 layer1->SetContentsOpaque(true); |
| 3630 layer1->SetOpacity(1.f); | 3630 layer1->SetOpacity(1.f); |
| 3631 layer1->SetExpectation(false, false); | 3631 layer1->SetExpectation(false, false); |
| 3632 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3632 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3633 layer2->SetContentsOpaque(true); | 3633 layer2->SetContentsOpaque(true); |
| 3634 layer2->SetOpacity(1.f); | 3634 layer2->SetOpacity(1.f); |
| 3635 layer2->SetExpectation(false, false); | 3635 layer2->SetExpectation(false, false); |
| 3636 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3636 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3637 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3637 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3638 host_impl_->DrawLayers(&frame); | 3638 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3639 EXPECT_TRUE(layer1->quads_appended()); | 3639 EXPECT_TRUE(layer1->quads_appended()); |
| 3640 EXPECT_TRUE(layer2->quads_appended()); | 3640 EXPECT_TRUE(layer2->quads_appended()); |
| 3641 host_impl_->DidDrawAllLayers(frame); | 3641 host_impl_->DidDrawAllLayers(frame); |
| 3642 | 3642 |
| 3643 // Parent layer with translucent content, drawn with blending. | 3643 // Parent layer with translucent content, drawn with blending. |
| 3644 // Child layer with opaque content, drawn without blending. | 3644 // Child layer with opaque content, drawn without blending. |
| 3645 layer1->SetContentsOpaque(false); | 3645 layer1->SetContentsOpaque(false); |
| 3646 layer1->SetExpectation(true, false); | 3646 layer1->SetExpectation(true, false); |
| 3647 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3647 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3648 layer2->SetExpectation(false, false); | 3648 layer2->SetExpectation(false, false); |
| 3649 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3649 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3650 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3650 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3651 host_impl_->DrawLayers(&frame); | 3651 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3652 EXPECT_TRUE(layer1->quads_appended()); | 3652 EXPECT_TRUE(layer1->quads_appended()); |
| 3653 EXPECT_TRUE(layer2->quads_appended()); | 3653 EXPECT_TRUE(layer2->quads_appended()); |
| 3654 host_impl_->DidDrawAllLayers(frame); | 3654 host_impl_->DidDrawAllLayers(frame); |
| 3655 | 3655 |
| 3656 // Parent layer with translucent content but opaque painting, drawn without | 3656 // Parent layer with translucent content but opaque painting, drawn without |
| 3657 // blending. | 3657 // blending. |
| 3658 // Child layer with opaque content, drawn without blending. | 3658 // Child layer with opaque content, drawn without blending. |
| 3659 layer1->SetContentsOpaque(true); | 3659 layer1->SetContentsOpaque(true); |
| 3660 layer1->SetExpectation(false, false); | 3660 layer1->SetExpectation(false, false); |
| 3661 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3661 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3662 layer2->SetExpectation(false, false); | 3662 layer2->SetExpectation(false, false); |
| 3663 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3663 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3664 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3664 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3665 host_impl_->DrawLayers(&frame); | 3665 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3666 EXPECT_TRUE(layer1->quads_appended()); | 3666 EXPECT_TRUE(layer1->quads_appended()); |
| 3667 EXPECT_TRUE(layer2->quads_appended()); | 3667 EXPECT_TRUE(layer2->quads_appended()); |
| 3668 host_impl_->DidDrawAllLayers(frame); | 3668 host_impl_->DidDrawAllLayers(frame); |
| 3669 | 3669 |
| 3670 // Parent layer with translucent opacity and opaque content. Since it has a | 3670 // Parent layer with translucent opacity and opaque content. Since it has a |
| 3671 // drawing child, it's drawn to a render surface which carries the opacity, | 3671 // drawing child, it's drawn to a render surface which carries the opacity, |
| 3672 // so it's itself drawn without blending. | 3672 // so it's itself drawn without blending. |
| 3673 // Child layer with opaque content, drawn without blending (parent surface | 3673 // Child layer with opaque content, drawn without blending (parent surface |
| 3674 // carries the inherited opacity). | 3674 // carries the inherited opacity). |
| 3675 layer1->SetContentsOpaque(true); | 3675 layer1->SetContentsOpaque(true); |
| 3676 layer1->SetOpacity(0.5f); | 3676 layer1->SetOpacity(0.5f); |
| 3677 layer1->SetExpectation(false, true); | 3677 layer1->SetExpectation(false, true); |
| 3678 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3678 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3679 layer2->SetExpectation(false, false); | 3679 layer2->SetExpectation(false, false); |
| 3680 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3680 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3681 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3681 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3682 host_impl_->DrawLayers(&frame); | 3682 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3683 EXPECT_TRUE(layer1->quads_appended()); | 3683 EXPECT_TRUE(layer1->quads_appended()); |
| 3684 EXPECT_TRUE(layer2->quads_appended()); | 3684 EXPECT_TRUE(layer2->quads_appended()); |
| 3685 host_impl_->DidDrawAllLayers(frame); | 3685 host_impl_->DidDrawAllLayers(frame); |
| 3686 | 3686 |
| 3687 // Draw again, but with child non-opaque, to make sure | 3687 // Draw again, but with child non-opaque, to make sure |
| 3688 // layer1 not culled. | 3688 // layer1 not culled. |
| 3689 layer1->SetContentsOpaque(true); | 3689 layer1->SetContentsOpaque(true); |
| 3690 layer1->SetOpacity(1.f); | 3690 layer1->SetOpacity(1.f); |
| 3691 layer1->SetExpectation(false, false); | 3691 layer1->SetExpectation(false, false); |
| 3692 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3692 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3693 layer2->SetContentsOpaque(true); | 3693 layer2->SetContentsOpaque(true); |
| 3694 layer2->SetOpacity(0.5f); | 3694 layer2->SetOpacity(0.5f); |
| 3695 layer2->SetExpectation(true, false); | 3695 layer2->SetExpectation(true, false); |
| 3696 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3696 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3697 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3697 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3698 host_impl_->DrawLayers(&frame); | 3698 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3699 EXPECT_TRUE(layer1->quads_appended()); | 3699 EXPECT_TRUE(layer1->quads_appended()); |
| 3700 EXPECT_TRUE(layer2->quads_appended()); | 3700 EXPECT_TRUE(layer2->quads_appended()); |
| 3701 host_impl_->DidDrawAllLayers(frame); | 3701 host_impl_->DidDrawAllLayers(frame); |
| 3702 | 3702 |
| 3703 // A second way of making the child non-opaque. | 3703 // A second way of making the child non-opaque. |
| 3704 layer1->SetContentsOpaque(true); | 3704 layer1->SetContentsOpaque(true); |
| 3705 layer1->SetOpacity(1.f); | 3705 layer1->SetOpacity(1.f); |
| 3706 layer1->SetExpectation(false, false); | 3706 layer1->SetExpectation(false, false); |
| 3707 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3707 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3708 layer2->SetContentsOpaque(false); | 3708 layer2->SetContentsOpaque(false); |
| 3709 layer2->SetOpacity(1.f); | 3709 layer2->SetOpacity(1.f); |
| 3710 layer2->SetExpectation(true, false); | 3710 layer2->SetExpectation(true, false); |
| 3711 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3711 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3712 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3712 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3713 host_impl_->DrawLayers(&frame); | 3713 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3714 EXPECT_TRUE(layer1->quads_appended()); | 3714 EXPECT_TRUE(layer1->quads_appended()); |
| 3715 EXPECT_TRUE(layer2->quads_appended()); | 3715 EXPECT_TRUE(layer2->quads_appended()); |
| 3716 host_impl_->DidDrawAllLayers(frame); | 3716 host_impl_->DidDrawAllLayers(frame); |
| 3717 | 3717 |
| 3718 // And when the layer says its not opaque but is painted opaque, it is not | 3718 // And when the layer says its not opaque but is painted opaque, it is not |
| 3719 // blended. | 3719 // blended. |
| 3720 layer1->SetContentsOpaque(true); | 3720 layer1->SetContentsOpaque(true); |
| 3721 layer1->SetOpacity(1.f); | 3721 layer1->SetOpacity(1.f); |
| 3722 layer1->SetExpectation(false, false); | 3722 layer1->SetExpectation(false, false); |
| 3723 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3723 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3724 layer2->SetContentsOpaque(true); | 3724 layer2->SetContentsOpaque(true); |
| 3725 layer2->SetOpacity(1.f); | 3725 layer2->SetOpacity(1.f); |
| 3726 layer2->SetExpectation(false, false); | 3726 layer2->SetExpectation(false, false); |
| 3727 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3727 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3728 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3728 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3729 host_impl_->DrawLayers(&frame); | 3729 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3730 EXPECT_TRUE(layer1->quads_appended()); | 3730 EXPECT_TRUE(layer1->quads_appended()); |
| 3731 EXPECT_TRUE(layer2->quads_appended()); | 3731 EXPECT_TRUE(layer2->quads_appended()); |
| 3732 host_impl_->DidDrawAllLayers(frame); | 3732 host_impl_->DidDrawAllLayers(frame); |
| 3733 | 3733 |
| 3734 // Layer with partially opaque contents, drawn with blending. | 3734 // Layer with partially opaque contents, drawn with blending. |
| 3735 layer1->SetContentsOpaque(false); | 3735 layer1->SetContentsOpaque(false); |
| 3736 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 3736 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 3737 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); | 3737 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); |
| 3738 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 3738 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 3739 layer1->SetExpectation(true, false); | 3739 layer1->SetExpectation(true, false); |
| 3740 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3740 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3741 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3741 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3742 host_impl_->DrawLayers(&frame); | 3742 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3743 EXPECT_TRUE(layer1->quads_appended()); | 3743 EXPECT_TRUE(layer1->quads_appended()); |
| 3744 host_impl_->DidDrawAllLayers(frame); | 3744 host_impl_->DidDrawAllLayers(frame); |
| 3745 | 3745 |
| 3746 // Layer with partially opaque contents partially culled, drawn with blending. | 3746 // Layer with partially opaque contents partially culled, drawn with blending. |
| 3747 layer1->SetContentsOpaque(false); | 3747 layer1->SetContentsOpaque(false); |
| 3748 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 3748 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 3749 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); | 3749 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); |
| 3750 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 3750 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 3751 layer1->SetExpectation(true, false); | 3751 layer1->SetExpectation(true, false); |
| 3752 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3752 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3753 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3753 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3754 host_impl_->DrawLayers(&frame); | 3754 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3755 EXPECT_TRUE(layer1->quads_appended()); | 3755 EXPECT_TRUE(layer1->quads_appended()); |
| 3756 host_impl_->DidDrawAllLayers(frame); | 3756 host_impl_->DidDrawAllLayers(frame); |
| 3757 | 3757 |
| 3758 // Layer with partially opaque contents culled, drawn with blending. | 3758 // Layer with partially opaque contents culled, drawn with blending. |
| 3759 layer1->SetContentsOpaque(false); | 3759 layer1->SetContentsOpaque(false); |
| 3760 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 3760 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 3761 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); | 3761 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); |
| 3762 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 3762 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 3763 layer1->SetExpectation(true, false); | 3763 layer1->SetExpectation(true, false); |
| 3764 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3764 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3765 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3765 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3766 host_impl_->DrawLayers(&frame); | 3766 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3767 EXPECT_TRUE(layer1->quads_appended()); | 3767 EXPECT_TRUE(layer1->quads_appended()); |
| 3768 host_impl_->DidDrawAllLayers(frame); | 3768 host_impl_->DidDrawAllLayers(frame); |
| 3769 | 3769 |
| 3770 // Layer with partially opaque contents and translucent contents culled, drawn | 3770 // Layer with partially opaque contents and translucent contents culled, drawn |
| 3771 // without blending. | 3771 // without blending. |
| 3772 layer1->SetContentsOpaque(false); | 3772 layer1->SetContentsOpaque(false); |
| 3773 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 3773 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
| 3774 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); | 3774 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); |
| 3775 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 3775 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
| 3776 layer1->SetExpectation(false, false); | 3776 layer1->SetExpectation(false, false); |
| 3777 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); | 3777 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); |
| 3778 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3778 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 3779 host_impl_->DrawLayers(&frame); | 3779 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 3780 EXPECT_TRUE(layer1->quads_appended()); | 3780 EXPECT_TRUE(layer1->quads_appended()); |
| 3781 host_impl_->DidDrawAllLayers(frame); | 3781 host_impl_->DidDrawAllLayers(frame); |
| 3782 } | 3782 } |
| 3783 | 3783 |
| 3784 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 3784 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
| 3785 protected: | 3785 protected: |
| 3786 LayerTreeHostImplViewportCoveredTest() : | 3786 LayerTreeHostImplViewportCoveredTest() : |
| 3787 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 3787 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
| 3788 child_(NULL), | 3788 child_(NULL), |
| 3789 did_activate_pending_tree_(false) {} | 3789 did_activate_pending_tree_(false) {} |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4092 root->SetContentBounds(gfx::Size(10, 10)); | 4092 root->SetContentBounds(gfx::Size(10, 10)); |
| 4093 root->SetDrawsContent(true); | 4093 root->SetDrawsContent(true); |
| 4094 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 4094 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 4095 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | 4095 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); |
| 4096 provider->TestContext3d()->clear_reshape_called(); | 4096 provider->TestContext3d()->clear_reshape_called(); |
| 4097 | 4097 |
| 4098 LayerTreeHostImpl::FrameData frame; | 4098 LayerTreeHostImpl::FrameData frame; |
| 4099 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 4099 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 4100 host_impl_->SetDeviceScaleFactor(1.f); | 4100 host_impl_->SetDeviceScaleFactor(1.f); |
| 4101 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4101 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4102 host_impl_->DrawLayers(&frame); | 4102 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4103 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 4103 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 4104 EXPECT_EQ(provider->TestContext3d()->width(), 10); | 4104 EXPECT_EQ(provider->TestContext3d()->width(), 10); |
| 4105 EXPECT_EQ(provider->TestContext3d()->height(), 10); | 4105 EXPECT_EQ(provider->TestContext3d()->height(), 10); |
| 4106 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 4106 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
| 4107 host_impl_->DidDrawAllLayers(frame); | 4107 host_impl_->DidDrawAllLayers(frame); |
| 4108 provider->TestContext3d()->clear_reshape_called(); | 4108 provider->TestContext3d()->clear_reshape_called(); |
| 4109 | 4109 |
| 4110 host_impl_->SetViewportSize(gfx::Size(20, 30)); | 4110 host_impl_->SetViewportSize(gfx::Size(20, 30)); |
| 4111 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4111 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4112 host_impl_->DrawLayers(&frame); | 4112 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4113 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 4113 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 4114 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 4114 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
| 4115 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 4115 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
| 4116 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | 4116 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); |
| 4117 host_impl_->DidDrawAllLayers(frame); | 4117 host_impl_->DidDrawAllLayers(frame); |
| 4118 provider->TestContext3d()->clear_reshape_called(); | 4118 provider->TestContext3d()->clear_reshape_called(); |
| 4119 | 4119 |
| 4120 host_impl_->SetDeviceScaleFactor(2.f); | 4120 host_impl_->SetDeviceScaleFactor(2.f); |
| 4121 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4121 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4122 host_impl_->DrawLayers(&frame); | 4122 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4123 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | 4123 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); |
| 4124 EXPECT_EQ(provider->TestContext3d()->width(), 20); | 4124 EXPECT_EQ(provider->TestContext3d()->width(), 20); |
| 4125 EXPECT_EQ(provider->TestContext3d()->height(), 30); | 4125 EXPECT_EQ(provider->TestContext3d()->height(), 30); |
| 4126 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); | 4126 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); |
| 4127 host_impl_->DidDrawAllLayers(frame); | 4127 host_impl_->DidDrawAllLayers(frame); |
| 4128 provider->TestContext3d()->clear_reshape_called(); | 4128 provider->TestContext3d()->clear_reshape_called(); |
| 4129 } | 4129 } |
| 4130 | 4130 |
| 4131 // Make sure damage tracking propagates all the way to the graphics context, | 4131 // Make sure damage tracking propagates all the way to the graphics context, |
| 4132 // where it should request to swap only the sub-buffer that is damaged. | 4132 // where it should request to swap only the sub-buffer that is damaged. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4166 root->SetBounds(gfx::Size(500, 500)); | 4166 root->SetBounds(gfx::Size(500, 500)); |
| 4167 root->SetContentBounds(gfx::Size(500, 500)); | 4167 root->SetContentBounds(gfx::Size(500, 500)); |
| 4168 root->SetDrawsContent(true); | 4168 root->SetDrawsContent(true); |
| 4169 root->AddChild(child.Pass()); | 4169 root->AddChild(child.Pass()); |
| 4170 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); | 4170 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); |
| 4171 | 4171 |
| 4172 LayerTreeHostImpl::FrameData frame; | 4172 LayerTreeHostImpl::FrameData frame; |
| 4173 | 4173 |
| 4174 // First frame, the entire screen should get swapped. | 4174 // First frame, the entire screen should get swapped. |
| 4175 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 4175 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 4176 layer_tree_host_impl->DrawLayers(&frame); | 4176 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4177 layer_tree_host_impl->DidDrawAllLayers(frame); | 4177 layer_tree_host_impl->DidDrawAllLayers(frame); |
| 4178 layer_tree_host_impl->SwapBuffers(frame); | 4178 layer_tree_host_impl->SwapBuffers(frame); |
| 4179 EXPECT_EQ(TestContextSupport::SWAP, | 4179 EXPECT_EQ(TestContextSupport::SWAP, |
| 4180 context_provider->support()->last_swap_type()); | 4180 context_provider->support()->last_swap_type()); |
| 4181 | 4181 |
| 4182 // Second frame, only the damaged area should get swapped. Damage should be | 4182 // Second frame, only the damaged area should get swapped. Damage should be |
| 4183 // the union of old and new child rects. | 4183 // the union of old and new child rects. |
| 4184 // expected damage rect: gfx::Rect(26, 28); | 4184 // expected damage rect: gfx::Rect(26, 28); |
| 4185 // expected swap rect: vertically flipped, with origin at bottom left corner. | 4185 // expected swap rect: vertically flipped, with origin at bottom left corner. |
| 4186 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( | 4186 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( |
| 4187 gfx::PointF()); | 4187 gfx::PointF()); |
| 4188 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 4188 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 4189 layer_tree_host_impl->DrawLayers(&frame); | 4189 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4190 host_impl_->DidDrawAllLayers(frame); | 4190 host_impl_->DidDrawAllLayers(frame); |
| 4191 layer_tree_host_impl->SwapBuffers(frame); | 4191 layer_tree_host_impl->SwapBuffers(frame); |
| 4192 | 4192 |
| 4193 // Make sure that partial swap is constrained to the viewport dimensions | 4193 // Make sure that partial swap is constrained to the viewport dimensions |
| 4194 // expected damage rect: gfx::Rect(500, 500); | 4194 // expected damage rect: gfx::Rect(500, 500); |
| 4195 // expected swap rect: flipped damage rect, but also clamped to viewport | 4195 // expected swap rect: flipped damage rect, but also clamped to viewport |
| 4196 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, | 4196 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, |
| 4197 context_provider->support()->last_swap_type()); | 4197 context_provider->support()->last_swap_type()); |
| 4198 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); | 4198 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); |
| 4199 EXPECT_EQ(expected_swap_rect.ToString(), | 4199 EXPECT_EQ(expected_swap_rect.ToString(), |
| 4200 context_provider->support()-> | 4200 context_provider->support()-> |
| 4201 last_partial_swap_rect().ToString()); | 4201 last_partial_swap_rect().ToString()); |
| 4202 | 4202 |
| 4203 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); | 4203 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); |
| 4204 // This will damage everything. | 4204 // This will damage everything. |
| 4205 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( | 4205 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( |
| 4206 SK_ColorBLACK); | 4206 SK_ColorBLACK); |
| 4207 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 4207 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 4208 layer_tree_host_impl->DrawLayers(&frame); | 4208 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4209 host_impl_->DidDrawAllLayers(frame); | 4209 host_impl_->DidDrawAllLayers(frame); |
| 4210 layer_tree_host_impl->SwapBuffers(frame); | 4210 layer_tree_host_impl->SwapBuffers(frame); |
| 4211 | 4211 |
| 4212 EXPECT_EQ(TestContextSupport::SWAP, | 4212 EXPECT_EQ(TestContextSupport::SWAP, |
| 4213 context_provider->support()->last_swap_type()); | 4213 context_provider->support()->last_swap_type()); |
| 4214 } | 4214 } |
| 4215 | 4215 |
| 4216 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 4216 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
| 4217 scoped_ptr<LayerImpl> root = | 4217 scoped_ptr<LayerImpl> root = |
| 4218 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 4218 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4364 settings.partial_swap_enabled = false; | 4364 settings.partial_swap_enabled = false; |
| 4365 CreateHostImpl(settings, output_surface.Pass()); | 4365 CreateHostImpl(settings, output_surface.Pass()); |
| 4366 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 4366 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 4367 | 4367 |
| 4368 // Without partial swap, and no clipping, no scissor is set. | 4368 // Without partial swap, and no clipping, no scissor is set. |
| 4369 harness.MustDrawSolidQuad(); | 4369 harness.MustDrawSolidQuad(); |
| 4370 harness.MustSetNoScissor(); | 4370 harness.MustSetNoScissor(); |
| 4371 { | 4371 { |
| 4372 LayerTreeHostImpl::FrameData frame; | 4372 LayerTreeHostImpl::FrameData frame; |
| 4373 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4373 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4374 host_impl_->DrawLayers(&frame); | 4374 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4375 host_impl_->DidDrawAllLayers(frame); | 4375 host_impl_->DidDrawAllLayers(frame); |
| 4376 } | 4376 } |
| 4377 Mock::VerifyAndClearExpectations(&mock_context); | 4377 Mock::VerifyAndClearExpectations(&mock_context); |
| 4378 | 4378 |
| 4379 // Without partial swap, but a layer does clip its subtree, one scissor is | 4379 // Without partial swap, but a layer does clip its subtree, one scissor is |
| 4380 // set. | 4380 // set. |
| 4381 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); | 4381 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); |
| 4382 harness.MustDrawSolidQuad(); | 4382 harness.MustDrawSolidQuad(); |
| 4383 harness.MustSetScissor(0, 0, 10, 10); | 4383 harness.MustSetScissor(0, 0, 10, 10); |
| 4384 { | 4384 { |
| 4385 LayerTreeHostImpl::FrameData frame; | 4385 LayerTreeHostImpl::FrameData frame; |
| 4386 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4386 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4387 host_impl_->DrawLayers(&frame); | 4387 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4388 host_impl_->DidDrawAllLayers(frame); | 4388 host_impl_->DidDrawAllLayers(frame); |
| 4389 } | 4389 } |
| 4390 Mock::VerifyAndClearExpectations(&mock_context); | 4390 Mock::VerifyAndClearExpectations(&mock_context); |
| 4391 } | 4391 } |
| 4392 | 4392 |
| 4393 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 4393 TEST_F(LayerTreeHostImplTest, PartialSwap) { |
| 4394 scoped_ptr<MockContext> context_owned(new MockContext); | 4394 scoped_ptr<MockContext> context_owned(new MockContext); |
| 4395 MockContext* mock_context = context_owned.get(); | 4395 MockContext* mock_context = context_owned.get(); |
| 4396 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( | 4396 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 4397 context_owned.PassAs<TestWebGraphicsContext3D>())); | 4397 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 4398 MockContextHarness harness(mock_context); | 4398 MockContextHarness harness(mock_context); |
| 4399 | 4399 |
| 4400 LayerTreeSettings settings = DefaultSettings(); | 4400 LayerTreeSettings settings = DefaultSettings(); |
| 4401 settings.partial_swap_enabled = true; | 4401 settings.partial_swap_enabled = true; |
| 4402 CreateHostImpl(settings, output_surface.Pass()); | 4402 CreateHostImpl(settings, output_surface.Pass()); |
| 4403 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 4403 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 4404 | 4404 |
| 4405 // The first frame is not a partially-swapped one. | 4405 // The first frame is not a partially-swapped one. |
| 4406 harness.MustSetScissor(0, 0, 10, 10); | 4406 harness.MustSetScissor(0, 0, 10, 10); |
| 4407 harness.MustDrawSolidQuad(); | 4407 harness.MustDrawSolidQuad(); |
| 4408 { | 4408 { |
| 4409 LayerTreeHostImpl::FrameData frame; | 4409 LayerTreeHostImpl::FrameData frame; |
| 4410 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4410 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4411 host_impl_->DrawLayers(&frame); | 4411 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4412 host_impl_->DidDrawAllLayers(frame); | 4412 host_impl_->DidDrawAllLayers(frame); |
| 4413 } | 4413 } |
| 4414 Mock::VerifyAndClearExpectations(&mock_context); | 4414 Mock::VerifyAndClearExpectations(&mock_context); |
| 4415 | 4415 |
| 4416 // Damage a portion of the frame. | 4416 // Damage a portion of the frame. |
| 4417 host_impl_->active_tree()->root_layer()->SetUpdateRect( | 4417 host_impl_->active_tree()->root_layer()->SetUpdateRect( |
| 4418 gfx::Rect(0, 0, 2, 3)); | 4418 gfx::Rect(0, 0, 2, 3)); |
| 4419 | 4419 |
| 4420 // The second frame will be partially-swapped (the y coordinates are flipped). | 4420 // The second frame will be partially-swapped (the y coordinates are flipped). |
| 4421 harness.MustSetScissor(0, 7, 2, 3); | 4421 harness.MustSetScissor(0, 7, 2, 3); |
| 4422 harness.MustDrawSolidQuad(); | 4422 harness.MustDrawSolidQuad(); |
| 4423 { | 4423 { |
| 4424 LayerTreeHostImpl::FrameData frame; | 4424 LayerTreeHostImpl::FrameData frame; |
| 4425 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4425 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4426 host_impl_->DrawLayers(&frame); | 4426 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4427 host_impl_->DidDrawAllLayers(frame); | 4427 host_impl_->DidDrawAllLayers(frame); |
| 4428 } | 4428 } |
| 4429 Mock::VerifyAndClearExpectations(&mock_context); | 4429 Mock::VerifyAndClearExpectations(&mock_context); |
| 4430 } | 4430 } |
| 4431 | 4431 |
| 4432 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 4432 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
| 4433 bool partial_swap, | 4433 bool partial_swap, |
| 4434 LayerTreeHostImplClient* client, | 4434 LayerTreeHostImplClient* client, |
| 4435 Proxy* proxy, | 4435 Proxy* proxy, |
| 4436 SharedBitmapManager* manager, | 4436 SharedBitmapManager* manager, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4521 | 4521 |
| 4522 // Verify all quads have been computed | 4522 // Verify all quads have been computed |
| 4523 ASSERT_EQ(2U, frame.render_passes.size()); | 4523 ASSERT_EQ(2U, frame.render_passes.size()); |
| 4524 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 4524 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 4525 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 4525 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 4526 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 4526 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| 4527 frame.render_passes[0]->quad_list[0]->material); | 4527 frame.render_passes[0]->quad_list[0]->material); |
| 4528 EXPECT_EQ(DrawQuad::RENDER_PASS, | 4528 EXPECT_EQ(DrawQuad::RENDER_PASS, |
| 4529 frame.render_passes[1]->quad_list[0]->material); | 4529 frame.render_passes[1]->quad_list[0]->material); |
| 4530 | 4530 |
| 4531 my_host_impl->DrawLayers(&frame); | 4531 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4532 my_host_impl->DidDrawAllLayers(frame); | 4532 my_host_impl->DidDrawAllLayers(frame); |
| 4533 } | 4533 } |
| 4534 } | 4534 } |
| 4535 | 4535 |
| 4536 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 4536 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
| 4537 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 4537 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 4538 new TestSharedBitmapManager()); | 4538 new TestSharedBitmapManager()); |
| 4539 scoped_ptr<LayerTreeHostImpl> my_host_impl = | 4539 scoped_ptr<LayerTreeHostImpl> my_host_impl = |
| 4540 SetupLayersForOpacity(false, | 4540 SetupLayersForOpacity(false, |
| 4541 this, | 4541 this, |
| 4542 &proxy_, | 4542 &proxy_, |
| 4543 shared_bitmap_manager.get(), | 4543 shared_bitmap_manager.get(), |
| 4544 &stats_instrumentation_); | 4544 &stats_instrumentation_); |
| 4545 { | 4545 { |
| 4546 LayerTreeHostImpl::FrameData frame; | 4546 LayerTreeHostImpl::FrameData frame; |
| 4547 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 4547 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
| 4548 | 4548 |
| 4549 // Verify all quads have been computed | 4549 // Verify all quads have been computed |
| 4550 ASSERT_EQ(2U, frame.render_passes.size()); | 4550 ASSERT_EQ(2U, frame.render_passes.size()); |
| 4551 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 4551 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 4552 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 4552 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 4553 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 4553 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| 4554 frame.render_passes[0]->quad_list[0]->material); | 4554 frame.render_passes[0]->quad_list[0]->material); |
| 4555 EXPECT_EQ(DrawQuad::RENDER_PASS, | 4555 EXPECT_EQ(DrawQuad::RENDER_PASS, |
| 4556 frame.render_passes[1]->quad_list[0]->material); | 4556 frame.render_passes[1]->quad_list[0]->material); |
| 4557 | 4557 |
| 4558 my_host_impl->DrawLayers(&frame); | 4558 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4559 my_host_impl->DidDrawAllLayers(frame); | 4559 my_host_impl->DidDrawAllLayers(frame); |
| 4560 } | 4560 } |
| 4561 } | 4561 } |
| 4562 | 4562 |
| 4563 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { | 4563 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
| 4564 scoped_ptr<TestWebGraphicsContext3D> context = | 4564 scoped_ptr<TestWebGraphicsContext3D> context = |
| 4565 TestWebGraphicsContext3D::Create(); | 4565 TestWebGraphicsContext3D::Create(); |
| 4566 TestWebGraphicsContext3D* context3d = context.get(); | 4566 TestWebGraphicsContext3D* context3d = context.get(); |
| 4567 scoped_ptr<OutputSurface> output_surface( | 4567 scoped_ptr<OutputSurface> output_surface( |
| 4568 FakeOutputSurface::Create3d(context.Pass())); | 4568 FakeOutputSurface::Create3d(context.Pass())); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4591 io_surface_layer->SetDrawsContent(true); | 4591 io_surface_layer->SetDrawsContent(true); |
| 4592 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); | 4592 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); |
| 4593 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); | 4593 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); |
| 4594 | 4594 |
| 4595 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); | 4595 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); |
| 4596 | 4596 |
| 4597 EXPECT_EQ(0u, context3d->NumTextures()); | 4597 EXPECT_EQ(0u, context3d->NumTextures()); |
| 4598 | 4598 |
| 4599 LayerTreeHostImpl::FrameData frame; | 4599 LayerTreeHostImpl::FrameData frame; |
| 4600 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4600 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4601 host_impl_->DrawLayers(&frame); | 4601 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4602 host_impl_->DidDrawAllLayers(frame); | 4602 host_impl_->DidDrawAllLayers(frame); |
| 4603 host_impl_->SwapBuffers(frame); | 4603 host_impl_->SwapBuffers(frame); |
| 4604 | 4604 |
| 4605 EXPECT_GT(context3d->NumTextures(), 0u); | 4605 EXPECT_GT(context3d->NumTextures(), 0u); |
| 4606 | 4606 |
| 4607 // Kill the layer tree. | 4607 // Kill the layer tree. |
| 4608 host_impl_->active_tree()->SetRootLayer( | 4608 host_impl_->active_tree()->SetRootLayer( |
| 4609 LayerImpl::Create(host_impl_->active_tree(), 100)); | 4609 LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 4610 // There should be no textures left in use after. | 4610 // There should be no textures left in use after. |
| 4611 EXPECT_EQ(0u, context3d->NumTextures()); | 4611 EXPECT_EQ(0u, context3d->NumTextures()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4636 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 4636 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
| 4637 | 4637 |
| 4638 // Verify one quad is drawn when transparent background set is not set. | 4638 // Verify one quad is drawn when transparent background set is not set. |
| 4639 host_impl_->active_tree()->set_has_transparent_background(false); | 4639 host_impl_->active_tree()->set_has_transparent_background(false); |
| 4640 EXPECT_CALL(*mock_context, useProgram(_)) | 4640 EXPECT_CALL(*mock_context, useProgram(_)) |
| 4641 .Times(1); | 4641 .Times(1); |
| 4642 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | 4642 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) |
| 4643 .Times(1); | 4643 .Times(1); |
| 4644 LayerTreeHostImpl::FrameData frame; | 4644 LayerTreeHostImpl::FrameData frame; |
| 4645 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4645 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4646 host_impl_->DrawLayers(&frame); | 4646 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4647 host_impl_->DidDrawAllLayers(frame); | 4647 host_impl_->DidDrawAllLayers(frame); |
| 4648 Mock::VerifyAndClearExpectations(&mock_context); | 4648 Mock::VerifyAndClearExpectations(&mock_context); |
| 4649 | 4649 |
| 4650 // Verify no quads are drawn when transparent background is set. | 4650 // Verify no quads are drawn when transparent background is set. |
| 4651 host_impl_->active_tree()->set_has_transparent_background(true); | 4651 host_impl_->active_tree()->set_has_transparent_background(true); |
| 4652 host_impl_->SetFullRootLayerDamage(); | 4652 host_impl_->SetFullRootLayerDamage(); |
| 4653 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4653 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4654 host_impl_->DrawLayers(&frame); | 4654 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4655 host_impl_->DidDrawAllLayers(frame); | 4655 host_impl_->DidDrawAllLayers(frame); |
| 4656 Mock::VerifyAndClearExpectations(&mock_context); | 4656 Mock::VerifyAndClearExpectations(&mock_context); |
| 4657 } | 4657 } |
| 4658 | 4658 |
| 4659 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { | 4659 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { |
| 4660 set_reduce_memory_result(false); | 4660 set_reduce_memory_result(false); |
| 4661 | 4661 |
| 4662 // If changing the memory limit wouldn't result in changing what was | 4662 // If changing the memory limit wouldn't result in changing what was |
| 4663 // committed, then no commit should be requested. | 4663 // committed, then no commit should be requested. |
| 4664 set_reduce_memory_result(false); | 4664 set_reduce_memory_result(false); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4727 gfx::RectF expected_child_visible_rect(child->content_bounds()); | 4727 gfx::RectF expected_child_visible_rect(child->content_bounds()); |
| 4728 EXPECT_RECT_EQ(expected_child_visible_rect, | 4728 EXPECT_RECT_EQ(expected_child_visible_rect, |
| 4729 root_render_pass->quad_list[0]->visible_rect); | 4729 root_render_pass->quad_list[0]->visible_rect); |
| 4730 | 4730 |
| 4731 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4731 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 4732 gfx::RectF expected_root_visible_rect(root->content_bounds()); | 4732 gfx::RectF expected_root_visible_rect(root->content_bounds()); |
| 4733 EXPECT_RECT_EQ(expected_root_visible_rect, | 4733 EXPECT_RECT_EQ(expected_root_visible_rect, |
| 4734 root_render_pass->quad_list[1]->visible_rect); | 4734 root_render_pass->quad_list[1]->visible_rect); |
| 4735 } | 4735 } |
| 4736 | 4736 |
| 4737 host_impl_->DrawLayers(&frame); | 4737 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4738 host_impl_->DidDrawAllLayers(frame); | 4738 host_impl_->DidDrawAllLayers(frame); |
| 4739 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); | 4739 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); |
| 4740 } | 4740 } |
| 4741 }; | 4741 }; |
| 4742 | 4742 |
| 4743 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { | 4743 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { |
| 4744 scoped_ptr<SolidColorLayerImpl> root = | 4744 scoped_ptr<SolidColorLayerImpl> root = |
| 4745 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 4745 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 4746 root->SetPosition(gfx::PointF()); | 4746 root->SetPosition(gfx::PointF()); |
| 4747 root->SetBounds(gfx::Size(10, 10)); | 4747 root->SetBounds(gfx::Size(10, 10)); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4866 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4866 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4867 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4867 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4868 frame.render_passes[0]->quad_list[0]->material); | 4868 frame.render_passes[0]->quad_list[0]->material); |
| 4869 const RenderPassDrawQuad* render_pass_quad = | 4869 const RenderPassDrawQuad* render_pass_quad = |
| 4870 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4870 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4871 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 4871 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 4872 render_pass_quad->rect.ToString()); | 4872 render_pass_quad->rect.ToString()); |
| 4873 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4873 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4874 render_pass_quad->mask_uv_rect.ToString()); | 4874 render_pass_quad->mask_uv_rect.ToString()); |
| 4875 | 4875 |
| 4876 host_impl_->DrawLayers(&frame); | 4876 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4877 host_impl_->DidDrawAllLayers(frame); | 4877 host_impl_->DidDrawAllLayers(frame); |
| 4878 } | 4878 } |
| 4879 | 4879 |
| 4880 | 4880 |
| 4881 // Applying a DSF should change the render surface size, but won't affect | 4881 // Applying a DSF should change the render surface size, but won't affect |
| 4882 // which part of the mask is used. | 4882 // which part of the mask is used. |
| 4883 device_scale_factor = 2.f; | 4883 device_scale_factor = 2.f; |
| 4884 gfx::Size device_viewport = | 4884 gfx::Size device_viewport = |
| 4885 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); | 4885 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 4886 host_impl_->SetViewportSize(device_viewport); | 4886 host_impl_->SetViewportSize(device_viewport); |
| 4887 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4887 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4888 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4888 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4889 { | 4889 { |
| 4890 LayerTreeHostImpl::FrameData frame; | 4890 LayerTreeHostImpl::FrameData frame; |
| 4891 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4891 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4892 | 4892 |
| 4893 ASSERT_EQ(1u, frame.render_passes.size()); | 4893 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4894 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4894 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4895 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4895 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4896 frame.render_passes[0]->quad_list[0]->material); | 4896 frame.render_passes[0]->quad_list[0]->material); |
| 4897 const RenderPassDrawQuad* render_pass_quad = | 4897 const RenderPassDrawQuad* render_pass_quad = |
| 4898 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4898 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4899 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), | 4899 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), |
| 4900 render_pass_quad->rect.ToString()); | 4900 render_pass_quad->rect.ToString()); |
| 4901 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4901 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4902 render_pass_quad->mask_uv_rect.ToString()); | 4902 render_pass_quad->mask_uv_rect.ToString()); |
| 4903 | 4903 |
| 4904 host_impl_->DrawLayers(&frame); | 4904 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4905 host_impl_->DidDrawAllLayers(frame); | 4905 host_impl_->DidDrawAllLayers(frame); |
| 4906 } | 4906 } |
| 4907 | 4907 |
| 4908 | 4908 |
| 4909 // Applying an equivalent content scale on the content layer and the mask | 4909 // Applying an equivalent content scale on the content layer and the mask |
| 4910 // should still result in the same part of the mask being used. | 4910 // should still result in the same part of the mask being used. |
| 4911 gfx::Size content_bounds = | 4911 gfx::Size content_bounds = |
| 4912 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, | 4912 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, |
| 4913 device_scale_factor)); | 4913 device_scale_factor)); |
| 4914 content_layer->SetContentBounds(content_bounds); | 4914 content_layer->SetContentBounds(content_bounds); |
| 4915 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 4915 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 4916 mask_layer->SetContentBounds(content_bounds); | 4916 mask_layer->SetContentBounds(content_bounds); |
| 4917 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 4917 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 4918 host_impl_->active_tree()->set_needs_update_draw_properties(); | 4918 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 4919 { | 4919 { |
| 4920 LayerTreeHostImpl::FrameData frame; | 4920 LayerTreeHostImpl::FrameData frame; |
| 4921 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 4921 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 4922 | 4922 |
| 4923 ASSERT_EQ(1u, frame.render_passes.size()); | 4923 ASSERT_EQ(1u, frame.render_passes.size()); |
| 4924 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4924 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4925 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4925 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4926 frame.render_passes[0]->quad_list[0]->material); | 4926 frame.render_passes[0]->quad_list[0]->material); |
| 4927 const RenderPassDrawQuad* render_pass_quad = | 4927 const RenderPassDrawQuad* render_pass_quad = |
| 4928 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4928 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4929 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), | 4929 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), |
| 4930 render_pass_quad->rect.ToString()); | 4930 render_pass_quad->rect.ToString()); |
| 4931 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4931 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4932 render_pass_quad->mask_uv_rect.ToString()); | 4932 render_pass_quad->mask_uv_rect.ToString()); |
| 4933 | 4933 |
| 4934 host_impl_->DrawLayers(&frame); | 4934 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4935 host_impl_->DidDrawAllLayers(frame); | 4935 host_impl_->DidDrawAllLayers(frame); |
| 4936 } | 4936 } |
| 4937 } | 4937 } |
| 4938 | 4938 |
| 4939 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { | 4939 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { |
| 4940 // The mask layer has bounds 100x100 but is attached to a layer with bounds | 4940 // The mask layer has bounds 100x100 but is attached to a layer with bounds |
| 4941 // 50x50. | 4941 // 50x50. |
| 4942 | 4942 |
| 4943 scoped_ptr<LayerImpl> scoped_root = | 4943 scoped_ptr<LayerImpl> scoped_root = |
| 4944 LayerImpl::Create(host_impl_->active_tree(), 1); | 4944 LayerImpl::Create(host_impl_->active_tree(), 1); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4984 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 4984 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 4985 ASSERT_EQ(DrawQuad::RENDER_PASS, | 4985 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 4986 frame.render_passes[0]->quad_list[0]->material); | 4986 frame.render_passes[0]->quad_list[0]->material); |
| 4987 const RenderPassDrawQuad* render_pass_quad = | 4987 const RenderPassDrawQuad* render_pass_quad = |
| 4988 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 4988 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 4989 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 4989 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 4990 render_pass_quad->rect.ToString()); | 4990 render_pass_quad->rect.ToString()); |
| 4991 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 4991 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 4992 render_pass_quad->mask_uv_rect.ToString()); | 4992 render_pass_quad->mask_uv_rect.ToString()); |
| 4993 | 4993 |
| 4994 host_impl_->DrawLayers(&frame); | 4994 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4995 host_impl_->DidDrawAllLayers(frame); | 4995 host_impl_->DidDrawAllLayers(frame); |
| 4996 } | 4996 } |
| 4997 | 4997 |
| 4998 // Applying a DSF should change the render surface size, but won't affect | 4998 // Applying a DSF should change the render surface size, but won't affect |
| 4999 // which part of the mask is used. | 4999 // which part of the mask is used. |
| 5000 device_scale_factor = 2.f; | 5000 device_scale_factor = 2.f; |
| 5001 gfx::Size device_viewport = | 5001 gfx::Size device_viewport = |
| 5002 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); | 5002 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 5003 host_impl_->SetViewportSize(device_viewport); | 5003 host_impl_->SetViewportSize(device_viewport); |
| 5004 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 5004 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 5005 host_impl_->active_tree()->set_needs_update_draw_properties(); | 5005 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 5006 { | 5006 { |
| 5007 LayerTreeHostImpl::FrameData frame; | 5007 LayerTreeHostImpl::FrameData frame; |
| 5008 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5008 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5009 | 5009 |
| 5010 ASSERT_EQ(1u, frame.render_passes.size()); | 5010 ASSERT_EQ(1u, frame.render_passes.size()); |
| 5011 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 5011 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 5012 ASSERT_EQ(DrawQuad::RENDER_PASS, | 5012 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 5013 frame.render_passes[0]->quad_list[0]->material); | 5013 frame.render_passes[0]->quad_list[0]->material); |
| 5014 const RenderPassDrawQuad* render_pass_quad = | 5014 const RenderPassDrawQuad* render_pass_quad = |
| 5015 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 5015 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 5016 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 5016 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 5017 render_pass_quad->rect.ToString()); | 5017 render_pass_quad->rect.ToString()); |
| 5018 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 5018 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 5019 render_pass_quad->mask_uv_rect.ToString()); | 5019 render_pass_quad->mask_uv_rect.ToString()); |
| 5020 | 5020 |
| 5021 host_impl_->DrawLayers(&frame); | 5021 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5022 host_impl_->DidDrawAllLayers(frame); | 5022 host_impl_->DidDrawAllLayers(frame); |
| 5023 } | 5023 } |
| 5024 | 5024 |
| 5025 // Applying an equivalent content scale on the content layer and the mask | 5025 // Applying an equivalent content scale on the content layer and the mask |
| 5026 // should still result in the same part of the mask being used. | 5026 // should still result in the same part of the mask being used. |
| 5027 gfx::Size layer_size_large = | 5027 gfx::Size layer_size_large = |
| 5028 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); | 5028 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); |
| 5029 content_layer->SetContentBounds(layer_size_large); | 5029 content_layer->SetContentBounds(layer_size_large); |
| 5030 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 5030 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 5031 gfx::Size mask_size_large = | 5031 gfx::Size mask_size_large = |
| 5032 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); | 5032 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); |
| 5033 mask_layer->SetContentBounds(mask_size_large); | 5033 mask_layer->SetContentBounds(mask_size_large); |
| 5034 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 5034 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 5035 host_impl_->active_tree()->set_needs_update_draw_properties(); | 5035 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 5036 { | 5036 { |
| 5037 LayerTreeHostImpl::FrameData frame; | 5037 LayerTreeHostImpl::FrameData frame; |
| 5038 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5038 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5039 | 5039 |
| 5040 ASSERT_EQ(1u, frame.render_passes.size()); | 5040 ASSERT_EQ(1u, frame.render_passes.size()); |
| 5041 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 5041 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 5042 ASSERT_EQ(DrawQuad::RENDER_PASS, | 5042 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 5043 frame.render_passes[0]->quad_list[0]->material); | 5043 frame.render_passes[0]->quad_list[0]->material); |
| 5044 const RenderPassDrawQuad* render_pass_quad = | 5044 const RenderPassDrawQuad* render_pass_quad = |
| 5045 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 5045 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 5046 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 5046 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 5047 render_pass_quad->rect.ToString()); | 5047 render_pass_quad->rect.ToString()); |
| 5048 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 5048 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 5049 render_pass_quad->mask_uv_rect.ToString()); | 5049 render_pass_quad->mask_uv_rect.ToString()); |
| 5050 | 5050 |
| 5051 host_impl_->DrawLayers(&frame); | 5051 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5052 host_impl_->DidDrawAllLayers(frame); | 5052 host_impl_->DidDrawAllLayers(frame); |
| 5053 } | 5053 } |
| 5054 | 5054 |
| 5055 // Applying a different contents scale to the mask layer means it will have | 5055 // Applying a different contents scale to the mask layer means it will have |
| 5056 // a larger texture, but it should use the same tex coords to cover the | 5056 // a larger texture, but it should use the same tex coords to cover the |
| 5057 // layer it masks. | 5057 // layer it masks. |
| 5058 mask_layer->SetContentBounds(mask_size); | 5058 mask_layer->SetContentBounds(mask_size); |
| 5059 mask_layer->SetContentsScale(1.f, 1.f); | 5059 mask_layer->SetContentsScale(1.f, 1.f); |
| 5060 host_impl_->active_tree()->set_needs_update_draw_properties(); | 5060 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 5061 { | 5061 { |
| 5062 LayerTreeHostImpl::FrameData frame; | 5062 LayerTreeHostImpl::FrameData frame; |
| 5063 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5063 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5064 | 5064 |
| 5065 ASSERT_EQ(1u, frame.render_passes.size()); | 5065 ASSERT_EQ(1u, frame.render_passes.size()); |
| 5066 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); | 5066 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); |
| 5067 ASSERT_EQ(DrawQuad::RENDER_PASS, | 5067 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 5068 frame.render_passes[0]->quad_list[0]->material); | 5068 frame.render_passes[0]->quad_list[0]->material); |
| 5069 const RenderPassDrawQuad* render_pass_quad = | 5069 const RenderPassDrawQuad* render_pass_quad = |
| 5070 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); | 5070 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); |
| 5071 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 5071 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 5072 render_pass_quad->rect.ToString()); | 5072 render_pass_quad->rect.ToString()); |
| 5073 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 5073 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 5074 render_pass_quad->mask_uv_rect.ToString()); | 5074 render_pass_quad->mask_uv_rect.ToString()); |
| 5075 | 5075 |
| 5076 host_impl_->DrawLayers(&frame); | 5076 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5077 host_impl_->DidDrawAllLayers(frame); | 5077 host_impl_->DidDrawAllLayers(frame); |
| 5078 } | 5078 } |
| 5079 } | 5079 } |
| 5080 | 5080 |
| 5081 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { | 5081 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { |
| 5082 // The replica's mask layer has bounds 100x100 but the replica is of a | 5082 // The replica's mask layer has bounds 100x100 but the replica is of a |
| 5083 // layer with bounds 50x50. | 5083 // layer with bounds 50x50. |
| 5084 | 5084 |
| 5085 scoped_ptr<LayerImpl> scoped_root = | 5085 scoped_ptr<LayerImpl> scoped_root = |
| 5086 LayerImpl::Create(host_impl_->active_tree(), 1); | 5086 LayerImpl::Create(host_impl_->active_tree(), 1); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5132 ASSERT_EQ(DrawQuad::RENDER_PASS, | 5132 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 5133 frame.render_passes[0]->quad_list[1]->material); | 5133 frame.render_passes[0]->quad_list[1]->material); |
| 5134 const RenderPassDrawQuad* replica_quad = | 5134 const RenderPassDrawQuad* replica_quad = |
| 5135 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 5135 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 5136 EXPECT_TRUE(replica_quad->is_replica); | 5136 EXPECT_TRUE(replica_quad->is_replica); |
| 5137 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 5137 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 5138 replica_quad->rect.ToString()); | 5138 replica_quad->rect.ToString()); |
| 5139 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 5139 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 5140 replica_quad->mask_uv_rect.ToString()); | 5140 replica_quad->mask_uv_rect.ToString()); |
| 5141 | 5141 |
| 5142 host_impl_->DrawLayers(&frame); | 5142 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5143 host_impl_->DidDrawAllLayers(frame); | 5143 host_impl_->DidDrawAllLayers(frame); |
| 5144 } | 5144 } |
| 5145 | 5145 |
| 5146 // Applying a DSF should change the render surface size, but won't affect | 5146 // Applying a DSF should change the render surface size, but won't affect |
| 5147 // which part of the mask is used. | 5147 // which part of the mask is used. |
| 5148 device_scale_factor = 2.f; | 5148 device_scale_factor = 2.f; |
| 5149 gfx::Size device_viewport = | 5149 gfx::Size device_viewport = |
| 5150 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); | 5150 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); |
| 5151 host_impl_->SetViewportSize(device_viewport); | 5151 host_impl_->SetViewportSize(device_viewport); |
| 5152 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 5152 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 5153 host_impl_->active_tree()->set_needs_update_draw_properties(); | 5153 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 5154 { | 5154 { |
| 5155 LayerTreeHostImpl::FrameData frame; | 5155 LayerTreeHostImpl::FrameData frame; |
| 5156 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5156 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5157 | 5157 |
| 5158 ASSERT_EQ(1u, frame.render_passes.size()); | 5158 ASSERT_EQ(1u, frame.render_passes.size()); |
| 5159 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | 5159 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); |
| 5160 ASSERT_EQ(DrawQuad::RENDER_PASS, | 5160 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 5161 frame.render_passes[0]->quad_list[1]->material); | 5161 frame.render_passes[0]->quad_list[1]->material); |
| 5162 const RenderPassDrawQuad* replica_quad = | 5162 const RenderPassDrawQuad* replica_quad = |
| 5163 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 5163 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 5164 EXPECT_TRUE(replica_quad->is_replica); | 5164 EXPECT_TRUE(replica_quad->is_replica); |
| 5165 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 5165 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 5166 replica_quad->rect.ToString()); | 5166 replica_quad->rect.ToString()); |
| 5167 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 5167 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 5168 replica_quad->mask_uv_rect.ToString()); | 5168 replica_quad->mask_uv_rect.ToString()); |
| 5169 | 5169 |
| 5170 host_impl_->DrawLayers(&frame); | 5170 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5171 host_impl_->DidDrawAllLayers(frame); | 5171 host_impl_->DidDrawAllLayers(frame); |
| 5172 } | 5172 } |
| 5173 | 5173 |
| 5174 // Applying an equivalent content scale on the content layer and the mask | 5174 // Applying an equivalent content scale on the content layer and the mask |
| 5175 // should still result in the same part of the mask being used. | 5175 // should still result in the same part of the mask being used. |
| 5176 gfx::Size layer_size_large = | 5176 gfx::Size layer_size_large = |
| 5177 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); | 5177 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); |
| 5178 content_layer->SetContentBounds(layer_size_large); | 5178 content_layer->SetContentBounds(layer_size_large); |
| 5179 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); | 5179 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); |
| 5180 gfx::Size mask_size_large = | 5180 gfx::Size mask_size_large = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5191 ASSERT_EQ(DrawQuad::RENDER_PASS, | 5191 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 5192 frame.render_passes[0]->quad_list[1]->material); | 5192 frame.render_passes[0]->quad_list[1]->material); |
| 5193 const RenderPassDrawQuad* replica_quad = | 5193 const RenderPassDrawQuad* replica_quad = |
| 5194 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 5194 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 5195 EXPECT_TRUE(replica_quad->is_replica); | 5195 EXPECT_TRUE(replica_quad->is_replica); |
| 5196 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 5196 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 5197 replica_quad->rect.ToString()); | 5197 replica_quad->rect.ToString()); |
| 5198 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 5198 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 5199 replica_quad->mask_uv_rect.ToString()); | 5199 replica_quad->mask_uv_rect.ToString()); |
| 5200 | 5200 |
| 5201 host_impl_->DrawLayers(&frame); | 5201 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5202 host_impl_->DidDrawAllLayers(frame); | 5202 host_impl_->DidDrawAllLayers(frame); |
| 5203 } | 5203 } |
| 5204 | 5204 |
| 5205 // Applying a different contents scale to the mask layer means it will have | 5205 // Applying a different contents scale to the mask layer means it will have |
| 5206 // a larger texture, but it should use the same tex coords to cover the | 5206 // a larger texture, but it should use the same tex coords to cover the |
| 5207 // layer it masks. | 5207 // layer it masks. |
| 5208 mask_layer->SetContentBounds(mask_size); | 5208 mask_layer->SetContentBounds(mask_size); |
| 5209 mask_layer->SetContentsScale(1.f, 1.f); | 5209 mask_layer->SetContentsScale(1.f, 1.f); |
| 5210 host_impl_->active_tree()->set_needs_update_draw_properties(); | 5210 host_impl_->active_tree()->set_needs_update_draw_properties(); |
| 5211 { | 5211 { |
| 5212 LayerTreeHostImpl::FrameData frame; | 5212 LayerTreeHostImpl::FrameData frame; |
| 5213 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5213 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5214 | 5214 |
| 5215 ASSERT_EQ(1u, frame.render_passes.size()); | 5215 ASSERT_EQ(1u, frame.render_passes.size()); |
| 5216 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); | 5216 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); |
| 5217 ASSERT_EQ(DrawQuad::RENDER_PASS, | 5217 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 5218 frame.render_passes[0]->quad_list[1]->material); | 5218 frame.render_passes[0]->quad_list[1]->material); |
| 5219 const RenderPassDrawQuad* replica_quad = | 5219 const RenderPassDrawQuad* replica_quad = |
| 5220 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 5220 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 5221 EXPECT_TRUE(replica_quad->is_replica); | 5221 EXPECT_TRUE(replica_quad->is_replica); |
| 5222 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 5222 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 5223 replica_quad->rect.ToString()); | 5223 replica_quad->rect.ToString()); |
| 5224 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 5224 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 5225 replica_quad->mask_uv_rect.ToString()); | 5225 replica_quad->mask_uv_rect.ToString()); |
| 5226 | 5226 |
| 5227 host_impl_->DrawLayers(&frame); | 5227 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5228 host_impl_->DidDrawAllLayers(frame); | 5228 host_impl_->DidDrawAllLayers(frame); |
| 5229 } | 5229 } |
| 5230 } | 5230 } |
| 5231 | 5231 |
| 5232 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { | 5232 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { |
| 5233 // The replica is of a layer with bounds 50x50, but it has a child that causes | 5233 // The replica is of a layer with bounds 50x50, but it has a child that causes |
| 5234 // the surface bounds to be larger. | 5234 // the surface bounds to be larger. |
| 5235 | 5235 |
| 5236 scoped_ptr<LayerImpl> scoped_root = | 5236 scoped_ptr<LayerImpl> scoped_root = |
| 5237 LayerImpl::Create(host_impl_->active_tree(), 1); | 5237 LayerImpl::Create(host_impl_->active_tree(), 1); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5304 ASSERT_EQ(DrawQuad::RENDER_PASS, | 5304 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 5305 frame.render_passes[0]->quad_list[1]->material); | 5305 frame.render_passes[0]->quad_list[1]->material); |
| 5306 const RenderPassDrawQuad* replica_quad = | 5306 const RenderPassDrawQuad* replica_quad = |
| 5307 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 5307 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 5308 EXPECT_TRUE(replica_quad->is_replica); | 5308 EXPECT_TRUE(replica_quad->is_replica); |
| 5309 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), | 5309 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 5310 replica_quad->rect.ToString()); | 5310 replica_quad->rect.ToString()); |
| 5311 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), | 5311 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), |
| 5312 replica_quad->mask_uv_rect.ToString()); | 5312 replica_quad->mask_uv_rect.ToString()); |
| 5313 | 5313 |
| 5314 host_impl_->DrawLayers(&frame); | 5314 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5315 host_impl_->DidDrawAllLayers(frame); | 5315 host_impl_->DidDrawAllLayers(frame); |
| 5316 } | 5316 } |
| 5317 | 5317 |
| 5318 // Move the child to (-50, 0) instead. Now the mask should be moved to still | 5318 // Move the child to (-50, 0) instead. Now the mask should be moved to still |
| 5319 // cover the layer being replicated. | 5319 // cover the layer being replicated. |
| 5320 content_child_layer->SetPosition(gfx::Point(-50, 0)); | 5320 content_child_layer->SetPosition(gfx::Point(-50, 0)); |
| 5321 { | 5321 { |
| 5322 LayerTreeHostImpl::FrameData frame; | 5322 LayerTreeHostImpl::FrameData frame; |
| 5323 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5323 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5324 | 5324 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5338 ASSERT_EQ(DrawQuad::RENDER_PASS, | 5338 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 5339 frame.render_passes[0]->quad_list[1]->material); | 5339 frame.render_passes[0]->quad_list[1]->material); |
| 5340 const RenderPassDrawQuad* replica_quad = | 5340 const RenderPassDrawQuad* replica_quad = |
| 5341 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); | 5341 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); |
| 5342 EXPECT_TRUE(replica_quad->is_replica); | 5342 EXPECT_TRUE(replica_quad->is_replica); |
| 5343 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), | 5343 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), |
| 5344 replica_quad->rect.ToString()); | 5344 replica_quad->rect.ToString()); |
| 5345 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), | 5345 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), |
| 5346 replica_quad->mask_uv_rect.ToString()); | 5346 replica_quad->mask_uv_rect.ToString()); |
| 5347 | 5347 |
| 5348 host_impl_->DrawLayers(&frame); | 5348 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5349 host_impl_->DidDrawAllLayers(frame); | 5349 host_impl_->DidDrawAllLayers(frame); |
| 5350 } | 5350 } |
| 5351 } | 5351 } |
| 5352 | 5352 |
| 5353 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { | 5353 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { |
| 5354 // The masked layer has bounds 50x50, but it has a child that causes | 5354 // The masked layer has bounds 50x50, but it has a child that causes |
| 5355 // the surface bounds to be larger. It also has a parent that clips the | 5355 // the surface bounds to be larger. It also has a parent that clips the |
| 5356 // masked layer and its surface. | 5356 // masked layer and its surface. |
| 5357 | 5357 |
| 5358 scoped_ptr<LayerImpl> scoped_root = | 5358 scoped_ptr<LayerImpl> scoped_root = |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5429 render_pass_quad->rect.ToString()); | 5429 render_pass_quad->rect.ToString()); |
| 5430 | 5430 |
| 5431 // The masked layer is 50x50, but the surface size is 10x20. So the texture | 5431 // The masked layer is 50x50, but the surface size is 10x20. So the texture |
| 5432 // coords in the mask are scaled by 10/50 and 20/50. | 5432 // coords in the mask are scaled by 10/50 and 20/50. |
| 5433 // The surface is clipped to (20,10) so the mask texture coords are offset | 5433 // The surface is clipped to (20,10) so the mask texture coords are offset |
| 5434 // by 20/50 and 10/50 | 5434 // by 20/50 and 10/50 |
| 5435 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), | 5435 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), |
| 5436 1.f / 50.f).ToString(), | 5436 1.f / 50.f).ToString(), |
| 5437 render_pass_quad->mask_uv_rect.ToString()); | 5437 render_pass_quad->mask_uv_rect.ToString()); |
| 5438 | 5438 |
| 5439 host_impl_->DrawLayers(&frame); | 5439 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5440 host_impl_->DidDrawAllLayers(frame); | 5440 host_impl_->DidDrawAllLayers(frame); |
| 5441 } | 5441 } |
| 5442 } | 5442 } |
| 5443 | 5443 |
| 5444 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer { | 5444 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer { |
| 5445 public: | 5445 public: |
| 5446 using GLRenderer::SetupQuadForAntialiasing; | 5446 using GLRenderer::SetupQuadForAntialiasing; |
| 5447 }; | 5447 }; |
| 5448 | 5448 |
| 5449 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { | 5449 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5501 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); | 5501 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); |
| 5502 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; | 5502 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; |
| 5503 | 5503 |
| 5504 float edge[24]; | 5504 float edge[24]; |
| 5505 gfx::QuadF device_layer_quad; | 5505 gfx::QuadF device_layer_quad; |
| 5506 bool antialiased = | 5506 bool antialiased = |
| 5507 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( | 5507 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( |
| 5508 quad->quadTransform(), quad, &device_layer_quad, edge); | 5508 quad->quadTransform(), quad, &device_layer_quad, edge); |
| 5509 EXPECT_FALSE(antialiased); | 5509 EXPECT_FALSE(antialiased); |
| 5510 | 5510 |
| 5511 host_impl_->DrawLayers(&frame); | 5511 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5512 host_impl_->DidDrawAllLayers(frame); | 5512 host_impl_->DidDrawAllLayers(frame); |
| 5513 } | 5513 } |
| 5514 | 5514 |
| 5515 | 5515 |
| 5516 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { | 5516 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { |
| 5517 public: | 5517 public: |
| 5518 CompositorFrameMetadataTest() | 5518 CompositorFrameMetadataTest() |
| 5519 : swap_buffers_complete_(0) {} | 5519 : swap_buffers_complete_(0) {} |
| 5520 | 5520 |
| 5521 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE { | 5521 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE { |
| 5522 swap_buffers_complete_++; | 5522 swap_buffers_complete_++; |
| 5523 } | 5523 } |
| 5524 | 5524 |
| 5525 int swap_buffers_complete_; | 5525 int swap_buffers_complete_; |
| 5526 }; | 5526 }; |
| 5527 | 5527 |
| 5528 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { | 5528 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { |
| 5529 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 5529 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 5530 { | 5530 { |
| 5531 LayerTreeHostImpl::FrameData frame; | 5531 LayerTreeHostImpl::FrameData frame; |
| 5532 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5532 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5533 host_impl_->DrawLayers(&frame); | 5533 host_impl_->DrawLayers(&frame, base::TimeTicks()); |
| 5534 host_impl_->DidDrawAllLayers(frame); | 5534 host_impl_->DidDrawAllLayers(frame); |
| 5535 } | 5535 } |
| 5536 CompositorFrameAck ack; | 5536 CompositorFrameAck ack; |
| 5537 host_impl_->ReclaimResources(&ack); | 5537 host_impl_->ReclaimResources(&ack); |
| 5538 host_impl_->DidSwapBuffersComplete(); | 5538 host_impl_->DidSwapBuffersComplete(); |
| 5539 EXPECT_EQ(swap_buffers_complete_, 1); | 5539 EXPECT_EQ(swap_buffers_complete_, 1); |
| 5540 } | 5540 } |
| 5541 | 5541 |
| 5542 class CountingSoftwareDevice : public SoftwareOutputDevice { | 5542 class CountingSoftwareDevice : public SoftwareOutputDevice { |
| 5543 public: | 5543 public: |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5621 scoped_ptr<VideoLayerImpl> video_layer = | 5621 scoped_ptr<VideoLayerImpl> video_layer = |
| 5622 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); | 5622 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); |
| 5623 video_layer->SetBounds(gfx::Size(10, 10)); | 5623 video_layer->SetBounds(gfx::Size(10, 10)); |
| 5624 video_layer->SetContentBounds(gfx::Size(10, 10)); | 5624 video_layer->SetContentBounds(gfx::Size(10, 10)); |
| 5625 video_layer->SetDrawsContent(true); | 5625 video_layer->SetDrawsContent(true); |
| 5626 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); | 5626 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); |
| 5627 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); | 5627 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); |
| 5628 | 5628 |
| 5629 LayerTreeHostImpl::FrameData frame; | 5629 LayerTreeHostImpl::FrameData frame; |
| 5630 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5630 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5631 host_impl_->DrawLayers(&frame); | 5631 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5632 host_impl_->DidDrawAllLayers(frame); | 5632 host_impl_->DidDrawAllLayers(frame); |
| 5633 | 5633 |
| 5634 EXPECT_EQ(1u, frame.will_draw_layers.size()); | 5634 EXPECT_EQ(1u, frame.will_draw_layers.size()); |
| 5635 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); | 5635 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); |
| 5636 } | 5636 } |
| 5637 | 5637 |
| 5638 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { | 5638 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { |
| 5639 protected: | 5639 protected: |
| 5640 virtual void SetUp() OVERRIDE { | 5640 virtual void SetUp() OVERRIDE { |
| 5641 LayerTreeHostImplTest::SetUp(); | 5641 LayerTreeHostImplTest::SetUp(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5927 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 5927 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 5928 | 5928 |
| 5929 ScopedPtrVector<CopyOutputRequest> requests; | 5929 ScopedPtrVector<CopyOutputRequest> requests; |
| 5930 requests.push_back(CopyOutputRequest::CreateRequest( | 5930 requests.push_back(CopyOutputRequest::CreateRequest( |
| 5931 base::Bind(&ShutdownReleasesContext_Callback))); | 5931 base::Bind(&ShutdownReleasesContext_Callback))); |
| 5932 | 5932 |
| 5933 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); | 5933 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); |
| 5934 | 5934 |
| 5935 LayerTreeHostImpl::FrameData frame; | 5935 LayerTreeHostImpl::FrameData frame; |
| 5936 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 5936 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 5937 host_impl_->DrawLayers(&frame); | 5937 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 5938 host_impl_->DidDrawAllLayers(frame); | 5938 host_impl_->DidDrawAllLayers(frame); |
| 5939 | 5939 |
| 5940 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 5940 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
| 5941 // texture in a texture mailbox. | 5941 // texture in a texture mailbox. |
| 5942 EXPECT_FALSE(context_provider->HasOneRef()); | 5942 EXPECT_FALSE(context_provider->HasOneRef()); |
| 5943 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 5943 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
| 5944 | 5944 |
| 5945 host_impl_.reset(); | 5945 host_impl_.reset(); |
| 5946 | 5946 |
| 5947 // The CopyOutputResult's callback was cancelled, the CopyOutputResult | 5947 // The CopyOutputResult's callback was cancelled, the CopyOutputResult |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6287 latency_info.AddLatencyNumber( | 6287 latency_info.AddLatencyNumber( |
| 6288 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 6288 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); |
| 6289 scoped_ptr<SwapPromise> swap_promise( | 6289 scoped_ptr<SwapPromise> swap_promise( |
| 6290 new LatencyInfoSwapPromise(latency_info)); | 6290 new LatencyInfoSwapPromise(latency_info)); |
| 6291 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); | 6291 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); |
| 6292 host_impl_->SetNeedsRedraw(); | 6292 host_impl_->SetNeedsRedraw(); |
| 6293 | 6293 |
| 6294 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 6294 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 6295 LayerTreeHostImpl::FrameData frame; | 6295 LayerTreeHostImpl::FrameData frame; |
| 6296 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6296 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6297 host_impl_->DrawLayers(&frame); | 6297 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 6298 host_impl_->DidDrawAllLayers(frame); | 6298 host_impl_->DidDrawAllLayers(frame); |
| 6299 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 6299 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
| 6300 | 6300 |
| 6301 const std::vector<ui::LatencyInfo>& metadata_latency_after = | 6301 const std::vector<ui::LatencyInfo>& metadata_latency_after = |
| 6302 fake_output_surface->last_sent_frame().metadata.latency_info; | 6302 fake_output_surface->last_sent_frame().metadata.latency_info; |
| 6303 EXPECT_EQ(1u, metadata_latency_after.size()); | 6303 EXPECT_EQ(1u, metadata_latency_after.size()); |
| 6304 EXPECT_TRUE(metadata_latency_after[0].FindLatency( | 6304 EXPECT_TRUE(metadata_latency_after[0].FindLatency( |
| 6305 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); | 6305 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); |
| 6306 } | 6306 } |
| 6307 | 6307 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6334 start.layer_rect = selection_rect; | 6334 start.layer_rect = selection_rect; |
| 6335 end = start; | 6335 end = start; |
| 6336 host_impl_->active_tree()->RegisterSelection(start, end); | 6336 host_impl_->active_tree()->RegisterSelection(start, end); |
| 6337 | 6337 |
| 6338 // Trigger a draw-swap sequence. | 6338 // Trigger a draw-swap sequence. |
| 6339 host_impl_->SetNeedsRedraw(); | 6339 host_impl_->SetNeedsRedraw(); |
| 6340 | 6340 |
| 6341 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 6341 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 6342 LayerTreeHostImpl::FrameData frame; | 6342 LayerTreeHostImpl::FrameData frame; |
| 6343 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6343 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6344 host_impl_->DrawLayers(&frame); | 6344 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 6345 host_impl_->DidDrawAllLayers(frame); | 6345 host_impl_->DidDrawAllLayers(frame); |
| 6346 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); | 6346 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); |
| 6347 | 6347 |
| 6348 // Ensure the selection bounds have propagated to the frame metadata. | 6348 // Ensure the selection bounds have propagated to the frame metadata. |
| 6349 const ViewportSelectionBound& selection_start_after = | 6349 const ViewportSelectionBound& selection_start_after = |
| 6350 fake_output_surface->last_sent_frame().metadata.selection_start; | 6350 fake_output_surface->last_sent_frame().metadata.selection_start; |
| 6351 const ViewportSelectionBound& selection_end_after = | 6351 const ViewportSelectionBound& selection_end_after = |
| 6352 fake_output_surface->last_sent_frame().metadata.selection_end; | 6352 fake_output_surface->last_sent_frame().metadata.selection_end; |
| 6353 EXPECT_EQ(start.type, selection_start_after.type); | 6353 EXPECT_EQ(start.type, selection_start_after.type); |
| 6354 EXPECT_EQ(end.type, selection_end_after.type); | 6354 EXPECT_EQ(end.type, selection_end_after.type); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6706 | 6706 |
| 6707 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); | 6707 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); |
| 6708 host_impl_->UpdateAnimationState(true); | 6708 host_impl_->UpdateAnimationState(true); |
| 6709 | 6709 |
| 6710 EXPECT_EQ(gfx::Vector2dF(0, 100), scrolling_layer->TotalScrollOffset()); | 6710 EXPECT_EQ(gfx::Vector2dF(0, 100), scrolling_layer->TotalScrollOffset()); |
| 6711 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 6711 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 6712 } | 6712 } |
| 6713 | 6713 |
| 6714 } // namespace | 6714 } // namespace |
| 6715 } // namespace cc | 6715 } // namespace cc |
| OLD | NEW |