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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 340743002: cc: Removing base::TimeTicks argument to DrawLayers as it isn't used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 layer->SetDrawsContent(true); 292 layer->SetDrawsContent(true);
293 layer->SetBounds(size); 293 layer->SetBounds(size);
294 layer->SetContentBounds(size); 294 layer->SetContentBounds(size);
295 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); 295 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2));
296 return layer.Pass(); 296 return layer.Pass();
297 } 297 }
298 298
299 void DrawFrame() { 299 void DrawFrame() {
300 LayerTreeHostImpl::FrameData frame; 300 LayerTreeHostImpl::FrameData frame;
301 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 301 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
302 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 302 host_impl_->DrawLayers(&frame);
303 host_impl_->DidDrawAllLayers(frame); 303 host_impl_->DidDrawAllLayers(frame);
304 } 304 }
305 305
306 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); 306 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
307 void pinch_zoom_pan_viewport_test(float device_scale_factor); 307 void pinch_zoom_pan_viewport_test(float device_scale_factor);
308 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); 308 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor);
309 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 309 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
310 float device_scale_factor); 310 float device_scale_factor);
311 311
312 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) { 312 void CheckNotifyCalledIfCanDrawChanged(bool always_draw) {
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 1706 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
1707 host_impl_->active_tree()->root_layer()); 1707 host_impl_->active_tree()->root_layer());
1708 1708
1709 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1709 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1710 DidDrawCheckLayer* layer = 1710 DidDrawCheckLayer* layer =
1711 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1711 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1712 1712
1713 { 1713 {
1714 LayerTreeHostImpl::FrameData frame; 1714 LayerTreeHostImpl::FrameData frame;
1715 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1715 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1716 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1716 host_impl_->DrawLayers(&frame);
1717 host_impl_->DidDrawAllLayers(frame); 1717 host_impl_->DidDrawAllLayers(frame);
1718 1718
1719 EXPECT_TRUE(layer->will_draw_called()); 1719 EXPECT_TRUE(layer->will_draw_called());
1720 EXPECT_TRUE(layer->append_quads_called()); 1720 EXPECT_TRUE(layer->append_quads_called());
1721 EXPECT_TRUE(layer->did_draw_called()); 1721 EXPECT_TRUE(layer->did_draw_called());
1722 } 1722 }
1723 1723
1724 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); 1724 host_impl_->SetViewportDamage(gfx::Rect(10, 10));
1725 1725
1726 { 1726 {
1727 LayerTreeHostImpl::FrameData frame; 1727 LayerTreeHostImpl::FrameData frame;
1728 1728
1729 layer->set_will_draw_returns_false(); 1729 layer->set_will_draw_returns_false();
1730 layer->ClearDidDrawCheck(); 1730 layer->ClearDidDrawCheck();
1731 1731
1732 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1732 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1733 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1733 host_impl_->DrawLayers(&frame);
1734 host_impl_->DidDrawAllLayers(frame); 1734 host_impl_->DidDrawAllLayers(frame);
1735 1735
1736 EXPECT_TRUE(layer->will_draw_called()); 1736 EXPECT_TRUE(layer->will_draw_called());
1737 EXPECT_FALSE(layer->append_quads_called()); 1737 EXPECT_FALSE(layer->append_quads_called());
1738 EXPECT_FALSE(layer->did_draw_called()); 1738 EXPECT_FALSE(layer->did_draw_called());
1739 } 1739 }
1740 } 1740 }
1741 1741
1742 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { 1742 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
1743 // The root layer is always drawn, so run this test on a child layer that 1743 // The root layer is always drawn, so run this test on a child layer that
(...skipping 11 matching lines...) Expand all
1755 layer->SetPosition(gfx::PointF(100.f, 100.f)); 1755 layer->SetPosition(gfx::PointF(100.f, 100.f));
1756 layer->SetBounds(gfx::Size(10, 10)); 1756 layer->SetBounds(gfx::Size(10, 10));
1757 layer->SetContentBounds(gfx::Size(10, 10)); 1757 layer->SetContentBounds(gfx::Size(10, 10));
1758 1758
1759 LayerTreeHostImpl::FrameData frame; 1759 LayerTreeHostImpl::FrameData frame;
1760 1760
1761 EXPECT_FALSE(layer->will_draw_called()); 1761 EXPECT_FALSE(layer->will_draw_called());
1762 EXPECT_FALSE(layer->did_draw_called()); 1762 EXPECT_FALSE(layer->did_draw_called());
1763 1763
1764 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1764 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1765 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1765 host_impl_->DrawLayers(&frame);
1766 host_impl_->DidDrawAllLayers(frame); 1766 host_impl_->DidDrawAllLayers(frame);
1767 1767
1768 EXPECT_FALSE(layer->will_draw_called()); 1768 EXPECT_FALSE(layer->will_draw_called());
1769 EXPECT_FALSE(layer->did_draw_called()); 1769 EXPECT_FALSE(layer->did_draw_called());
1770 1770
1771 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); 1771 EXPECT_TRUE(layer->visible_content_rect().IsEmpty());
1772 1772
1773 // Ensure visible_content_rect for layer is not empty 1773 // Ensure visible_content_rect for layer is not empty
1774 layer->SetPosition(gfx::PointF()); 1774 layer->SetPosition(gfx::PointF());
1775 1775
1776 EXPECT_FALSE(layer->will_draw_called()); 1776 EXPECT_FALSE(layer->will_draw_called());
1777 EXPECT_FALSE(layer->did_draw_called()); 1777 EXPECT_FALSE(layer->did_draw_called());
1778 1778
1779 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1779 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1780 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1780 host_impl_->DrawLayers(&frame);
1781 host_impl_->DidDrawAllLayers(frame); 1781 host_impl_->DidDrawAllLayers(frame);
1782 1782
1783 EXPECT_TRUE(layer->will_draw_called()); 1783 EXPECT_TRUE(layer->will_draw_called());
1784 EXPECT_TRUE(layer->did_draw_called()); 1784 EXPECT_TRUE(layer->did_draw_called());
1785 1785
1786 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); 1786 EXPECT_FALSE(layer->visible_content_rect().IsEmpty());
1787 } 1787 }
1788 1788
1789 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 1789 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
1790 gfx::Size big_size(1000, 1000); 1790 gfx::Size big_size(1000, 1000);
(...skipping 18 matching lines...) Expand all
1809 top_layer->SetContentsOpaque(true); 1809 top_layer->SetContentsOpaque(true);
1810 1810
1811 LayerTreeHostImpl::FrameData frame; 1811 LayerTreeHostImpl::FrameData frame;
1812 1812
1813 EXPECT_FALSE(occluded_layer->will_draw_called()); 1813 EXPECT_FALSE(occluded_layer->will_draw_called());
1814 EXPECT_FALSE(occluded_layer->did_draw_called()); 1814 EXPECT_FALSE(occluded_layer->did_draw_called());
1815 EXPECT_FALSE(top_layer->will_draw_called()); 1815 EXPECT_FALSE(top_layer->will_draw_called());
1816 EXPECT_FALSE(top_layer->did_draw_called()); 1816 EXPECT_FALSE(top_layer->did_draw_called());
1817 1817
1818 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1818 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1819 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1819 host_impl_->DrawLayers(&frame);
1820 host_impl_->DidDrawAllLayers(frame); 1820 host_impl_->DidDrawAllLayers(frame);
1821 1821
1822 EXPECT_FALSE(occluded_layer->will_draw_called()); 1822 EXPECT_FALSE(occluded_layer->will_draw_called());
1823 EXPECT_FALSE(occluded_layer->did_draw_called()); 1823 EXPECT_FALSE(occluded_layer->did_draw_called());
1824 EXPECT_TRUE(top_layer->will_draw_called()); 1824 EXPECT_TRUE(top_layer->will_draw_called());
1825 EXPECT_TRUE(top_layer->did_draw_called()); 1825 EXPECT_TRUE(top_layer->did_draw_called());
1826 } 1826 }
1827 1827
1828 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 1828 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
1829 host_impl_->active_tree()->SetRootLayer( 1829 host_impl_->active_tree()->SetRootLayer(
(...skipping 11 matching lines...) Expand all
1841 1841
1842 layer1->SetOpacity(0.3f); 1842 layer1->SetOpacity(0.3f);
1843 layer1->SetShouldFlattenTransform(true); 1843 layer1->SetShouldFlattenTransform(true);
1844 1844
1845 EXPECT_FALSE(root->did_draw_called()); 1845 EXPECT_FALSE(root->did_draw_called());
1846 EXPECT_FALSE(layer1->did_draw_called()); 1846 EXPECT_FALSE(layer1->did_draw_called());
1847 EXPECT_FALSE(layer2->did_draw_called()); 1847 EXPECT_FALSE(layer2->did_draw_called());
1848 1848
1849 LayerTreeHostImpl::FrameData frame; 1849 LayerTreeHostImpl::FrameData frame;
1850 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1850 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1851 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1851 host_impl_->DrawLayers(&frame);
1852 host_impl_->DidDrawAllLayers(frame); 1852 host_impl_->DidDrawAllLayers(frame);
1853 1853
1854 EXPECT_TRUE(root->did_draw_called()); 1854 EXPECT_TRUE(root->did_draw_called());
1855 EXPECT_TRUE(layer1->did_draw_called()); 1855 EXPECT_TRUE(layer1->did_draw_called());
1856 EXPECT_TRUE(layer2->did_draw_called()); 1856 EXPECT_TRUE(layer2->did_draw_called());
1857 1857
1858 EXPECT_NE(root->render_surface(), layer1->render_surface()); 1858 EXPECT_NE(root->render_surface(), layer1->render_surface());
1859 EXPECT_TRUE(!!layer1->render_surface()); 1859 EXPECT_TRUE(!!layer1->render_surface());
1860 } 1860 }
1861 1861
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1916 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1917 2, 1917 2,
1918 tile_missing, 1918 tile_missing,
1919 had_incomplete_tile, 1919 had_incomplete_tile,
1920 is_animating, 1920 is_animating,
1921 host_impl_->resource_provider())); 1921 host_impl_->resource_provider()));
1922 1922
1923 LayerTreeHostImpl::FrameData frame; 1923 LayerTreeHostImpl::FrameData frame;
1924 1924
1925 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1925 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1926 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1926 host_impl_->DrawLayers(&frame);
1927 host_impl_->DidDrawAllLayers(frame); 1927 host_impl_->DidDrawAllLayers(frame);
1928 } 1928 }
1929 1929
1930 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { 1930 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) {
1931 host_impl_->active_tree()->SetRootLayer( 1931 host_impl_->active_tree()->SetRootLayer(
1932 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1932 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1933 DidDrawCheckLayer* root = 1933 DidDrawCheckLayer* root =
1934 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1934 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1935 bool tile_missing = false; 1935 bool tile_missing = false;
1936 bool had_incomplete_tile = false; 1936 bool had_incomplete_tile = false;
1937 bool is_animating = true; 1937 bool is_animating = true;
1938 root->AddChild( 1938 root->AddChild(
1939 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1939 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1940 2, 1940 2,
1941 tile_missing, 1941 tile_missing,
1942 had_incomplete_tile, 1942 had_incomplete_tile,
1943 is_animating, 1943 is_animating,
1944 host_impl_->resource_provider())); 1944 host_impl_->resource_provider()));
1945 1945
1946 LayerTreeHostImpl::FrameData frame; 1946 LayerTreeHostImpl::FrameData frame;
1947 1947
1948 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1948 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1949 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1949 host_impl_->DrawLayers(&frame);
1950 host_impl_->DidDrawAllLayers(frame); 1950 host_impl_->DidDrawAllLayers(frame);
1951 } 1951 }
1952 1952
1953 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { 1953 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) {
1954 host_impl_->active_tree()->SetRootLayer( 1954 host_impl_->active_tree()->SetRootLayer(
1955 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1955 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1956 DidDrawCheckLayer* root = 1956 DidDrawCheckLayer* root =
1957 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1957 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1958 1958
1959 bool tile_missing = true; 1959 bool tile_missing = true;
1960 bool had_incomplete_tile = false; 1960 bool had_incomplete_tile = false;
1961 bool is_animating = false; 1961 bool is_animating = false;
1962 root->AddChild( 1962 root->AddChild(
1963 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1963 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1964 4, 1964 4,
1965 tile_missing, 1965 tile_missing,
1966 had_incomplete_tile, 1966 had_incomplete_tile,
1967 is_animating, 1967 is_animating,
1968 host_impl_->resource_provider())); 1968 host_impl_->resource_provider()));
1969 LayerTreeHostImpl::FrameData frame; 1969 LayerTreeHostImpl::FrameData frame;
1970 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1970 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1971 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1971 host_impl_->DrawLayers(&frame);
1972 host_impl_->DidDrawAllLayers(frame); 1972 host_impl_->DidDrawAllLayers(frame);
1973 } 1973 }
1974 1974
1975 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { 1975 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) {
1976 host_impl_->active_tree()->SetRootLayer( 1976 host_impl_->active_tree()->SetRootLayer(
1977 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1977 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1978 DidDrawCheckLayer* root = 1978 DidDrawCheckLayer* root =
1979 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1979 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1980 1980
1981 bool tile_missing = false; 1981 bool tile_missing = false;
1982 bool had_incomplete_tile = true; 1982 bool had_incomplete_tile = true;
1983 bool is_animating = false; 1983 bool is_animating = false;
1984 root->AddChild( 1984 root->AddChild(
1985 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1985 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1986 4, 1986 4,
1987 tile_missing, 1987 tile_missing,
1988 had_incomplete_tile, 1988 had_incomplete_tile,
1989 is_animating, 1989 is_animating,
1990 host_impl_->resource_provider())); 1990 host_impl_->resource_provider()));
1991 LayerTreeHostImpl::FrameData frame; 1991 LayerTreeHostImpl::FrameData frame;
1992 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1992 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1993 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1993 host_impl_->DrawLayers(&frame);
1994 host_impl_->DidDrawAllLayers(frame); 1994 host_impl_->DidDrawAllLayers(frame);
1995 } 1995 }
1996 1996
1997 TEST_F(LayerTreeHostImplTest, 1997 TEST_F(LayerTreeHostImplTest,
1998 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { 1998 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) {
1999 host_impl_->active_tree()->SetRootLayer( 1999 host_impl_->active_tree()->SetRootLayer(
2000 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 2000 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
2001 DidDrawCheckLayer* root = 2001 DidDrawCheckLayer* root =
2002 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2002 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2003 bool tile_missing = true; 2003 bool tile_missing = true;
2004 bool had_incomplete_tile = false; 2004 bool had_incomplete_tile = false;
2005 bool is_animating = true; 2005 bool is_animating = true;
2006 root->AddChild( 2006 root->AddChild(
2007 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2007 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2008 6, 2008 6,
2009 tile_missing, 2009 tile_missing,
2010 had_incomplete_tile, 2010 had_incomplete_tile,
2011 is_animating, 2011 is_animating,
2012 host_impl_->resource_provider())); 2012 host_impl_->resource_provider()));
2013 LayerTreeHostImpl::FrameData frame; 2013 LayerTreeHostImpl::FrameData frame;
2014 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, 2014 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
2015 host_impl_->PrepareToDraw(&frame)); 2015 host_impl_->PrepareToDraw(&frame));
2016 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2016 host_impl_->DrawLayers(&frame);
2017 host_impl_->DidDrawAllLayers(frame); 2017 host_impl_->DidDrawAllLayers(frame);
2018 } 2018 }
2019 2019
2020 TEST_F(LayerTreeHostImplTest, 2020 TEST_F(LayerTreeHostImplTest,
2021 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { 2021 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) {
2022 host_impl_->active_tree()->SetRootLayer( 2022 host_impl_->active_tree()->SetRootLayer(
2023 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 2023 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
2024 DidDrawCheckLayer* root = 2024 DidDrawCheckLayer* root =
2025 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2025 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2026 bool tile_missing = false; 2026 bool tile_missing = false;
2027 bool had_incomplete_tile = true; 2027 bool had_incomplete_tile = true;
2028 bool is_animating = true; 2028 bool is_animating = true;
2029 root->AddChild( 2029 root->AddChild(
2030 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2030 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2031 6, 2031 6,
2032 tile_missing, 2032 tile_missing,
2033 had_incomplete_tile, 2033 had_incomplete_tile,
2034 is_animating, 2034 is_animating,
2035 host_impl_->resource_provider())); 2035 host_impl_->resource_provider()));
2036 LayerTreeHostImpl::FrameData frame; 2036 LayerTreeHostImpl::FrameData frame;
2037 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2037 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2038 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2038 host_impl_->DrawLayers(&frame);
2039 host_impl_->DidDrawAllLayers(frame); 2039 host_impl_->DidDrawAllLayers(frame);
2040 } 2040 }
2041 2041
2042 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { 2042 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) {
2043 host_impl_->active_tree()->SetRootLayer( 2043 host_impl_->active_tree()->SetRootLayer(
2044 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2044 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2045 DidDrawCheckLayer* root = 2045 DidDrawCheckLayer* root =
2046 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2046 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2047 bool tile_missing = false; 2047 bool tile_missing = false;
2048 bool had_incomplete_tile = false; 2048 bool had_incomplete_tile = false;
2049 bool is_animating = false; 2049 bool is_animating = false;
2050 root->AddChild( 2050 root->AddChild(
2051 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2051 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2052 8, 2052 8,
2053 tile_missing, 2053 tile_missing,
2054 had_incomplete_tile, 2054 had_incomplete_tile,
2055 is_animating, 2055 is_animating,
2056 host_impl_->resource_provider())); 2056 host_impl_->resource_provider()));
2057 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2057 host_impl_->active_tree()->SetRequiresHighResToDraw();
2058 LayerTreeHostImpl::FrameData frame; 2058 LayerTreeHostImpl::FrameData frame;
2059 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2059 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2060 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2060 host_impl_->DrawLayers(&frame);
2061 host_impl_->DidDrawAllLayers(frame); 2061 host_impl_->DidDrawAllLayers(frame);
2062 } 2062 }
2063 2063
2064 TEST_F(LayerTreeHostImplTest, 2064 TEST_F(LayerTreeHostImplTest,
2065 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { 2065 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) {
2066 host_impl_->active_tree()->SetRootLayer( 2066 host_impl_->active_tree()->SetRootLayer(
2067 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2067 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2068 DidDrawCheckLayer* root = 2068 DidDrawCheckLayer* root =
2069 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2069 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2070 bool tile_missing = false; 2070 bool tile_missing = false;
2071 bool had_incomplete_tile = true; 2071 bool had_incomplete_tile = true;
2072 bool is_animating = false; 2072 bool is_animating = false;
2073 root->AddChild( 2073 root->AddChild(
2074 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2074 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2075 8, 2075 8,
2076 tile_missing, 2076 tile_missing,
2077 had_incomplete_tile, 2077 had_incomplete_tile,
2078 is_animating, 2078 is_animating,
2079 host_impl_->resource_provider())); 2079 host_impl_->resource_provider()));
2080 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2080 host_impl_->active_tree()->SetRequiresHighResToDraw();
2081 LayerTreeHostImpl::FrameData frame; 2081 LayerTreeHostImpl::FrameData frame;
2082 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, 2082 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2083 host_impl_->PrepareToDraw(&frame)); 2083 host_impl_->PrepareToDraw(&frame));
2084 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2084 host_impl_->DrawLayers(&frame);
2085 host_impl_->DidDrawAllLayers(frame); 2085 host_impl_->DidDrawAllLayers(frame);
2086 } 2086 }
2087 2087
2088 TEST_F(LayerTreeHostImplTest, 2088 TEST_F(LayerTreeHostImplTest,
2089 PrepareToDrawSucceedsWhenHighResRequiredAndMissingTile) { 2089 PrepareToDrawSucceedsWhenHighResRequiredAndMissingTile) {
2090 host_impl_->active_tree()->SetRootLayer( 2090 host_impl_->active_tree()->SetRootLayer(
2091 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2091 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2092 DidDrawCheckLayer* root = 2092 DidDrawCheckLayer* root =
2093 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2093 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2094 bool tile_missing = true; 2094 bool tile_missing = true;
2095 bool had_incomplete_tile = false; 2095 bool had_incomplete_tile = false;
2096 bool is_animating = false; 2096 bool is_animating = false;
2097 root->AddChild( 2097 root->AddChild(
2098 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2098 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2099 8, 2099 8,
2100 tile_missing, 2100 tile_missing,
2101 had_incomplete_tile, 2101 had_incomplete_tile,
2102 is_animating, 2102 is_animating,
2103 host_impl_->resource_provider())); 2103 host_impl_->resource_provider()));
2104 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2104 host_impl_->active_tree()->SetRequiresHighResToDraw();
2105 LayerTreeHostImpl::FrameData frame; 2105 LayerTreeHostImpl::FrameData frame;
2106 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2106 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2107 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2107 host_impl_->DrawLayers(&frame);
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
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, gfx::FrameTime::Now()); 2556 host_impl_->DrawLayers(&frame);
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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
3575 static_cast<BlendStateCheckLayer*>(root->children()[0]); 3575 static_cast<BlendStateCheckLayer*>(root->children()[0]);
3576 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 3576 layer1->SetPosition(gfx::PointF(2.f, 2.f));
3577 3577
3578 LayerTreeHostImpl::FrameData frame; 3578 LayerTreeHostImpl::FrameData frame;
3579 3579
3580 // Opaque layer, drawn without blending. 3580 // Opaque layer, drawn without blending.
3581 layer1->SetContentsOpaque(true); 3581 layer1->SetContentsOpaque(true);
3582 layer1->SetExpectation(false, false); 3582 layer1->SetExpectation(false, false);
3583 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3583 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3584 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3584 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3585 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3585 host_impl_->DrawLayers(&frame);
3586 EXPECT_TRUE(layer1->quads_appended()); 3586 EXPECT_TRUE(layer1->quads_appended());
3587 host_impl_->DidDrawAllLayers(frame); 3587 host_impl_->DidDrawAllLayers(frame);
3588 3588
3589 // Layer with translucent content and painting, so drawn with blending. 3589 // Layer with translucent content and painting, so drawn with blending.
3590 layer1->SetContentsOpaque(false); 3590 layer1->SetContentsOpaque(false);
3591 layer1->SetExpectation(true, false); 3591 layer1->SetExpectation(true, false);
3592 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3592 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3593 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3593 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3594 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3594 host_impl_->DrawLayers(&frame);
3595 EXPECT_TRUE(layer1->quads_appended()); 3595 EXPECT_TRUE(layer1->quads_appended());
3596 host_impl_->DidDrawAllLayers(frame); 3596 host_impl_->DidDrawAllLayers(frame);
3597 3597
3598 // Layer with translucent opacity, drawn with blending. 3598 // Layer with translucent opacity, drawn with blending.
3599 layer1->SetContentsOpaque(true); 3599 layer1->SetContentsOpaque(true);
3600 layer1->SetOpacity(0.5f); 3600 layer1->SetOpacity(0.5f);
3601 layer1->SetExpectation(true, false); 3601 layer1->SetExpectation(true, false);
3602 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3602 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3603 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3603 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3604 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3604 host_impl_->DrawLayers(&frame);
3605 EXPECT_TRUE(layer1->quads_appended()); 3605 EXPECT_TRUE(layer1->quads_appended());
3606 host_impl_->DidDrawAllLayers(frame); 3606 host_impl_->DidDrawAllLayers(frame);
3607 3607
3608 // Layer with translucent opacity and painting, drawn with blending. 3608 // Layer with translucent opacity and painting, drawn with blending.
3609 layer1->SetContentsOpaque(true); 3609 layer1->SetContentsOpaque(true);
3610 layer1->SetOpacity(0.5f); 3610 layer1->SetOpacity(0.5f);
3611 layer1->SetExpectation(true, false); 3611 layer1->SetExpectation(true, false);
3612 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3612 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3613 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3613 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3614 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3614 host_impl_->DrawLayers(&frame);
3615 EXPECT_TRUE(layer1->quads_appended()); 3615 EXPECT_TRUE(layer1->quads_appended());
3616 host_impl_->DidDrawAllLayers(frame); 3616 host_impl_->DidDrawAllLayers(frame);
3617 3617
3618 layer1->AddChild( 3618 layer1->AddChild(
3619 BlendStateCheckLayer::Create(host_impl_->active_tree(), 3619 BlendStateCheckLayer::Create(host_impl_->active_tree(),
3620 3, 3620 3,
3621 host_impl_->resource_provider())); 3621 host_impl_->resource_provider()));
3622 BlendStateCheckLayer* layer2 = 3622 BlendStateCheckLayer* layer2 =
3623 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); 3623 static_cast<BlendStateCheckLayer*>(layer1->children()[0]);
3624 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 3624 layer2->SetPosition(gfx::PointF(4.f, 4.f));
3625 3625
3626 // 2 opaque layers, drawn without blending. 3626 // 2 opaque layers, drawn without blending.
3627 layer1->SetContentsOpaque(true); 3627 layer1->SetContentsOpaque(true);
3628 layer1->SetOpacity(1.f); 3628 layer1->SetOpacity(1.f);
3629 layer1->SetExpectation(false, false); 3629 layer1->SetExpectation(false, false);
3630 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3630 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3631 layer2->SetContentsOpaque(true); 3631 layer2->SetContentsOpaque(true);
3632 layer2->SetOpacity(1.f); 3632 layer2->SetOpacity(1.f);
3633 layer2->SetExpectation(false, false); 3633 layer2->SetExpectation(false, false);
3634 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3634 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3635 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3635 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3636 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3636 host_impl_->DrawLayers(&frame);
3637 EXPECT_TRUE(layer1->quads_appended()); 3637 EXPECT_TRUE(layer1->quads_appended());
3638 EXPECT_TRUE(layer2->quads_appended()); 3638 EXPECT_TRUE(layer2->quads_appended());
3639 host_impl_->DidDrawAllLayers(frame); 3639 host_impl_->DidDrawAllLayers(frame);
3640 3640
3641 // Parent layer with translucent content, drawn with blending. 3641 // Parent layer with translucent content, drawn with blending.
3642 // Child layer with opaque content, drawn without blending. 3642 // Child layer with opaque content, drawn without blending.
3643 layer1->SetContentsOpaque(false); 3643 layer1->SetContentsOpaque(false);
3644 layer1->SetExpectation(true, false); 3644 layer1->SetExpectation(true, false);
3645 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3645 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3646 layer2->SetExpectation(false, false); 3646 layer2->SetExpectation(false, false);
3647 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3647 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3648 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3648 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3649 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3649 host_impl_->DrawLayers(&frame);
3650 EXPECT_TRUE(layer1->quads_appended()); 3650 EXPECT_TRUE(layer1->quads_appended());
3651 EXPECT_TRUE(layer2->quads_appended()); 3651 EXPECT_TRUE(layer2->quads_appended());
3652 host_impl_->DidDrawAllLayers(frame); 3652 host_impl_->DidDrawAllLayers(frame);
3653 3653
3654 // Parent layer with translucent content but opaque painting, drawn without 3654 // Parent layer with translucent content but opaque painting, drawn without
3655 // blending. 3655 // blending.
3656 // Child layer with opaque content, drawn without blending. 3656 // Child layer with opaque content, drawn without blending.
3657 layer1->SetContentsOpaque(true); 3657 layer1->SetContentsOpaque(true);
3658 layer1->SetExpectation(false, false); 3658 layer1->SetExpectation(false, false);
3659 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3659 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3660 layer2->SetExpectation(false, false); 3660 layer2->SetExpectation(false, false);
3661 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3661 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3662 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3662 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3663 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3663 host_impl_->DrawLayers(&frame);
3664 EXPECT_TRUE(layer1->quads_appended()); 3664 EXPECT_TRUE(layer1->quads_appended());
3665 EXPECT_TRUE(layer2->quads_appended()); 3665 EXPECT_TRUE(layer2->quads_appended());
3666 host_impl_->DidDrawAllLayers(frame); 3666 host_impl_->DidDrawAllLayers(frame);
3667 3667
3668 // Parent layer with translucent opacity and opaque content. Since it has a 3668 // Parent layer with translucent opacity and opaque content. Since it has a
3669 // drawing child, it's drawn to a render surface which carries the opacity, 3669 // drawing child, it's drawn to a render surface which carries the opacity,
3670 // so it's itself drawn without blending. 3670 // so it's itself drawn without blending.
3671 // Child layer with opaque content, drawn without blending (parent surface 3671 // Child layer with opaque content, drawn without blending (parent surface
3672 // carries the inherited opacity). 3672 // carries the inherited opacity).
3673 layer1->SetContentsOpaque(true); 3673 layer1->SetContentsOpaque(true);
3674 layer1->SetOpacity(0.5f); 3674 layer1->SetOpacity(0.5f);
3675 layer1->SetExpectation(false, true); 3675 layer1->SetExpectation(false, true);
3676 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3676 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3677 layer2->SetExpectation(false, false); 3677 layer2->SetExpectation(false, false);
3678 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3678 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3679 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3679 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3680 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3680 host_impl_->DrawLayers(&frame);
3681 EXPECT_TRUE(layer1->quads_appended()); 3681 EXPECT_TRUE(layer1->quads_appended());
3682 EXPECT_TRUE(layer2->quads_appended()); 3682 EXPECT_TRUE(layer2->quads_appended());
3683 host_impl_->DidDrawAllLayers(frame); 3683 host_impl_->DidDrawAllLayers(frame);
3684 3684
3685 // Draw again, but with child non-opaque, to make sure 3685 // Draw again, but with child non-opaque, to make sure
3686 // layer1 not culled. 3686 // layer1 not culled.
3687 layer1->SetContentsOpaque(true); 3687 layer1->SetContentsOpaque(true);
3688 layer1->SetOpacity(1.f); 3688 layer1->SetOpacity(1.f);
3689 layer1->SetExpectation(false, false); 3689 layer1->SetExpectation(false, false);
3690 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3690 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3691 layer2->SetContentsOpaque(true); 3691 layer2->SetContentsOpaque(true);
3692 layer2->SetOpacity(0.5f); 3692 layer2->SetOpacity(0.5f);
3693 layer2->SetExpectation(true, false); 3693 layer2->SetExpectation(true, false);
3694 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3694 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3695 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3695 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3696 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3696 host_impl_->DrawLayers(&frame);
3697 EXPECT_TRUE(layer1->quads_appended()); 3697 EXPECT_TRUE(layer1->quads_appended());
3698 EXPECT_TRUE(layer2->quads_appended()); 3698 EXPECT_TRUE(layer2->quads_appended());
3699 host_impl_->DidDrawAllLayers(frame); 3699 host_impl_->DidDrawAllLayers(frame);
3700 3700
3701 // A second way of making the child non-opaque. 3701 // A second way of making the child non-opaque.
3702 layer1->SetContentsOpaque(true); 3702 layer1->SetContentsOpaque(true);
3703 layer1->SetOpacity(1.f); 3703 layer1->SetOpacity(1.f);
3704 layer1->SetExpectation(false, false); 3704 layer1->SetExpectation(false, false);
3705 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3705 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3706 layer2->SetContentsOpaque(false); 3706 layer2->SetContentsOpaque(false);
3707 layer2->SetOpacity(1.f); 3707 layer2->SetOpacity(1.f);
3708 layer2->SetExpectation(true, false); 3708 layer2->SetExpectation(true, false);
3709 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3709 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3710 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3710 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3711 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3711 host_impl_->DrawLayers(&frame);
3712 EXPECT_TRUE(layer1->quads_appended()); 3712 EXPECT_TRUE(layer1->quads_appended());
3713 EXPECT_TRUE(layer2->quads_appended()); 3713 EXPECT_TRUE(layer2->quads_appended());
3714 host_impl_->DidDrawAllLayers(frame); 3714 host_impl_->DidDrawAllLayers(frame);
3715 3715
3716 // And when the layer says its not opaque but is painted opaque, it is not 3716 // And when the layer says its not opaque but is painted opaque, it is not
3717 // blended. 3717 // blended.
3718 layer1->SetContentsOpaque(true); 3718 layer1->SetContentsOpaque(true);
3719 layer1->SetOpacity(1.f); 3719 layer1->SetOpacity(1.f);
3720 layer1->SetExpectation(false, false); 3720 layer1->SetExpectation(false, false);
3721 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3721 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3722 layer2->SetContentsOpaque(true); 3722 layer2->SetContentsOpaque(true);
3723 layer2->SetOpacity(1.f); 3723 layer2->SetOpacity(1.f);
3724 layer2->SetExpectation(false, false); 3724 layer2->SetExpectation(false, false);
3725 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3725 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3726 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3726 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3727 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3727 host_impl_->DrawLayers(&frame);
3728 EXPECT_TRUE(layer1->quads_appended()); 3728 EXPECT_TRUE(layer1->quads_appended());
3729 EXPECT_TRUE(layer2->quads_appended()); 3729 EXPECT_TRUE(layer2->quads_appended());
3730 host_impl_->DidDrawAllLayers(frame); 3730 host_impl_->DidDrawAllLayers(frame);
3731 3731
3732 // Layer with partially opaque contents, drawn with blending. 3732 // Layer with partially opaque contents, drawn with blending.
3733 layer1->SetContentsOpaque(false); 3733 layer1->SetContentsOpaque(false);
3734 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3734 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3735 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 3735 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
3736 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3736 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3737 layer1->SetExpectation(true, false); 3737 layer1->SetExpectation(true, false);
3738 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3738 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3739 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3739 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3740 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3740 host_impl_->DrawLayers(&frame);
3741 EXPECT_TRUE(layer1->quads_appended()); 3741 EXPECT_TRUE(layer1->quads_appended());
3742 host_impl_->DidDrawAllLayers(frame); 3742 host_impl_->DidDrawAllLayers(frame);
3743 3743
3744 // Layer with partially opaque contents partially culled, drawn with blending. 3744 // Layer with partially opaque contents partially culled, drawn with blending.
3745 layer1->SetContentsOpaque(false); 3745 layer1->SetContentsOpaque(false);
3746 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3746 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3747 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 3747 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
3748 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3748 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3749 layer1->SetExpectation(true, false); 3749 layer1->SetExpectation(true, false);
3750 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3750 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3751 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3751 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3752 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3752 host_impl_->DrawLayers(&frame);
3753 EXPECT_TRUE(layer1->quads_appended()); 3753 EXPECT_TRUE(layer1->quads_appended());
3754 host_impl_->DidDrawAllLayers(frame); 3754 host_impl_->DidDrawAllLayers(frame);
3755 3755
3756 // Layer with partially opaque contents culled, drawn with blending. 3756 // Layer with partially opaque contents culled, drawn with blending.
3757 layer1->SetContentsOpaque(false); 3757 layer1->SetContentsOpaque(false);
3758 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3758 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3759 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 3759 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
3760 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3760 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3761 layer1->SetExpectation(true, false); 3761 layer1->SetExpectation(true, false);
3762 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3762 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3763 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3763 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3764 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3764 host_impl_->DrawLayers(&frame);
3765 EXPECT_TRUE(layer1->quads_appended()); 3765 EXPECT_TRUE(layer1->quads_appended());
3766 host_impl_->DidDrawAllLayers(frame); 3766 host_impl_->DidDrawAllLayers(frame);
3767 3767
3768 // Layer with partially opaque contents and translucent contents culled, drawn 3768 // Layer with partially opaque contents and translucent contents culled, drawn
3769 // without blending. 3769 // without blending.
3770 layer1->SetContentsOpaque(false); 3770 layer1->SetContentsOpaque(false);
3771 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3771 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3772 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 3772 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
3773 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3773 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3774 layer1->SetExpectation(false, false); 3774 layer1->SetExpectation(false, false);
3775 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3775 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3776 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 3776 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3777 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3777 host_impl_->DrawLayers(&frame);
3778 EXPECT_TRUE(layer1->quads_appended()); 3778 EXPECT_TRUE(layer1->quads_appended());
3779 host_impl_->DidDrawAllLayers(frame); 3779 host_impl_->DidDrawAllLayers(frame);
3780 } 3780 }
3781 3781
3782 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { 3782 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
3783 protected: 3783 protected:
3784 LayerTreeHostImplViewportCoveredTest() : 3784 LayerTreeHostImplViewportCoveredTest() :
3785 gutter_quad_material_(DrawQuad::SOLID_COLOR), 3785 gutter_quad_material_(DrawQuad::SOLID_COLOR),
3786 child_(NULL), 3786 child_(NULL),
3787 did_activate_pending_tree_(false) {} 3787 did_activate_pending_tree_(false) {}
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
4090 root->SetContentBounds(gfx::Size(10, 10)); 4090 root->SetContentBounds(gfx::Size(10, 10));
4091 root->SetDrawsContent(true); 4091 root->SetDrawsContent(true);
4092 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4092 host_impl_->active_tree()->SetRootLayer(root.Pass());
4093 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); 4093 EXPECT_FALSE(provider->TestContext3d()->reshape_called());
4094 provider->TestContext3d()->clear_reshape_called(); 4094 provider->TestContext3d()->clear_reshape_called();
4095 4095
4096 LayerTreeHostImpl::FrameData frame; 4096 LayerTreeHostImpl::FrameData frame;
4097 host_impl_->SetViewportSize(gfx::Size(10, 10)); 4097 host_impl_->SetViewportSize(gfx::Size(10, 10));
4098 host_impl_->SetDeviceScaleFactor(1.f); 4098 host_impl_->SetDeviceScaleFactor(1.f);
4099 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4099 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4100 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4100 host_impl_->DrawLayers(&frame);
4101 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4101 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4102 EXPECT_EQ(provider->TestContext3d()->width(), 10); 4102 EXPECT_EQ(provider->TestContext3d()->width(), 10);
4103 EXPECT_EQ(provider->TestContext3d()->height(), 10); 4103 EXPECT_EQ(provider->TestContext3d()->height(), 10);
4104 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); 4104 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
4105 host_impl_->DidDrawAllLayers(frame); 4105 host_impl_->DidDrawAllLayers(frame);
4106 provider->TestContext3d()->clear_reshape_called(); 4106 provider->TestContext3d()->clear_reshape_called();
4107 4107
4108 host_impl_->SetViewportSize(gfx::Size(20, 30)); 4108 host_impl_->SetViewportSize(gfx::Size(20, 30));
4109 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4109 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4110 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4110 host_impl_->DrawLayers(&frame);
4111 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4111 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4112 EXPECT_EQ(provider->TestContext3d()->width(), 20); 4112 EXPECT_EQ(provider->TestContext3d()->width(), 20);
4113 EXPECT_EQ(provider->TestContext3d()->height(), 30); 4113 EXPECT_EQ(provider->TestContext3d()->height(), 30);
4114 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); 4114 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
4115 host_impl_->DidDrawAllLayers(frame); 4115 host_impl_->DidDrawAllLayers(frame);
4116 provider->TestContext3d()->clear_reshape_called(); 4116 provider->TestContext3d()->clear_reshape_called();
4117 4117
4118 host_impl_->SetDeviceScaleFactor(2.f); 4118 host_impl_->SetDeviceScaleFactor(2.f);
4119 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4119 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4120 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4120 host_impl_->DrawLayers(&frame);
4121 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4121 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4122 EXPECT_EQ(provider->TestContext3d()->width(), 20); 4122 EXPECT_EQ(provider->TestContext3d()->width(), 20);
4123 EXPECT_EQ(provider->TestContext3d()->height(), 30); 4123 EXPECT_EQ(provider->TestContext3d()->height(), 30);
4124 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); 4124 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f);
4125 host_impl_->DidDrawAllLayers(frame); 4125 host_impl_->DidDrawAllLayers(frame);
4126 provider->TestContext3d()->clear_reshape_called(); 4126 provider->TestContext3d()->clear_reshape_called();
4127 } 4127 }
4128 4128
4129 // Make sure damage tracking propagates all the way to the graphics context, 4129 // Make sure damage tracking propagates all the way to the graphics context,
4130 // where it should request to swap only the sub-buffer that is damaged. 4130 // 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
4164 root->SetBounds(gfx::Size(500, 500)); 4164 root->SetBounds(gfx::Size(500, 500));
4165 root->SetContentBounds(gfx::Size(500, 500)); 4165 root->SetContentBounds(gfx::Size(500, 500));
4166 root->SetDrawsContent(true); 4166 root->SetDrawsContent(true);
4167 root->AddChild(child.Pass()); 4167 root->AddChild(child.Pass());
4168 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); 4168 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass());
4169 4169
4170 LayerTreeHostImpl::FrameData frame; 4170 LayerTreeHostImpl::FrameData frame;
4171 4171
4172 // First frame, the entire screen should get swapped. 4172 // First frame, the entire screen should get swapped.
4173 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 4173 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
4174 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4174 layer_tree_host_impl->DrawLayers(&frame);
4175 layer_tree_host_impl->DidDrawAllLayers(frame); 4175 layer_tree_host_impl->DidDrawAllLayers(frame);
4176 layer_tree_host_impl->SwapBuffers(frame); 4176 layer_tree_host_impl->SwapBuffers(frame);
4177 EXPECT_EQ(TestContextSupport::SWAP, 4177 EXPECT_EQ(TestContextSupport::SWAP,
4178 context_provider->support()->last_swap_type()); 4178 context_provider->support()->last_swap_type());
4179 4179
4180 // Second frame, only the damaged area should get swapped. Damage should be 4180 // Second frame, only the damaged area should get swapped. Damage should be
4181 // the union of old and new child rects. 4181 // the union of old and new child rects.
4182 // expected damage rect: gfx::Rect(26, 28); 4182 // expected damage rect: gfx::Rect(26, 28);
4183 // expected swap rect: vertically flipped, with origin at bottom left corner. 4183 // expected swap rect: vertically flipped, with origin at bottom left corner.
4184 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( 4184 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition(
4185 gfx::PointF()); 4185 gfx::PointF());
4186 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 4186 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
4187 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4187 layer_tree_host_impl->DrawLayers(&frame);
4188 host_impl_->DidDrawAllLayers(frame); 4188 host_impl_->DidDrawAllLayers(frame);
4189 layer_tree_host_impl->SwapBuffers(frame); 4189 layer_tree_host_impl->SwapBuffers(frame);
4190 4190
4191 // Make sure that partial swap is constrained to the viewport dimensions 4191 // Make sure that partial swap is constrained to the viewport dimensions
4192 // expected damage rect: gfx::Rect(500, 500); 4192 // expected damage rect: gfx::Rect(500, 500);
4193 // expected swap rect: flipped damage rect, but also clamped to viewport 4193 // expected swap rect: flipped damage rect, but also clamped to viewport
4194 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, 4194 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP,
4195 context_provider->support()->last_swap_type()); 4195 context_provider->support()->last_swap_type());
4196 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); 4196 gfx::Rect expected_swap_rect(0, 500-28, 26, 28);
4197 EXPECT_EQ(expected_swap_rect.ToString(), 4197 EXPECT_EQ(expected_swap_rect.ToString(),
4198 context_provider->support()-> 4198 context_provider->support()->
4199 last_partial_swap_rect().ToString()); 4199 last_partial_swap_rect().ToString());
4200 4200
4201 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); 4201 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10));
4202 // This will damage everything. 4202 // This will damage everything.
4203 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( 4203 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor(
4204 SK_ColorBLACK); 4204 SK_ColorBLACK);
4205 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); 4205 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
4206 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4206 layer_tree_host_impl->DrawLayers(&frame);
4207 host_impl_->DidDrawAllLayers(frame); 4207 host_impl_->DidDrawAllLayers(frame);
4208 layer_tree_host_impl->SwapBuffers(frame); 4208 layer_tree_host_impl->SwapBuffers(frame);
4209 4209
4210 EXPECT_EQ(TestContextSupport::SWAP, 4210 EXPECT_EQ(TestContextSupport::SWAP,
4211 context_provider->support()->last_swap_type()); 4211 context_provider->support()->last_swap_type());
4212 } 4212 }
4213 4213
4214 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 4214 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
4215 scoped_ptr<LayerImpl> root = 4215 scoped_ptr<LayerImpl> root =
4216 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4216 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4360 settings.partial_swap_enabled = false; 4360 settings.partial_swap_enabled = false;
4361 CreateHostImpl(settings, output_surface.Pass()); 4361 CreateHostImpl(settings, output_surface.Pass());
4362 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 4362 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
4363 4363
4364 // Without partial swap, and no clipping, no scissor is set. 4364 // Without partial swap, and no clipping, no scissor is set.
4365 harness.MustDrawSolidQuad(); 4365 harness.MustDrawSolidQuad();
4366 harness.MustSetNoScissor(); 4366 harness.MustSetNoScissor();
4367 { 4367 {
4368 LayerTreeHostImpl::FrameData frame; 4368 LayerTreeHostImpl::FrameData frame;
4369 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4369 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4370 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4370 host_impl_->DrawLayers(&frame);
4371 host_impl_->DidDrawAllLayers(frame); 4371 host_impl_->DidDrawAllLayers(frame);
4372 } 4372 }
4373 Mock::VerifyAndClearExpectations(&mock_context); 4373 Mock::VerifyAndClearExpectations(&mock_context);
4374 4374
4375 // Without partial swap, but a layer does clip its subtree, one scissor is 4375 // Without partial swap, but a layer does clip its subtree, one scissor is
4376 // set. 4376 // set.
4377 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); 4377 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true);
4378 harness.MustDrawSolidQuad(); 4378 harness.MustDrawSolidQuad();
4379 harness.MustSetScissor(0, 0, 10, 10); 4379 harness.MustSetScissor(0, 0, 10, 10);
4380 { 4380 {
4381 LayerTreeHostImpl::FrameData frame; 4381 LayerTreeHostImpl::FrameData frame;
4382 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4382 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4383 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4383 host_impl_->DrawLayers(&frame);
4384 host_impl_->DidDrawAllLayers(frame); 4384 host_impl_->DidDrawAllLayers(frame);
4385 } 4385 }
4386 Mock::VerifyAndClearExpectations(&mock_context); 4386 Mock::VerifyAndClearExpectations(&mock_context);
4387 } 4387 }
4388 4388
4389 TEST_F(LayerTreeHostImplTest, PartialSwap) { 4389 TEST_F(LayerTreeHostImplTest, PartialSwap) {
4390 scoped_ptr<MockContext> context_owned(new MockContext); 4390 scoped_ptr<MockContext> context_owned(new MockContext);
4391 MockContext* mock_context = context_owned.get(); 4391 MockContext* mock_context = context_owned.get();
4392 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 4392 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
4393 context_owned.PassAs<TestWebGraphicsContext3D>())); 4393 context_owned.PassAs<TestWebGraphicsContext3D>()));
4394 MockContextHarness harness(mock_context); 4394 MockContextHarness harness(mock_context);
4395 4395
4396 LayerTreeSettings settings = DefaultSettings(); 4396 LayerTreeSettings settings = DefaultSettings();
4397 settings.partial_swap_enabled = true; 4397 settings.partial_swap_enabled = true;
4398 CreateHostImpl(settings, output_surface.Pass()); 4398 CreateHostImpl(settings, output_surface.Pass());
4399 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 4399 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
4400 4400
4401 // The first frame is not a partially-swapped one. 4401 // The first frame is not a partially-swapped one.
4402 harness.MustSetScissor(0, 0, 10, 10); 4402 harness.MustSetScissor(0, 0, 10, 10);
4403 harness.MustDrawSolidQuad(); 4403 harness.MustDrawSolidQuad();
4404 { 4404 {
4405 LayerTreeHostImpl::FrameData frame; 4405 LayerTreeHostImpl::FrameData frame;
4406 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4406 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4407 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4407 host_impl_->DrawLayers(&frame);
4408 host_impl_->DidDrawAllLayers(frame); 4408 host_impl_->DidDrawAllLayers(frame);
4409 } 4409 }
4410 Mock::VerifyAndClearExpectations(&mock_context); 4410 Mock::VerifyAndClearExpectations(&mock_context);
4411 4411
4412 // Damage a portion of the frame. 4412 // Damage a portion of the frame.
4413 host_impl_->active_tree()->root_layer()->SetUpdateRect( 4413 host_impl_->active_tree()->root_layer()->SetUpdateRect(
4414 gfx::Rect(0, 0, 2, 3)); 4414 gfx::Rect(0, 0, 2, 3));
4415 4415
4416 // The second frame will be partially-swapped (the y coordinates are flipped). 4416 // The second frame will be partially-swapped (the y coordinates are flipped).
4417 harness.MustSetScissor(0, 7, 2, 3); 4417 harness.MustSetScissor(0, 7, 2, 3);
4418 harness.MustDrawSolidQuad(); 4418 harness.MustDrawSolidQuad();
4419 { 4419 {
4420 LayerTreeHostImpl::FrameData frame; 4420 LayerTreeHostImpl::FrameData frame;
4421 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4421 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4422 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4422 host_impl_->DrawLayers(&frame);
4423 host_impl_->DidDrawAllLayers(frame); 4423 host_impl_->DidDrawAllLayers(frame);
4424 } 4424 }
4425 Mock::VerifyAndClearExpectations(&mock_context); 4425 Mock::VerifyAndClearExpectations(&mock_context);
4426 } 4426 }
4427 4427
4428 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( 4428 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
4429 bool partial_swap, 4429 bool partial_swap,
4430 LayerTreeHostImplClient* client, 4430 LayerTreeHostImplClient* client,
4431 Proxy* proxy, 4431 Proxy* proxy,
4432 SharedBitmapManager* manager, 4432 SharedBitmapManager* manager,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4517 4517
4518 // Verify all quads have been computed 4518 // Verify all quads have been computed
4519 ASSERT_EQ(2U, frame.render_passes.size()); 4519 ASSERT_EQ(2U, frame.render_passes.size());
4520 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 4520 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
4521 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 4521 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
4522 EXPECT_EQ(DrawQuad::SOLID_COLOR, 4522 EXPECT_EQ(DrawQuad::SOLID_COLOR,
4523 frame.render_passes[0]->quad_list[0]->material); 4523 frame.render_passes[0]->quad_list[0]->material);
4524 EXPECT_EQ(DrawQuad::RENDER_PASS, 4524 EXPECT_EQ(DrawQuad::RENDER_PASS,
4525 frame.render_passes[1]->quad_list[0]->material); 4525 frame.render_passes[1]->quad_list[0]->material);
4526 4526
4527 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4527 my_host_impl->DrawLayers(&frame);
4528 my_host_impl->DidDrawAllLayers(frame); 4528 my_host_impl->DidDrawAllLayers(frame);
4529 } 4529 }
4530 } 4530 }
4531 4531
4532 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 4532 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
4533 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 4533 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
4534 new TestSharedBitmapManager()); 4534 new TestSharedBitmapManager());
4535 scoped_ptr<LayerTreeHostImpl> my_host_impl = 4535 scoped_ptr<LayerTreeHostImpl> my_host_impl =
4536 SetupLayersForOpacity(false, 4536 SetupLayersForOpacity(false,
4537 this, 4537 this,
4538 &proxy_, 4538 &proxy_,
4539 shared_bitmap_manager.get(), 4539 shared_bitmap_manager.get(),
4540 &stats_instrumentation_); 4540 &stats_instrumentation_);
4541 { 4541 {
4542 LayerTreeHostImpl::FrameData frame; 4542 LayerTreeHostImpl::FrameData frame;
4543 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); 4543 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
4544 4544
4545 // Verify all quads have been computed 4545 // Verify all quads have been computed
4546 ASSERT_EQ(2U, frame.render_passes.size()); 4546 ASSERT_EQ(2U, frame.render_passes.size());
4547 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 4547 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
4548 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 4548 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
4549 EXPECT_EQ(DrawQuad::SOLID_COLOR, 4549 EXPECT_EQ(DrawQuad::SOLID_COLOR,
4550 frame.render_passes[0]->quad_list[0]->material); 4550 frame.render_passes[0]->quad_list[0]->material);
4551 EXPECT_EQ(DrawQuad::RENDER_PASS, 4551 EXPECT_EQ(DrawQuad::RENDER_PASS,
4552 frame.render_passes[1]->quad_list[0]->material); 4552 frame.render_passes[1]->quad_list[0]->material);
4553 4553
4554 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4554 my_host_impl->DrawLayers(&frame);
4555 my_host_impl->DidDrawAllLayers(frame); 4555 my_host_impl->DidDrawAllLayers(frame);
4556 } 4556 }
4557 } 4557 }
4558 4558
4559 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { 4559 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) {
4560 scoped_ptr<TestWebGraphicsContext3D> context = 4560 scoped_ptr<TestWebGraphicsContext3D> context =
4561 TestWebGraphicsContext3D::Create(); 4561 TestWebGraphicsContext3D::Create();
4562 TestWebGraphicsContext3D* context3d = context.get(); 4562 TestWebGraphicsContext3D* context3d = context.get();
4563 scoped_ptr<OutputSurface> output_surface( 4563 scoped_ptr<OutputSurface> output_surface(
4564 FakeOutputSurface::Create3d(context.Pass())); 4564 FakeOutputSurface::Create3d(context.Pass()));
(...skipping 22 matching lines...) Expand all
4587 io_surface_layer->SetDrawsContent(true); 4587 io_surface_layer->SetDrawsContent(true);
4588 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); 4588 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
4589 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); 4589 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>());
4590 4590
4591 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 4591 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
4592 4592
4593 EXPECT_EQ(0u, context3d->NumTextures()); 4593 EXPECT_EQ(0u, context3d->NumTextures());
4594 4594
4595 LayerTreeHostImpl::FrameData frame; 4595 LayerTreeHostImpl::FrameData frame;
4596 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4596 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4597 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4597 host_impl_->DrawLayers(&frame);
4598 host_impl_->DidDrawAllLayers(frame); 4598 host_impl_->DidDrawAllLayers(frame);
4599 host_impl_->SwapBuffers(frame); 4599 host_impl_->SwapBuffers(frame);
4600 4600
4601 EXPECT_GT(context3d->NumTextures(), 0u); 4601 EXPECT_GT(context3d->NumTextures(), 0u);
4602 4602
4603 // Kill the layer tree. 4603 // Kill the layer tree.
4604 host_impl_->active_tree()->SetRootLayer( 4604 host_impl_->active_tree()->SetRootLayer(
4605 LayerImpl::Create(host_impl_->active_tree(), 100)); 4605 LayerImpl::Create(host_impl_->active_tree(), 100));
4606 // There should be no textures left in use after. 4606 // There should be no textures left in use after.
4607 EXPECT_EQ(0u, context3d->NumTextures()); 4607 EXPECT_EQ(0u, context3d->NumTextures());
(...skipping 24 matching lines...) Expand all
4632 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); 4632 host_impl_->active_tree()->set_background_color(SK_ColorWHITE);
4633 4633
4634 // Verify one quad is drawn when transparent background set is not set. 4634 // Verify one quad is drawn when transparent background set is not set.
4635 host_impl_->active_tree()->set_has_transparent_background(false); 4635 host_impl_->active_tree()->set_has_transparent_background(false);
4636 EXPECT_CALL(*mock_context, useProgram(_)) 4636 EXPECT_CALL(*mock_context, useProgram(_))
4637 .Times(1); 4637 .Times(1);
4638 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) 4638 EXPECT_CALL(*mock_context, drawElements(_, _, _, _))
4639 .Times(1); 4639 .Times(1);
4640 LayerTreeHostImpl::FrameData frame; 4640 LayerTreeHostImpl::FrameData frame;
4641 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4641 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4642 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4642 host_impl_->DrawLayers(&frame);
4643 host_impl_->DidDrawAllLayers(frame); 4643 host_impl_->DidDrawAllLayers(frame);
4644 Mock::VerifyAndClearExpectations(&mock_context); 4644 Mock::VerifyAndClearExpectations(&mock_context);
4645 4645
4646 // Verify no quads are drawn when transparent background is set. 4646 // Verify no quads are drawn when transparent background is set.
4647 host_impl_->active_tree()->set_has_transparent_background(true); 4647 host_impl_->active_tree()->set_has_transparent_background(true);
4648 host_impl_->SetFullRootLayerDamage(); 4648 host_impl_->SetFullRootLayerDamage();
4649 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4649 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4650 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4650 host_impl_->DrawLayers(&frame);
4651 host_impl_->DidDrawAllLayers(frame); 4651 host_impl_->DidDrawAllLayers(frame);
4652 Mock::VerifyAndClearExpectations(&mock_context); 4652 Mock::VerifyAndClearExpectations(&mock_context);
4653 } 4653 }
4654 4654
4655 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { 4655 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) {
4656 set_reduce_memory_result(false); 4656 set_reduce_memory_result(false);
4657 4657
4658 // If changing the memory limit wouldn't result in changing what was 4658 // If changing the memory limit wouldn't result in changing what was
4659 // committed, then no commit should be requested. 4659 // committed, then no commit should be requested.
4660 set_reduce_memory_result(false); 4660 set_reduce_memory_result(false);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4723 gfx::RectF expected_child_visible_rect(child->content_bounds()); 4723 gfx::RectF expected_child_visible_rect(child->content_bounds());
4724 EXPECT_RECT_EQ(expected_child_visible_rect, 4724 EXPECT_RECT_EQ(expected_child_visible_rect,
4725 root_render_pass->quad_list[0]->visible_rect); 4725 root_render_pass->quad_list[0]->visible_rect);
4726 4726
4727 LayerImpl* root = host_impl_->active_tree()->root_layer(); 4727 LayerImpl* root = host_impl_->active_tree()->root_layer();
4728 gfx::RectF expected_root_visible_rect(root->content_bounds()); 4728 gfx::RectF expected_root_visible_rect(root->content_bounds());
4729 EXPECT_RECT_EQ(expected_root_visible_rect, 4729 EXPECT_RECT_EQ(expected_root_visible_rect,
4730 root_render_pass->quad_list[1]->visible_rect); 4730 root_render_pass->quad_list[1]->visible_rect);
4731 } 4731 }
4732 4732
4733 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4733 host_impl_->DrawLayers(&frame);
4734 host_impl_->DidDrawAllLayers(frame); 4734 host_impl_->DidDrawAllLayers(frame);
4735 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame)); 4735 EXPECT_EQ(expect_to_draw, host_impl_->SwapBuffers(frame));
4736 } 4736 }
4737 }; 4737 };
4738 4738
4739 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { 4739 TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
4740 scoped_ptr<SolidColorLayerImpl> root = 4740 scoped_ptr<SolidColorLayerImpl> root =
4741 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); 4741 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
4742 root->SetPosition(gfx::PointF()); 4742 root->SetPosition(gfx::PointF());
4743 root->SetBounds(gfx::Size(10, 10)); 4743 root->SetBounds(gfx::Size(10, 10));
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4862 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4862 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4863 ASSERT_EQ(DrawQuad::RENDER_PASS, 4863 ASSERT_EQ(DrawQuad::RENDER_PASS,
4864 frame.render_passes[0]->quad_list[0]->material); 4864 frame.render_passes[0]->quad_list[0]->material);
4865 const RenderPassDrawQuad* render_pass_quad = 4865 const RenderPassDrawQuad* render_pass_quad =
4866 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4866 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4867 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4867 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4868 render_pass_quad->rect.ToString()); 4868 render_pass_quad->rect.ToString());
4869 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4869 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4870 render_pass_quad->mask_uv_rect.ToString()); 4870 render_pass_quad->mask_uv_rect.ToString());
4871 4871
4872 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4872 host_impl_->DrawLayers(&frame);
4873 host_impl_->DidDrawAllLayers(frame); 4873 host_impl_->DidDrawAllLayers(frame);
4874 } 4874 }
4875 4875
4876 4876
4877 // Applying a DSF should change the render surface size, but won't affect 4877 // Applying a DSF should change the render surface size, but won't affect
4878 // which part of the mask is used. 4878 // which part of the mask is used.
4879 device_scale_factor = 2.f; 4879 device_scale_factor = 2.f;
4880 gfx::Size device_viewport = 4880 gfx::Size device_viewport =
4881 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4881 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4882 host_impl_->SetViewportSize(device_viewport); 4882 host_impl_->SetViewportSize(device_viewport);
4883 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4883 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4884 host_impl_->active_tree()->set_needs_update_draw_properties(); 4884 host_impl_->active_tree()->set_needs_update_draw_properties();
4885 { 4885 {
4886 LayerTreeHostImpl::FrameData frame; 4886 LayerTreeHostImpl::FrameData frame;
4887 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4887 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4888 4888
4889 ASSERT_EQ(1u, frame.render_passes.size()); 4889 ASSERT_EQ(1u, frame.render_passes.size());
4890 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4890 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4891 ASSERT_EQ(DrawQuad::RENDER_PASS, 4891 ASSERT_EQ(DrawQuad::RENDER_PASS,
4892 frame.render_passes[0]->quad_list[0]->material); 4892 frame.render_passes[0]->quad_list[0]->material);
4893 const RenderPassDrawQuad* render_pass_quad = 4893 const RenderPassDrawQuad* render_pass_quad =
4894 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4894 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4895 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4895 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4896 render_pass_quad->rect.ToString()); 4896 render_pass_quad->rect.ToString());
4897 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4897 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4898 render_pass_quad->mask_uv_rect.ToString()); 4898 render_pass_quad->mask_uv_rect.ToString());
4899 4899
4900 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4900 host_impl_->DrawLayers(&frame);
4901 host_impl_->DidDrawAllLayers(frame); 4901 host_impl_->DidDrawAllLayers(frame);
4902 } 4902 }
4903 4903
4904 4904
4905 // Applying an equivalent content scale on the content layer and the mask 4905 // Applying an equivalent content scale on the content layer and the mask
4906 // should still result in the same part of the mask being used. 4906 // should still result in the same part of the mask being used.
4907 gfx::Size content_bounds = 4907 gfx::Size content_bounds =
4908 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, 4908 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size,
4909 device_scale_factor)); 4909 device_scale_factor));
4910 content_layer->SetContentBounds(content_bounds); 4910 content_layer->SetContentBounds(content_bounds);
4911 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4911 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4912 mask_layer->SetContentBounds(content_bounds); 4912 mask_layer->SetContentBounds(content_bounds);
4913 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4913 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4914 host_impl_->active_tree()->set_needs_update_draw_properties(); 4914 host_impl_->active_tree()->set_needs_update_draw_properties();
4915 { 4915 {
4916 LayerTreeHostImpl::FrameData frame; 4916 LayerTreeHostImpl::FrameData frame;
4917 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 4917 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4918 4918
4919 ASSERT_EQ(1u, frame.render_passes.size()); 4919 ASSERT_EQ(1u, frame.render_passes.size());
4920 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4920 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4921 ASSERT_EQ(DrawQuad::RENDER_PASS, 4921 ASSERT_EQ(DrawQuad::RENDER_PASS,
4922 frame.render_passes[0]->quad_list[0]->material); 4922 frame.render_passes[0]->quad_list[0]->material);
4923 const RenderPassDrawQuad* render_pass_quad = 4923 const RenderPassDrawQuad* render_pass_quad =
4924 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4924 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4925 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4925 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4926 render_pass_quad->rect.ToString()); 4926 render_pass_quad->rect.ToString());
4927 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4927 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4928 render_pass_quad->mask_uv_rect.ToString()); 4928 render_pass_quad->mask_uv_rect.ToString());
4929 4929
4930 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4930 host_impl_->DrawLayers(&frame);
4931 host_impl_->DidDrawAllLayers(frame); 4931 host_impl_->DidDrawAllLayers(frame);
4932 } 4932 }
4933 } 4933 }
4934 4934
4935 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { 4935 TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) {
4936 // The mask layer has bounds 100x100 but is attached to a layer with bounds 4936 // The mask layer has bounds 100x100 but is attached to a layer with bounds
4937 // 50x50. 4937 // 50x50.
4938 4938
4939 scoped_ptr<LayerImpl> scoped_root = 4939 scoped_ptr<LayerImpl> scoped_root =
4940 LayerImpl::Create(host_impl_->active_tree(), 1); 4940 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4980 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4980 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4981 ASSERT_EQ(DrawQuad::RENDER_PASS, 4981 ASSERT_EQ(DrawQuad::RENDER_PASS,
4982 frame.render_passes[0]->quad_list[0]->material); 4982 frame.render_passes[0]->quad_list[0]->material);
4983 const RenderPassDrawQuad* render_pass_quad = 4983 const RenderPassDrawQuad* render_pass_quad =
4984 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4984 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4985 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4985 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
4986 render_pass_quad->rect.ToString()); 4986 render_pass_quad->rect.ToString());
4987 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4987 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4988 render_pass_quad->mask_uv_rect.ToString()); 4988 render_pass_quad->mask_uv_rect.ToString());
4989 4989
4990 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4990 host_impl_->DrawLayers(&frame);
4991 host_impl_->DidDrawAllLayers(frame); 4991 host_impl_->DidDrawAllLayers(frame);
4992 } 4992 }
4993 4993
4994 // Applying a DSF should change the render surface size, but won't affect 4994 // Applying a DSF should change the render surface size, but won't affect
4995 // which part of the mask is used. 4995 // which part of the mask is used.
4996 device_scale_factor = 2.f; 4996 device_scale_factor = 2.f;
4997 gfx::Size device_viewport = 4997 gfx::Size device_viewport =
4998 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4998 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4999 host_impl_->SetViewportSize(device_viewport); 4999 host_impl_->SetViewportSize(device_viewport);
5000 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5000 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5001 host_impl_->active_tree()->set_needs_update_draw_properties(); 5001 host_impl_->active_tree()->set_needs_update_draw_properties();
5002 { 5002 {
5003 LayerTreeHostImpl::FrameData frame; 5003 LayerTreeHostImpl::FrameData frame;
5004 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5004 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5005 5005
5006 ASSERT_EQ(1u, frame.render_passes.size()); 5006 ASSERT_EQ(1u, frame.render_passes.size());
5007 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5007 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5008 ASSERT_EQ(DrawQuad::RENDER_PASS, 5008 ASSERT_EQ(DrawQuad::RENDER_PASS,
5009 frame.render_passes[0]->quad_list[0]->material); 5009 frame.render_passes[0]->quad_list[0]->material);
5010 const RenderPassDrawQuad* render_pass_quad = 5010 const RenderPassDrawQuad* render_pass_quad =
5011 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5011 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5012 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5012 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5013 render_pass_quad->rect.ToString()); 5013 render_pass_quad->rect.ToString());
5014 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5014 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5015 render_pass_quad->mask_uv_rect.ToString()); 5015 render_pass_quad->mask_uv_rect.ToString());
5016 5016
5017 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5017 host_impl_->DrawLayers(&frame);
5018 host_impl_->DidDrawAllLayers(frame); 5018 host_impl_->DidDrawAllLayers(frame);
5019 } 5019 }
5020 5020
5021 // Applying an equivalent content scale on the content layer and the mask 5021 // Applying an equivalent content scale on the content layer and the mask
5022 // should still result in the same part of the mask being used. 5022 // should still result in the same part of the mask being used.
5023 gfx::Size layer_size_large = 5023 gfx::Size layer_size_large =
5024 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 5024 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
5025 content_layer->SetContentBounds(layer_size_large); 5025 content_layer->SetContentBounds(layer_size_large);
5026 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5026 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5027 gfx::Size mask_size_large = 5027 gfx::Size mask_size_large =
5028 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 5028 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
5029 mask_layer->SetContentBounds(mask_size_large); 5029 mask_layer->SetContentBounds(mask_size_large);
5030 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5030 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5031 host_impl_->active_tree()->set_needs_update_draw_properties(); 5031 host_impl_->active_tree()->set_needs_update_draw_properties();
5032 { 5032 {
5033 LayerTreeHostImpl::FrameData frame; 5033 LayerTreeHostImpl::FrameData frame;
5034 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5034 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5035 5035
5036 ASSERT_EQ(1u, frame.render_passes.size()); 5036 ASSERT_EQ(1u, frame.render_passes.size());
5037 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5037 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5038 ASSERT_EQ(DrawQuad::RENDER_PASS, 5038 ASSERT_EQ(DrawQuad::RENDER_PASS,
5039 frame.render_passes[0]->quad_list[0]->material); 5039 frame.render_passes[0]->quad_list[0]->material);
5040 const RenderPassDrawQuad* render_pass_quad = 5040 const RenderPassDrawQuad* render_pass_quad =
5041 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5041 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5042 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5042 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5043 render_pass_quad->rect.ToString()); 5043 render_pass_quad->rect.ToString());
5044 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5044 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5045 render_pass_quad->mask_uv_rect.ToString()); 5045 render_pass_quad->mask_uv_rect.ToString());
5046 5046
5047 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5047 host_impl_->DrawLayers(&frame);
5048 host_impl_->DidDrawAllLayers(frame); 5048 host_impl_->DidDrawAllLayers(frame);
5049 } 5049 }
5050 5050
5051 // Applying a different contents scale to the mask layer means it will have 5051 // Applying a different contents scale to the mask layer means it will have
5052 // a larger texture, but it should use the same tex coords to cover the 5052 // a larger texture, but it should use the same tex coords to cover the
5053 // layer it masks. 5053 // layer it masks.
5054 mask_layer->SetContentBounds(mask_size); 5054 mask_layer->SetContentBounds(mask_size);
5055 mask_layer->SetContentsScale(1.f, 1.f); 5055 mask_layer->SetContentsScale(1.f, 1.f);
5056 host_impl_->active_tree()->set_needs_update_draw_properties(); 5056 host_impl_->active_tree()->set_needs_update_draw_properties();
5057 { 5057 {
5058 LayerTreeHostImpl::FrameData frame; 5058 LayerTreeHostImpl::FrameData frame;
5059 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5059 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5060 5060
5061 ASSERT_EQ(1u, frame.render_passes.size()); 5061 ASSERT_EQ(1u, frame.render_passes.size());
5062 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5062 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5063 ASSERT_EQ(DrawQuad::RENDER_PASS, 5063 ASSERT_EQ(DrawQuad::RENDER_PASS,
5064 frame.render_passes[0]->quad_list[0]->material); 5064 frame.render_passes[0]->quad_list[0]->material);
5065 const RenderPassDrawQuad* render_pass_quad = 5065 const RenderPassDrawQuad* render_pass_quad =
5066 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5066 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5067 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5067 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5068 render_pass_quad->rect.ToString()); 5068 render_pass_quad->rect.ToString());
5069 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5069 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5070 render_pass_quad->mask_uv_rect.ToString()); 5070 render_pass_quad->mask_uv_rect.ToString());
5071 5071
5072 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5072 host_impl_->DrawLayers(&frame);
5073 host_impl_->DidDrawAllLayers(frame); 5073 host_impl_->DidDrawAllLayers(frame);
5074 } 5074 }
5075 } 5075 }
5076 5076
5077 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { 5077 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) {
5078 // The replica's mask layer has bounds 100x100 but the replica is of a 5078 // The replica's mask layer has bounds 100x100 but the replica is of a
5079 // layer with bounds 50x50. 5079 // layer with bounds 50x50.
5080 5080
5081 scoped_ptr<LayerImpl> scoped_root = 5081 scoped_ptr<LayerImpl> scoped_root =
5082 LayerImpl::Create(host_impl_->active_tree(), 1); 5082 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5128 ASSERT_EQ(DrawQuad::RENDER_PASS, 5128 ASSERT_EQ(DrawQuad::RENDER_PASS,
5129 frame.render_passes[0]->quad_list[1]->material); 5129 frame.render_passes[0]->quad_list[1]->material);
5130 const RenderPassDrawQuad* replica_quad = 5130 const RenderPassDrawQuad* replica_quad =
5131 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5131 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5132 EXPECT_TRUE(replica_quad->is_replica); 5132 EXPECT_TRUE(replica_quad->is_replica);
5133 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 5133 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
5134 replica_quad->rect.ToString()); 5134 replica_quad->rect.ToString());
5135 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5135 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5136 replica_quad->mask_uv_rect.ToString()); 5136 replica_quad->mask_uv_rect.ToString());
5137 5137
5138 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5138 host_impl_->DrawLayers(&frame);
5139 host_impl_->DidDrawAllLayers(frame); 5139 host_impl_->DidDrawAllLayers(frame);
5140 } 5140 }
5141 5141
5142 // Applying a DSF should change the render surface size, but won't affect 5142 // Applying a DSF should change the render surface size, but won't affect
5143 // which part of the mask is used. 5143 // which part of the mask is used.
5144 device_scale_factor = 2.f; 5144 device_scale_factor = 2.f;
5145 gfx::Size device_viewport = 5145 gfx::Size device_viewport =
5146 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 5146 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
5147 host_impl_->SetViewportSize(device_viewport); 5147 host_impl_->SetViewportSize(device_viewport);
5148 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5148 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5149 host_impl_->active_tree()->set_needs_update_draw_properties(); 5149 host_impl_->active_tree()->set_needs_update_draw_properties();
5150 { 5150 {
5151 LayerTreeHostImpl::FrameData frame; 5151 LayerTreeHostImpl::FrameData frame;
5152 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5152 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5153 5153
5154 ASSERT_EQ(1u, frame.render_passes.size()); 5154 ASSERT_EQ(1u, frame.render_passes.size());
5155 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5155 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5156 ASSERT_EQ(DrawQuad::RENDER_PASS, 5156 ASSERT_EQ(DrawQuad::RENDER_PASS,
5157 frame.render_passes[0]->quad_list[1]->material); 5157 frame.render_passes[0]->quad_list[1]->material);
5158 const RenderPassDrawQuad* replica_quad = 5158 const RenderPassDrawQuad* replica_quad =
5159 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5159 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5160 EXPECT_TRUE(replica_quad->is_replica); 5160 EXPECT_TRUE(replica_quad->is_replica);
5161 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5161 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5162 replica_quad->rect.ToString()); 5162 replica_quad->rect.ToString());
5163 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5163 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5164 replica_quad->mask_uv_rect.ToString()); 5164 replica_quad->mask_uv_rect.ToString());
5165 5165
5166 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5166 host_impl_->DrawLayers(&frame);
5167 host_impl_->DidDrawAllLayers(frame); 5167 host_impl_->DidDrawAllLayers(frame);
5168 } 5168 }
5169 5169
5170 // Applying an equivalent content scale on the content layer and the mask 5170 // Applying an equivalent content scale on the content layer and the mask
5171 // should still result in the same part of the mask being used. 5171 // should still result in the same part of the mask being used.
5172 gfx::Size layer_size_large = 5172 gfx::Size layer_size_large =
5173 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 5173 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
5174 content_layer->SetContentBounds(layer_size_large); 5174 content_layer->SetContentBounds(layer_size_large);
5175 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5175 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5176 gfx::Size mask_size_large = 5176 gfx::Size mask_size_large =
(...skipping 10 matching lines...) Expand all
5187 ASSERT_EQ(DrawQuad::RENDER_PASS, 5187 ASSERT_EQ(DrawQuad::RENDER_PASS,
5188 frame.render_passes[0]->quad_list[1]->material); 5188 frame.render_passes[0]->quad_list[1]->material);
5189 const RenderPassDrawQuad* replica_quad = 5189 const RenderPassDrawQuad* replica_quad =
5190 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5190 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5191 EXPECT_TRUE(replica_quad->is_replica); 5191 EXPECT_TRUE(replica_quad->is_replica);
5192 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5192 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5193 replica_quad->rect.ToString()); 5193 replica_quad->rect.ToString());
5194 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5194 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5195 replica_quad->mask_uv_rect.ToString()); 5195 replica_quad->mask_uv_rect.ToString());
5196 5196
5197 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5197 host_impl_->DrawLayers(&frame);
5198 host_impl_->DidDrawAllLayers(frame); 5198 host_impl_->DidDrawAllLayers(frame);
5199 } 5199 }
5200 5200
5201 // Applying a different contents scale to the mask layer means it will have 5201 // Applying a different contents scale to the mask layer means it will have
5202 // a larger texture, but it should use the same tex coords to cover the 5202 // a larger texture, but it should use the same tex coords to cover the
5203 // layer it masks. 5203 // layer it masks.
5204 mask_layer->SetContentBounds(mask_size); 5204 mask_layer->SetContentBounds(mask_size);
5205 mask_layer->SetContentsScale(1.f, 1.f); 5205 mask_layer->SetContentsScale(1.f, 1.f);
5206 host_impl_->active_tree()->set_needs_update_draw_properties(); 5206 host_impl_->active_tree()->set_needs_update_draw_properties();
5207 { 5207 {
5208 LayerTreeHostImpl::FrameData frame; 5208 LayerTreeHostImpl::FrameData frame;
5209 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5209 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5210 5210
5211 ASSERT_EQ(1u, frame.render_passes.size()); 5211 ASSERT_EQ(1u, frame.render_passes.size());
5212 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5212 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5213 ASSERT_EQ(DrawQuad::RENDER_PASS, 5213 ASSERT_EQ(DrawQuad::RENDER_PASS,
5214 frame.render_passes[0]->quad_list[1]->material); 5214 frame.render_passes[0]->quad_list[1]->material);
5215 const RenderPassDrawQuad* replica_quad = 5215 const RenderPassDrawQuad* replica_quad =
5216 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5216 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5217 EXPECT_TRUE(replica_quad->is_replica); 5217 EXPECT_TRUE(replica_quad->is_replica);
5218 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5218 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5219 replica_quad->rect.ToString()); 5219 replica_quad->rect.ToString());
5220 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5220 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5221 replica_quad->mask_uv_rect.ToString()); 5221 replica_quad->mask_uv_rect.ToString());
5222 5222
5223 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5223 host_impl_->DrawLayers(&frame);
5224 host_impl_->DidDrawAllLayers(frame); 5224 host_impl_->DidDrawAllLayers(frame);
5225 } 5225 }
5226 } 5226 }
5227 5227
5228 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { 5228 TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) {
5229 // The replica is of a layer with bounds 50x50, but it has a child that causes 5229 // The replica is of a layer with bounds 50x50, but it has a child that causes
5230 // the surface bounds to be larger. 5230 // the surface bounds to be larger.
5231 5231
5232 scoped_ptr<LayerImpl> scoped_root = 5232 scoped_ptr<LayerImpl> scoped_root =
5233 LayerImpl::Create(host_impl_->active_tree(), 1); 5233 LayerImpl::Create(host_impl_->active_tree(), 1);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
5300 ASSERT_EQ(DrawQuad::RENDER_PASS, 5300 ASSERT_EQ(DrawQuad::RENDER_PASS,
5301 frame.render_passes[0]->quad_list[1]->material); 5301 frame.render_passes[0]->quad_list[1]->material);
5302 const RenderPassDrawQuad* replica_quad = 5302 const RenderPassDrawQuad* replica_quad =
5303 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5303 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5304 EXPECT_TRUE(replica_quad->is_replica); 5304 EXPECT_TRUE(replica_quad->is_replica);
5305 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 5305 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
5306 replica_quad->rect.ToString()); 5306 replica_quad->rect.ToString());
5307 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), 5307 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(),
5308 replica_quad->mask_uv_rect.ToString()); 5308 replica_quad->mask_uv_rect.ToString());
5309 5309
5310 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5310 host_impl_->DrawLayers(&frame);
5311 host_impl_->DidDrawAllLayers(frame); 5311 host_impl_->DidDrawAllLayers(frame);
5312 } 5312 }
5313 5313
5314 // Move the child to (-50, 0) instead. Now the mask should be moved to still 5314 // Move the child to (-50, 0) instead. Now the mask should be moved to still
5315 // cover the layer being replicated. 5315 // cover the layer being replicated.
5316 content_child_layer->SetPosition(gfx::Point(-50, 0)); 5316 content_child_layer->SetPosition(gfx::Point(-50, 0));
5317 { 5317 {
5318 LayerTreeHostImpl::FrameData frame; 5318 LayerTreeHostImpl::FrameData frame;
5319 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5319 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5320 5320
(...skipping 13 matching lines...) Expand all
5334 ASSERT_EQ(DrawQuad::RENDER_PASS, 5334 ASSERT_EQ(DrawQuad::RENDER_PASS,
5335 frame.render_passes[0]->quad_list[1]->material); 5335 frame.render_passes[0]->quad_list[1]->material);
5336 const RenderPassDrawQuad* replica_quad = 5336 const RenderPassDrawQuad* replica_quad =
5337 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5337 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5338 EXPECT_TRUE(replica_quad->is_replica); 5338 EXPECT_TRUE(replica_quad->is_replica);
5339 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), 5339 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
5340 replica_quad->rect.ToString()); 5340 replica_quad->rect.ToString());
5341 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), 5341 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(),
5342 replica_quad->mask_uv_rect.ToString()); 5342 replica_quad->mask_uv_rect.ToString());
5343 5343
5344 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5344 host_impl_->DrawLayers(&frame);
5345 host_impl_->DidDrawAllLayers(frame); 5345 host_impl_->DidDrawAllLayers(frame);
5346 } 5346 }
5347 } 5347 }
5348 5348
5349 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { 5349 TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) {
5350 // The masked layer has bounds 50x50, but it has a child that causes 5350 // The masked layer has bounds 50x50, but it has a child that causes
5351 // the surface bounds to be larger. It also has a parent that clips the 5351 // the surface bounds to be larger. It also has a parent that clips the
5352 // masked layer and its surface. 5352 // masked layer and its surface.
5353 5353
5354 scoped_ptr<LayerImpl> scoped_root = 5354 scoped_ptr<LayerImpl> scoped_root =
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5425 render_pass_quad->rect.ToString()); 5425 render_pass_quad->rect.ToString());
5426 5426
5427 // The masked layer is 50x50, but the surface size is 10x20. So the texture 5427 // The masked layer is 50x50, but the surface size is 10x20. So the texture
5428 // coords in the mask are scaled by 10/50 and 20/50. 5428 // coords in the mask are scaled by 10/50 and 20/50.
5429 // The surface is clipped to (20,10) so the mask texture coords are offset 5429 // The surface is clipped to (20,10) so the mask texture coords are offset
5430 // by 20/50 and 10/50 5430 // by 20/50 and 10/50
5431 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 5431 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f),
5432 1.f / 50.f).ToString(), 5432 1.f / 50.f).ToString(),
5433 render_pass_quad->mask_uv_rect.ToString()); 5433 render_pass_quad->mask_uv_rect.ToString());
5434 5434
5435 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5435 host_impl_->DrawLayers(&frame);
5436 host_impl_->DidDrawAllLayers(frame); 5436 host_impl_->DidDrawAllLayers(frame);
5437 } 5437 }
5438 } 5438 }
5439 5439
5440 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer { 5440 class GLRendererWithSetupQuadForAntialiasing : public GLRenderer {
5441 public: 5441 public:
5442 using GLRenderer::SetupQuadForAntialiasing; 5442 using GLRenderer::SetupQuadForAntialiasing;
5443 }; 5443 };
5444 5444
5445 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { 5445 TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
5497 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 5497 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
5498 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; 5498 const DrawQuad* quad = frame.render_passes[0]->quad_list[0];
5499 5499
5500 float edge[24]; 5500 float edge[24];
5501 gfx::QuadF device_layer_quad; 5501 gfx::QuadF device_layer_quad;
5502 bool antialiased = 5502 bool antialiased =
5503 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( 5503 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing(
5504 quad->quadTransform(), quad, &device_layer_quad, edge); 5504 quad->quadTransform(), quad, &device_layer_quad, edge);
5505 EXPECT_FALSE(antialiased); 5505 EXPECT_FALSE(antialiased);
5506 5506
5507 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5507 host_impl_->DrawLayers(&frame);
5508 host_impl_->DidDrawAllLayers(frame); 5508 host_impl_->DidDrawAllLayers(frame);
5509 } 5509 }
5510 5510
5511 5511
5512 class CompositorFrameMetadataTest : public LayerTreeHostImplTest { 5512 class CompositorFrameMetadataTest : public LayerTreeHostImplTest {
5513 public: 5513 public:
5514 CompositorFrameMetadataTest() 5514 CompositorFrameMetadataTest()
5515 : swap_buffers_complete_(0) {} 5515 : swap_buffers_complete_(0) {}
5516 5516
5517 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE { 5517 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE {
5518 swap_buffers_complete_++; 5518 swap_buffers_complete_++;
5519 } 5519 }
5520 5520
5521 int swap_buffers_complete_; 5521 int swap_buffers_complete_;
5522 }; 5522 };
5523 5523
5524 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { 5524 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) {
5525 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 5525 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
5526 { 5526 {
5527 LayerTreeHostImpl::FrameData frame; 5527 LayerTreeHostImpl::FrameData frame;
5528 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5528 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5529 host_impl_->DrawLayers(&frame, base::TimeTicks()); 5529 host_impl_->DrawLayers(&frame);
5530 host_impl_->DidDrawAllLayers(frame); 5530 host_impl_->DidDrawAllLayers(frame);
5531 } 5531 }
5532 CompositorFrameAck ack; 5532 CompositorFrameAck ack;
5533 host_impl_->ReclaimResources(&ack); 5533 host_impl_->ReclaimResources(&ack);
5534 host_impl_->DidSwapBuffersComplete(); 5534 host_impl_->DidSwapBuffersComplete();
5535 EXPECT_EQ(swap_buffers_complete_, 1); 5535 EXPECT_EQ(swap_buffers_complete_, 1);
5536 } 5536 }
5537 5537
5538 class CountingSoftwareDevice : public SoftwareOutputDevice { 5538 class CountingSoftwareDevice : public SoftwareOutputDevice {
5539 public: 5539 public:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5605 scoped_ptr<VideoLayerImpl> video_layer = 5605 scoped_ptr<VideoLayerImpl> video_layer =
5606 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); 5606 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
5607 video_layer->SetBounds(gfx::Size(10, 10)); 5607 video_layer->SetBounds(gfx::Size(10, 10));
5608 video_layer->SetContentBounds(gfx::Size(10, 10)); 5608 video_layer->SetContentBounds(gfx::Size(10, 10));
5609 video_layer->SetDrawsContent(true); 5609 video_layer->SetDrawsContent(true);
5610 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); 5610 root_layer->AddChild(video_layer.PassAs<LayerImpl>());
5611 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); 5611 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
5612 5612
5613 LayerTreeHostImpl::FrameData frame; 5613 LayerTreeHostImpl::FrameData frame;
5614 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5614 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5615 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5615 host_impl_->DrawLayers(&frame);
5616 host_impl_->DidDrawAllLayers(frame); 5616 host_impl_->DidDrawAllLayers(frame);
5617 5617
5618 EXPECT_EQ(1u, frame.will_draw_layers.size()); 5618 EXPECT_EQ(1u, frame.will_draw_layers.size());
5619 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); 5619 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]);
5620 } 5620 }
5621 5621
5622 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { 5622 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest {
5623 protected: 5623 protected:
5624 virtual void SetUp() OVERRIDE { 5624 virtual void SetUp() OVERRIDE {
5625 LayerTreeHostImplTest::SetUp(); 5625 LayerTreeHostImplTest::SetUp();
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
5911 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 5911 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
5912 5912
5913 ScopedPtrVector<CopyOutputRequest> requests; 5913 ScopedPtrVector<CopyOutputRequest> requests;
5914 requests.push_back(CopyOutputRequest::CreateRequest( 5914 requests.push_back(CopyOutputRequest::CreateRequest(
5915 base::Bind(&ShutdownReleasesContext_Callback))); 5915 base::Bind(&ShutdownReleasesContext_Callback)));
5916 5916
5917 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); 5917 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests);
5918 5918
5919 LayerTreeHostImpl::FrameData frame; 5919 LayerTreeHostImpl::FrameData frame;
5920 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5920 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5921 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5921 host_impl_->DrawLayers(&frame);
5922 host_impl_->DidDrawAllLayers(frame); 5922 host_impl_->DidDrawAllLayers(frame);
5923 5923
5924 // The CopyOutputResult's callback has a ref on the ContextProvider and a 5924 // The CopyOutputResult's callback has a ref on the ContextProvider and a
5925 // texture in a texture mailbox. 5925 // texture in a texture mailbox.
5926 EXPECT_FALSE(context_provider->HasOneRef()); 5926 EXPECT_FALSE(context_provider->HasOneRef());
5927 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 5927 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
5928 5928
5929 host_impl_.reset(); 5929 host_impl_.reset();
5930 5930
5931 // The CopyOutputResult's callback was cancelled, the CopyOutputResult 5931 // The CopyOutputResult's callback was cancelled, the CopyOutputResult
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
6271 latency_info.AddLatencyNumber( 6271 latency_info.AddLatencyNumber(
6272 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); 6272 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0);
6273 scoped_ptr<SwapPromise> swap_promise( 6273 scoped_ptr<SwapPromise> swap_promise(
6274 new LatencyInfoSwapPromise(latency_info)); 6274 new LatencyInfoSwapPromise(latency_info));
6275 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); 6275 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
6276 host_impl_->SetNeedsRedraw(); 6276 host_impl_->SetNeedsRedraw();
6277 6277
6278 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 6278 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
6279 LayerTreeHostImpl::FrameData frame; 6279 LayerTreeHostImpl::FrameData frame;
6280 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6280 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6281 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 6281 host_impl_->DrawLayers(&frame);
6282 host_impl_->DidDrawAllLayers(frame); 6282 host_impl_->DidDrawAllLayers(frame);
6283 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); 6283 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
6284 6284
6285 const std::vector<ui::LatencyInfo>& metadata_latency_after = 6285 const std::vector<ui::LatencyInfo>& metadata_latency_after =
6286 fake_output_surface->last_sent_frame().metadata.latency_info; 6286 fake_output_surface->last_sent_frame().metadata.latency_info;
6287 EXPECT_EQ(1u, metadata_latency_after.size()); 6287 EXPECT_EQ(1u, metadata_latency_after.size());
6288 EXPECT_TRUE(metadata_latency_after[0].FindLatency( 6288 EXPECT_TRUE(metadata_latency_after[0].FindLatency(
6289 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); 6289 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL));
6290 } 6290 }
6291 6291
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
6625 FakePictureLayerImpl* active_mask_content = 6625 FakePictureLayerImpl* active_mask_content =
6626 static_cast<FakePictureLayerImpl*>( 6626 static_cast<FakePictureLayerImpl*>(
6627 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); 6627 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer());
6628 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); 6628 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority();
6629 6629
6630 ASSERT_TRUE(!r2.IsEmpty()); 6630 ASSERT_TRUE(!r2.IsEmpty());
6631 } 6631 }
6632 6632
6633 } // namespace 6633 } // namespace
6634 } // namespace cc 6634 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698