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

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

Powered by Google App Engine
This is Rietveld 408576698