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

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

Issue 279013002: Remove CompositeAndReadback from LayerTreeHost(Impl) and the Proxys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm-cnr-lth-proxy-renderer: rebase-on-drawresult 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_pixeltest_readback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 305 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
306 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 306 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
307 host_impl_->DidDrawAllLayers(frame); 307 host_impl_->DidDrawAllLayers(frame);
308 } 308 }
309 309
310 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);
311 void pinch_zoom_pan_viewport_test(float device_scale_factor); 311 void pinch_zoom_pan_viewport_test(float device_scale_factor);
312 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);
313 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 313 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
314 float device_scale_factor); 314 float device_scale_factor);
315 315
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 381
382 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); 382 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor);
383 383
384 protected: 384 protected:
385 virtual scoped_ptr<OutputSurface> CreateOutputSurface() { 385 virtual scoped_ptr<OutputSurface> CreateOutputSurface() {
386 return FakeOutputSurface::Create3d().PassAs<OutputSurface>(); 386 return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
387 } 387 }
388 388
389 void DrawOneFrame() { 389 void DrawOneFrame() {
390 LayerTreeHostImpl::FrameData frame_data; 390 LayerTreeHostImpl::FrameData frame_data;
391 host_impl_->PrepareToDraw(&frame_data, gfx::Rect()); 391 host_impl_->PrepareToDraw(&frame_data);
392 host_impl_->DidDrawAllLayers(frame_data); 392 host_impl_->DidDrawAllLayers(frame_data);
393 } 393 }
394 394
395 FakeProxy proxy_; 395 FakeProxy proxy_;
396 DebugScopedSetImplThread always_impl_thread_; 396 DebugScopedSetImplThread always_impl_thread_;
397 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; 397 DebugScopedSetMainThreadBlocked always_main_thread_blocked_;
398 398
399 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 399 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
400 scoped_ptr<LayerTreeHostImpl> host_impl_; 400 scoped_ptr<LayerTreeHostImpl> host_impl_;
401 FakeRenderingStatsInstrumentation stats_instrumentation_; 401 FakeRenderingStatsInstrumentation stats_instrumentation_;
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1719 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1720 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 1720 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
1721 host_impl_->active_tree()->root_layer()); 1721 host_impl_->active_tree()->root_layer());
1722 1722
1723 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1723 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1724 DidDrawCheckLayer* layer = 1724 DidDrawCheckLayer* layer =
1725 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1725 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1726 1726
1727 { 1727 {
1728 LayerTreeHostImpl::FrameData frame; 1728 LayerTreeHostImpl::FrameData frame;
1729 EXPECT_EQ(DRAW_SUCCESS, 1729 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1730 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1731 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1730 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1732 host_impl_->DidDrawAllLayers(frame); 1731 host_impl_->DidDrawAllLayers(frame);
1733 1732
1734 EXPECT_TRUE(layer->will_draw_called()); 1733 EXPECT_TRUE(layer->will_draw_called());
1735 EXPECT_TRUE(layer->append_quads_called()); 1734 EXPECT_TRUE(layer->append_quads_called());
1736 EXPECT_TRUE(layer->did_draw_called()); 1735 EXPECT_TRUE(layer->did_draw_called());
1737 } 1736 }
1738 1737
1738 host_impl_->SetViewportDamage(gfx::Rect(10, 10));
1739
1739 { 1740 {
1740 LayerTreeHostImpl::FrameData frame; 1741 LayerTreeHostImpl::FrameData frame;
1741 1742
1742 layer->set_will_draw_returns_false(); 1743 layer->set_will_draw_returns_false();
1743 layer->ClearDidDrawCheck(); 1744 layer->ClearDidDrawCheck();
1744 1745
1745 EXPECT_EQ(DRAW_SUCCESS, 1746 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1746 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1747 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1747 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1748 host_impl_->DidDrawAllLayers(frame); 1748 host_impl_->DidDrawAllLayers(frame);
1749 1749
1750 EXPECT_TRUE(layer->will_draw_called()); 1750 EXPECT_TRUE(layer->will_draw_called());
1751 EXPECT_FALSE(layer->append_quads_called()); 1751 EXPECT_FALSE(layer->append_quads_called());
1752 EXPECT_FALSE(layer->did_draw_called()); 1752 EXPECT_FALSE(layer->did_draw_called());
1753 } 1753 }
1754 } 1754 }
1755 1755
1756 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { 1756 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) {
(...skipping 11 matching lines...) Expand all
1768 // Ensure visible_content_rect for layer is empty. 1768 // Ensure visible_content_rect for layer is empty.
1769 layer->SetPosition(gfx::PointF(100.f, 100.f)); 1769 layer->SetPosition(gfx::PointF(100.f, 100.f));
1770 layer->SetBounds(gfx::Size(10, 10)); 1770 layer->SetBounds(gfx::Size(10, 10));
1771 layer->SetContentBounds(gfx::Size(10, 10)); 1771 layer->SetContentBounds(gfx::Size(10, 10));
1772 1772
1773 LayerTreeHostImpl::FrameData frame; 1773 LayerTreeHostImpl::FrameData frame;
1774 1774
1775 EXPECT_FALSE(layer->will_draw_called()); 1775 EXPECT_FALSE(layer->will_draw_called());
1776 EXPECT_FALSE(layer->did_draw_called()); 1776 EXPECT_FALSE(layer->did_draw_called());
1777 1777
1778 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1778 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1779 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1779 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1780 host_impl_->DidDrawAllLayers(frame); 1780 host_impl_->DidDrawAllLayers(frame);
1781 1781
1782 EXPECT_FALSE(layer->will_draw_called()); 1782 EXPECT_FALSE(layer->will_draw_called());
1783 EXPECT_FALSE(layer->did_draw_called()); 1783 EXPECT_FALSE(layer->did_draw_called());
1784 1784
1785 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); 1785 EXPECT_TRUE(layer->visible_content_rect().IsEmpty());
1786 1786
1787 // Ensure visible_content_rect for layer is not empty 1787 // Ensure visible_content_rect for layer is not empty
1788 layer->SetPosition(gfx::PointF()); 1788 layer->SetPosition(gfx::PointF());
1789 1789
1790 EXPECT_FALSE(layer->will_draw_called()); 1790 EXPECT_FALSE(layer->will_draw_called());
1791 EXPECT_FALSE(layer->did_draw_called()); 1791 EXPECT_FALSE(layer->did_draw_called());
1792 1792
1793 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1793 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1794 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1794 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1795 host_impl_->DidDrawAllLayers(frame); 1795 host_impl_->DidDrawAllLayers(frame);
1796 1796
1797 EXPECT_TRUE(layer->will_draw_called()); 1797 EXPECT_TRUE(layer->will_draw_called());
1798 EXPECT_TRUE(layer->did_draw_called()); 1798 EXPECT_TRUE(layer->did_draw_called());
1799 1799
1800 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); 1800 EXPECT_FALSE(layer->visible_content_rect().IsEmpty());
1801 } 1801 }
1802 1802
1803 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 1803 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
(...skipping 18 matching lines...) Expand all
1822 top_layer->SetContentBounds(big_size); 1822 top_layer->SetContentBounds(big_size);
1823 top_layer->SetContentsOpaque(true); 1823 top_layer->SetContentsOpaque(true);
1824 1824
1825 LayerTreeHostImpl::FrameData frame; 1825 LayerTreeHostImpl::FrameData frame;
1826 1826
1827 EXPECT_FALSE(occluded_layer->will_draw_called()); 1827 EXPECT_FALSE(occluded_layer->will_draw_called());
1828 EXPECT_FALSE(occluded_layer->did_draw_called()); 1828 EXPECT_FALSE(occluded_layer->did_draw_called());
1829 EXPECT_FALSE(top_layer->will_draw_called()); 1829 EXPECT_FALSE(top_layer->will_draw_called());
1830 EXPECT_FALSE(top_layer->did_draw_called()); 1830 EXPECT_FALSE(top_layer->did_draw_called());
1831 1831
1832 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1832 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1833 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1833 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1834 host_impl_->DidDrawAllLayers(frame); 1834 host_impl_->DidDrawAllLayers(frame);
1835 1835
1836 EXPECT_FALSE(occluded_layer->will_draw_called()); 1836 EXPECT_FALSE(occluded_layer->will_draw_called());
1837 EXPECT_FALSE(occluded_layer->did_draw_called()); 1837 EXPECT_FALSE(occluded_layer->did_draw_called());
1838 EXPECT_TRUE(top_layer->will_draw_called()); 1838 EXPECT_TRUE(top_layer->will_draw_called());
1839 EXPECT_TRUE(top_layer->did_draw_called()); 1839 EXPECT_TRUE(top_layer->did_draw_called());
1840 } 1840 }
1841 1841
1842 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 1842 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
(...skipping 11 matching lines...) Expand all
1854 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); 1854 static_cast<DidDrawCheckLayer*>(layer1->children()[0]);
1855 1855
1856 layer1->SetOpacity(0.3f); 1856 layer1->SetOpacity(0.3f);
1857 layer1->SetShouldFlattenTransform(true); 1857 layer1->SetShouldFlattenTransform(true);
1858 1858
1859 EXPECT_FALSE(root->did_draw_called()); 1859 EXPECT_FALSE(root->did_draw_called());
1860 EXPECT_FALSE(layer1->did_draw_called()); 1860 EXPECT_FALSE(layer1->did_draw_called());
1861 EXPECT_FALSE(layer2->did_draw_called()); 1861 EXPECT_FALSE(layer2->did_draw_called());
1862 1862
1863 LayerTreeHostImpl::FrameData frame; 1863 LayerTreeHostImpl::FrameData frame;
1864 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1864 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1865 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1865 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1866 host_impl_->DidDrawAllLayers(frame); 1866 host_impl_->DidDrawAllLayers(frame);
1867 1867
1868 EXPECT_TRUE(root->did_draw_called()); 1868 EXPECT_TRUE(root->did_draw_called());
1869 EXPECT_TRUE(layer1->did_draw_called()); 1869 EXPECT_TRUE(layer1->did_draw_called());
1870 EXPECT_TRUE(layer2->did_draw_called()); 1870 EXPECT_TRUE(layer2->did_draw_called());
1871 1871
1872 EXPECT_NE(root->render_surface(), layer1->render_surface()); 1872 EXPECT_NE(root->render_surface(), layer1->render_surface());
1873 EXPECT_TRUE(!!layer1->render_surface()); 1873 EXPECT_TRUE(!!layer1->render_surface());
1874 } 1874 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 root->AddChild( 1939 root->AddChild(
1940 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1940 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1941 2, 1941 2,
1942 tile_missing, 1942 tile_missing,
1943 skips_draw, 1943 skips_draw,
1944 is_animating, 1944 is_animating,
1945 host_impl_->resource_provider())); 1945 host_impl_->resource_provider()));
1946 1946
1947 LayerTreeHostImpl::FrameData frame; 1947 LayerTreeHostImpl::FrameData frame;
1948 1948
1949 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1949 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1950 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1950 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1951 host_impl_->DidDrawAllLayers(frame); 1951 host_impl_->DidDrawAllLayers(frame);
1952 } 1952 }
1953 1953
1954 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { 1954 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) {
1955 host_impl_->active_tree()->SetRootLayer( 1955 host_impl_->active_tree()->SetRootLayer(
1956 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1956 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1957 DidDrawCheckLayer* root = 1957 DidDrawCheckLayer* root =
1958 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1958 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1959 bool tile_missing = false; 1959 bool tile_missing = false;
1960 bool skips_draw = false; 1960 bool skips_draw = false;
1961 bool is_animating = true; 1961 bool is_animating = true;
1962 root->AddChild( 1962 root->AddChild(
1963 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1963 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1964 2, 1964 2,
1965 tile_missing, 1965 tile_missing,
1966 skips_draw, 1966 skips_draw,
1967 is_animating, 1967 is_animating,
1968 host_impl_->resource_provider())); 1968 host_impl_->resource_provider()));
1969 1969
1970 LayerTreeHostImpl::FrameData frame; 1970 LayerTreeHostImpl::FrameData frame;
1971 1971
1972 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1972 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1973 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1973 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1974 host_impl_->DidDrawAllLayers(frame); 1974 host_impl_->DidDrawAllLayers(frame);
1975 } 1975 }
1976 1976
1977 TEST_F(LayerTreeHostImplTest, 1977 TEST_F(LayerTreeHostImplTest,
1978 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) { 1978 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) {
1979 // 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
1980 // checkerboarding. 1980 // checkerboarding.
1981 host_impl_->active_tree()->SetRootLayer( 1981 host_impl_->active_tree()->SetRootLayer(
1982 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1982 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1983 DidDrawCheckLayer* root = 1983 DidDrawCheckLayer* root =
1984 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1984 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1985 1985
1986 bool tile_missing = true; 1986 bool tile_missing = true;
1987 bool skips_draw = false; 1987 bool skips_draw = false;
1988 bool is_animating = false; 1988 bool is_animating = false;
1989 root->AddChild( 1989 root->AddChild(
1990 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1990 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1991 4, 1991 4,
1992 tile_missing, 1992 tile_missing,
1993 skips_draw, 1993 skips_draw,
1994 is_animating, 1994 is_animating,
1995 host_impl_->resource_provider())); 1995 host_impl_->resource_provider()));
1996 LayerTreeHostImpl::FrameData frame; 1996 LayerTreeHostImpl::FrameData frame;
1997 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1997 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1998 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1998 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1999 host_impl_->DidDrawAllLayers(frame); 1999 host_impl_->DidDrawAllLayers(frame);
2000 } 2000 }
2001 2001
2002 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { 2002 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) {
2003 // 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
2004 // anything. 2004 // anything.
2005 host_impl_->active_tree()->SetRootLayer( 2005 host_impl_->active_tree()->SetRootLayer(
2006 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 2006 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
2007 DidDrawCheckLayer* root = 2007 DidDrawCheckLayer* root =
2008 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2008 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2009 bool tile_missing = true; 2009 bool tile_missing = true;
2010 bool skips_draw = false; 2010 bool skips_draw = false;
2011 bool is_animating = true; 2011 bool is_animating = true;
2012 root->AddChild( 2012 root->AddChild(
2013 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2013 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2014 6, 2014 6,
2015 tile_missing, 2015 tile_missing,
2016 skips_draw, 2016 skips_draw,
2017 is_animating, 2017 is_animating,
2018 host_impl_->resource_provider())); 2018 host_impl_->resource_provider()));
2019 LayerTreeHostImpl::FrameData frame; 2019 LayerTreeHostImpl::FrameData frame;
2020 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, 2020 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
2021 host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2021 host_impl_->PrepareToDraw(&frame));
2022 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2022 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2023 host_impl_->DidDrawAllLayers(frame); 2023 host_impl_->DidDrawAllLayers(frame);
2024 } 2024 }
2025 2025
2026 TEST_F(LayerTreeHostImplTest, 2026 TEST_F(LayerTreeHostImplTest,
2027 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) { 2027 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) {
2028 // 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.
2029 host_impl_->active_tree()->SetRootLayer( 2029 host_impl_->active_tree()->SetRootLayer(
2030 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2030 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2031 DidDrawCheckLayer* root = 2031 DidDrawCheckLayer* root =
2032 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2032 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2033 bool tile_missing = false; 2033 bool tile_missing = false;
2034 bool skips_draw = true; 2034 bool skips_draw = true;
2035 bool is_animating = true; 2035 bool is_animating = true;
2036 root->AddChild( 2036 root->AddChild(
2037 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2037 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2038 8, 2038 8,
2039 tile_missing, 2039 tile_missing,
2040 skips_draw, 2040 skips_draw,
2041 is_animating, 2041 is_animating,
2042 host_impl_->resource_provider())); 2042 host_impl_->resource_provider()));
2043 LayerTreeHostImpl::FrameData frame; 2043 LayerTreeHostImpl::FrameData frame;
2044 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), DRAW_SUCCESS); 2044 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2045 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2045 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2046 host_impl_->DidDrawAllLayers(frame); 2046 host_impl_->DidDrawAllLayers(frame);
2047 } 2047 }
2048 2048
2049 TEST_F(LayerTreeHostImplTest, 2049 TEST_F(LayerTreeHostImplTest,
2050 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) { 2050 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) {
2051 // 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.
2052 host_impl_->active_tree()->SetRootLayer( 2052 host_impl_->active_tree()->SetRootLayer(
2053 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2053 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2054 DidDrawCheckLayer* root = 2054 DidDrawCheckLayer* root =
2055 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2055 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2056 bool tile_missing = false; 2056 bool tile_missing = false;
2057 bool skips_draw = false; 2057 bool skips_draw = false;
2058 bool is_animating = false; 2058 bool is_animating = false;
2059 root->AddChild( 2059 root->AddChild(
2060 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2060 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2061 8, 2061 8,
2062 tile_missing, 2062 tile_missing,
2063 skips_draw, 2063 skips_draw,
2064 is_animating, 2064 is_animating,
2065 host_impl_->resource_provider())); 2065 host_impl_->resource_provider()));
2066 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2066 host_impl_->active_tree()->SetRequiresHighResToDraw();
2067 LayerTreeHostImpl::FrameData frame; 2067 LayerTreeHostImpl::FrameData frame;
2068 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), DRAW_SUCCESS); 2068 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2069 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2069 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2070 host_impl_->DidDrawAllLayers(frame); 2070 host_impl_->DidDrawAllLayers(frame);
2071 } 2071 }
2072 2072
2073 TEST_F(LayerTreeHostImplTest, 2073 TEST_F(LayerTreeHostImplTest,
2074 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) { 2074 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) {
2075 // 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.
2076 host_impl_->active_tree()->SetRootLayer( 2076 host_impl_->active_tree()->SetRootLayer(
2077 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2077 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2078 DidDrawCheckLayer* root = 2078 DidDrawCheckLayer* root =
2079 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2079 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2080 bool tile_missing = true; 2080 bool tile_missing = true;
2081 bool skips_draw = false; 2081 bool skips_draw = false;
2082 bool is_animating = false; 2082 bool is_animating = false;
2083 root->AddChild( 2083 root->AddChild(
2084 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2084 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2085 8, 2085 8,
2086 tile_missing, 2086 tile_missing,
2087 skips_draw, 2087 skips_draw,
2088 is_animating, 2088 is_animating,
2089 host_impl_->resource_provider())); 2089 host_impl_->resource_provider()));
2090 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2090 host_impl_->active_tree()->SetRequiresHighResToDraw();
2091 LayerTreeHostImpl::FrameData frame; 2091 LayerTreeHostImpl::FrameData frame;
2092 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), 2092 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2093 DRAW_ABORTED_MISSING_HIGH_RES_CONTENT); 2093 host_impl_->PrepareToDraw(&frame));
2094 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2094 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2095 host_impl_->DidDrawAllLayers(frame); 2095 host_impl_->DidDrawAllLayers(frame);
2096 } 2096 }
2097 2097
2098 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 2098 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
2099 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2099 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2100 root->SetScrollClipLayer(Layer::INVALID_ID); 2100 root->SetScrollClipLayer(Layer::INVALID_ID);
2101 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2101 host_impl_->active_tree()->SetRootLayer(root.Pass());
2102 DrawFrame(); 2102 DrawFrame();
2103 2103
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 EXPECT_EQ(1.f, scroll->contents_scale_x()); 2535 EXPECT_EQ(1.f, scroll->contents_scale_x());
2536 EXPECT_EQ(1.f, scroll->contents_scale_y()); 2536 EXPECT_EQ(1.f, scroll->contents_scale_y());
2537 EXPECT_EQ(1.f, child->contents_scale_x()); 2537 EXPECT_EQ(1.f, child->contents_scale_x());
2538 EXPECT_EQ(1.f, child->contents_scale_y()); 2538 EXPECT_EQ(1.f, child->contents_scale_y());
2539 EXPECT_EQ(1.f, grand_child->contents_scale_x()); 2539 EXPECT_EQ(1.f, grand_child->contents_scale_x());
2540 EXPECT_EQ(1.f, grand_child->contents_scale_y()); 2540 EXPECT_EQ(1.f, grand_child->contents_scale_y());
2541 2541
2542 // 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.,
2543 // the page scale delta on the root layer is applied hierarchically. 2543 // the page scale delta on the root layer is applied hierarchically.
2544 LayerTreeHostImpl::FrameData frame; 2544 LayerTreeHostImpl::FrameData frame;
2545 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 2545 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2546 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2546 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2547 host_impl_->DidDrawAllLayers(frame); 2547 host_impl_->DidDrawAllLayers(frame);
2548 2548
2549 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); 2549 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0));
2550 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); 2550 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1));
2551 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));
2552 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));
2553 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));
2554 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));
2555 EXPECT_EQ(new_page_scale, 2555 EXPECT_EQ(new_page_scale,
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
3524 BlendStateCheckLayer* layer1 = 3524 BlendStateCheckLayer* layer1 =
3525 static_cast<BlendStateCheckLayer*>(root->children()[0]); 3525 static_cast<BlendStateCheckLayer*>(root->children()[0]);
3526 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 3526 layer1->SetPosition(gfx::PointF(2.f, 2.f));
3527 3527
3528 LayerTreeHostImpl::FrameData frame; 3528 LayerTreeHostImpl::FrameData frame;
3529 3529
3530 // Opaque layer, drawn without blending. 3530 // Opaque layer, drawn without blending.
3531 layer1->SetContentsOpaque(true); 3531 layer1->SetContentsOpaque(true);
3532 layer1->SetExpectation(false, false); 3532 layer1->SetExpectation(false, false);
3533 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3533 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3534 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3534 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3535 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3535 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3536 EXPECT_TRUE(layer1->quads_appended()); 3536 EXPECT_TRUE(layer1->quads_appended());
3537 host_impl_->DidDrawAllLayers(frame); 3537 host_impl_->DidDrawAllLayers(frame);
3538 3538
3539 // Layer with translucent content and painting, so drawn with blending. 3539 // Layer with translucent content and painting, so drawn with blending.
3540 layer1->SetContentsOpaque(false); 3540 layer1->SetContentsOpaque(false);
3541 layer1->SetExpectation(true, false); 3541 layer1->SetExpectation(true, false);
3542 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3542 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3543 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3543 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3544 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3544 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3545 EXPECT_TRUE(layer1->quads_appended()); 3545 EXPECT_TRUE(layer1->quads_appended());
3546 host_impl_->DidDrawAllLayers(frame); 3546 host_impl_->DidDrawAllLayers(frame);
3547 3547
3548 // Layer with translucent opacity, drawn with blending. 3548 // Layer with translucent opacity, drawn with blending.
3549 layer1->SetContentsOpaque(true); 3549 layer1->SetContentsOpaque(true);
3550 layer1->SetOpacity(0.5f); 3550 layer1->SetOpacity(0.5f);
3551 layer1->SetExpectation(true, false); 3551 layer1->SetExpectation(true, false);
3552 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3552 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3553 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3553 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3554 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3554 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3555 EXPECT_TRUE(layer1->quads_appended()); 3555 EXPECT_TRUE(layer1->quads_appended());
3556 host_impl_->DidDrawAllLayers(frame); 3556 host_impl_->DidDrawAllLayers(frame);
3557 3557
3558 // Layer with translucent opacity and painting, drawn with blending. 3558 // Layer with translucent opacity and painting, drawn with blending.
3559 layer1->SetContentsOpaque(true); 3559 layer1->SetContentsOpaque(true);
3560 layer1->SetOpacity(0.5f); 3560 layer1->SetOpacity(0.5f);
3561 layer1->SetExpectation(true, false); 3561 layer1->SetExpectation(true, false);
3562 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3562 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3563 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3563 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3564 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3564 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3565 EXPECT_TRUE(layer1->quads_appended()); 3565 EXPECT_TRUE(layer1->quads_appended());
3566 host_impl_->DidDrawAllLayers(frame); 3566 host_impl_->DidDrawAllLayers(frame);
3567 3567
3568 layer1->AddChild( 3568 layer1->AddChild(
3569 BlendStateCheckLayer::Create(host_impl_->active_tree(), 3569 BlendStateCheckLayer::Create(host_impl_->active_tree(),
3570 3, 3570 3,
3571 host_impl_->resource_provider())); 3571 host_impl_->resource_provider()));
3572 BlendStateCheckLayer* layer2 = 3572 BlendStateCheckLayer* layer2 =
3573 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); 3573 static_cast<BlendStateCheckLayer*>(layer1->children()[0]);
3574 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 3574 layer2->SetPosition(gfx::PointF(4.f, 4.f));
3575 3575
3576 // 2 opaque layers, drawn without blending. 3576 // 2 opaque layers, drawn without blending.
3577 layer1->SetContentsOpaque(true); 3577 layer1->SetContentsOpaque(true);
3578 layer1->SetOpacity(1.f); 3578 layer1->SetOpacity(1.f);
3579 layer1->SetExpectation(false, false); 3579 layer1->SetExpectation(false, false);
3580 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3580 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3581 layer2->SetContentsOpaque(true); 3581 layer2->SetContentsOpaque(true);
3582 layer2->SetOpacity(1.f); 3582 layer2->SetOpacity(1.f);
3583 layer2->SetExpectation(false, false); 3583 layer2->SetExpectation(false, false);
3584 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3584 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3585 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3585 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3586 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3586 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3587 EXPECT_TRUE(layer1->quads_appended()); 3587 EXPECT_TRUE(layer1->quads_appended());
3588 EXPECT_TRUE(layer2->quads_appended()); 3588 EXPECT_TRUE(layer2->quads_appended());
3589 host_impl_->DidDrawAllLayers(frame); 3589 host_impl_->DidDrawAllLayers(frame);
3590 3590
3591 // Parent layer with translucent content, drawn with blending. 3591 // Parent layer with translucent content, drawn with blending.
3592 // Child layer with opaque content, drawn without blending. 3592 // Child layer with opaque content, drawn without blending.
3593 layer1->SetContentsOpaque(false); 3593 layer1->SetContentsOpaque(false);
3594 layer1->SetExpectation(true, false); 3594 layer1->SetExpectation(true, false);
3595 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3595 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3596 layer2->SetExpectation(false, false); 3596 layer2->SetExpectation(false, false);
3597 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3597 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3598 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3598 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3599 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3599 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3600 EXPECT_TRUE(layer1->quads_appended()); 3600 EXPECT_TRUE(layer1->quads_appended());
3601 EXPECT_TRUE(layer2->quads_appended()); 3601 EXPECT_TRUE(layer2->quads_appended());
3602 host_impl_->DidDrawAllLayers(frame); 3602 host_impl_->DidDrawAllLayers(frame);
3603 3603
3604 // Parent layer with translucent content but opaque painting, drawn without 3604 // Parent layer with translucent content but opaque painting, drawn without
3605 // blending. 3605 // blending.
3606 // Child layer with opaque content, drawn without blending. 3606 // Child layer with opaque content, drawn without blending.
3607 layer1->SetContentsOpaque(true); 3607 layer1->SetContentsOpaque(true);
3608 layer1->SetExpectation(false, false); 3608 layer1->SetExpectation(false, false);
3609 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3609 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3610 layer2->SetExpectation(false, false); 3610 layer2->SetExpectation(false, false);
3611 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3611 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3612 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3612 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3613 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3613 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3614 EXPECT_TRUE(layer1->quads_appended()); 3614 EXPECT_TRUE(layer1->quads_appended());
3615 EXPECT_TRUE(layer2->quads_appended()); 3615 EXPECT_TRUE(layer2->quads_appended());
3616 host_impl_->DidDrawAllLayers(frame); 3616 host_impl_->DidDrawAllLayers(frame);
3617 3617
3618 // 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
3619 // 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,
3620 // so it's itself drawn without blending. 3620 // so it's itself drawn without blending.
3621 // Child layer with opaque content, drawn without blending (parent surface 3621 // Child layer with opaque content, drawn without blending (parent surface
3622 // carries the inherited opacity). 3622 // carries the inherited opacity).
3623 layer1->SetContentsOpaque(true); 3623 layer1->SetContentsOpaque(true);
3624 layer1->SetOpacity(0.5f); 3624 layer1->SetOpacity(0.5f);
3625 layer1->SetExpectation(false, true); 3625 layer1->SetExpectation(false, true);
3626 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3626 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3627 layer2->SetExpectation(false, false); 3627 layer2->SetExpectation(false, false);
3628 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3628 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3629 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3629 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3630 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3630 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3631 EXPECT_TRUE(layer1->quads_appended()); 3631 EXPECT_TRUE(layer1->quads_appended());
3632 EXPECT_TRUE(layer2->quads_appended()); 3632 EXPECT_TRUE(layer2->quads_appended());
3633 host_impl_->DidDrawAllLayers(frame); 3633 host_impl_->DidDrawAllLayers(frame);
3634 3634
3635 // Draw again, but with child non-opaque, to make sure 3635 // Draw again, but with child non-opaque, to make sure
3636 // layer1 not culled. 3636 // layer1 not culled.
3637 layer1->SetContentsOpaque(true); 3637 layer1->SetContentsOpaque(true);
3638 layer1->SetOpacity(1.f); 3638 layer1->SetOpacity(1.f);
3639 layer1->SetExpectation(false, false); 3639 layer1->SetExpectation(false, false);
3640 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3640 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3641 layer2->SetContentsOpaque(true); 3641 layer2->SetContentsOpaque(true);
3642 layer2->SetOpacity(0.5f); 3642 layer2->SetOpacity(0.5f);
3643 layer2->SetExpectation(true, false); 3643 layer2->SetExpectation(true, false);
3644 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3644 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3645 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3645 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3646 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3646 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3647 EXPECT_TRUE(layer1->quads_appended()); 3647 EXPECT_TRUE(layer1->quads_appended());
3648 EXPECT_TRUE(layer2->quads_appended()); 3648 EXPECT_TRUE(layer2->quads_appended());
3649 host_impl_->DidDrawAllLayers(frame); 3649 host_impl_->DidDrawAllLayers(frame);
3650 3650
3651 // A second way of making the child non-opaque. 3651 // A second way of making the child non-opaque.
3652 layer1->SetContentsOpaque(true); 3652 layer1->SetContentsOpaque(true);
3653 layer1->SetOpacity(1.f); 3653 layer1->SetOpacity(1.f);
3654 layer1->SetExpectation(false, false); 3654 layer1->SetExpectation(false, false);
3655 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3655 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3656 layer2->SetContentsOpaque(false); 3656 layer2->SetContentsOpaque(false);
3657 layer2->SetOpacity(1.f); 3657 layer2->SetOpacity(1.f);
3658 layer2->SetExpectation(true, false); 3658 layer2->SetExpectation(true, false);
3659 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3659 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3660 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3660 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3661 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3661 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3662 EXPECT_TRUE(layer1->quads_appended()); 3662 EXPECT_TRUE(layer1->quads_appended());
3663 EXPECT_TRUE(layer2->quads_appended()); 3663 EXPECT_TRUE(layer2->quads_appended());
3664 host_impl_->DidDrawAllLayers(frame); 3664 host_impl_->DidDrawAllLayers(frame);
3665 3665
3666 // 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
3667 // blended. 3667 // blended.
3668 layer1->SetContentsOpaque(true); 3668 layer1->SetContentsOpaque(true);
3669 layer1->SetOpacity(1.f); 3669 layer1->SetOpacity(1.f);
3670 layer1->SetExpectation(false, false); 3670 layer1->SetExpectation(false, false);
3671 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3671 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3672 layer2->SetContentsOpaque(true); 3672 layer2->SetContentsOpaque(true);
3673 layer2->SetOpacity(1.f); 3673 layer2->SetOpacity(1.f);
3674 layer2->SetExpectation(false, false); 3674 layer2->SetExpectation(false, false);
3675 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3675 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3676 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3676 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3677 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3677 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3678 EXPECT_TRUE(layer1->quads_appended()); 3678 EXPECT_TRUE(layer1->quads_appended());
3679 EXPECT_TRUE(layer2->quads_appended()); 3679 EXPECT_TRUE(layer2->quads_appended());
3680 host_impl_->DidDrawAllLayers(frame); 3680 host_impl_->DidDrawAllLayers(frame);
3681 3681
3682 // Layer with partially opaque contents, drawn with blending. 3682 // Layer with partially opaque contents, drawn with blending.
3683 layer1->SetContentsOpaque(false); 3683 layer1->SetContentsOpaque(false);
3684 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3684 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3685 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 3685 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
3686 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3686 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3687 layer1->SetExpectation(true, false); 3687 layer1->SetExpectation(true, false);
3688 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3688 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3689 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3689 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3690 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3690 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3691 EXPECT_TRUE(layer1->quads_appended()); 3691 EXPECT_TRUE(layer1->quads_appended());
3692 host_impl_->DidDrawAllLayers(frame); 3692 host_impl_->DidDrawAllLayers(frame);
3693 3693
3694 // Layer with partially opaque contents partially culled, drawn with blending. 3694 // Layer with partially opaque contents partially culled, drawn with blending.
3695 layer1->SetContentsOpaque(false); 3695 layer1->SetContentsOpaque(false);
3696 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3696 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3697 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 3697 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
3698 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3698 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3699 layer1->SetExpectation(true, false); 3699 layer1->SetExpectation(true, false);
3700 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3700 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3701 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3701 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3702 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3702 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3703 EXPECT_TRUE(layer1->quads_appended()); 3703 EXPECT_TRUE(layer1->quads_appended());
3704 host_impl_->DidDrawAllLayers(frame); 3704 host_impl_->DidDrawAllLayers(frame);
3705 3705
3706 // Layer with partially opaque contents culled, drawn with blending. 3706 // Layer with partially opaque contents culled, drawn with blending.
3707 layer1->SetContentsOpaque(false); 3707 layer1->SetContentsOpaque(false);
3708 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3708 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3709 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 3709 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
3710 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3710 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3711 layer1->SetExpectation(true, false); 3711 layer1->SetExpectation(true, false);
3712 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3712 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3713 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3713 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3714 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3714 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3715 EXPECT_TRUE(layer1->quads_appended()); 3715 EXPECT_TRUE(layer1->quads_appended());
3716 host_impl_->DidDrawAllLayers(frame); 3716 host_impl_->DidDrawAllLayers(frame);
3717 3717
3718 // Layer with partially opaque contents and translucent contents culled, drawn 3718 // Layer with partially opaque contents and translucent contents culled, drawn
3719 // without blending. 3719 // without blending.
3720 layer1->SetContentsOpaque(false); 3720 layer1->SetContentsOpaque(false);
3721 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3721 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3722 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 3722 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
3723 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3723 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3724 layer1->SetExpectation(false, false); 3724 layer1->SetExpectation(false, false);
3725 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3725 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3726 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3726 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3727 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3727 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3728 EXPECT_TRUE(layer1->quads_appended()); 3728 EXPECT_TRUE(layer1->quads_appended());
3729 host_impl_->DidDrawAllLayers(frame); 3729 host_impl_->DidDrawAllLayers(frame);
3730 } 3730 }
3731 3731
3732 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { 3732 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
3733 protected: 3733 protected:
3734 LayerTreeHostImplViewportCoveredTest() : 3734 LayerTreeHostImplViewportCoveredTest() :
3735 gutter_quad_material_(DrawQuad::SOLID_COLOR), 3735 gutter_quad_material_(DrawQuad::SOLID_COLOR),
3736 child_(NULL), 3736 child_(NULL),
(...skipping 24 matching lines...) Expand all
3761 // Expect no gutter rects. 3761 // Expect no gutter rects.
3762 void TestLayerCoversFullViewport() { 3762 void TestLayerCoversFullViewport() {
3763 gfx::Rect layer_rect(viewport_size_); 3763 gfx::Rect layer_rect(viewport_size_);
3764 child_->SetPosition(layer_rect.origin()); 3764 child_->SetPosition(layer_rect.origin());
3765 child_->SetBounds(layer_rect.size()); 3765 child_->SetBounds(layer_rect.size());
3766 child_->SetContentBounds(layer_rect.size()); 3766 child_->SetContentBounds(layer_rect.size());
3767 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3767 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3768 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3768 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3769 3769
3770 LayerTreeHostImpl::FrameData frame; 3770 LayerTreeHostImpl::FrameData frame;
3771 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3771 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3772 ASSERT_EQ(1u, frame.render_passes.size()); 3772 ASSERT_EQ(1u, frame.render_passes.size());
3773 3773
3774 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3774 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list));
3775 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 3775 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
3776 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3776 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3777 3777
3778 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 3778 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
3779 host_impl_->DidDrawAllLayers(frame); 3779 host_impl_->DidDrawAllLayers(frame);
3780 } 3780 }
3781 3781
3782 // Expect fullscreen gutter rect. 3782 // Expect fullscreen gutter rect.
3783 void TestEmptyLayer() { 3783 void TestEmptyLayer() {
3784 gfx::Rect layer_rect(0, 0, 0, 0); 3784 gfx::Rect layer_rect(0, 0, 0, 0);
3785 child_->SetPosition(layer_rect.origin()); 3785 child_->SetPosition(layer_rect.origin());
3786 child_->SetBounds(layer_rect.size()); 3786 child_->SetBounds(layer_rect.size());
3787 child_->SetContentBounds(layer_rect.size()); 3787 child_->SetContentBounds(layer_rect.size());
3788 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3788 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3789 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3789 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3790 3790
3791 LayerTreeHostImpl::FrameData frame; 3791 LayerTreeHostImpl::FrameData frame;
3792 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3792 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3793 ASSERT_EQ(1u, frame.render_passes.size()); 3793 ASSERT_EQ(1u, frame.render_passes.size());
3794 3794
3795 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3795 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list));
3796 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 3796 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
3797 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3797 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3798 3798
3799 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 3799 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
3800 host_impl_->DidDrawAllLayers(frame); 3800 host_impl_->DidDrawAllLayers(frame);
3801 } 3801 }
3802 3802
3803 // Expect four surrounding gutter rects. 3803 // Expect four surrounding gutter rects.
3804 void TestLayerInMiddleOfViewport() { 3804 void TestLayerInMiddleOfViewport() {
3805 gfx::Rect layer_rect(500, 500, 200, 200); 3805 gfx::Rect layer_rect(500, 500, 200, 200);
3806 child_->SetPosition(layer_rect.origin()); 3806 child_->SetPosition(layer_rect.origin());
3807 child_->SetBounds(layer_rect.size()); 3807 child_->SetBounds(layer_rect.size());
3808 child_->SetContentBounds(layer_rect.size()); 3808 child_->SetContentBounds(layer_rect.size());
3809 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3809 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3810 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3810 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3811 3811
3812 LayerTreeHostImpl::FrameData frame; 3812 LayerTreeHostImpl::FrameData frame;
3813 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3813 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3814 ASSERT_EQ(1u, frame.render_passes.size()); 3814 ASSERT_EQ(1u, frame.render_passes.size());
3815 3815
3816 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3816 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list));
3817 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size()); 3817 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size());
3818 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3818 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3819 3819
3820 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 3820 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
3821 host_impl_->DidDrawAllLayers(frame); 3821 host_impl_->DidDrawAllLayers(frame);
3822 } 3822 }
3823 3823
3824 // Expect no gutter rects. 3824 // Expect no gutter rects.
3825 void TestLayerIsLargerThanViewport() { 3825 void TestLayerIsLargerThanViewport() {
3826 gfx::Rect layer_rect(viewport_size_.width() + 10, 3826 gfx::Rect layer_rect(viewport_size_.width() + 10,
3827 viewport_size_.height() + 10); 3827 viewport_size_.height() + 10);
3828 child_->SetPosition(layer_rect.origin()); 3828 child_->SetPosition(layer_rect.origin());
3829 child_->SetBounds(layer_rect.size()); 3829 child_->SetBounds(layer_rect.size());
3830 child_->SetContentBounds(layer_rect.size()); 3830 child_->SetContentBounds(layer_rect.size());
3831 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3831 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3832 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3832 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3833 3833
3834 LayerTreeHostImpl::FrameData frame; 3834 LayerTreeHostImpl::FrameData frame;
3835 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 3835 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
3836 ASSERT_EQ(1u, frame.render_passes.size()); 3836 ASSERT_EQ(1u, frame.render_passes.size());
3837 3837
3838 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3838 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list));
3839 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 3839 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
3840 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3840 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3841 3841
3842 host_impl_->DidDrawAllLayers(frame); 3842 host_impl_->DidDrawAllLayers(frame);
3843 } 3843 }
3844 3844
3845 virtual void DidActivatePendingTree() OVERRIDE { 3845 virtual void DidActivatePendingTree() OVERRIDE {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
4040 root->SetBounds(gfx::Size(10, 10)); 4040 root->SetBounds(gfx::Size(10, 10));
4041 root->SetContentBounds(gfx::Size(10, 10)); 4041 root->SetContentBounds(gfx::Size(10, 10));
4042 root->SetDrawsContent(true); 4042 root->SetDrawsContent(true);
4043 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4043 host_impl_->active_tree()->SetRootLayer(root.Pass());
4044 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); 4044 EXPECT_FALSE(provider->TestContext3d()->reshape_called());
4045 provider->TestContext3d()->clear_reshape_called(); 4045 provider->TestContext3d()->clear_reshape_called();
4046 4046
4047 LayerTreeHostImpl::FrameData frame; 4047 LayerTreeHostImpl::FrameData frame;
4048 host_impl_->SetViewportSize(gfx::Size(10, 10)); 4048 host_impl_->SetViewportSize(gfx::Size(10, 10));
4049 host_impl_->SetDeviceScaleFactor(1.f); 4049 host_impl_->SetDeviceScaleFactor(1.f);
4050 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4050 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4051 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4051 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4052 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4052 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4053 EXPECT_EQ(provider->TestContext3d()->width(), 10); 4053 EXPECT_EQ(provider->TestContext3d()->width(), 10);
4054 EXPECT_EQ(provider->TestContext3d()->height(), 10); 4054 EXPECT_EQ(provider->TestContext3d()->height(), 10);
4055 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); 4055 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
4056 host_impl_->DidDrawAllLayers(frame); 4056 host_impl_->DidDrawAllLayers(frame);
4057 provider->TestContext3d()->clear_reshape_called(); 4057 provider->TestContext3d()->clear_reshape_called();
4058 4058
4059 host_impl_->SetViewportSize(gfx::Size(20, 30)); 4059 host_impl_->SetViewportSize(gfx::Size(20, 30));
4060 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4060 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4061 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4061 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4062 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4062 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4063 EXPECT_EQ(provider->TestContext3d()->width(), 20); 4063 EXPECT_EQ(provider->TestContext3d()->width(), 20);
4064 EXPECT_EQ(provider->TestContext3d()->height(), 30); 4064 EXPECT_EQ(provider->TestContext3d()->height(), 30);
4065 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); 4065 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
4066 host_impl_->DidDrawAllLayers(frame); 4066 host_impl_->DidDrawAllLayers(frame);
4067 provider->TestContext3d()->clear_reshape_called(); 4067 provider->TestContext3d()->clear_reshape_called();
4068 4068
4069 host_impl_->SetDeviceScaleFactor(2.f); 4069 host_impl_->SetDeviceScaleFactor(2.f);
4070 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4070 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4071 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4071 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4072 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 4072 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4073 EXPECT_EQ(provider->TestContext3d()->width(), 20); 4073 EXPECT_EQ(provider->TestContext3d()->width(), 20);
4074 EXPECT_EQ(provider->TestContext3d()->height(), 30); 4074 EXPECT_EQ(provider->TestContext3d()->height(), 30);
4075 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); 4075 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f);
4076 host_impl_->DidDrawAllLayers(frame); 4076 host_impl_->DidDrawAllLayers(frame);
4077 provider->TestContext3d()->clear_reshape_called(); 4077 provider->TestContext3d()->clear_reshape_called();
4078 } 4078 }
4079 4079
4080 // 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
4116 root->SetAnchorPoint(gfx::PointF()); 4116 root->SetAnchorPoint(gfx::PointF());
4117 root->SetBounds(gfx::Size(500, 500)); 4117 root->SetBounds(gfx::Size(500, 500));
4118 root->SetContentBounds(gfx::Size(500, 500)); 4118 root->SetContentBounds(gfx::Size(500, 500));
4119 root->SetDrawsContent(true); 4119 root->SetDrawsContent(true);
4120 root->AddChild(child.Pass()); 4120 root->AddChild(child.Pass());
4121 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); 4121 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass());
4122 4122
4123 LayerTreeHostImpl::FrameData frame; 4123 LayerTreeHostImpl::FrameData frame;
4124 4124
4125 // First frame, the entire screen should get swapped. 4125 // First frame, the entire screen should get swapped.
4126 EXPECT_EQ(DRAW_SUCCESS, 4126 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
4127 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4128 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4127 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4129 layer_tree_host_impl->DidDrawAllLayers(frame); 4128 layer_tree_host_impl->DidDrawAllLayers(frame);
4130 layer_tree_host_impl->SwapBuffers(frame); 4129 layer_tree_host_impl->SwapBuffers(frame);
4131 EXPECT_EQ(TestContextSupport::SWAP, 4130 EXPECT_EQ(TestContextSupport::SWAP,
4132 context_provider->support()->last_swap_type()); 4131 context_provider->support()->last_swap_type());
4133 4132
4134 // Second frame, only the damaged area should get swapped. Damage should be 4133 // Second frame, only the damaged area should get swapped. Damage should be
4135 // the union of old and new child rects. 4134 // the union of old and new child rects.
4136 // expected damage rect: gfx::Rect(26, 28); 4135 // expected damage rect: gfx::Rect(26, 28);
4137 // expected swap rect: vertically flipped, with origin at bottom left corner. 4136 // expected swap rect: vertically flipped, with origin at bottom left corner.
4138 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( 4137 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition(
4139 gfx::PointF()); 4138 gfx::PointF());
4140 EXPECT_EQ(DRAW_SUCCESS, 4139 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
4141 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4142 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4140 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4143 host_impl_->DidDrawAllLayers(frame); 4141 host_impl_->DidDrawAllLayers(frame);
4144 layer_tree_host_impl->SwapBuffers(frame); 4142 layer_tree_host_impl->SwapBuffers(frame);
4145 4143
4146 // Make sure that partial swap is constrained to the viewport dimensions 4144 // Make sure that partial swap is constrained to the viewport dimensions
4147 // expected damage rect: gfx::Rect(500, 500); 4145 // expected damage rect: gfx::Rect(500, 500);
4148 // expected swap rect: flipped damage rect, but also clamped to viewport 4146 // expected swap rect: flipped damage rect, but also clamped to viewport
4149 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, 4147 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP,
4150 context_provider->support()->last_swap_type()); 4148 context_provider->support()->last_swap_type());
4151 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); 4149 gfx::Rect expected_swap_rect(0, 500-28, 26, 28);
4152 EXPECT_EQ(expected_swap_rect.ToString(), 4150 EXPECT_EQ(expected_swap_rect.ToString(),
4153 context_provider->support()-> 4151 context_provider->support()->
4154 last_partial_swap_rect().ToString()); 4152 last_partial_swap_rect().ToString());
4155 4153
4156 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); 4154 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10));
4157 // This will damage everything. 4155 // This will damage everything.
4158 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( 4156 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor(
4159 SK_ColorBLACK); 4157 SK_ColorBLACK);
4160 EXPECT_EQ(DRAW_SUCCESS, 4158 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
4161 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4162 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4159 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4163 host_impl_->DidDrawAllLayers(frame); 4160 host_impl_->DidDrawAllLayers(frame);
4164 layer_tree_host_impl->SwapBuffers(frame); 4161 layer_tree_host_impl->SwapBuffers(frame);
4165 4162
4166 EXPECT_EQ(TestContextSupport::SWAP, 4163 EXPECT_EQ(TestContextSupport::SWAP,
4167 context_provider->support()->last_swap_type()); 4164 context_provider->support()->last_swap_type());
4168 } 4165 }
4169 4166
4170 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 4167 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
4171 scoped_ptr<LayerImpl> root = 4168 scoped_ptr<LayerImpl> root =
4172 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4169 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
4173 scoped_ptr<LayerImpl> child = 4170 scoped_ptr<LayerImpl> child =
4174 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 4171 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
4175 child->SetAnchorPoint(gfx::PointF()); 4172 child->SetAnchorPoint(gfx::PointF());
4176 child->SetBounds(gfx::Size(10, 10)); 4173 child->SetBounds(gfx::Size(10, 10));
4177 child->SetContentBounds(gfx::Size(10, 10)); 4174 child->SetContentBounds(gfx::Size(10, 10));
4178 child->SetDrawsContent(true); 4175 child->SetDrawsContent(true);
4179 root->SetAnchorPoint(gfx::PointF()); 4176 root->SetAnchorPoint(gfx::PointF());
4180 root->SetBounds(gfx::Size(10, 10)); 4177 root->SetBounds(gfx::Size(10, 10));
4181 root->SetContentBounds(gfx::Size(10, 10)); 4178 root->SetContentBounds(gfx::Size(10, 10));
4182 root->SetDrawsContent(true); 4179 root->SetDrawsContent(true);
4183 root->SetForceRenderSurface(true); 4180 root->SetForceRenderSurface(true);
4184 root->AddChild(child.Pass()); 4181 root->AddChild(child.Pass());
4185 4182
4186 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4183 host_impl_->active_tree()->SetRootLayer(root.Pass());
4187 4184
4188 LayerTreeHostImpl::FrameData frame; 4185 LayerTreeHostImpl::FrameData frame;
4189 4186
4190 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4187 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4191 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); 4188 EXPECT_EQ(1u, frame.render_surface_layer_list->size());
4192 EXPECT_EQ(1u, frame.render_passes.size()); 4189 EXPECT_EQ(1u, frame.render_passes.size());
4193 host_impl_->DidDrawAllLayers(frame); 4190 host_impl_->DidDrawAllLayers(frame);
4194 } 4191 }
4195 4192
4196 class FakeLayerWithQuads : public LayerImpl { 4193 class FakeLayerWithQuads : public LayerImpl {
4197 public: 4194 public:
4198 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 4195 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
4199 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id)); 4196 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id));
4200 } 4197 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4317 LayerTreeSettings settings = DefaultSettings(); 4314 LayerTreeSettings settings = DefaultSettings();
4318 settings.partial_swap_enabled = false; 4315 settings.partial_swap_enabled = false;
4319 CreateHostImpl(settings, output_surface.Pass()); 4316 CreateHostImpl(settings, output_surface.Pass());
4320 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 4317 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
4321 4318
4322 // Without partial swap, and no clipping, no scissor is set. 4319 // Without partial swap, and no clipping, no scissor is set.
4323 harness.MustDrawSolidQuad(); 4320 harness.MustDrawSolidQuad();
4324 harness.MustSetNoScissor(); 4321 harness.MustSetNoScissor();
4325 { 4322 {
4326 LayerTreeHostImpl::FrameData frame; 4323 LayerTreeHostImpl::FrameData frame;
4327 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4324 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4328 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4325 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4329 host_impl_->DidDrawAllLayers(frame); 4326 host_impl_->DidDrawAllLayers(frame);
4330 } 4327 }
4331 Mock::VerifyAndClearExpectations(&mock_context); 4328 Mock::VerifyAndClearExpectations(&mock_context);
4332 4329
4333 // Without partial swap, but a layer does clip its subtree, one scissor is 4330 // Without partial swap, but a layer does clip its subtree, one scissor is
4334 // set. 4331 // set.
4335 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); 4332 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true);
4336 harness.MustDrawSolidQuad(); 4333 harness.MustDrawSolidQuad();
4337 harness.MustSetScissor(0, 0, 10, 10); 4334 harness.MustSetScissor(0, 0, 10, 10);
4338 { 4335 {
4339 LayerTreeHostImpl::FrameData frame; 4336 LayerTreeHostImpl::FrameData frame;
4340 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4337 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4341 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4338 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4342 host_impl_->DidDrawAllLayers(frame); 4339 host_impl_->DidDrawAllLayers(frame);
4343 } 4340 }
4344 Mock::VerifyAndClearExpectations(&mock_context); 4341 Mock::VerifyAndClearExpectations(&mock_context);
4345 } 4342 }
4346 4343
4347 TEST_F(LayerTreeHostImplTest, PartialSwap) { 4344 TEST_F(LayerTreeHostImplTest, PartialSwap) {
4348 scoped_ptr<MockContext> context_owned(new MockContext); 4345 scoped_ptr<MockContext> context_owned(new MockContext);
4349 MockContext* mock_context = context_owned.get(); 4346 MockContext* mock_context = context_owned.get();
4350 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 4347 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
4351 context_owned.PassAs<TestWebGraphicsContext3D>())); 4348 context_owned.PassAs<TestWebGraphicsContext3D>()));
4352 MockContextHarness harness(mock_context); 4349 MockContextHarness harness(mock_context);
4353 4350
4354 LayerTreeSettings settings = DefaultSettings(); 4351 LayerTreeSettings settings = DefaultSettings();
4355 settings.partial_swap_enabled = true; 4352 settings.partial_swap_enabled = true;
4356 CreateHostImpl(settings, output_surface.Pass()); 4353 CreateHostImpl(settings, output_surface.Pass());
4357 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 4354 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
4358 4355
4359 // The first frame is not a partially-swapped one. 4356 // The first frame is not a partially-swapped one.
4360 harness.MustSetScissor(0, 0, 10, 10); 4357 harness.MustSetScissor(0, 0, 10, 10);
4361 harness.MustDrawSolidQuad(); 4358 harness.MustDrawSolidQuad();
4362 { 4359 {
4363 LayerTreeHostImpl::FrameData frame; 4360 LayerTreeHostImpl::FrameData frame;
4364 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4361 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4365 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4362 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4366 host_impl_->DidDrawAllLayers(frame); 4363 host_impl_->DidDrawAllLayers(frame);
4367 } 4364 }
4368 Mock::VerifyAndClearExpectations(&mock_context); 4365 Mock::VerifyAndClearExpectations(&mock_context);
4369 4366
4370 // Damage a portion of the frame. 4367 // Damage a portion of the frame.
4371 host_impl_->active_tree()->root_layer()->SetUpdateRect( 4368 host_impl_->active_tree()->root_layer()->SetUpdateRect(
4372 gfx::Rect(0, 0, 2, 3)); 4369 gfx::Rect(0, 0, 2, 3));
4373 4370
4374 // The second frame will be partially-swapped (the y coordinates are flipped). 4371 // The second frame will be partially-swapped (the y coordinates are flipped).
4375 harness.MustSetScissor(0, 7, 2, 3); 4372 harness.MustSetScissor(0, 7, 2, 3);
4376 harness.MustDrawSolidQuad(); 4373 harness.MustDrawSolidQuad();
4377 { 4374 {
4378 LayerTreeHostImpl::FrameData frame; 4375 LayerTreeHostImpl::FrameData frame;
4379 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4376 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4380 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4377 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4381 host_impl_->DidDrawAllLayers(frame); 4378 host_impl_->DidDrawAllLayers(frame);
4382 } 4379 }
4383 Mock::VerifyAndClearExpectations(&mock_context); 4380 Mock::VerifyAndClearExpectations(&mock_context);
4384 } 4381 }
4385 4382
4386 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( 4383 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
4387 bool partial_swap, 4384 bool partial_swap,
4388 LayerTreeHostImplClient* client, 4385 LayerTreeHostImplClient* client,
4389 Proxy* proxy, 4386 Proxy* proxy,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4467 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 4464 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
4468 new TestSharedBitmapManager()); 4465 new TestSharedBitmapManager());
4469 scoped_ptr<LayerTreeHostImpl> my_host_impl = 4466 scoped_ptr<LayerTreeHostImpl> my_host_impl =
4470 SetupLayersForOpacity(true, 4467 SetupLayersForOpacity(true,
4471 this, 4468 this,
4472 &proxy_, 4469 &proxy_,
4473 shared_bitmap_manager.get(), 4470 shared_bitmap_manager.get(),
4474 &stats_instrumentation_); 4471 &stats_instrumentation_);
4475 { 4472 {
4476 LayerTreeHostImpl::FrameData frame; 4473 LayerTreeHostImpl::FrameData frame;
4477 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame, gfx::Rect())); 4474 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
4478 4475
4479 // Verify all quads have been computed 4476 // Verify all quads have been computed
4480 ASSERT_EQ(2U, frame.render_passes.size()); 4477 ASSERT_EQ(2U, frame.render_passes.size());
4481 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 4478 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
4482 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 4479 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
4483 EXPECT_EQ(DrawQuad::SOLID_COLOR, 4480 EXPECT_EQ(DrawQuad::SOLID_COLOR,
4484 frame.render_passes[0]->quad_list[0]->material); 4481 frame.render_passes[0]->quad_list[0]->material);
4485 EXPECT_EQ(DrawQuad::RENDER_PASS, 4482 EXPECT_EQ(DrawQuad::RENDER_PASS,
4486 frame.render_passes[1]->quad_list[0]->material); 4483 frame.render_passes[1]->quad_list[0]->material);
4487 4484
4488 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4485 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4489 my_host_impl->DidDrawAllLayers(frame); 4486 my_host_impl->DidDrawAllLayers(frame);
4490 } 4487 }
4491 } 4488 }
4492 4489
4493 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 4490 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
4494 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 4491 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
4495 new TestSharedBitmapManager()); 4492 new TestSharedBitmapManager());
4496 scoped_ptr<LayerTreeHostImpl> my_host_impl = 4493 scoped_ptr<LayerTreeHostImpl> my_host_impl =
4497 SetupLayersForOpacity(false, 4494 SetupLayersForOpacity(false,
4498 this, 4495 this,
4499 &proxy_, 4496 &proxy_,
4500 shared_bitmap_manager.get(), 4497 shared_bitmap_manager.get(),
4501 &stats_instrumentation_); 4498 &stats_instrumentation_);
4502 { 4499 {
4503 LayerTreeHostImpl::FrameData frame; 4500 LayerTreeHostImpl::FrameData frame;
4504 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame, gfx::Rect())); 4501 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
4505 4502
4506 // Verify all quads have been computed 4503 // Verify all quads have been computed
4507 ASSERT_EQ(2U, frame.render_passes.size()); 4504 ASSERT_EQ(2U, frame.render_passes.size());
4508 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 4505 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
4509 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 4506 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
4510 EXPECT_EQ(DrawQuad::SOLID_COLOR, 4507 EXPECT_EQ(DrawQuad::SOLID_COLOR,
4511 frame.render_passes[0]->quad_list[0]->material); 4508 frame.render_passes[0]->quad_list[0]->material);
4512 EXPECT_EQ(DrawQuad::RENDER_PASS, 4509 EXPECT_EQ(DrawQuad::RENDER_PASS,
4513 frame.render_passes[1]->quad_list[0]->material); 4510 frame.render_passes[1]->quad_list[0]->material);
4514 4511
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4550 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); 4547 io_surface_layer->SetContentBounds(gfx::Size(10, 10));
4551 io_surface_layer->SetDrawsContent(true); 4548 io_surface_layer->SetDrawsContent(true);
4552 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); 4549 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
4553 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); 4550 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>());
4554 4551
4555 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 4552 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
4556 4553
4557 EXPECT_EQ(0u, context3d->NumTextures()); 4554 EXPECT_EQ(0u, context3d->NumTextures());
4558 4555
4559 LayerTreeHostImpl::FrameData frame; 4556 LayerTreeHostImpl::FrameData frame;
4560 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4557 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4561 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4558 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4562 host_impl_->DidDrawAllLayers(frame); 4559 host_impl_->DidDrawAllLayers(frame);
4563 host_impl_->SwapBuffers(frame); 4560 host_impl_->SwapBuffers(frame);
4564 4561
4565 EXPECT_GT(context3d->NumTextures(), 0u); 4562 EXPECT_GT(context3d->NumTextures(), 0u);
4566 4563
4567 // Kill the layer tree. 4564 // Kill the layer tree.
4568 host_impl_->active_tree()->SetRootLayer( 4565 host_impl_->active_tree()->SetRootLayer(
4569 LayerImpl::Create(host_impl_->active_tree(), 100)); 4566 LayerImpl::Create(host_impl_->active_tree(), 100));
4570 // There should be no textures left in use after. 4567 // There should be no textures left in use after.
(...skipping 24 matching lines...) Expand all
4595 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 4592 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
4596 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); 4593 host_impl_->active_tree()->set_background_color(SK_ColorWHITE);
4597 4594
4598 // Verify one quad is drawn when transparent background set is not set. 4595 // Verify one quad is drawn when transparent background set is not set.
4599 host_impl_->active_tree()->set_has_transparent_background(false); 4596 host_impl_->active_tree()->set_has_transparent_background(false);
4600 EXPECT_CALL(*mock_context, useProgram(_)) 4597 EXPECT_CALL(*mock_context, useProgram(_))
4601 .Times(1); 4598 .Times(1);
4602 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) 4599 EXPECT_CALL(*mock_context, drawElements(_, _, _, _))
4603 .Times(1); 4600 .Times(1);
4604 LayerTreeHostImpl::FrameData frame; 4601 LayerTreeHostImpl::FrameData frame;
4605 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4602 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4606 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4603 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4607 host_impl_->DidDrawAllLayers(frame); 4604 host_impl_->DidDrawAllLayers(frame);
4608 Mock::VerifyAndClearExpectations(&mock_context); 4605 Mock::VerifyAndClearExpectations(&mock_context);
4609 4606
4610 // Verify no quads are drawn when transparent background is set. 4607 // Verify no quads are drawn when transparent background is set.
4611 host_impl_->active_tree()->set_has_transparent_background(true); 4608 host_impl_->active_tree()->set_has_transparent_background(true);
4612 host_impl_->SetFullRootLayerDamage(); 4609 host_impl_->SetFullRootLayerDamage();
4613 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4610 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4614 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4611 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4615 host_impl_->DidDrawAllLayers(frame); 4612 host_impl_->DidDrawAllLayers(frame);
4616 Mock::VerifyAndClearExpectations(&mock_context); 4613 Mock::VerifyAndClearExpectations(&mock_context);
4617 } 4614 }
4618 4615
4619 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { 4616 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) {
4620 set_reduce_memory_result(false); 4617 set_reduce_memory_result(false);
4621 4618
4622 // If changing the memory limit wouldn't result in changing what was 4619 // If changing the memory limit wouldn't result in changing what was
4623 // committed, then no commit should be requested. 4620 // committed, then no commit should be requested.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4660 : public LayerTreeHostImplTest { 4657 : public LayerTreeHostImplTest {
4661 protected: 4658 protected:
4662 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { 4659 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
4663 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>(); 4660 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
4664 } 4661 }
4665 4662
4666 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) { 4663 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) {
4667 bool expect_to_draw = !expected_damage.IsEmpty(); 4664 bool expect_to_draw = !expected_damage.IsEmpty();
4668 4665
4669 LayerTreeHostImpl::FrameData frame; 4666 LayerTreeHostImpl::FrameData frame;
4670 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4667 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4671 4668
4672 if (!expect_to_draw) { 4669 if (!expect_to_draw) {
4673 // With no damage, we don't draw, and no quads are created. 4670 // With no damage, we don't draw, and no quads are created.
4674 ASSERT_EQ(0u, frame.render_passes.size()); 4671 ASSERT_EQ(0u, frame.render_passes.size());
4675 } else { 4672 } else {
4676 ASSERT_EQ(1u, frame.render_passes.size()); 4673 ASSERT_EQ(1u, frame.render_passes.size());
4677 4674
4678 // Verify the damage rect for the root render pass. 4675 // Verify the damage rect for the root render pass.
4679 const RenderPass* root_render_pass = frame.render_passes.back(); 4676 const RenderPass* root_render_pass = frame.render_passes.back();
4680 EXPECT_RECT_EQ(expected_damage, root_render_pass->damage_rect); 4677 EXPECT_RECT_EQ(expected_damage, root_render_pass->damage_rect);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
4819 mask_layer->SetDrawsContent(true); 4816 mask_layer->SetDrawsContent(true);
4820 4817
4821 4818
4822 // Check that the tree scaling is correctly taken into account for the mask, 4819 // Check that the tree scaling is correctly taken into account for the mask,
4823 // that should fully map onto the quad. 4820 // that should fully map onto the quad.
4824 float device_scale_factor = 1.f; 4821 float device_scale_factor = 1.f;
4825 host_impl_->SetViewportSize(root_size); 4822 host_impl_->SetViewportSize(root_size);
4826 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4823 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4827 { 4824 {
4828 LayerTreeHostImpl::FrameData frame; 4825 LayerTreeHostImpl::FrameData frame;
4829 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4826 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4830 4827
4831 ASSERT_EQ(1u, frame.render_passes.size()); 4828 ASSERT_EQ(1u, frame.render_passes.size());
4832 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4829 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4833 ASSERT_EQ(DrawQuad::RENDER_PASS, 4830 ASSERT_EQ(DrawQuad::RENDER_PASS,
4834 frame.render_passes[0]->quad_list[0]->material); 4831 frame.render_passes[0]->quad_list[0]->material);
4835 const RenderPassDrawQuad* render_pass_quad = 4832 const RenderPassDrawQuad* render_pass_quad =
4836 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4833 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4837 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4834 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4838 render_pass_quad->rect.ToString()); 4835 render_pass_quad->rect.ToString());
4839 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4836 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4840 render_pass_quad->mask_uv_rect.ToString()); 4837 render_pass_quad->mask_uv_rect.ToString());
4841 4838
4842 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4839 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4843 host_impl_->DidDrawAllLayers(frame); 4840 host_impl_->DidDrawAllLayers(frame);
4844 } 4841 }
4845 4842
4846 4843
4847 // Applying a DSF should change the render surface size, but won't affect 4844 // Applying a DSF should change the render surface size, but won't affect
4848 // which part of the mask is used. 4845 // which part of the mask is used.
4849 device_scale_factor = 2.f; 4846 device_scale_factor = 2.f;
4850 gfx::Size device_viewport = 4847 gfx::Size device_viewport =
4851 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4848 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4852 host_impl_->SetViewportSize(device_viewport); 4849 host_impl_->SetViewportSize(device_viewport);
4853 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4850 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4854 host_impl_->active_tree()->set_needs_update_draw_properties(); 4851 host_impl_->active_tree()->set_needs_update_draw_properties();
4855 { 4852 {
4856 LayerTreeHostImpl::FrameData frame; 4853 LayerTreeHostImpl::FrameData frame;
4857 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4854 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4858 4855
4859 ASSERT_EQ(1u, frame.render_passes.size()); 4856 ASSERT_EQ(1u, frame.render_passes.size());
4860 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4857 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4861 ASSERT_EQ(DrawQuad::RENDER_PASS, 4858 ASSERT_EQ(DrawQuad::RENDER_PASS,
4862 frame.render_passes[0]->quad_list[0]->material); 4859 frame.render_passes[0]->quad_list[0]->material);
4863 const RenderPassDrawQuad* render_pass_quad = 4860 const RenderPassDrawQuad* render_pass_quad =
4864 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4861 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4865 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4862 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4866 render_pass_quad->rect.ToString()); 4863 render_pass_quad->rect.ToString());
4867 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4864 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4868 render_pass_quad->mask_uv_rect.ToString()); 4865 render_pass_quad->mask_uv_rect.ToString());
4869 4866
4870 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4867 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4871 host_impl_->DidDrawAllLayers(frame); 4868 host_impl_->DidDrawAllLayers(frame);
4872 } 4869 }
4873 4870
4874 4871
4875 // Applying an equivalent content scale on the content layer and the mask 4872 // Applying an equivalent content scale on the content layer and the mask
4876 // should still result in the same part of the mask being used. 4873 // should still result in the same part of the mask being used.
4877 gfx::Size content_bounds = 4874 gfx::Size content_bounds =
4878 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, 4875 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size,
4879 device_scale_factor)); 4876 device_scale_factor));
4880 content_layer->SetContentBounds(content_bounds); 4877 content_layer->SetContentBounds(content_bounds);
4881 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4878 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4882 mask_layer->SetContentBounds(content_bounds); 4879 mask_layer->SetContentBounds(content_bounds);
4883 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4880 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4884 host_impl_->active_tree()->set_needs_update_draw_properties(); 4881 host_impl_->active_tree()->set_needs_update_draw_properties();
4885 { 4882 {
4886 LayerTreeHostImpl::FrameData frame; 4883 LayerTreeHostImpl::FrameData frame;
4887 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4884 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4888 4885
4889 ASSERT_EQ(1u, frame.render_passes.size()); 4886 ASSERT_EQ(1u, frame.render_passes.size());
4890 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4887 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4891 ASSERT_EQ(DrawQuad::RENDER_PASS, 4888 ASSERT_EQ(DrawQuad::RENDER_PASS,
4892 frame.render_passes[0]->quad_list[0]->material); 4889 frame.render_passes[0]->quad_list[0]->material);
4893 const RenderPassDrawQuad* render_pass_quad = 4890 const RenderPassDrawQuad* render_pass_quad =
4894 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4891 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4895 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4892 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4896 render_pass_quad->rect.ToString()); 4893 render_pass_quad->rect.ToString());
4897 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4894 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
4940 mask_layer->SetPosition(gfx::PointF()); 4937 mask_layer->SetPosition(gfx::PointF());
4941 mask_layer->SetAnchorPoint(gfx::PointF()); 4938 mask_layer->SetAnchorPoint(gfx::PointF());
4942 mask_layer->SetDrawsContent(true); 4939 mask_layer->SetDrawsContent(true);
4943 4940
4944 // Check that the mask fills the surface. 4941 // Check that the mask fills the surface.
4945 float device_scale_factor = 1.f; 4942 float device_scale_factor = 1.f;
4946 host_impl_->SetViewportSize(root_size); 4943 host_impl_->SetViewportSize(root_size);
4947 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4944 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4948 { 4945 {
4949 LayerTreeHostImpl::FrameData frame; 4946 LayerTreeHostImpl::FrameData frame;
4950 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4947 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4951 4948
4952 ASSERT_EQ(1u, frame.render_passes.size()); 4949 ASSERT_EQ(1u, frame.render_passes.size());
4953 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4950 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4954 ASSERT_EQ(DrawQuad::RENDER_PASS, 4951 ASSERT_EQ(DrawQuad::RENDER_PASS,
4955 frame.render_passes[0]->quad_list[0]->material); 4952 frame.render_passes[0]->quad_list[0]->material);
4956 const RenderPassDrawQuad* render_pass_quad = 4953 const RenderPassDrawQuad* render_pass_quad =
4957 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4954 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4958 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4955 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
4959 render_pass_quad->rect.ToString()); 4956 render_pass_quad->rect.ToString());
4960 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4957 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4961 render_pass_quad->mask_uv_rect.ToString()); 4958 render_pass_quad->mask_uv_rect.ToString());
4962 4959
4963 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4960 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4964 host_impl_->DidDrawAllLayers(frame); 4961 host_impl_->DidDrawAllLayers(frame);
4965 } 4962 }
4966 4963
4967 // Applying a DSF should change the render surface size, but won't affect 4964 // Applying a DSF should change the render surface size, but won't affect
4968 // which part of the mask is used. 4965 // which part of the mask is used.
4969 device_scale_factor = 2.f; 4966 device_scale_factor = 2.f;
4970 gfx::Size device_viewport = 4967 gfx::Size device_viewport =
4971 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4968 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4972 host_impl_->SetViewportSize(device_viewport); 4969 host_impl_->SetViewportSize(device_viewport);
4973 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4970 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4974 host_impl_->active_tree()->set_needs_update_draw_properties(); 4971 host_impl_->active_tree()->set_needs_update_draw_properties();
4975 { 4972 {
4976 LayerTreeHostImpl::FrameData frame; 4973 LayerTreeHostImpl::FrameData frame;
4977 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 4974 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
4978 4975
4979 ASSERT_EQ(1u, frame.render_passes.size()); 4976 ASSERT_EQ(1u, frame.render_passes.size());
4980 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4977 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4981 ASSERT_EQ(DrawQuad::RENDER_PASS, 4978 ASSERT_EQ(DrawQuad::RENDER_PASS,
4982 frame.render_passes[0]->quad_list[0]->material); 4979 frame.render_passes[0]->quad_list[0]->material);
4983 const RenderPassDrawQuad* render_pass_quad = 4980 const RenderPassDrawQuad* render_pass_quad =
4984 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4981 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4985 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4982 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4986 render_pass_quad->rect.ToString()); 4983 render_pass_quad->rect.ToString());
4987 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4984 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4988 render_pass_quad->mask_uv_rect.ToString()); 4985 render_pass_quad->mask_uv_rect.ToString());
4989 4986
4990 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4987 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4991 host_impl_->DidDrawAllLayers(frame); 4988 host_impl_->DidDrawAllLayers(frame);
4992 } 4989 }
4993 4990
4994 // Applying an equivalent content scale on the content layer and the mask 4991 // Applying an equivalent content scale on the content layer and the mask
4995 // should still result in the same part of the mask being used. 4992 // should still result in the same part of the mask being used.
4996 gfx::Size layer_size_large = 4993 gfx::Size layer_size_large =
4997 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 4994 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
4998 content_layer->SetContentBounds(layer_size_large); 4995 content_layer->SetContentBounds(layer_size_large);
4999 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4996 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5000 gfx::Size mask_size_large = 4997 gfx::Size mask_size_large =
5001 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 4998 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
5002 mask_layer->SetContentBounds(mask_size_large); 4999 mask_layer->SetContentBounds(mask_size_large);
5003 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5000 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5004 host_impl_->active_tree()->set_needs_update_draw_properties(); 5001 host_impl_->active_tree()->set_needs_update_draw_properties();
5005 { 5002 {
5006 LayerTreeHostImpl::FrameData frame; 5003 LayerTreeHostImpl::FrameData frame;
5007 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5004 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5008 5005
5009 ASSERT_EQ(1u, frame.render_passes.size()); 5006 ASSERT_EQ(1u, frame.render_passes.size());
5010 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5007 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5011 ASSERT_EQ(DrawQuad::RENDER_PASS, 5008 ASSERT_EQ(DrawQuad::RENDER_PASS,
5012 frame.render_passes[0]->quad_list[0]->material); 5009 frame.render_passes[0]->quad_list[0]->material);
5013 const RenderPassDrawQuad* render_pass_quad = 5010 const RenderPassDrawQuad* render_pass_quad =
5014 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5011 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5015 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5012 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5016 render_pass_quad->rect.ToString()); 5013 render_pass_quad->rect.ToString());
5017 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5014 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5018 render_pass_quad->mask_uv_rect.ToString()); 5015 render_pass_quad->mask_uv_rect.ToString());
5019 5016
5020 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5017 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5021 host_impl_->DidDrawAllLayers(frame); 5018 host_impl_->DidDrawAllLayers(frame);
5022 } 5019 }
5023 5020
5024 // Applying a different contents scale to the mask layer means it will have 5021 // Applying a different contents scale to the mask layer means it will have
5025 // a larger texture, but it should use the same tex coords to cover the 5022 // a larger texture, but it should use the same tex coords to cover the
5026 // layer it masks. 5023 // layer it masks.
5027 mask_layer->SetContentBounds(mask_size); 5024 mask_layer->SetContentBounds(mask_size);
5028 mask_layer->SetContentsScale(1.f, 1.f); 5025 mask_layer->SetContentsScale(1.f, 1.f);
5029 host_impl_->active_tree()->set_needs_update_draw_properties(); 5026 host_impl_->active_tree()->set_needs_update_draw_properties();
5030 { 5027 {
5031 LayerTreeHostImpl::FrameData frame; 5028 LayerTreeHostImpl::FrameData frame;
5032 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5029 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5033 5030
5034 ASSERT_EQ(1u, frame.render_passes.size()); 5031 ASSERT_EQ(1u, frame.render_passes.size());
5035 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5032 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5036 ASSERT_EQ(DrawQuad::RENDER_PASS, 5033 ASSERT_EQ(DrawQuad::RENDER_PASS,
5037 frame.render_passes[0]->quad_list[0]->material); 5034 frame.render_passes[0]->quad_list[0]->material);
5038 const RenderPassDrawQuad* render_pass_quad = 5035 const RenderPassDrawQuad* render_pass_quad =
5039 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5036 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5040 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5037 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5041 render_pass_quad->rect.ToString()); 5038 render_pass_quad->rect.ToString());
5042 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5039 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
5090 mask_layer->SetPosition(gfx::PointF()); 5087 mask_layer->SetPosition(gfx::PointF());
5091 mask_layer->SetAnchorPoint(gfx::PointF()); 5088 mask_layer->SetAnchorPoint(gfx::PointF());
5092 mask_layer->SetDrawsContent(true); 5089 mask_layer->SetDrawsContent(true);
5093 5090
5094 // Check that the mask fills the surface. 5091 // Check that the mask fills the surface.
5095 float device_scale_factor = 1.f; 5092 float device_scale_factor = 1.f;
5096 host_impl_->SetViewportSize(root_size); 5093 host_impl_->SetViewportSize(root_size);
5097 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5094 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5098 { 5095 {
5099 LayerTreeHostImpl::FrameData frame; 5096 LayerTreeHostImpl::FrameData frame;
5100 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5097 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5101 5098
5102 ASSERT_EQ(1u, frame.render_passes.size()); 5099 ASSERT_EQ(1u, frame.render_passes.size());
5103 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5100 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5104 ASSERT_EQ(DrawQuad::RENDER_PASS, 5101 ASSERT_EQ(DrawQuad::RENDER_PASS,
5105 frame.render_passes[0]->quad_list[1]->material); 5102 frame.render_passes[0]->quad_list[1]->material);
5106 const RenderPassDrawQuad* replica_quad = 5103 const RenderPassDrawQuad* replica_quad =
5107 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5104 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5108 EXPECT_TRUE(replica_quad->is_replica); 5105 EXPECT_TRUE(replica_quad->is_replica);
5109 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 5106 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
5110 replica_quad->rect.ToString()); 5107 replica_quad->rect.ToString());
5111 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5108 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5112 replica_quad->mask_uv_rect.ToString()); 5109 replica_quad->mask_uv_rect.ToString());
5113 5110
5114 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5111 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5115 host_impl_->DidDrawAllLayers(frame); 5112 host_impl_->DidDrawAllLayers(frame);
5116 } 5113 }
5117 5114
5118 // Applying a DSF should change the render surface size, but won't affect 5115 // Applying a DSF should change the render surface size, but won't affect
5119 // which part of the mask is used. 5116 // which part of the mask is used.
5120 device_scale_factor = 2.f; 5117 device_scale_factor = 2.f;
5121 gfx::Size device_viewport = 5118 gfx::Size device_viewport =
5122 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 5119 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
5123 host_impl_->SetViewportSize(device_viewport); 5120 host_impl_->SetViewportSize(device_viewport);
5124 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5121 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5125 host_impl_->active_tree()->set_needs_update_draw_properties(); 5122 host_impl_->active_tree()->set_needs_update_draw_properties();
5126 { 5123 {
5127 LayerTreeHostImpl::FrameData frame; 5124 LayerTreeHostImpl::FrameData frame;
5128 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5125 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5129 5126
5130 ASSERT_EQ(1u, frame.render_passes.size()); 5127 ASSERT_EQ(1u, frame.render_passes.size());
5131 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5128 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5132 ASSERT_EQ(DrawQuad::RENDER_PASS, 5129 ASSERT_EQ(DrawQuad::RENDER_PASS,
5133 frame.render_passes[0]->quad_list[1]->material); 5130 frame.render_passes[0]->quad_list[1]->material);
5134 const RenderPassDrawQuad* replica_quad = 5131 const RenderPassDrawQuad* replica_quad =
5135 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5132 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5136 EXPECT_TRUE(replica_quad->is_replica); 5133 EXPECT_TRUE(replica_quad->is_replica);
5137 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5134 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5138 replica_quad->rect.ToString()); 5135 replica_quad->rect.ToString());
(...skipping 10 matching lines...) Expand all
5149 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 5146 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
5150 content_layer->SetContentBounds(layer_size_large); 5147 content_layer->SetContentBounds(layer_size_large);
5151 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5148 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5152 gfx::Size mask_size_large = 5149 gfx::Size mask_size_large =
5153 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 5150 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
5154 mask_layer->SetContentBounds(mask_size_large); 5151 mask_layer->SetContentBounds(mask_size_large);
5155 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5152 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5156 host_impl_->active_tree()->set_needs_update_draw_properties(); 5153 host_impl_->active_tree()->set_needs_update_draw_properties();
5157 { 5154 {
5158 LayerTreeHostImpl::FrameData frame; 5155 LayerTreeHostImpl::FrameData frame;
5159 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5156 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5160 5157
5161 ASSERT_EQ(1u, frame.render_passes.size()); 5158 ASSERT_EQ(1u, frame.render_passes.size());
5162 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5159 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5163 ASSERT_EQ(DrawQuad::RENDER_PASS, 5160 ASSERT_EQ(DrawQuad::RENDER_PASS,
5164 frame.render_passes[0]->quad_list[1]->material); 5161 frame.render_passes[0]->quad_list[1]->material);
5165 const RenderPassDrawQuad* replica_quad = 5162 const RenderPassDrawQuad* replica_quad =
5166 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5163 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5167 EXPECT_TRUE(replica_quad->is_replica); 5164 EXPECT_TRUE(replica_quad->is_replica);
5168 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5165 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5169 replica_quad->rect.ToString()); 5166 replica_quad->rect.ToString());
5170 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5167 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5171 replica_quad->mask_uv_rect.ToString()); 5168 replica_quad->mask_uv_rect.ToString());
5172 5169
5173 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5170 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5174 host_impl_->DidDrawAllLayers(frame); 5171 host_impl_->DidDrawAllLayers(frame);
5175 } 5172 }
5176 5173
5177 // Applying a different contents scale to the mask layer means it will have 5174 // Applying a different contents scale to the mask layer means it will have
5178 // a larger texture, but it should use the same tex coords to cover the 5175 // a larger texture, but it should use the same tex coords to cover the
5179 // layer it masks. 5176 // layer it masks.
5180 mask_layer->SetContentBounds(mask_size); 5177 mask_layer->SetContentBounds(mask_size);
5181 mask_layer->SetContentsScale(1.f, 1.f); 5178 mask_layer->SetContentsScale(1.f, 1.f);
5182 host_impl_->active_tree()->set_needs_update_draw_properties(); 5179 host_impl_->active_tree()->set_needs_update_draw_properties();
5183 { 5180 {
5184 LayerTreeHostImpl::FrameData frame; 5181 LayerTreeHostImpl::FrameData frame;
5185 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5182 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5186 5183
5187 ASSERT_EQ(1u, frame.render_passes.size()); 5184 ASSERT_EQ(1u, frame.render_passes.size());
5188 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5185 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5189 ASSERT_EQ(DrawQuad::RENDER_PASS, 5186 ASSERT_EQ(DrawQuad::RENDER_PASS,
5190 frame.render_passes[0]->quad_list[1]->material); 5187 frame.render_passes[0]->quad_list[1]->material);
5191 const RenderPassDrawQuad* replica_quad = 5188 const RenderPassDrawQuad* replica_quad =
5192 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5189 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5193 EXPECT_TRUE(replica_quad->is_replica); 5190 EXPECT_TRUE(replica_quad->is_replica);
5194 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5191 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5195 replica_quad->rect.ToString()); 5192 replica_quad->rect.ToString());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5255 mask_layer->SetContentBounds(mask_size); 5252 mask_layer->SetContentBounds(mask_size);
5256 mask_layer->SetPosition(gfx::PointF()); 5253 mask_layer->SetPosition(gfx::PointF());
5257 mask_layer->SetAnchorPoint(gfx::PointF()); 5254 mask_layer->SetAnchorPoint(gfx::PointF());
5258 mask_layer->SetDrawsContent(true); 5255 mask_layer->SetDrawsContent(true);
5259 5256
5260 float device_scale_factor = 1.f; 5257 float device_scale_factor = 1.f;
5261 host_impl_->SetViewportSize(root_size); 5258 host_impl_->SetViewportSize(root_size);
5262 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5259 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5263 { 5260 {
5264 LayerTreeHostImpl::FrameData frame; 5261 LayerTreeHostImpl::FrameData frame;
5265 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5262 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5266 5263
5267 ASSERT_EQ(1u, frame.render_passes.size()); 5264 ASSERT_EQ(1u, frame.render_passes.size());
5268 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5265 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5269 5266
5270 // The surface is 100x50. 5267 // The surface is 100x50.
5271 ASSERT_EQ(DrawQuad::RENDER_PASS, 5268 ASSERT_EQ(DrawQuad::RENDER_PASS,
5272 frame.render_passes[0]->quad_list[0]->material); 5269 frame.render_passes[0]->quad_list[0]->material);
5273 const RenderPassDrawQuad* render_pass_quad = 5270 const RenderPassDrawQuad* render_pass_quad =
5274 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5271 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5275 EXPECT_FALSE(render_pass_quad->is_replica); 5272 EXPECT_FALSE(render_pass_quad->is_replica);
(...skipping 13 matching lines...) Expand all
5289 5286
5290 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5287 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5291 host_impl_->DidDrawAllLayers(frame); 5288 host_impl_->DidDrawAllLayers(frame);
5292 } 5289 }
5293 5290
5294 // Move the child to (-50, 0) instead. Now the mask should be moved to still 5291 // Move the child to (-50, 0) instead. Now the mask should be moved to still
5295 // cover the layer being replicated. 5292 // cover the layer being replicated.
5296 content_child_layer->SetPosition(gfx::Point(-50, 0)); 5293 content_child_layer->SetPosition(gfx::Point(-50, 0));
5297 { 5294 {
5298 LayerTreeHostImpl::FrameData frame; 5295 LayerTreeHostImpl::FrameData frame;
5299 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5296 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5300 5297
5301 ASSERT_EQ(1u, frame.render_passes.size()); 5298 ASSERT_EQ(1u, frame.render_passes.size());
5302 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5299 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5303 5300
5304 // The surface is 100x50 with its origin at (-50, 0). 5301 // The surface is 100x50 with its origin at (-50, 0).
5305 ASSERT_EQ(DrawQuad::RENDER_PASS, 5302 ASSERT_EQ(DrawQuad::RENDER_PASS,
5306 frame.render_passes[0]->quad_list[0]->material); 5303 frame.render_passes[0]->quad_list[0]->material);
5307 const RenderPassDrawQuad* render_pass_quad = 5304 const RenderPassDrawQuad* render_pass_quad =
5308 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5305 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5309 EXPECT_FALSE(render_pass_quad->is_replica); 5306 EXPECT_FALSE(render_pass_quad->is_replica);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 mask_layer->SetContentBounds(mask_size); 5385 mask_layer->SetContentBounds(mask_size);
5389 mask_layer->SetPosition(gfx::PointF()); 5386 mask_layer->SetPosition(gfx::PointF());
5390 mask_layer->SetAnchorPoint(gfx::PointF()); 5387 mask_layer->SetAnchorPoint(gfx::PointF());
5391 mask_layer->SetDrawsContent(true); 5388 mask_layer->SetDrawsContent(true);
5392 5389
5393 float device_scale_factor = 1.f; 5390 float device_scale_factor = 1.f;
5394 host_impl_->SetViewportSize(root_size); 5391 host_impl_->SetViewportSize(root_size);
5395 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5392 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5396 { 5393 {
5397 LayerTreeHostImpl::FrameData frame; 5394 LayerTreeHostImpl::FrameData frame;
5398 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5395 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5399 5396
5400 ASSERT_EQ(1u, frame.render_passes.size()); 5397 ASSERT_EQ(1u, frame.render_passes.size());
5401 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5398 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5402 5399
5403 // The surface is clipped to 10x20. 5400 // The surface is clipped to 10x20.
5404 ASSERT_EQ(DrawQuad::RENDER_PASS, 5401 ASSERT_EQ(DrawQuad::RENDER_PASS,
5405 frame.render_passes[0]->quad_list[0]->material); 5402 frame.render_passes[0]->quad_list[0]->material);
5406 const RenderPassDrawQuad* render_pass_quad = 5403 const RenderPassDrawQuad* render_pass_quad =
5407 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5404 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5408 EXPECT_FALSE(render_pass_quad->is_replica); 5405 EXPECT_FALSE(render_pass_quad->is_replica);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5469 gfx::Vector2d scroll_offset(100000, 0); 5466 gfx::Vector2d scroll_offset(100000, 0);
5470 scrolling_layer->SetScrollClipLayer(root->id()); 5467 scrolling_layer->SetScrollClipLayer(root->id());
5471 scrolling_layer->SetScrollOffset(scroll_offset); 5468 scrolling_layer->SetScrollOffset(scroll_offset);
5472 5469
5473 host_impl_->ActivatePendingTree(); 5470 host_impl_->ActivatePendingTree();
5474 5471
5475 host_impl_->active_tree()->UpdateDrawProperties(); 5472 host_impl_->active_tree()->UpdateDrawProperties();
5476 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); 5473 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
5477 5474
5478 LayerTreeHostImpl::FrameData frame; 5475 LayerTreeHostImpl::FrameData frame;
5479 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5476 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5480 5477
5481 ASSERT_EQ(1u, frame.render_passes.size()); 5478 ASSERT_EQ(1u, frame.render_passes.size());
5482 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 5479 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
5483 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; 5480 const DrawQuad* quad = frame.render_passes[0]->quad_list[0];
5484 5481
5485 float edge[24]; 5482 float edge[24];
5486 gfx::QuadF device_layer_quad; 5483 gfx::QuadF device_layer_quad;
5487 bool antialiased = 5484 bool antialiased =
5488 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( 5485 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing(
5489 quad->quadTransform(), quad, &device_layer_quad, edge); 5486 quad->quadTransform(), quad, &device_layer_quad, edge);
(...skipping 13 matching lines...) Expand all
5503 swap_buffers_complete_++; 5500 swap_buffers_complete_++;
5504 } 5501 }
5505 5502
5506 int swap_buffers_complete_; 5503 int swap_buffers_complete_;
5507 }; 5504 };
5508 5505
5509 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { 5506 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) {
5510 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 5507 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
5511 { 5508 {
5512 LayerTreeHostImpl::FrameData frame; 5509 LayerTreeHostImpl::FrameData frame;
5513 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5510 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5514 host_impl_->DrawLayers(&frame, base::TimeTicks()); 5511 host_impl_->DrawLayers(&frame, base::TimeTicks());
5515 host_impl_->DidDrawAllLayers(frame); 5512 host_impl_->DidDrawAllLayers(frame);
5516 } 5513 }
5517 CompositorFrameAck ack; 5514 CompositorFrameAck ack;
5518 host_impl_->ReclaimResources(&ack); 5515 host_impl_->ReclaimResources(&ack);
5519 host_impl_->DidSwapBuffersComplete(); 5516 host_impl_->DidSwapBuffersComplete();
5520 EXPECT_EQ(swap_buffers_complete_, 1); 5517 EXPECT_EQ(swap_buffers_complete_, 1);
5521 } 5518 }
5522 5519
5523 class CountingSoftwareDevice : public SoftwareOutputDevice { 5520 class CountingSoftwareDevice : public SoftwareOutputDevice {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5583 FakeVideoFrameProvider provider; 5580 FakeVideoFrameProvider provider;
5584 scoped_ptr<VideoLayerImpl> video_layer = 5581 scoped_ptr<VideoLayerImpl> video_layer =
5585 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); 5582 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
5586 video_layer->SetBounds(gfx::Size(10, 10)); 5583 video_layer->SetBounds(gfx::Size(10, 10));
5587 video_layer->SetContentBounds(gfx::Size(10, 10)); 5584 video_layer->SetContentBounds(gfx::Size(10, 10));
5588 video_layer->SetDrawsContent(true); 5585 video_layer->SetDrawsContent(true);
5589 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); 5586 root_layer->AddChild(video_layer.PassAs<LayerImpl>());
5590 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); 5587 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
5591 5588
5592 LayerTreeHostImpl::FrameData frame; 5589 LayerTreeHostImpl::FrameData frame;
5593 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5590 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5594 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5591 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5595 host_impl_->DidDrawAllLayers(frame); 5592 host_impl_->DidDrawAllLayers(frame);
5596 5593
5597 EXPECT_EQ(1u, frame.will_draw_layers.size()); 5594 EXPECT_EQ(1u, frame.will_draw_layers.size());
5598 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); 5595 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]);
5599 } 5596 }
5600 5597
5601 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { 5598 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest {
5602 protected: 5599 protected:
5603 virtual void SetUp() OVERRIDE { 5600 virtual void SetUp() OVERRIDE {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
5848 5845
5849 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 5846 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
5850 5847
5851 ScopedPtrVector<CopyOutputRequest> requests; 5848 ScopedPtrVector<CopyOutputRequest> requests;
5852 requests.push_back(CopyOutputRequest::CreateRequest( 5849 requests.push_back(CopyOutputRequest::CreateRequest(
5853 base::Bind(&ShutdownReleasesContext_Callback))); 5850 base::Bind(&ShutdownReleasesContext_Callback)));
5854 5851
5855 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); 5852 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests);
5856 5853
5857 LayerTreeHostImpl::FrameData frame; 5854 LayerTreeHostImpl::FrameData frame;
5858 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 5855 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
5859 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5856 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5860 host_impl_->DidDrawAllLayers(frame); 5857 host_impl_->DidDrawAllLayers(frame);
5861 5858
5862 // The CopyOutputResult's callback has a ref on the ContextProvider and a 5859 // The CopyOutputResult's callback has a ref on the ContextProvider and a
5863 // texture in a texture mailbox. 5860 // texture in a texture mailbox.
5864 EXPECT_FALSE(context_provider->HasOneRef()); 5861 EXPECT_FALSE(context_provider->HasOneRef());
5865 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 5862 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
5866 5863
5867 host_impl_.reset(); 5864 host_impl_.reset();
5868 5865
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
6123 ui::LatencyInfo latency_info; 6120 ui::LatencyInfo latency_info;
6124 latency_info.AddLatencyNumber( 6121 latency_info.AddLatencyNumber(
6125 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); 6122 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0);
6126 scoped_ptr<SwapPromise> swap_promise( 6123 scoped_ptr<SwapPromise> swap_promise(
6127 new LatencyInfoSwapPromise(latency_info)); 6124 new LatencyInfoSwapPromise(latency_info));
6128 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); 6125 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
6129 host_impl_->SetNeedsRedraw(); 6126 host_impl_->SetNeedsRedraw();
6130 6127
6131 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 6128 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
6132 LayerTreeHostImpl::FrameData frame; 6129 LayerTreeHostImpl::FrameData frame;
6133 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect())); 6130 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6134 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 6131 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
6135 host_impl_->DidDrawAllLayers(frame); 6132 host_impl_->DidDrawAllLayers(frame);
6136 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); 6133 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
6137 6134
6138 const std::vector<ui::LatencyInfo>& metadata_latency_after = 6135 const std::vector<ui::LatencyInfo>& metadata_latency_after =
6139 fake_output_surface->last_sent_frame().metadata.latency_info; 6136 fake_output_surface->last_sent_frame().metadata.latency_info;
6140 EXPECT_EQ(1u, metadata_latency_after.size()); 6137 EXPECT_EQ(1u, metadata_latency_after.size());
6141 EXPECT_TRUE(metadata_latency_after[0].FindLatency( 6138 EXPECT_TRUE(metadata_latency_after[0].FindLatency(
6142 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); 6139 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL));
6143 } 6140 }
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
6478 FakePictureLayerImpl* active_mask_content = 6475 FakePictureLayerImpl* active_mask_content =
6479 static_cast<FakePictureLayerImpl*>( 6476 static_cast<FakePictureLayerImpl*>(
6480 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); 6477 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer());
6481 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); 6478 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority();
6482 6479
6483 ASSERT_TRUE(!r2.IsEmpty()); 6480 ASSERT_TRUE(!r2.IsEmpty());
6484 } 6481 }
6485 6482
6486 } // namespace 6483 } // namespace
6487 } // namespace cc 6484 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_pixeltest_readback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698