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

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

Issue 246753008: cc: Unify use of DidSwapBuffers() and did_request_swap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use did_swap_request Created 6 years, 7 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 layer->SetScrollClipLayer(clip_layer->id()); 295 layer->SetScrollClipLayer(clip_layer->id());
296 layer->SetDrawsContent(true); 296 layer->SetDrawsContent(true);
297 layer->SetBounds(size); 297 layer->SetBounds(size);
298 layer->SetContentBounds(size); 298 layer->SetContentBounds(size);
299 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); 299 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2));
300 return layer.Pass(); 300 return layer.Pass();
301 } 301 }
302 302
303 void DrawFrame() { 303 void DrawFrame() {
304 LayerTreeHostImpl::FrameData frame; 304 LayerTreeHostImpl::FrameData frame;
305 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 305 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
306 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
307 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 306 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
308 host_impl_->DidDrawAllLayers(frame); 307 host_impl_->DidDrawAllLayers(frame);
309 } 308 }
310 309
311 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); 310 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
312 void pinch_zoom_pan_viewport_test(float device_scale_factor); 311 void pinch_zoom_pan_viewport_test(float device_scale_factor);
313 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); 312 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor);
314 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 313 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
315 float device_scale_factor); 314 float device_scale_factor);
316 315
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1718 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1720 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 1719 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
1721 host_impl_->active_tree()->root_layer()); 1720 host_impl_->active_tree()->root_layer());
1722 1721
1723 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1722 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1724 DidDrawCheckLayer* layer = 1723 DidDrawCheckLayer* layer =
1725 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1724 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1726 1725
1727 { 1726 {
1728 LayerTreeHostImpl::FrameData frame; 1727 LayerTreeHostImpl::FrameData frame;
1729 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1728 EXPECT_EQ(DRAW_SUCCESS,
1730 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1729 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1731 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1730 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1732 host_impl_->DidDrawAllLayers(frame); 1731 host_impl_->DidDrawAllLayers(frame);
1733 1732
1734 EXPECT_TRUE(layer->will_draw_called()); 1733 EXPECT_TRUE(layer->will_draw_called());
1735 EXPECT_TRUE(layer->append_quads_called()); 1734 EXPECT_TRUE(layer->append_quads_called());
1736 EXPECT_TRUE(layer->did_draw_called()); 1735 EXPECT_TRUE(layer->did_draw_called());
1737 } 1736 }
1738 1737
1739 { 1738 {
1740 LayerTreeHostImpl::FrameData frame; 1739 LayerTreeHostImpl::FrameData frame;
1741 1740
1742 layer->set_will_draw_returns_false(); 1741 layer->set_will_draw_returns_false();
1743 layer->ClearDidDrawCheck(); 1742 layer->ClearDidDrawCheck();
1744 1743
1745 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1744 EXPECT_EQ(DRAW_SUCCESS,
1746 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1745 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1747 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1746 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1748 host_impl_->DidDrawAllLayers(frame); 1747 host_impl_->DidDrawAllLayers(frame);
1749 1748
1750 EXPECT_TRUE(layer->will_draw_called()); 1749 EXPECT_TRUE(layer->will_draw_called());
1751 EXPECT_FALSE(layer->append_quads_called()); 1750 EXPECT_FALSE(layer->append_quads_called());
1752 EXPECT_FALSE(layer->did_draw_called()); 1751 EXPECT_FALSE(layer->did_draw_called());
1753 } 1752 }
1754 } 1753 }
1755 1754
(...skipping 12 matching lines...) Expand all
1768 // Ensure visible_content_rect for layer is empty. 1767 // Ensure visible_content_rect for layer is empty.
1769 layer->SetPosition(gfx::PointF(100.f, 100.f)); 1768 layer->SetPosition(gfx::PointF(100.f, 100.f));
1770 layer->SetBounds(gfx::Size(10, 10)); 1769 layer->SetBounds(gfx::Size(10, 10));
1771 layer->SetContentBounds(gfx::Size(10, 10)); 1770 layer->SetContentBounds(gfx::Size(10, 10));
1772 1771
1773 LayerTreeHostImpl::FrameData frame; 1772 LayerTreeHostImpl::FrameData frame;
1774 1773
1775 EXPECT_FALSE(layer->will_draw_called()); 1774 EXPECT_FALSE(layer->will_draw_called());
1776 EXPECT_FALSE(layer->did_draw_called()); 1775 EXPECT_FALSE(layer->did_draw_called());
1777 1776
1778 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1777 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1779 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1780 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1778 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1781 host_impl_->DidDrawAllLayers(frame); 1779 host_impl_->DidDrawAllLayers(frame);
1782 1780
1783 EXPECT_FALSE(layer->will_draw_called()); 1781 EXPECT_FALSE(layer->will_draw_called());
1784 EXPECT_FALSE(layer->did_draw_called()); 1782 EXPECT_FALSE(layer->did_draw_called());
1785 1783
1786 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); 1784 EXPECT_TRUE(layer->visible_content_rect().IsEmpty());
1787 1785
1788 // Ensure visible_content_rect for layer is not empty 1786 // Ensure visible_content_rect for layer is not empty
1789 layer->SetPosition(gfx::PointF()); 1787 layer->SetPosition(gfx::PointF());
1790 1788
1791 EXPECT_FALSE(layer->will_draw_called()); 1789 EXPECT_FALSE(layer->will_draw_called());
1792 EXPECT_FALSE(layer->did_draw_called()); 1790 EXPECT_FALSE(layer->did_draw_called());
1793 1791
1794 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1792 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1795 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1796 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1793 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1797 host_impl_->DidDrawAllLayers(frame); 1794 host_impl_->DidDrawAllLayers(frame);
1798 1795
1799 EXPECT_TRUE(layer->will_draw_called()); 1796 EXPECT_TRUE(layer->will_draw_called());
1800 EXPECT_TRUE(layer->did_draw_called()); 1797 EXPECT_TRUE(layer->did_draw_called());
1801 1798
1802 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); 1799 EXPECT_FALSE(layer->visible_content_rect().IsEmpty());
1803 } 1800 }
1804 1801
1805 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 1802 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
(...skipping 18 matching lines...) Expand all
1824 top_layer->SetContentBounds(big_size); 1821 top_layer->SetContentBounds(big_size);
1825 top_layer->SetContentsOpaque(true); 1822 top_layer->SetContentsOpaque(true);
1826 1823
1827 LayerTreeHostImpl::FrameData frame; 1824 LayerTreeHostImpl::FrameData frame;
1828 1825
1829 EXPECT_FALSE(occluded_layer->will_draw_called()); 1826 EXPECT_FALSE(occluded_layer->will_draw_called());
1830 EXPECT_FALSE(occluded_layer->did_draw_called()); 1827 EXPECT_FALSE(occluded_layer->did_draw_called());
1831 EXPECT_FALSE(top_layer->will_draw_called()); 1828 EXPECT_FALSE(top_layer->will_draw_called());
1832 EXPECT_FALSE(top_layer->did_draw_called()); 1829 EXPECT_FALSE(top_layer->did_draw_called());
1833 1830
1834 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1831 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1835 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1836 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1832 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1837 host_impl_->DidDrawAllLayers(frame); 1833 host_impl_->DidDrawAllLayers(frame);
1838 1834
1839 EXPECT_FALSE(occluded_layer->will_draw_called()); 1835 EXPECT_FALSE(occluded_layer->will_draw_called());
1840 EXPECT_FALSE(occluded_layer->did_draw_called()); 1836 EXPECT_FALSE(occluded_layer->did_draw_called());
1841 EXPECT_TRUE(top_layer->will_draw_called()); 1837 EXPECT_TRUE(top_layer->will_draw_called());
1842 EXPECT_TRUE(top_layer->did_draw_called()); 1838 EXPECT_TRUE(top_layer->did_draw_called());
1843 } 1839 }
1844 1840
1845 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 1841 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
(...skipping 11 matching lines...) Expand all
1857 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); 1853 static_cast<DidDrawCheckLayer*>(layer1->children()[0]);
1858 1854
1859 layer1->SetOpacity(0.3f); 1855 layer1->SetOpacity(0.3f);
1860 layer1->SetShouldFlattenTransform(true); 1856 layer1->SetShouldFlattenTransform(true);
1861 1857
1862 EXPECT_FALSE(root->did_draw_called()); 1858 EXPECT_FALSE(root->did_draw_called());
1863 EXPECT_FALSE(layer1->did_draw_called()); 1859 EXPECT_FALSE(layer1->did_draw_called());
1864 EXPECT_FALSE(layer2->did_draw_called()); 1860 EXPECT_FALSE(layer2->did_draw_called());
1865 1861
1866 LayerTreeHostImpl::FrameData frame; 1862 LayerTreeHostImpl::FrameData frame;
1867 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1863 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1868 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1869 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1864 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1870 host_impl_->DidDrawAllLayers(frame); 1865 host_impl_->DidDrawAllLayers(frame);
1871 1866
1872 EXPECT_TRUE(root->did_draw_called()); 1867 EXPECT_TRUE(root->did_draw_called());
1873 EXPECT_TRUE(layer1->did_draw_called()); 1868 EXPECT_TRUE(layer1->did_draw_called());
1874 EXPECT_TRUE(layer2->did_draw_called()); 1869 EXPECT_TRUE(layer2->did_draw_called());
1875 1870
1876 EXPECT_NE(root->render_surface(), layer1->render_surface()); 1871 EXPECT_NE(root->render_surface(), layer1->render_surface());
1877 EXPECT_TRUE(!!layer1->render_surface()); 1872 EXPECT_TRUE(!!layer1->render_surface());
1878 } 1873 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 root->AddChild( 1938 root->AddChild(
1944 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1939 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1945 2, 1940 2,
1946 tile_missing, 1941 tile_missing,
1947 skips_draw, 1942 skips_draw,
1948 is_animating, 1943 is_animating,
1949 host_impl_->resource_provider())); 1944 host_impl_->resource_provider()));
1950 1945
1951 LayerTreeHostImpl::FrameData frame; 1946 LayerTreeHostImpl::FrameData frame;
1952 1947
1953 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1948 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1954 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1955 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1949 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1956 host_impl_->DidDrawAllLayers(frame); 1950 host_impl_->DidDrawAllLayers(frame);
1957 } 1951 }
1958 1952
1959 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { 1953 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) {
1960 host_impl_->active_tree()->SetRootLayer( 1954 host_impl_->active_tree()->SetRootLayer(
1961 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1955 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1962 DidDrawCheckLayer* root = 1956 DidDrawCheckLayer* root =
1963 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1957 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1964 bool tile_missing = false; 1958 bool tile_missing = false;
1965 bool skips_draw = false; 1959 bool skips_draw = false;
1966 bool is_animating = true; 1960 bool is_animating = true;
1967 root->AddChild( 1961 root->AddChild(
1968 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1962 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1969 2, 1963 2,
1970 tile_missing, 1964 tile_missing,
1971 skips_draw, 1965 skips_draw,
1972 is_animating, 1966 is_animating,
1973 host_impl_->resource_provider())); 1967 host_impl_->resource_provider()));
1974 1968
1975 LayerTreeHostImpl::FrameData frame; 1969 LayerTreeHostImpl::FrameData frame;
1976 1970
1977 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1971 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1978 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1979 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1972 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1980 host_impl_->DidDrawAllLayers(frame); 1973 host_impl_->DidDrawAllLayers(frame);
1981 } 1974 }
1982 1975
1983 TEST_F(LayerTreeHostImplTest, 1976 TEST_F(LayerTreeHostImplTest,
1984 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) { 1977 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) {
1985 // When a texture is missing and we're not animating, we draw as usual with 1978 // When a texture is missing and we're not animating, we draw as usual with
1986 // checkerboarding. 1979 // checkerboarding.
1987 host_impl_->active_tree()->SetRootLayer( 1980 host_impl_->active_tree()->SetRootLayer(
1988 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1981 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1989 DidDrawCheckLayer* root = 1982 DidDrawCheckLayer* root =
1990 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1983 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1991 1984
1992 bool tile_missing = true; 1985 bool tile_missing = true;
1993 bool skips_draw = false; 1986 bool skips_draw = false;
1994 bool is_animating = false; 1987 bool is_animating = false;
1995 root->AddChild( 1988 root->AddChild(
1996 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1989 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1997 4, 1990 4,
1998 tile_missing, 1991 tile_missing,
1999 skips_draw, 1992 skips_draw,
2000 is_animating, 1993 is_animating,
2001 host_impl_->resource_provider())); 1994 host_impl_->resource_provider()));
2002 LayerTreeHostImpl::FrameData frame; 1995 LayerTreeHostImpl::FrameData frame;
2003 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1996 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2004 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2005 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1997 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2006 host_impl_->DidDrawAllLayers(frame); 1998 host_impl_->DidDrawAllLayers(frame);
2007 } 1999 }
2008 2000
2009 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { 2001 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) {
2010 // When a texture is missing and we're animating, we don't want to draw 2002 // When a texture is missing and we're animating, we don't want to draw
2011 // anything. 2003 // anything.
2012 host_impl_->active_tree()->SetRootLayer( 2004 host_impl_->active_tree()->SetRootLayer(
2013 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 2005 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
2014 DidDrawCheckLayer* root = 2006 DidDrawCheckLayer* root =
2015 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2007 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2016 bool tile_missing = true; 2008 bool tile_missing = true;
2017 bool skips_draw = false; 2009 bool skips_draw = false;
2018 bool is_animating = true; 2010 bool is_animating = true;
2019 root->AddChild( 2011 root->AddChild(
2020 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2012 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2021 6, 2013 6,
2022 tile_missing, 2014 tile_missing,
2023 skips_draw, 2015 skips_draw,
2024 is_animating, 2016 is_animating,
2025 host_impl_->resource_provider())); 2017 host_impl_->resource_provider()));
2026 LayerTreeHostImpl::FrameData frame; 2018 LayerTreeHostImpl::FrameData frame;
2027 EXPECT_EQ(DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, 2019 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
2028 host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2020 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2029 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2021 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2030 host_impl_->DidDrawAllLayers(frame); 2022 host_impl_->DidDrawAllLayers(frame);
2031 } 2023 }
2032 2024
2033 TEST_F(LayerTreeHostImplTest, 2025 TEST_F(LayerTreeHostImplTest,
2034 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) { 2026 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) {
2035 // When the layer skips draw and we're animating, we still draw the frame. 2027 // When the layer skips draw and we're animating, we still draw the frame.
2036 host_impl_->active_tree()->SetRootLayer( 2028 host_impl_->active_tree()->SetRootLayer(
2037 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2029 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2038 DidDrawCheckLayer* root = 2030 DidDrawCheckLayer* root =
2039 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2031 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2040 bool tile_missing = false; 2032 bool tile_missing = false;
2041 bool skips_draw = true; 2033 bool skips_draw = true;
2042 bool is_animating = true; 2034 bool is_animating = true;
2043 root->AddChild( 2035 root->AddChild(
2044 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2036 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2045 8, 2037 8,
2046 tile_missing, 2038 tile_missing,
2047 skips_draw, 2039 skips_draw,
2048 is_animating, 2040 is_animating,
2049 host_impl_->resource_provider())); 2041 host_impl_->resource_provider()));
2050 LayerTreeHostImpl::FrameData frame; 2042 LayerTreeHostImpl::FrameData frame;
2051 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), 2043 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), DRAW_SUCCESS);
2052 DrawSwapReadbackResult::DRAW_SUCCESS);
2053 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2044 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2054 host_impl_->DidDrawAllLayers(frame); 2045 host_impl_->DidDrawAllLayers(frame);
2055 } 2046 }
2056 2047
2057 TEST_F(LayerTreeHostImplTest, 2048 TEST_F(LayerTreeHostImplTest,
2058 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) { 2049 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) {
2059 // When the layer skips draw and we're animating, we still draw the frame. 2050 // When the layer skips draw and we're animating, we still draw the frame.
2060 host_impl_->active_tree()->SetRootLayer( 2051 host_impl_->active_tree()->SetRootLayer(
2061 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2052 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2062 DidDrawCheckLayer* root = 2053 DidDrawCheckLayer* root =
2063 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2054 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2064 bool tile_missing = false; 2055 bool tile_missing = false;
2065 bool skips_draw = false; 2056 bool skips_draw = false;
2066 bool is_animating = false; 2057 bool is_animating = false;
2067 root->AddChild( 2058 root->AddChild(
2068 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2059 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2069 8, 2060 8,
2070 tile_missing, 2061 tile_missing,
2071 skips_draw, 2062 skips_draw,
2072 is_animating, 2063 is_animating,
2073 host_impl_->resource_provider())); 2064 host_impl_->resource_provider()));
2074 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2065 host_impl_->active_tree()->SetRequiresHighResToDraw();
2075 LayerTreeHostImpl::FrameData frame; 2066 LayerTreeHostImpl::FrameData frame;
2076 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), 2067 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), DRAW_SUCCESS);
2077 DrawSwapReadbackResult::DRAW_SUCCESS);
2078 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2068 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2079 host_impl_->DidDrawAllLayers(frame); 2069 host_impl_->DidDrawAllLayers(frame);
2080 } 2070 }
2081 2071
2082 TEST_F(LayerTreeHostImplTest, 2072 TEST_F(LayerTreeHostImplTest,
2083 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) { 2073 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) {
2084 // When the layer skips draw and we're animating, we still draw the frame. 2074 // When the layer skips draw and we're animating, we still draw the frame.
2085 host_impl_->active_tree()->SetRootLayer( 2075 host_impl_->active_tree()->SetRootLayer(
2086 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2076 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2087 DidDrawCheckLayer* root = 2077 DidDrawCheckLayer* root =
2088 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2078 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2089 bool tile_missing = true; 2079 bool tile_missing = true;
2090 bool skips_draw = false; 2080 bool skips_draw = false;
2091 bool is_animating = false; 2081 bool is_animating = false;
2092 root->AddChild( 2082 root->AddChild(
2093 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2083 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2094 8, 2084 8,
2095 tile_missing, 2085 tile_missing,
2096 skips_draw, 2086 skips_draw,
2097 is_animating, 2087 is_animating,
2098 host_impl_->resource_provider())); 2088 host_impl_->resource_provider()));
2099 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2089 host_impl_->active_tree()->SetRequiresHighResToDraw();
2100 LayerTreeHostImpl::FrameData frame; 2090 LayerTreeHostImpl::FrameData frame;
2101 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), 2091 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()),
2102 DrawSwapReadbackResult::DRAW_ABORTED_MISSING_HIGH_RES_CONTENT); 2092 DRAW_ABORTED_MISSING_HIGH_RES_CONTENT);
2103 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2093 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2104 host_impl_->DidDrawAllLayers(frame); 2094 host_impl_->DidDrawAllLayers(frame);
2105 } 2095 }
2106 2096
2107 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 2097 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
2108 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2098 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2109 root->SetScrollClipLayer(Layer::INVALID_ID); 2099 root->SetScrollClipLayer(Layer::INVALID_ID);
2110 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2100 host_impl_->active_tree()->SetRootLayer(root.Pass());
2111 DrawFrame(); 2101 DrawFrame();
2112 2102
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 EXPECT_EQ(1.f, scroll->contents_scale_x()); 2534 EXPECT_EQ(1.f, scroll->contents_scale_x());
2545 EXPECT_EQ(1.f, scroll->contents_scale_y()); 2535 EXPECT_EQ(1.f, scroll->contents_scale_y());
2546 EXPECT_EQ(1.f, child->contents_scale_x()); 2536 EXPECT_EQ(1.f, child->contents_scale_x());
2547 EXPECT_EQ(1.f, child->contents_scale_y()); 2537 EXPECT_EQ(1.f, child->contents_scale_y());
2548 EXPECT_EQ(1.f, grand_child->contents_scale_x()); 2538 EXPECT_EQ(1.f, grand_child->contents_scale_x());
2549 EXPECT_EQ(1.f, grand_child->contents_scale_y()); 2539 EXPECT_EQ(1.f, grand_child->contents_scale_y());
2550 2540
2551 // Make sure all the layers are drawn with the page scale delta applied, i.e., 2541 // Make sure all the layers are drawn with the page scale delta applied, i.e.,
2552 // the page scale delta on the root layer is applied hierarchically. 2542 // the page scale delta on the root layer is applied hierarchically.
2553 LayerTreeHostImpl::FrameData frame; 2543 LayerTreeHostImpl::FrameData frame;
2554 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 2544 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2555 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2556 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2545 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2557 host_impl_->DidDrawAllLayers(frame); 2546 host_impl_->DidDrawAllLayers(frame);
2558 2547
2559 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); 2548 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0));
2560 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); 2549 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1));
2561 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); 2550 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)); 2551 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)); 2552 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)); 2553 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1));
2565 EXPECT_EQ(new_page_scale, 2554 EXPECT_EQ(new_page_scale,
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
3533 BlendStateCheckLayer* layer1 = 3522 BlendStateCheckLayer* layer1 =
3534 static_cast<BlendStateCheckLayer*>(root->children()[0]); 3523 static_cast<BlendStateCheckLayer*>(root->children()[0]);
3535 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 3524 layer1->SetPosition(gfx::PointF(2.f, 2.f));
3536 3525
3537 LayerTreeHostImpl::FrameData frame; 3526 LayerTreeHostImpl::FrameData frame;
3538 3527
3539 // Opaque layer, drawn without blending. 3528 // Opaque layer, drawn without blending.
3540 layer1->SetContentsOpaque(true); 3529 layer1->SetContentsOpaque(true);
3541 layer1->SetExpectation(false, false); 3530 layer1->SetExpectation(false, false);
3542 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3531 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3543 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3532 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3544 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3545 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3533 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3546 EXPECT_TRUE(layer1->quads_appended()); 3534 EXPECT_TRUE(layer1->quads_appended());
3547 host_impl_->DidDrawAllLayers(frame); 3535 host_impl_->DidDrawAllLayers(frame);
3548 3536
3549 // Layer with translucent content and painting, so drawn with blending. 3537 // Layer with translucent content and painting, so drawn with blending.
3550 layer1->SetContentsOpaque(false); 3538 layer1->SetContentsOpaque(false);
3551 layer1->SetExpectation(true, false); 3539 layer1->SetExpectation(true, false);
3552 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3540 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3553 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3541 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3554 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3555 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3542 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3556 EXPECT_TRUE(layer1->quads_appended()); 3543 EXPECT_TRUE(layer1->quads_appended());
3557 host_impl_->DidDrawAllLayers(frame); 3544 host_impl_->DidDrawAllLayers(frame);
3558 3545
3559 // Layer with translucent opacity, drawn with blending. 3546 // Layer with translucent opacity, drawn with blending.
3560 layer1->SetContentsOpaque(true); 3547 layer1->SetContentsOpaque(true);
3561 layer1->SetOpacity(0.5f); 3548 layer1->SetOpacity(0.5f);
3562 layer1->SetExpectation(true, false); 3549 layer1->SetExpectation(true, false);
3563 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3550 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3564 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3551 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3565 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3566 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3552 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3567 EXPECT_TRUE(layer1->quads_appended()); 3553 EXPECT_TRUE(layer1->quads_appended());
3568 host_impl_->DidDrawAllLayers(frame); 3554 host_impl_->DidDrawAllLayers(frame);
3569 3555
3570 // Layer with translucent opacity and painting, drawn with blending. 3556 // Layer with translucent opacity and painting, drawn with blending.
3571 layer1->SetContentsOpaque(true); 3557 layer1->SetContentsOpaque(true);
3572 layer1->SetOpacity(0.5f); 3558 layer1->SetOpacity(0.5f);
3573 layer1->SetExpectation(true, false); 3559 layer1->SetExpectation(true, false);
3574 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3560 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3575 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3561 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3576 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3577 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3562 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3578 EXPECT_TRUE(layer1->quads_appended()); 3563 EXPECT_TRUE(layer1->quads_appended());
3579 host_impl_->DidDrawAllLayers(frame); 3564 host_impl_->DidDrawAllLayers(frame);
3580 3565
3581 layer1->AddChild( 3566 layer1->AddChild(
3582 BlendStateCheckLayer::Create(host_impl_->active_tree(), 3567 BlendStateCheckLayer::Create(host_impl_->active_tree(),
3583 3, 3568 3,
3584 host_impl_->resource_provider())); 3569 host_impl_->resource_provider()));
3585 BlendStateCheckLayer* layer2 = 3570 BlendStateCheckLayer* layer2 =
3586 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); 3571 static_cast<BlendStateCheckLayer*>(layer1->children()[0]);
3587 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 3572 layer2->SetPosition(gfx::PointF(4.f, 4.f));
3588 3573
3589 // 2 opaque layers, drawn without blending. 3574 // 2 opaque layers, drawn without blending.
3590 layer1->SetContentsOpaque(true); 3575 layer1->SetContentsOpaque(true);
3591 layer1->SetOpacity(1.f); 3576 layer1->SetOpacity(1.f);
3592 layer1->SetExpectation(false, false); 3577 layer1->SetExpectation(false, false);
3593 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3578 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3594 layer2->SetContentsOpaque(true); 3579 layer2->SetContentsOpaque(true);
3595 layer2->SetOpacity(1.f); 3580 layer2->SetOpacity(1.f);
3596 layer2->SetExpectation(false, false); 3581 layer2->SetExpectation(false, false);
3597 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3582 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3598 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3583 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3599 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3600 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3584 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3601 EXPECT_TRUE(layer1->quads_appended()); 3585 EXPECT_TRUE(layer1->quads_appended());
3602 EXPECT_TRUE(layer2->quads_appended()); 3586 EXPECT_TRUE(layer2->quads_appended());
3603 host_impl_->DidDrawAllLayers(frame); 3587 host_impl_->DidDrawAllLayers(frame);
3604 3588
3605 // Parent layer with translucent content, drawn with blending. 3589 // Parent layer with translucent content, drawn with blending.
3606 // Child layer with opaque content, drawn without blending. 3590 // Child layer with opaque content, drawn without blending.
3607 layer1->SetContentsOpaque(false); 3591 layer1->SetContentsOpaque(false);
3608 layer1->SetExpectation(true, false); 3592 layer1->SetExpectation(true, false);
3609 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3593 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3610 layer2->SetExpectation(false, false); 3594 layer2->SetExpectation(false, false);
3611 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3595 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3612 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3596 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3613 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3614 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3597 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3615 EXPECT_TRUE(layer1->quads_appended()); 3598 EXPECT_TRUE(layer1->quads_appended());
3616 EXPECT_TRUE(layer2->quads_appended()); 3599 EXPECT_TRUE(layer2->quads_appended());
3617 host_impl_->DidDrawAllLayers(frame); 3600 host_impl_->DidDrawAllLayers(frame);
3618 3601
3619 // Parent layer with translucent content but opaque painting, drawn without 3602 // Parent layer with translucent content but opaque painting, drawn without
3620 // blending. 3603 // blending.
3621 // Child layer with opaque content, drawn without blending. 3604 // Child layer with opaque content, drawn without blending.
3622 layer1->SetContentsOpaque(true); 3605 layer1->SetContentsOpaque(true);
3623 layer1->SetExpectation(false, false); 3606 layer1->SetExpectation(false, false);
3624 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3607 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3625 layer2->SetExpectation(false, false); 3608 layer2->SetExpectation(false, false);
3626 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3609 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3627 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3610 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3628 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3629 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3611 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3630 EXPECT_TRUE(layer1->quads_appended()); 3612 EXPECT_TRUE(layer1->quads_appended());
3631 EXPECT_TRUE(layer2->quads_appended()); 3613 EXPECT_TRUE(layer2->quads_appended());
3632 host_impl_->DidDrawAllLayers(frame); 3614 host_impl_->DidDrawAllLayers(frame);
3633 3615
3634 // Parent layer with translucent opacity and opaque content. Since it has a 3616 // Parent layer with translucent opacity and opaque content. Since it has a
3635 // drawing child, it's drawn to a render surface which carries the opacity, 3617 // drawing child, it's drawn to a render surface which carries the opacity,
3636 // so it's itself drawn without blending. 3618 // so it's itself drawn without blending.
3637 // Child layer with opaque content, drawn without blending (parent surface 3619 // Child layer with opaque content, drawn without blending (parent surface
3638 // carries the inherited opacity). 3620 // carries the inherited opacity).
3639 layer1->SetContentsOpaque(true); 3621 layer1->SetContentsOpaque(true);
3640 layer1->SetOpacity(0.5f); 3622 layer1->SetOpacity(0.5f);
3641 layer1->SetExpectation(false, true); 3623 layer1->SetExpectation(false, true);
3642 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3624 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3643 layer2->SetExpectation(false, false); 3625 layer2->SetExpectation(false, false);
3644 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3626 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3645 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3627 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3646 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3647 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3628 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3648 EXPECT_TRUE(layer1->quads_appended()); 3629 EXPECT_TRUE(layer1->quads_appended());
3649 EXPECT_TRUE(layer2->quads_appended()); 3630 EXPECT_TRUE(layer2->quads_appended());
3650 host_impl_->DidDrawAllLayers(frame); 3631 host_impl_->DidDrawAllLayers(frame);
3651 3632
3652 // Draw again, but with child non-opaque, to make sure 3633 // Draw again, but with child non-opaque, to make sure
3653 // layer1 not culled. 3634 // layer1 not culled.
3654 layer1->SetContentsOpaque(true); 3635 layer1->SetContentsOpaque(true);
3655 layer1->SetOpacity(1.f); 3636 layer1->SetOpacity(1.f);
3656 layer1->SetExpectation(false, false); 3637 layer1->SetExpectation(false, false);
3657 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3638 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3658 layer2->SetContentsOpaque(true); 3639 layer2->SetContentsOpaque(true);
3659 layer2->SetOpacity(0.5f); 3640 layer2->SetOpacity(0.5f);
3660 layer2->SetExpectation(true, false); 3641 layer2->SetExpectation(true, false);
3661 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3642 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3662 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3643 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3663 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3664 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3644 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3665 EXPECT_TRUE(layer1->quads_appended()); 3645 EXPECT_TRUE(layer1->quads_appended());
3666 EXPECT_TRUE(layer2->quads_appended()); 3646 EXPECT_TRUE(layer2->quads_appended());
3667 host_impl_->DidDrawAllLayers(frame); 3647 host_impl_->DidDrawAllLayers(frame);
3668 3648
3669 // A second way of making the child non-opaque. 3649 // A second way of making the child non-opaque.
3670 layer1->SetContentsOpaque(true); 3650 layer1->SetContentsOpaque(true);
3671 layer1->SetOpacity(1.f); 3651 layer1->SetOpacity(1.f);
3672 layer1->SetExpectation(false, false); 3652 layer1->SetExpectation(false, false);
3673 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3653 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3674 layer2->SetContentsOpaque(false); 3654 layer2->SetContentsOpaque(false);
3675 layer2->SetOpacity(1.f); 3655 layer2->SetOpacity(1.f);
3676 layer2->SetExpectation(true, false); 3656 layer2->SetExpectation(true, false);
3677 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3657 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3678 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3658 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3679 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3680 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3659 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3681 EXPECT_TRUE(layer1->quads_appended()); 3660 EXPECT_TRUE(layer1->quads_appended());
3682 EXPECT_TRUE(layer2->quads_appended()); 3661 EXPECT_TRUE(layer2->quads_appended());
3683 host_impl_->DidDrawAllLayers(frame); 3662 host_impl_->DidDrawAllLayers(frame);
3684 3663
3685 // And when the layer says its not opaque but is painted opaque, it is not 3664 // And when the layer says its not opaque but is painted opaque, it is not
3686 // blended. 3665 // blended.
3687 layer1->SetContentsOpaque(true); 3666 layer1->SetContentsOpaque(true);
3688 layer1->SetOpacity(1.f); 3667 layer1->SetOpacity(1.f);
3689 layer1->SetExpectation(false, false); 3668 layer1->SetExpectation(false, false);
3690 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3669 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3691 layer2->SetContentsOpaque(true); 3670 layer2->SetContentsOpaque(true);
3692 layer2->SetOpacity(1.f); 3671 layer2->SetOpacity(1.f);
3693 layer2->SetExpectation(false, false); 3672 layer2->SetExpectation(false, false);
3694 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3673 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3695 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3674 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3696 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3697 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3675 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3698 EXPECT_TRUE(layer1->quads_appended()); 3676 EXPECT_TRUE(layer1->quads_appended());
3699 EXPECT_TRUE(layer2->quads_appended()); 3677 EXPECT_TRUE(layer2->quads_appended());
3700 host_impl_->DidDrawAllLayers(frame); 3678 host_impl_->DidDrawAllLayers(frame);
3701 3679
3702 // Layer with partially opaque contents, drawn with blending. 3680 // Layer with partially opaque contents, drawn with blending.
3703 layer1->SetContentsOpaque(false); 3681 layer1->SetContentsOpaque(false);
3704 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3682 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3705 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 3683 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
3706 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3684 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3707 layer1->SetExpectation(true, false); 3685 layer1->SetExpectation(true, false);
3708 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3686 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3709 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3687 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3710 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3711 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3688 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3712 EXPECT_TRUE(layer1->quads_appended()); 3689 EXPECT_TRUE(layer1->quads_appended());
3713 host_impl_->DidDrawAllLayers(frame); 3690 host_impl_->DidDrawAllLayers(frame);
3714 3691
3715 // Layer with partially opaque contents partially culled, drawn with blending. 3692 // Layer with partially opaque contents partially culled, drawn with blending.
3716 layer1->SetContentsOpaque(false); 3693 layer1->SetContentsOpaque(false);
3717 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3694 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3718 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 3695 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
3719 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3696 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3720 layer1->SetExpectation(true, false); 3697 layer1->SetExpectation(true, false);
3721 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3698 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3722 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3699 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3723 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3724 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3700 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3725 EXPECT_TRUE(layer1->quads_appended()); 3701 EXPECT_TRUE(layer1->quads_appended());
3726 host_impl_->DidDrawAllLayers(frame); 3702 host_impl_->DidDrawAllLayers(frame);
3727 3703
3728 // Layer with partially opaque contents culled, drawn with blending. 3704 // Layer with partially opaque contents culled, drawn with blending.
3729 layer1->SetContentsOpaque(false); 3705 layer1->SetContentsOpaque(false);
3730 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3706 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3731 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 3707 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
3732 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3708 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3733 layer1->SetExpectation(true, false); 3709 layer1->SetExpectation(true, false);
3734 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3710 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3735 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3711 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3736 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3737 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3712 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3738 EXPECT_TRUE(layer1->quads_appended()); 3713 EXPECT_TRUE(layer1->quads_appended());
3739 host_impl_->DidDrawAllLayers(frame); 3714 host_impl_->DidDrawAllLayers(frame);
3740 3715
3741 // Layer with partially opaque contents and translucent contents culled, drawn 3716 // Layer with partially opaque contents and translucent contents culled, drawn
3742 // without blending. 3717 // without blending.
3743 layer1->SetContentsOpaque(false); 3718 layer1->SetContentsOpaque(false);
3744 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3719 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3745 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 3720 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
3746 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3721 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3747 layer1->SetExpectation(false, false); 3722 layer1->SetExpectation(false, false);
3748 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3723 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3749 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3724 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3750 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3751 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3725 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3752 EXPECT_TRUE(layer1->quads_appended()); 3726 EXPECT_TRUE(layer1->quads_appended());
3753 host_impl_->DidDrawAllLayers(frame); 3727 host_impl_->DidDrawAllLayers(frame);
3754 } 3728 }
3755 3729
3756 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { 3730 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
3757 protected: 3731 protected:
3758 LayerTreeHostImplViewportCoveredTest() : 3732 LayerTreeHostImplViewportCoveredTest() :
3759 gutter_quad_material_(DrawQuad::SOLID_COLOR), 3733 gutter_quad_material_(DrawQuad::SOLID_COLOR),
3760 child_(NULL), 3734 child_(NULL),
(...skipping 24 matching lines...) Expand all
3785 // Expect no gutter rects. 3759 // Expect no gutter rects.
3786 void TestLayerCoversFullViewport() { 3760 void TestLayerCoversFullViewport() {
3787 gfx::Rect layer_rect(viewport_size_); 3761 gfx::Rect layer_rect(viewport_size_);
3788 child_->SetPosition(layer_rect.origin()); 3762 child_->SetPosition(layer_rect.origin());
3789 child_->SetBounds(layer_rect.size()); 3763 child_->SetBounds(layer_rect.size());
3790 child_->SetContentBounds(layer_rect.size()); 3764 child_->SetContentBounds(layer_rect.size());
3791 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3765 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3792 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3766 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3793 3767
3794 LayerTreeHostImpl::FrameData frame; 3768 LayerTreeHostImpl::FrameData frame;
3795 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3769 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3796 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3797 ASSERT_EQ(1u, frame.render_passes.size()); 3770 ASSERT_EQ(1u, frame.render_passes.size());
3798 3771
3799 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3772 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list));
3800 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 3773 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
3801 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3774 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3802 3775
3803 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 3776 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
3804 host_impl_->DidDrawAllLayers(frame); 3777 host_impl_->DidDrawAllLayers(frame);
3805 } 3778 }
3806 3779
3807 // Expect fullscreen gutter rect. 3780 // Expect fullscreen gutter rect.
3808 void TestEmptyLayer() { 3781 void TestEmptyLayer() {
3809 gfx::Rect layer_rect(0, 0, 0, 0); 3782 gfx::Rect layer_rect(0, 0, 0, 0);
3810 child_->SetPosition(layer_rect.origin()); 3783 child_->SetPosition(layer_rect.origin());
3811 child_->SetBounds(layer_rect.size()); 3784 child_->SetBounds(layer_rect.size());
3812 child_->SetContentBounds(layer_rect.size()); 3785 child_->SetContentBounds(layer_rect.size());
3813 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3786 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3814 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3787 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3815 3788
3816 LayerTreeHostImpl::FrameData frame; 3789 LayerTreeHostImpl::FrameData frame;
3817 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3790 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3818 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3819 ASSERT_EQ(1u, frame.render_passes.size()); 3791 ASSERT_EQ(1u, frame.render_passes.size());
3820 3792
3821 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3793 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list));
3822 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 3794 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
3823 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3795 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3824 3796
3825 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 3797 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
3826 host_impl_->DidDrawAllLayers(frame); 3798 host_impl_->DidDrawAllLayers(frame);
3827 } 3799 }
3828 3800
3829 // Expect four surrounding gutter rects. 3801 // Expect four surrounding gutter rects.
3830 void TestLayerInMiddleOfViewport() { 3802 void TestLayerInMiddleOfViewport() {
3831 gfx::Rect layer_rect(500, 500, 200, 200); 3803 gfx::Rect layer_rect(500, 500, 200, 200);
3832 child_->SetPosition(layer_rect.origin()); 3804 child_->SetPosition(layer_rect.origin());
3833 child_->SetBounds(layer_rect.size()); 3805 child_->SetBounds(layer_rect.size());
3834 child_->SetContentBounds(layer_rect.size()); 3806 child_->SetContentBounds(layer_rect.size());
3835 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3807 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3836 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3808 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3837 3809
3838 LayerTreeHostImpl::FrameData frame; 3810 LayerTreeHostImpl::FrameData frame;
3839 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3811 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3840 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3841 ASSERT_EQ(1u, frame.render_passes.size()); 3812 ASSERT_EQ(1u, frame.render_passes.size());
3842 3813
3843 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3814 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list));
3844 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size()); 3815 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size());
3845 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3816 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3846 3817
3847 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 3818 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
3848 host_impl_->DidDrawAllLayers(frame); 3819 host_impl_->DidDrawAllLayers(frame);
3849 } 3820 }
3850 3821
3851 // Expect no gutter rects. 3822 // Expect no gutter rects.
3852 void TestLayerIsLargerThanViewport() { 3823 void TestLayerIsLargerThanViewport() {
3853 gfx::Rect layer_rect(viewport_size_.width() + 10, 3824 gfx::Rect layer_rect(viewport_size_.width() + 10,
3854 viewport_size_.height() + 10); 3825 viewport_size_.height() + 10);
3855 child_->SetPosition(layer_rect.origin()); 3826 child_->SetPosition(layer_rect.origin());
3856 child_->SetBounds(layer_rect.size()); 3827 child_->SetBounds(layer_rect.size());
3857 child_->SetContentBounds(layer_rect.size()); 3828 child_->SetContentBounds(layer_rect.size());
3858 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3829 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3859 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3830 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3860 3831
3861 LayerTreeHostImpl::FrameData frame; 3832 LayerTreeHostImpl::FrameData frame;
3862 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3833 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3863 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3864 ASSERT_EQ(1u, frame.render_passes.size()); 3834 ASSERT_EQ(1u, frame.render_passes.size());
3865 3835
3866 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3836 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list));
3867 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 3837 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
3868 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3838 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3869 3839
3870 host_impl_->DidDrawAllLayers(frame); 3840 host_impl_->DidDrawAllLayers(frame);
3871 } 3841 }
3872 3842
3873 virtual void DidActivatePendingTree() OVERRIDE { 3843 virtual void DidActivatePendingTree() OVERRIDE {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
4068 root->SetBounds(gfx::Size(10, 10)); 4038 root->SetBounds(gfx::Size(10, 10));
4069 root->SetContentBounds(gfx::Size(10, 10)); 4039 root->SetContentBounds(gfx::Size(10, 10));
4070 root->SetDrawsContent(true); 4040 root->SetDrawsContent(true);
4071 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4041 host_impl_->active_tree()->SetRootLayer(root.Pass());
4072 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); 4042 EXPECT_FALSE(provider->TestContext3d()->reshape_called());
4073 provider->TestContext3d()->clear_reshape_called(); 4043 provider->TestContext3d()->clear_reshape_called();
4074 4044
4075 LayerTreeHostImpl::FrameData frame; 4045 LayerTreeHostImpl::FrameData frame;
4076 host_impl_->SetViewportSize(gfx::Size(10, 10)); 4046 host_impl_->SetViewportSize(gfx::Size(10, 10));
4077 host_impl_->SetDeviceScaleFactor(1.f); 4047 host_impl_->SetDeviceScaleFactor(1.f);
4078 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4048 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4079 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4080 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4049 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4081 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4050 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4082 EXPECT_EQ(provider->TestContext3d()->width(), 10); 4051 EXPECT_EQ(provider->TestContext3d()->width(), 10);
4083 EXPECT_EQ(provider->TestContext3d()->height(), 10); 4052 EXPECT_EQ(provider->TestContext3d()->height(), 10);
4084 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); 4053 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
4085 host_impl_->DidDrawAllLayers(frame); 4054 host_impl_->DidDrawAllLayers(frame);
4086 provider->TestContext3d()->clear_reshape_called(); 4055 provider->TestContext3d()->clear_reshape_called();
4087 4056
4088 host_impl_->SetViewportSize(gfx::Size(20, 30)); 4057 host_impl_->SetViewportSize(gfx::Size(20, 30));
4089 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4058 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4090 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4091 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4059 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4092 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4060 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4093 EXPECT_EQ(provider->TestContext3d()->width(), 20); 4061 EXPECT_EQ(provider->TestContext3d()->width(), 20);
4094 EXPECT_EQ(provider->TestContext3d()->height(), 30); 4062 EXPECT_EQ(provider->TestContext3d()->height(), 30);
4095 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); 4063 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
4096 host_impl_->DidDrawAllLayers(frame); 4064 host_impl_->DidDrawAllLayers(frame);
4097 provider->TestContext3d()->clear_reshape_called(); 4065 provider->TestContext3d()->clear_reshape_called();
4098 4066
4099 host_impl_->SetDeviceScaleFactor(2.f); 4067 host_impl_->SetDeviceScaleFactor(2.f);
4100 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4068 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4101 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4102 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4069 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4103 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4070 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4104 EXPECT_EQ(provider->TestContext3d()->width(), 20); 4071 EXPECT_EQ(provider->TestContext3d()->width(), 20);
4105 EXPECT_EQ(provider->TestContext3d()->height(), 30); 4072 EXPECT_EQ(provider->TestContext3d()->height(), 30);
4106 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); 4073 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f);
4107 host_impl_->DidDrawAllLayers(frame); 4074 host_impl_->DidDrawAllLayers(frame);
4108 provider->TestContext3d()->clear_reshape_called(); 4075 provider->TestContext3d()->clear_reshape_called();
4109 } 4076 }
4110 4077
4111 // Make sure damage tracking propagates all the way to the graphics context, 4078 // Make sure damage tracking propagates all the way to the graphics context,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4147 root->SetAnchorPoint(gfx::PointF()); 4114 root->SetAnchorPoint(gfx::PointF());
4148 root->SetBounds(gfx::Size(500, 500)); 4115 root->SetBounds(gfx::Size(500, 500));
4149 root->SetContentBounds(gfx::Size(500, 500)); 4116 root->SetContentBounds(gfx::Size(500, 500));
4150 root->SetDrawsContent(true); 4117 root->SetDrawsContent(true);
4151 root->AddChild(child.Pass()); 4118 root->AddChild(child.Pass());
4152 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); 4119 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass());
4153 4120
4154 LayerTreeHostImpl::FrameData frame; 4121 LayerTreeHostImpl::FrameData frame;
4155 4122
4156 // First frame, the entire screen should get swapped. 4123 // First frame, the entire screen should get swapped.
4157 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4124 EXPECT_EQ(DRAW_SUCCESS,
4158 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 4125 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4159 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4126 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4160 layer_tree_host_impl->DidDrawAllLayers(frame); 4127 layer_tree_host_impl->DidDrawAllLayers(frame);
4161 layer_tree_host_impl->SwapBuffers(frame); 4128 layer_tree_host_impl->SwapBuffers(frame);
4162 EXPECT_EQ(TestContextSupport::SWAP, 4129 EXPECT_EQ(TestContextSupport::SWAP,
4163 context_provider->support()->last_swap_type()); 4130 context_provider->support()->last_swap_type());
4164 4131
4165 // Second frame, only the damaged area should get swapped. Damage should be 4132 // Second frame, only the damaged area should get swapped. Damage should be
4166 // the union of old and new child rects. 4133 // the union of old and new child rects.
4167 // expected damage rect: gfx::Rect(26, 28); 4134 // expected damage rect: gfx::Rect(26, 28);
4168 // expected swap rect: vertically flipped, with origin at bottom left corner. 4135 // expected swap rect: vertically flipped, with origin at bottom left corner.
4169 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( 4136 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition(
4170 gfx::PointF()); 4137 gfx::PointF());
4171 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4138 EXPECT_EQ(DRAW_SUCCESS,
4172 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 4139 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4173 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4140 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4174 host_impl_->DidDrawAllLayers(frame); 4141 host_impl_->DidDrawAllLayers(frame);
4175 layer_tree_host_impl->SwapBuffers(frame); 4142 layer_tree_host_impl->SwapBuffers(frame);
4176 4143
4177 // Make sure that partial swap is constrained to the viewport dimensions 4144 // Make sure that partial swap is constrained to the viewport dimensions
4178 // expected damage rect: gfx::Rect(500, 500); 4145 // expected damage rect: gfx::Rect(500, 500);
4179 // expected swap rect: flipped damage rect, but also clamped to viewport 4146 // expected swap rect: flipped damage rect, but also clamped to viewport
4180 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, 4147 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP,
4181 context_provider->support()->last_swap_type()); 4148 context_provider->support()->last_swap_type());
4182 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); 4149 gfx::Rect expected_swap_rect(0, 500-28, 26, 28);
4183 EXPECT_EQ(expected_swap_rect.ToString(), 4150 EXPECT_EQ(expected_swap_rect.ToString(),
4184 context_provider->support()-> 4151 context_provider->support()->
4185 last_partial_swap_rect().ToString()); 4152 last_partial_swap_rect().ToString());
4186 4153
4187 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); 4154 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10));
4188 // This will damage everything. 4155 // This will damage everything.
4189 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( 4156 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor(
4190 SK_ColorBLACK); 4157 SK_ColorBLACK);
4191 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4158 EXPECT_EQ(DRAW_SUCCESS,
4192 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 4159 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4193 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4160 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4194 host_impl_->DidDrawAllLayers(frame); 4161 host_impl_->DidDrawAllLayers(frame);
4195 layer_tree_host_impl->SwapBuffers(frame); 4162 layer_tree_host_impl->SwapBuffers(frame);
4196 4163
4197 EXPECT_EQ(TestContextSupport::SWAP, 4164 EXPECT_EQ(TestContextSupport::SWAP,
4198 context_provider->support()->last_swap_type()); 4165 context_provider->support()->last_swap_type());
4199 } 4166 }
4200 4167
4201 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 4168 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
4202 scoped_ptr<LayerImpl> root = 4169 scoped_ptr<LayerImpl> root =
4203 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4170 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
4204 scoped_ptr<LayerImpl> child = 4171 scoped_ptr<LayerImpl> child =
4205 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 4172 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
4206 child->SetAnchorPoint(gfx::PointF()); 4173 child->SetAnchorPoint(gfx::PointF());
4207 child->SetBounds(gfx::Size(10, 10)); 4174 child->SetBounds(gfx::Size(10, 10));
4208 child->SetContentBounds(gfx::Size(10, 10)); 4175 child->SetContentBounds(gfx::Size(10, 10));
4209 child->SetDrawsContent(true); 4176 child->SetDrawsContent(true);
4210 root->SetAnchorPoint(gfx::PointF()); 4177 root->SetAnchorPoint(gfx::PointF());
4211 root->SetBounds(gfx::Size(10, 10)); 4178 root->SetBounds(gfx::Size(10, 10));
4212 root->SetContentBounds(gfx::Size(10, 10)); 4179 root->SetContentBounds(gfx::Size(10, 10));
4213 root->SetDrawsContent(true); 4180 root->SetDrawsContent(true);
4214 root->SetForceRenderSurface(true); 4181 root->SetForceRenderSurface(true);
4215 root->AddChild(child.Pass()); 4182 root->AddChild(child.Pass());
4216 4183
4217 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4184 host_impl_->active_tree()->SetRootLayer(root.Pass());
4218 4185
4219 LayerTreeHostImpl::FrameData frame; 4186 LayerTreeHostImpl::FrameData frame;
4220 4187
4221 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4188 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4222 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4223 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); 4189 EXPECT_EQ(1u, frame.render_surface_layer_list->size());
4224 EXPECT_EQ(1u, frame.render_passes.size()); 4190 EXPECT_EQ(1u, frame.render_passes.size());
4225 host_impl_->DidDrawAllLayers(frame); 4191 host_impl_->DidDrawAllLayers(frame);
4226 } 4192 }
4227 4193
4228 class FakeLayerWithQuads : public LayerImpl { 4194 class FakeLayerWithQuads : public LayerImpl {
4229 public: 4195 public:
4230 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 4196 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
4231 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id)); 4197 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id));
4232 } 4198 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4349 LayerTreeSettings settings = DefaultSettings(); 4315 LayerTreeSettings settings = DefaultSettings();
4350 settings.partial_swap_enabled = false; 4316 settings.partial_swap_enabled = false;
4351 CreateHostImpl(settings, output_surface.Pass()); 4317 CreateHostImpl(settings, output_surface.Pass());
4352 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 4318 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
4353 4319
4354 // Without partial swap, and no clipping, no scissor is set. 4320 // Without partial swap, and no clipping, no scissor is set.
4355 harness.MustDrawSolidQuad(); 4321 harness.MustDrawSolidQuad();
4356 harness.MustSetNoScissor(); 4322 harness.MustSetNoScissor();
4357 { 4323 {
4358 LayerTreeHostImpl::FrameData frame; 4324 LayerTreeHostImpl::FrameData frame;
4359 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4325 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4360 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4361 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4326 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4362 host_impl_->DidDrawAllLayers(frame); 4327 host_impl_->DidDrawAllLayers(frame);
4363 } 4328 }
4364 Mock::VerifyAndClearExpectations(&mock_context); 4329 Mock::VerifyAndClearExpectations(&mock_context);
4365 4330
4366 // Without partial swap, but a layer does clip its subtree, one scissor is 4331 // Without partial swap, but a layer does clip its subtree, one scissor is
4367 // set. 4332 // set.
4368 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); 4333 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true);
4369 harness.MustDrawSolidQuad(); 4334 harness.MustDrawSolidQuad();
4370 harness.MustSetScissor(0, 0, 10, 10); 4335 harness.MustSetScissor(0, 0, 10, 10);
4371 { 4336 {
4372 LayerTreeHostImpl::FrameData frame; 4337 LayerTreeHostImpl::FrameData frame;
4373 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4338 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4374 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4375 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4339 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4376 host_impl_->DidDrawAllLayers(frame); 4340 host_impl_->DidDrawAllLayers(frame);
4377 } 4341 }
4378 Mock::VerifyAndClearExpectations(&mock_context); 4342 Mock::VerifyAndClearExpectations(&mock_context);
4379 } 4343 }
4380 4344
4381 TEST_F(LayerTreeHostImplTest, PartialSwap) { 4345 TEST_F(LayerTreeHostImplTest, PartialSwap) {
4382 scoped_ptr<MockContext> context_owned(new MockContext); 4346 scoped_ptr<MockContext> context_owned(new MockContext);
4383 MockContext* mock_context = context_owned.get(); 4347 MockContext* mock_context = context_owned.get();
4384 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 4348 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
4385 context_owned.PassAs<TestWebGraphicsContext3D>())); 4349 context_owned.PassAs<TestWebGraphicsContext3D>()));
4386 MockContextHarness harness(mock_context); 4350 MockContextHarness harness(mock_context);
4387 4351
4388 LayerTreeSettings settings = DefaultSettings(); 4352 LayerTreeSettings settings = DefaultSettings();
4389 settings.partial_swap_enabled = true; 4353 settings.partial_swap_enabled = true;
4390 CreateHostImpl(settings, output_surface.Pass()); 4354 CreateHostImpl(settings, output_surface.Pass());
4391 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 4355 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
4392 4356
4393 // The first frame is not a partially-swapped one. 4357 // The first frame is not a partially-swapped one.
4394 harness.MustSetScissor(0, 0, 10, 10); 4358 harness.MustSetScissor(0, 0, 10, 10);
4395 harness.MustDrawSolidQuad(); 4359 harness.MustDrawSolidQuad();
4396 { 4360 {
4397 LayerTreeHostImpl::FrameData frame; 4361 LayerTreeHostImpl::FrameData frame;
4398 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4362 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4399 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4400 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4363 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4401 host_impl_->DidDrawAllLayers(frame); 4364 host_impl_->DidDrawAllLayers(frame);
4402 } 4365 }
4403 Mock::VerifyAndClearExpectations(&mock_context); 4366 Mock::VerifyAndClearExpectations(&mock_context);
4404 4367
4405 // Damage a portion of the frame. 4368 // Damage a portion of the frame.
4406 host_impl_->active_tree()->root_layer()->SetUpdateRect( 4369 host_impl_->active_tree()->root_layer()->SetUpdateRect(
4407 gfx::Rect(0, 0, 2, 3)); 4370 gfx::Rect(0, 0, 2, 3));
4408 4371
4409 // The second frame will be partially-swapped (the y coordinates are flipped). 4372 // The second frame will be partially-swapped (the y coordinates are flipped).
4410 harness.MustSetScissor(0, 7, 2, 3); 4373 harness.MustSetScissor(0, 7, 2, 3);
4411 harness.MustDrawSolidQuad(); 4374 harness.MustDrawSolidQuad();
4412 { 4375 {
4413 LayerTreeHostImpl::FrameData frame; 4376 LayerTreeHostImpl::FrameData frame;
4414 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4377 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4415 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4416 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4378 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4417 host_impl_->DidDrawAllLayers(frame); 4379 host_impl_->DidDrawAllLayers(frame);
4418 } 4380 }
4419 Mock::VerifyAndClearExpectations(&mock_context); 4381 Mock::VerifyAndClearExpectations(&mock_context);
4420 } 4382 }
4421 4383
4422 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( 4384 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
4423 bool partial_swap, 4385 bool partial_swap,
4424 LayerTreeHostImplClient* client, 4386 LayerTreeHostImplClient* client,
4425 Proxy* proxy, 4387 Proxy* proxy,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4503 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 4465 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
4504 new TestSharedBitmapManager()); 4466 new TestSharedBitmapManager());
4505 scoped_ptr<LayerTreeHostImpl> my_host_impl = 4467 scoped_ptr<LayerTreeHostImpl> my_host_impl =
4506 SetupLayersForOpacity(true, 4468 SetupLayersForOpacity(true,
4507 this, 4469 this,
4508 &proxy_, 4470 &proxy_,
4509 shared_bitmap_manager.get(), 4471 shared_bitmap_manager.get(),
4510 &stats_instrumentation_); 4472 &stats_instrumentation_);
4511 { 4473 {
4512 LayerTreeHostImpl::FrameData frame; 4474 LayerTreeHostImpl::FrameData frame;
4513 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4475 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4514 my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4515 4476
4516 // Verify all quads have been computed 4477 // Verify all quads have been computed
4517 ASSERT_EQ(2U, frame.render_passes.size()); 4478 ASSERT_EQ(2U, frame.render_passes.size());
4518 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 4479 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
4519 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 4480 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
4520 EXPECT_EQ(DrawQuad::SOLID_COLOR, 4481 EXPECT_EQ(DrawQuad::SOLID_COLOR,
4521 frame.render_passes[0]->quad_list[0]->material); 4482 frame.render_passes[0]->quad_list[0]->material);
4522 EXPECT_EQ(DrawQuad::RENDER_PASS, 4483 EXPECT_EQ(DrawQuad::RENDER_PASS,
4523 frame.render_passes[1]->quad_list[0]->material); 4484 frame.render_passes[1]->quad_list[0]->material);
4524 4485
4525 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4486 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4526 my_host_impl->DidDrawAllLayers(frame); 4487 my_host_impl->DidDrawAllLayers(frame);
4527 } 4488 }
4528 } 4489 }
4529 4490
4530 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 4491 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
4531 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 4492 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
4532 new TestSharedBitmapManager()); 4493 new TestSharedBitmapManager());
4533 scoped_ptr<LayerTreeHostImpl> my_host_impl = 4494 scoped_ptr<LayerTreeHostImpl> my_host_impl =
4534 SetupLayersForOpacity(false, 4495 SetupLayersForOpacity(false,
4535 this, 4496 this,
4536 &proxy_, 4497 &proxy_,
4537 shared_bitmap_manager.get(), 4498 shared_bitmap_manager.get(),
4538 &stats_instrumentation_); 4499 &stats_instrumentation_);
4539 { 4500 {
4540 LayerTreeHostImpl::FrameData frame; 4501 LayerTreeHostImpl::FrameData frame;
4541 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4502 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4542 my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4543 4503
4544 // Verify all quads have been computed 4504 // Verify all quads have been computed
4545 ASSERT_EQ(2U, frame.render_passes.size()); 4505 ASSERT_EQ(2U, frame.render_passes.size());
4546 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 4506 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
4547 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 4507 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
4548 EXPECT_EQ(DrawQuad::SOLID_COLOR, 4508 EXPECT_EQ(DrawQuad::SOLID_COLOR,
4549 frame.render_passes[0]->quad_list[0]->material); 4509 frame.render_passes[0]->quad_list[0]->material);
4550 EXPECT_EQ(DrawQuad::RENDER_PASS, 4510 EXPECT_EQ(DrawQuad::RENDER_PASS,
4551 frame.render_passes[1]->quad_list[0]->material); 4511 frame.render_passes[1]->quad_list[0]->material);
4552 4512
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4588 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); 4548 io_surface_layer->SetContentBounds(gfx::Size(10, 10));
4589 io_surface_layer->SetDrawsContent(true); 4549 io_surface_layer->SetDrawsContent(true);
4590 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); 4550 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
4591 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); 4551 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>());
4592 4552
4593 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 4553 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
4594 4554
4595 EXPECT_EQ(0u, context3d->NumTextures()); 4555 EXPECT_EQ(0u, context3d->NumTextures());
4596 4556
4597 LayerTreeHostImpl::FrameData frame; 4557 LayerTreeHostImpl::FrameData frame;
4598 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4558 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4599 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4600 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4559 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4601 host_impl_->DidDrawAllLayers(frame); 4560 host_impl_->DidDrawAllLayers(frame);
4602 host_impl_->SwapBuffers(frame); 4561 host_impl_->SwapBuffers(frame);
4603 4562
4604 EXPECT_GT(context3d->NumTextures(), 0u); 4563 EXPECT_GT(context3d->NumTextures(), 0u);
4605 4564
4606 // Kill the layer tree. 4565 // Kill the layer tree.
4607 host_impl_->active_tree()->SetRootLayer( 4566 host_impl_->active_tree()->SetRootLayer(
4608 LayerImpl::Create(host_impl_->active_tree(), 100)); 4567 LayerImpl::Create(host_impl_->active_tree(), 100));
4609 // There should be no textures left in use after. 4568 // There should be no textures left in use after.
(...skipping 24 matching lines...) Expand all
4634 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 4593 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
4635 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); 4594 host_impl_->active_tree()->set_background_color(SK_ColorWHITE);
4636 4595
4637 // Verify one quad is drawn when transparent background set is not set. 4596 // Verify one quad is drawn when transparent background set is not set.
4638 host_impl_->active_tree()->set_has_transparent_background(false); 4597 host_impl_->active_tree()->set_has_transparent_background(false);
4639 EXPECT_CALL(*mock_context, useProgram(_)) 4598 EXPECT_CALL(*mock_context, useProgram(_))
4640 .Times(1); 4599 .Times(1);
4641 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) 4600 EXPECT_CALL(*mock_context, drawElements(_, _, _, _))
4642 .Times(1); 4601 .Times(1);
4643 LayerTreeHostImpl::FrameData frame; 4602 LayerTreeHostImpl::FrameData frame;
4644 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4603 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4645 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4646 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4604 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4647 host_impl_->DidDrawAllLayers(frame); 4605 host_impl_->DidDrawAllLayers(frame);
4648 Mock::VerifyAndClearExpectations(&mock_context); 4606 Mock::VerifyAndClearExpectations(&mock_context);
4649 4607
4650 // Verify no quads are drawn when transparent background is set. 4608 // Verify no quads are drawn when transparent background is set.
4651 host_impl_->active_tree()->set_has_transparent_background(true); 4609 host_impl_->active_tree()->set_has_transparent_background(true);
4652 host_impl_->SetFullRootLayerDamage(); 4610 host_impl_->SetFullRootLayerDamage();
4653 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4611 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4654 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4655 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4612 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4656 host_impl_->DidDrawAllLayers(frame); 4613 host_impl_->DidDrawAllLayers(frame);
4657 Mock::VerifyAndClearExpectations(&mock_context); 4614 Mock::VerifyAndClearExpectations(&mock_context);
4658 } 4615 }
4659 4616
4660 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { 4617 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) {
4661 set_reduce_memory_result(false); 4618 set_reduce_memory_result(false);
4662 4619
4663 // If changing the memory limit wouldn't result in changing what was 4620 // If changing the memory limit wouldn't result in changing what was
4664 // committed, then no commit should be requested. 4621 // committed, then no commit should be requested.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4701 : public LayerTreeHostImplTest { 4658 : public LayerTreeHostImplTest {
4702 protected: 4659 protected:
4703 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { 4660 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
4704 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>(); 4661 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
4705 } 4662 }
4706 4663
4707 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) { 4664 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) {
4708 bool expect_to_draw = !expected_damage.IsEmpty(); 4665 bool expect_to_draw = !expected_damage.IsEmpty();
4709 4666
4710 LayerTreeHostImpl::FrameData frame; 4667 LayerTreeHostImpl::FrameData frame;
4711 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4668 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4712 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4713 4669
4714 if (!expect_to_draw) { 4670 if (!expect_to_draw) {
4715 // With no damage, we don't draw, and no quads are created. 4671 // With no damage, we don't draw, and no quads are created.
4716 ASSERT_EQ(0u, frame.render_passes.size()); 4672 ASSERT_EQ(0u, frame.render_passes.size());
4717 } else { 4673 } else {
4718 ASSERT_EQ(1u, frame.render_passes.size()); 4674 ASSERT_EQ(1u, frame.render_passes.size());
4719 4675
4720 // Verify the damage rect for the root render pass. 4676 // Verify the damage rect for the root render pass.
4721 const RenderPass* root_render_pass = frame.render_passes.back(); 4677 const RenderPass* root_render_pass = frame.render_passes.back();
4722 EXPECT_RECT_EQ(expected_damage, root_render_pass->damage_rect); 4678 EXPECT_RECT_EQ(expected_damage, root_render_pass->damage_rect);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
4861 mask_layer->SetDrawsContent(true); 4817 mask_layer->SetDrawsContent(true);
4862 4818
4863 4819
4864 // Check that the tree scaling is correctly taken into account for the mask, 4820 // Check that the tree scaling is correctly taken into account for the mask,
4865 // that should fully map onto the quad. 4821 // that should fully map onto the quad.
4866 float device_scale_factor = 1.f; 4822 float device_scale_factor = 1.f;
4867 host_impl_->SetViewportSize(root_size); 4823 host_impl_->SetViewportSize(root_size);
4868 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4824 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4869 { 4825 {
4870 LayerTreeHostImpl::FrameData frame; 4826 LayerTreeHostImpl::FrameData frame;
4871 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4827 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4872 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4873 4828
4874 ASSERT_EQ(1u, frame.render_passes.size()); 4829 ASSERT_EQ(1u, frame.render_passes.size());
4875 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4830 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4876 ASSERT_EQ(DrawQuad::RENDER_PASS, 4831 ASSERT_EQ(DrawQuad::RENDER_PASS,
4877 frame.render_passes[0]->quad_list[0]->material); 4832 frame.render_passes[0]->quad_list[0]->material);
4878 const RenderPassDrawQuad* render_pass_quad = 4833 const RenderPassDrawQuad* render_pass_quad =
4879 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4834 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4880 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4835 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4881 render_pass_quad->rect.ToString()); 4836 render_pass_quad->rect.ToString());
4882 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4837 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4883 render_pass_quad->mask_uv_rect.ToString()); 4838 render_pass_quad->mask_uv_rect.ToString());
4884 4839
4885 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4840 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4886 host_impl_->DidDrawAllLayers(frame); 4841 host_impl_->DidDrawAllLayers(frame);
4887 } 4842 }
4888 4843
4889 4844
4890 // Applying a DSF should change the render surface size, but won't affect 4845 // Applying a DSF should change the render surface size, but won't affect
4891 // which part of the mask is used. 4846 // which part of the mask is used.
4892 device_scale_factor = 2.f; 4847 device_scale_factor = 2.f;
4893 gfx::Size device_viewport = 4848 gfx::Size device_viewport =
4894 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4849 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4895 host_impl_->SetViewportSize(device_viewport); 4850 host_impl_->SetViewportSize(device_viewport);
4896 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4851 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4897 host_impl_->active_tree()->set_needs_update_draw_properties(); 4852 host_impl_->active_tree()->set_needs_update_draw_properties();
4898 { 4853 {
4899 LayerTreeHostImpl::FrameData frame; 4854 LayerTreeHostImpl::FrameData frame;
4900 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4855 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4901 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4902 4856
4903 ASSERT_EQ(1u, frame.render_passes.size()); 4857 ASSERT_EQ(1u, frame.render_passes.size());
4904 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4858 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4905 ASSERT_EQ(DrawQuad::RENDER_PASS, 4859 ASSERT_EQ(DrawQuad::RENDER_PASS,
4906 frame.render_passes[0]->quad_list[0]->material); 4860 frame.render_passes[0]->quad_list[0]->material);
4907 const RenderPassDrawQuad* render_pass_quad = 4861 const RenderPassDrawQuad* render_pass_quad =
4908 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4862 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4909 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4863 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4910 render_pass_quad->rect.ToString()); 4864 render_pass_quad->rect.ToString());
4911 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4865 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4912 render_pass_quad->mask_uv_rect.ToString()); 4866 render_pass_quad->mask_uv_rect.ToString());
4913 4867
4914 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4868 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4915 host_impl_->DidDrawAllLayers(frame); 4869 host_impl_->DidDrawAllLayers(frame);
4916 } 4870 }
4917 4871
4918 4872
4919 // Applying an equivalent content scale on the content layer and the mask 4873 // Applying an equivalent content scale on the content layer and the mask
4920 // should still result in the same part of the mask being used. 4874 // should still result in the same part of the mask being used.
4921 gfx::Size content_bounds = 4875 gfx::Size content_bounds =
4922 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, 4876 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size,
4923 device_scale_factor)); 4877 device_scale_factor));
4924 content_layer->SetContentBounds(content_bounds); 4878 content_layer->SetContentBounds(content_bounds);
4925 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4879 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4926 mask_layer->SetContentBounds(content_bounds); 4880 mask_layer->SetContentBounds(content_bounds);
4927 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4881 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4928 host_impl_->active_tree()->set_needs_update_draw_properties(); 4882 host_impl_->active_tree()->set_needs_update_draw_properties();
4929 { 4883 {
4930 LayerTreeHostImpl::FrameData frame; 4884 LayerTreeHostImpl::FrameData frame;
4931 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4885 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4932 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4933 4886
4934 ASSERT_EQ(1u, frame.render_passes.size()); 4887 ASSERT_EQ(1u, frame.render_passes.size());
4935 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4888 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4936 ASSERT_EQ(DrawQuad::RENDER_PASS, 4889 ASSERT_EQ(DrawQuad::RENDER_PASS,
4937 frame.render_passes[0]->quad_list[0]->material); 4890 frame.render_passes[0]->quad_list[0]->material);
4938 const RenderPassDrawQuad* render_pass_quad = 4891 const RenderPassDrawQuad* render_pass_quad =
4939 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4892 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4940 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4893 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4941 render_pass_quad->rect.ToString()); 4894 render_pass_quad->rect.ToString());
4942 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4895 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4985 mask_layer->SetPosition(gfx::PointF()); 4938 mask_layer->SetPosition(gfx::PointF());
4986 mask_layer->SetAnchorPoint(gfx::PointF()); 4939 mask_layer->SetAnchorPoint(gfx::PointF());
4987 mask_layer->SetDrawsContent(true); 4940 mask_layer->SetDrawsContent(true);
4988 4941
4989 // Check that the mask fills the surface. 4942 // Check that the mask fills the surface.
4990 float device_scale_factor = 1.f; 4943 float device_scale_factor = 1.f;
4991 host_impl_->SetViewportSize(root_size); 4944 host_impl_->SetViewportSize(root_size);
4992 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4945 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4993 { 4946 {
4994 LayerTreeHostImpl::FrameData frame; 4947 LayerTreeHostImpl::FrameData frame;
4995 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4948 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4996 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4997 4949
4998 ASSERT_EQ(1u, frame.render_passes.size()); 4950 ASSERT_EQ(1u, frame.render_passes.size());
4999 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4951 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5000 ASSERT_EQ(DrawQuad::RENDER_PASS, 4952 ASSERT_EQ(DrawQuad::RENDER_PASS,
5001 frame.render_passes[0]->quad_list[0]->material); 4953 frame.render_passes[0]->quad_list[0]->material);
5002 const RenderPassDrawQuad* render_pass_quad = 4954 const RenderPassDrawQuad* render_pass_quad =
5003 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4955 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5004 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4956 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
5005 render_pass_quad->rect.ToString()); 4957 render_pass_quad->rect.ToString());
5006 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4958 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5007 render_pass_quad->mask_uv_rect.ToString()); 4959 render_pass_quad->mask_uv_rect.ToString());
5008 4960
5009 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4961 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5010 host_impl_->DidDrawAllLayers(frame); 4962 host_impl_->DidDrawAllLayers(frame);
5011 } 4963 }
5012 4964
5013 // Applying a DSF should change the render surface size, but won't affect 4965 // Applying a DSF should change the render surface size, but won't affect
5014 // which part of the mask is used. 4966 // which part of the mask is used.
5015 device_scale_factor = 2.f; 4967 device_scale_factor = 2.f;
5016 gfx::Size device_viewport = 4968 gfx::Size device_viewport =
5017 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4969 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
5018 host_impl_->SetViewportSize(device_viewport); 4970 host_impl_->SetViewportSize(device_viewport);
5019 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4971 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5020 host_impl_->active_tree()->set_needs_update_draw_properties(); 4972 host_impl_->active_tree()->set_needs_update_draw_properties();
5021 { 4973 {
5022 LayerTreeHostImpl::FrameData frame; 4974 LayerTreeHostImpl::FrameData frame;
5023 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4975 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5024 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5025 4976
5026 ASSERT_EQ(1u, frame.render_passes.size()); 4977 ASSERT_EQ(1u, frame.render_passes.size());
5027 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4978 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5028 ASSERT_EQ(DrawQuad::RENDER_PASS, 4979 ASSERT_EQ(DrawQuad::RENDER_PASS,
5029 frame.render_passes[0]->quad_list[0]->material); 4980 frame.render_passes[0]->quad_list[0]->material);
5030 const RenderPassDrawQuad* render_pass_quad = 4981 const RenderPassDrawQuad* render_pass_quad =
5031 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4982 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5032 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4983 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5033 render_pass_quad->rect.ToString()); 4984 render_pass_quad->rect.ToString());
5034 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4985 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5035 render_pass_quad->mask_uv_rect.ToString()); 4986 render_pass_quad->mask_uv_rect.ToString());
5036 4987
5037 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4988 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5038 host_impl_->DidDrawAllLayers(frame); 4989 host_impl_->DidDrawAllLayers(frame);
5039 } 4990 }
5040 4991
5041 // Applying an equivalent content scale on the content layer and the mask 4992 // Applying an equivalent content scale on the content layer and the mask
5042 // should still result in the same part of the mask being used. 4993 // should still result in the same part of the mask being used.
5043 gfx::Size layer_size_large = 4994 gfx::Size layer_size_large =
5044 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 4995 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
5045 content_layer->SetContentBounds(layer_size_large); 4996 content_layer->SetContentBounds(layer_size_large);
5046 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4997 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5047 gfx::Size mask_size_large = 4998 gfx::Size mask_size_large =
5048 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 4999 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
5049 mask_layer->SetContentBounds(mask_size_large); 5000 mask_layer->SetContentBounds(mask_size_large);
5050 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5001 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5051 host_impl_->active_tree()->set_needs_update_draw_properties(); 5002 host_impl_->active_tree()->set_needs_update_draw_properties();
5052 { 5003 {
5053 LayerTreeHostImpl::FrameData frame; 5004 LayerTreeHostImpl::FrameData frame;
5054 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5005 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5055 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5056 5006
5057 ASSERT_EQ(1u, frame.render_passes.size()); 5007 ASSERT_EQ(1u, frame.render_passes.size());
5058 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5008 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5059 ASSERT_EQ(DrawQuad::RENDER_PASS, 5009 ASSERT_EQ(DrawQuad::RENDER_PASS,
5060 frame.render_passes[0]->quad_list[0]->material); 5010 frame.render_passes[0]->quad_list[0]->material);
5061 const RenderPassDrawQuad* render_pass_quad = 5011 const RenderPassDrawQuad* render_pass_quad =
5062 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5012 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5063 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5013 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5064 render_pass_quad->rect.ToString()); 5014 render_pass_quad->rect.ToString());
5065 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5015 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5066 render_pass_quad->mask_uv_rect.ToString()); 5016 render_pass_quad->mask_uv_rect.ToString());
5067 5017
5068 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5018 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5069 host_impl_->DidDrawAllLayers(frame); 5019 host_impl_->DidDrawAllLayers(frame);
5070 } 5020 }
5071 5021
5072 // Applying a different contents scale to the mask layer means it will have 5022 // Applying a different contents scale to the mask layer means it will have
5073 // a larger texture, but it should use the same tex coords to cover the 5023 // a larger texture, but it should use the same tex coords to cover the
5074 // layer it masks. 5024 // layer it masks.
5075 mask_layer->SetContentBounds(mask_size); 5025 mask_layer->SetContentBounds(mask_size);
5076 mask_layer->SetContentsScale(1.f, 1.f); 5026 mask_layer->SetContentsScale(1.f, 1.f);
5077 host_impl_->active_tree()->set_needs_update_draw_properties(); 5027 host_impl_->active_tree()->set_needs_update_draw_properties();
5078 { 5028 {
5079 LayerTreeHostImpl::FrameData frame; 5029 LayerTreeHostImpl::FrameData frame;
5080 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5030 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5081 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5082 5031
5083 ASSERT_EQ(1u, frame.render_passes.size()); 5032 ASSERT_EQ(1u, frame.render_passes.size());
5084 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5033 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5085 ASSERT_EQ(DrawQuad::RENDER_PASS, 5034 ASSERT_EQ(DrawQuad::RENDER_PASS,
5086 frame.render_passes[0]->quad_list[0]->material); 5035 frame.render_passes[0]->quad_list[0]->material);
5087 const RenderPassDrawQuad* render_pass_quad = 5036 const RenderPassDrawQuad* render_pass_quad =
5088 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5037 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5089 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5038 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5090 render_pass_quad->rect.ToString()); 5039 render_pass_quad->rect.ToString());
5091 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5040 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5139 mask_layer->SetPosition(gfx::PointF()); 5088 mask_layer->SetPosition(gfx::PointF());
5140 mask_layer->SetAnchorPoint(gfx::PointF()); 5089 mask_layer->SetAnchorPoint(gfx::PointF());
5141 mask_layer->SetDrawsContent(true); 5090 mask_layer->SetDrawsContent(true);
5142 5091
5143 // Check that the mask fills the surface. 5092 // Check that the mask fills the surface.
5144 float device_scale_factor = 1.f; 5093 float device_scale_factor = 1.f;
5145 host_impl_->SetViewportSize(root_size); 5094 host_impl_->SetViewportSize(root_size);
5146 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5095 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5147 { 5096 {
5148 LayerTreeHostImpl::FrameData frame; 5097 LayerTreeHostImpl::FrameData frame;
5149 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5098 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5150 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5151 5099
5152 ASSERT_EQ(1u, frame.render_passes.size()); 5100 ASSERT_EQ(1u, frame.render_passes.size());
5153 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5101 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5154 ASSERT_EQ(DrawQuad::RENDER_PASS, 5102 ASSERT_EQ(DrawQuad::RENDER_PASS,
5155 frame.render_passes[0]->quad_list[1]->material); 5103 frame.render_passes[0]->quad_list[1]->material);
5156 const RenderPassDrawQuad* replica_quad = 5104 const RenderPassDrawQuad* replica_quad =
5157 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5105 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5158 EXPECT_TRUE(replica_quad->is_replica); 5106 EXPECT_TRUE(replica_quad->is_replica);
5159 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 5107 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
5160 replica_quad->rect.ToString()); 5108 replica_quad->rect.ToString());
5161 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5109 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5162 replica_quad->mask_uv_rect.ToString()); 5110 replica_quad->mask_uv_rect.ToString());
5163 5111
5164 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5112 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5165 host_impl_->DidDrawAllLayers(frame); 5113 host_impl_->DidDrawAllLayers(frame);
5166 } 5114 }
5167 5115
5168 // Applying a DSF should change the render surface size, but won't affect 5116 // Applying a DSF should change the render surface size, but won't affect
5169 // which part of the mask is used. 5117 // which part of the mask is used.
5170 device_scale_factor = 2.f; 5118 device_scale_factor = 2.f;
5171 gfx::Size device_viewport = 5119 gfx::Size device_viewport =
5172 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 5120 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
5173 host_impl_->SetViewportSize(device_viewport); 5121 host_impl_->SetViewportSize(device_viewport);
5174 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5122 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5175 host_impl_->active_tree()->set_needs_update_draw_properties(); 5123 host_impl_->active_tree()->set_needs_update_draw_properties();
5176 { 5124 {
5177 LayerTreeHostImpl::FrameData frame; 5125 LayerTreeHostImpl::FrameData frame;
5178 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5126 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5179 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5180 5127
5181 ASSERT_EQ(1u, frame.render_passes.size()); 5128 ASSERT_EQ(1u, frame.render_passes.size());
5182 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5129 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5183 ASSERT_EQ(DrawQuad::RENDER_PASS, 5130 ASSERT_EQ(DrawQuad::RENDER_PASS,
5184 frame.render_passes[0]->quad_list[1]->material); 5131 frame.render_passes[0]->quad_list[1]->material);
5185 const RenderPassDrawQuad* replica_quad = 5132 const RenderPassDrawQuad* replica_quad =
5186 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5133 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5187 EXPECT_TRUE(replica_quad->is_replica); 5134 EXPECT_TRUE(replica_quad->is_replica);
5188 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5135 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5189 replica_quad->rect.ToString()); 5136 replica_quad->rect.ToString());
(...skipping 10 matching lines...) Expand all
5200 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 5147 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
5201 content_layer->SetContentBounds(layer_size_large); 5148 content_layer->SetContentBounds(layer_size_large);
5202 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5149 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5203 gfx::Size mask_size_large = 5150 gfx::Size mask_size_large =
5204 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 5151 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
5205 mask_layer->SetContentBounds(mask_size_large); 5152 mask_layer->SetContentBounds(mask_size_large);
5206 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5153 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5207 host_impl_->active_tree()->set_needs_update_draw_properties(); 5154 host_impl_->active_tree()->set_needs_update_draw_properties();
5208 { 5155 {
5209 LayerTreeHostImpl::FrameData frame; 5156 LayerTreeHostImpl::FrameData frame;
5210 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5157 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5211 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5212 5158
5213 ASSERT_EQ(1u, frame.render_passes.size()); 5159 ASSERT_EQ(1u, frame.render_passes.size());
5214 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5160 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5215 ASSERT_EQ(DrawQuad::RENDER_PASS, 5161 ASSERT_EQ(DrawQuad::RENDER_PASS,
5216 frame.render_passes[0]->quad_list[1]->material); 5162 frame.render_passes[0]->quad_list[1]->material);
5217 const RenderPassDrawQuad* replica_quad = 5163 const RenderPassDrawQuad* replica_quad =
5218 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5164 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5219 EXPECT_TRUE(replica_quad->is_replica); 5165 EXPECT_TRUE(replica_quad->is_replica);
5220 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5166 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5221 replica_quad->rect.ToString()); 5167 replica_quad->rect.ToString());
5222 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5168 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5223 replica_quad->mask_uv_rect.ToString()); 5169 replica_quad->mask_uv_rect.ToString());
5224 5170
5225 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5171 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5226 host_impl_->DidDrawAllLayers(frame); 5172 host_impl_->DidDrawAllLayers(frame);
5227 } 5173 }
5228 5174
5229 // Applying a different contents scale to the mask layer means it will have 5175 // Applying a different contents scale to the mask layer means it will have
5230 // a larger texture, but it should use the same tex coords to cover the 5176 // a larger texture, but it should use the same tex coords to cover the
5231 // layer it masks. 5177 // layer it masks.
5232 mask_layer->SetContentBounds(mask_size); 5178 mask_layer->SetContentBounds(mask_size);
5233 mask_layer->SetContentsScale(1.f, 1.f); 5179 mask_layer->SetContentsScale(1.f, 1.f);
5234 host_impl_->active_tree()->set_needs_update_draw_properties(); 5180 host_impl_->active_tree()->set_needs_update_draw_properties();
5235 { 5181 {
5236 LayerTreeHostImpl::FrameData frame; 5182 LayerTreeHostImpl::FrameData frame;
5237 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5183 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5238 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5239 5184
5240 ASSERT_EQ(1u, frame.render_passes.size()); 5185 ASSERT_EQ(1u, frame.render_passes.size());
5241 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5186 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5242 ASSERT_EQ(DrawQuad::RENDER_PASS, 5187 ASSERT_EQ(DrawQuad::RENDER_PASS,
5243 frame.render_passes[0]->quad_list[1]->material); 5188 frame.render_passes[0]->quad_list[1]->material);
5244 const RenderPassDrawQuad* replica_quad = 5189 const RenderPassDrawQuad* replica_quad =
5245 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5190 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5246 EXPECT_TRUE(replica_quad->is_replica); 5191 EXPECT_TRUE(replica_quad->is_replica);
5247 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5192 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5248 replica_quad->rect.ToString()); 5193 replica_quad->rect.ToString());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5308 mask_layer->SetContentBounds(mask_size); 5253 mask_layer->SetContentBounds(mask_size);
5309 mask_layer->SetPosition(gfx::PointF()); 5254 mask_layer->SetPosition(gfx::PointF());
5310 mask_layer->SetAnchorPoint(gfx::PointF()); 5255 mask_layer->SetAnchorPoint(gfx::PointF());
5311 mask_layer->SetDrawsContent(true); 5256 mask_layer->SetDrawsContent(true);
5312 5257
5313 float device_scale_factor = 1.f; 5258 float device_scale_factor = 1.f;
5314 host_impl_->SetViewportSize(root_size); 5259 host_impl_->SetViewportSize(root_size);
5315 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5260 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5316 { 5261 {
5317 LayerTreeHostImpl::FrameData frame; 5262 LayerTreeHostImpl::FrameData frame;
5318 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5263 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5319 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5320 5264
5321 ASSERT_EQ(1u, frame.render_passes.size()); 5265 ASSERT_EQ(1u, frame.render_passes.size());
5322 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5266 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5323 5267
5324 // The surface is 100x50. 5268 // The surface is 100x50.
5325 ASSERT_EQ(DrawQuad::RENDER_PASS, 5269 ASSERT_EQ(DrawQuad::RENDER_PASS,
5326 frame.render_passes[0]->quad_list[0]->material); 5270 frame.render_passes[0]->quad_list[0]->material);
5327 const RenderPassDrawQuad* render_pass_quad = 5271 const RenderPassDrawQuad* render_pass_quad =
5328 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5272 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5329 EXPECT_FALSE(render_pass_quad->is_replica); 5273 EXPECT_FALSE(render_pass_quad->is_replica);
(...skipping 13 matching lines...) Expand all
5343 5287
5344 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5288 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5345 host_impl_->DidDrawAllLayers(frame); 5289 host_impl_->DidDrawAllLayers(frame);
5346 } 5290 }
5347 5291
5348 // Move the child to (-50, 0) instead. Now the mask should be moved to still 5292 // Move the child to (-50, 0) instead. Now the mask should be moved to still
5349 // cover the layer being replicated. 5293 // cover the layer being replicated.
5350 content_child_layer->SetPosition(gfx::Point(-50, 0)); 5294 content_child_layer->SetPosition(gfx::Point(-50, 0));
5351 { 5295 {
5352 LayerTreeHostImpl::FrameData frame; 5296 LayerTreeHostImpl::FrameData frame;
5353 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5297 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5354 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5355 5298
5356 ASSERT_EQ(1u, frame.render_passes.size()); 5299 ASSERT_EQ(1u, frame.render_passes.size());
5357 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5300 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5358 5301
5359 // The surface is 100x50 with its origin at (-50, 0). 5302 // The surface is 100x50 with its origin at (-50, 0).
5360 ASSERT_EQ(DrawQuad::RENDER_PASS, 5303 ASSERT_EQ(DrawQuad::RENDER_PASS,
5361 frame.render_passes[0]->quad_list[0]->material); 5304 frame.render_passes[0]->quad_list[0]->material);
5362 const RenderPassDrawQuad* render_pass_quad = 5305 const RenderPassDrawQuad* render_pass_quad =
5363 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5306 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5364 EXPECT_FALSE(render_pass_quad->is_replica); 5307 EXPECT_FALSE(render_pass_quad->is_replica);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5443 mask_layer->SetContentBounds(mask_size); 5386 mask_layer->SetContentBounds(mask_size);
5444 mask_layer->SetPosition(gfx::PointF()); 5387 mask_layer->SetPosition(gfx::PointF());
5445 mask_layer->SetAnchorPoint(gfx::PointF()); 5388 mask_layer->SetAnchorPoint(gfx::PointF());
5446 mask_layer->SetDrawsContent(true); 5389 mask_layer->SetDrawsContent(true);
5447 5390
5448 float device_scale_factor = 1.f; 5391 float device_scale_factor = 1.f;
5449 host_impl_->SetViewportSize(root_size); 5392 host_impl_->SetViewportSize(root_size);
5450 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5393 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5451 { 5394 {
5452 LayerTreeHostImpl::FrameData frame; 5395 LayerTreeHostImpl::FrameData frame;
5453 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5396 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5454 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5455 5397
5456 ASSERT_EQ(1u, frame.render_passes.size()); 5398 ASSERT_EQ(1u, frame.render_passes.size());
5457 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5399 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5458 5400
5459 // The surface is clipped to 10x20. 5401 // The surface is clipped to 10x20.
5460 ASSERT_EQ(DrawQuad::RENDER_PASS, 5402 ASSERT_EQ(DrawQuad::RENDER_PASS,
5461 frame.render_passes[0]->quad_list[0]->material); 5403 frame.render_passes[0]->quad_list[0]->material);
5462 const RenderPassDrawQuad* render_pass_quad = 5404 const RenderPassDrawQuad* render_pass_quad =
5463 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5405 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5464 EXPECT_FALSE(render_pass_quad->is_replica); 5406 EXPECT_FALSE(render_pass_quad->is_replica);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5525 gfx::Vector2d scroll_offset(100000, 0); 5467 gfx::Vector2d scroll_offset(100000, 0);
5526 scrolling_layer->SetScrollClipLayer(root->id()); 5468 scrolling_layer->SetScrollClipLayer(root->id());
5527 scrolling_layer->SetScrollOffset(scroll_offset); 5469 scrolling_layer->SetScrollOffset(scroll_offset);
5528 5470
5529 host_impl_->ActivatePendingTree(); 5471 host_impl_->ActivatePendingTree();
5530 5472
5531 host_impl_->active_tree()->UpdateDrawProperties(); 5473 host_impl_->active_tree()->UpdateDrawProperties();
5532 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); 5474 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
5533 5475
5534 LayerTreeHostImpl::FrameData frame; 5476 LayerTreeHostImpl::FrameData frame;
5535 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5477 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5536 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5537 5478
5538 ASSERT_EQ(1u, frame.render_passes.size()); 5479 ASSERT_EQ(1u, frame.render_passes.size());
5539 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 5480 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
5540 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; 5481 const DrawQuad* quad = frame.render_passes[0]->quad_list[0];
5541 5482
5542 float edge[24]; 5483 float edge[24];
5543 gfx::QuadF device_layer_quad; 5484 gfx::QuadF device_layer_quad;
5544 bool antialiased = 5485 bool antialiased =
5545 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( 5486 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing(
5546 quad->quadTransform(), quad, &device_layer_quad, edge); 5487 quad->quadTransform(), quad, &device_layer_quad, edge);
(...skipping 13 matching lines...) Expand all
5560 swap_buffers_complete_++; 5501 swap_buffers_complete_++;
5561 } 5502 }
5562 5503
5563 int swap_buffers_complete_; 5504 int swap_buffers_complete_;
5564 }; 5505 };
5565 5506
5566 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { 5507 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) {
5567 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 5508 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
5568 { 5509 {
5569 LayerTreeHostImpl::FrameData frame; 5510 LayerTreeHostImpl::FrameData frame;
5570 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5511 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5571 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5572 host_impl_->DrawLayers(&frame, base::TimeTicks()); 5512 host_impl_->DrawLayers(&frame, base::TimeTicks());
5573 host_impl_->DidDrawAllLayers(frame); 5513 host_impl_->DidDrawAllLayers(frame);
5574 } 5514 }
5575 CompositorFrameAck ack; 5515 CompositorFrameAck ack;
5576 host_impl_->ReclaimResources(&ack); 5516 host_impl_->ReclaimResources(&ack);
5577 host_impl_->DidSwapBuffersComplete(); 5517 host_impl_->DidSwapBuffersComplete();
5578 EXPECT_EQ(swap_buffers_complete_, 1); 5518 EXPECT_EQ(swap_buffers_complete_, 1);
5579 } 5519 }
5580 5520
5581 class CountingSoftwareDevice : public SoftwareOutputDevice { 5521 class CountingSoftwareDevice : public SoftwareOutputDevice {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5641 FakeVideoFrameProvider provider; 5581 FakeVideoFrameProvider provider;
5642 scoped_ptr<VideoLayerImpl> video_layer = 5582 scoped_ptr<VideoLayerImpl> video_layer =
5643 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); 5583 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
5644 video_layer->SetBounds(gfx::Size(10, 10)); 5584 video_layer->SetBounds(gfx::Size(10, 10));
5645 video_layer->SetContentBounds(gfx::Size(10, 10)); 5585 video_layer->SetContentBounds(gfx::Size(10, 10));
5646 video_layer->SetDrawsContent(true); 5586 video_layer->SetDrawsContent(true);
5647 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); 5587 root_layer->AddChild(video_layer.PassAs<LayerImpl>());
5648 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); 5588 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
5649 5589
5650 LayerTreeHostImpl::FrameData frame; 5590 LayerTreeHostImpl::FrameData frame;
5651 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5591 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5652 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5653 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5592 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5654 host_impl_->DidDrawAllLayers(frame); 5593 host_impl_->DidDrawAllLayers(frame);
5655 5594
5656 EXPECT_EQ(1u, frame.will_draw_layers.size()); 5595 EXPECT_EQ(1u, frame.will_draw_layers.size());
5657 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); 5596 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]);
5658 } 5597 }
5659 5598
5660 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { 5599 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest {
5661 protected: 5600 protected:
5662 virtual void SetUp() OVERRIDE { 5601 virtual void SetUp() OVERRIDE {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
5906 5845
5907 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 5846 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
5908 5847
5909 ScopedPtrVector<CopyOutputRequest> requests; 5848 ScopedPtrVector<CopyOutputRequest> requests;
5910 requests.push_back(CopyOutputRequest::CreateRequest( 5849 requests.push_back(CopyOutputRequest::CreateRequest(
5911 base::Bind(&ShutdownReleasesContext_Callback))); 5850 base::Bind(&ShutdownReleasesContext_Callback)));
5912 5851
5913 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); 5852 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests);
5914 5853
5915 LayerTreeHostImpl::FrameData frame; 5854 LayerTreeHostImpl::FrameData frame;
5916 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5855 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5917 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5918 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5856 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5919 host_impl_->DidDrawAllLayers(frame); 5857 host_impl_->DidDrawAllLayers(frame);
5920 5858
5921 // The CopyOutputResult's callback has a ref on the ContextProvider and a 5859 // The CopyOutputResult's callback has a ref on the ContextProvider and a
5922 // texture in a texture mailbox. 5860 // texture in a texture mailbox.
5923 EXPECT_FALSE(context_provider->HasOneRef()); 5861 EXPECT_FALSE(context_provider->HasOneRef());
5924 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 5862 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
5925 5863
5926 host_impl_.reset(); 5864 host_impl_.reset();
5927 5865
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
6182 ui::LatencyInfo latency_info; 6120 ui::LatencyInfo latency_info;
6183 latency_info.AddLatencyNumber( 6121 latency_info.AddLatencyNumber(
6184 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); 6122 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0);
6185 scoped_ptr<SwapPromise> swap_promise( 6123 scoped_ptr<SwapPromise> swap_promise(
6186 new LatencyInfoSwapPromise(latency_info)); 6124 new LatencyInfoSwapPromise(latency_info));
6187 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); 6125 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
6188 host_impl_->SetNeedsRedraw(); 6126 host_impl_->SetNeedsRedraw();
6189 6127
6190 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 6128 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
6191 LayerTreeHostImpl::FrameData frame; 6129 LayerTreeHostImpl::FrameData frame;
6192 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 6130 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
6193 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
6194 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 6131 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
6195 host_impl_->DidDrawAllLayers(frame); 6132 host_impl_->DidDrawAllLayers(frame);
6196 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); 6133 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
6197 6134
6198 const std::vector<ui::LatencyInfo>& metadata_latency_after = 6135 const std::vector<ui::LatencyInfo>& metadata_latency_after =
6199 fake_output_surface->last_sent_frame().metadata.latency_info; 6136 fake_output_surface->last_sent_frame().metadata.latency_info;
6200 EXPECT_EQ(1u, metadata_latency_after.size()); 6137 EXPECT_EQ(1u, metadata_latency_after.size());
6201 EXPECT_TRUE(metadata_latency_after[0].FindLatency( 6138 EXPECT_TRUE(metadata_latency_after[0].FindLatency(
6202 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); 6139 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL));
6203 } 6140 }
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
6485 // Verify implicit limits are calculated correctly with no overflows 6422 // Verify implicit limits are calculated correctly with no overflows
6486 host_impl_->SetMemoryPolicy(mem_policy); 6423 host_impl_->SetMemoryPolicy(mem_policy);
6487 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, 6424 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes,
6488 300u * 1024u * 1024u); 6425 300u * 1024u * 1024u);
6489 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, 6426 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes,
6490 150u * 1024u * 1024u); 6427 150u * 1024u * 1024u);
6491 } 6428 }
6492 6429
6493 } // namespace 6430 } // namespace
6494 } // namespace cc 6431 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698