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

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

Issue 246753008: cc: Unify use of DidSwapBuffers() and did_request_swap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Introduce HasSentDrawRequestThisFrame() Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 layer->SetScrollClipLayer(clip_layer->id()); 287 layer->SetScrollClipLayer(clip_layer->id());
288 layer->SetDrawsContent(true); 288 layer->SetDrawsContent(true);
289 layer->SetBounds(size); 289 layer->SetBounds(size);
290 layer->SetContentBounds(size); 290 layer->SetContentBounds(size);
291 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2)); 291 clip_layer->SetBounds(gfx::Size(size.width() / 2, size.height() / 2));
292 return layer.Pass(); 292 return layer.Pass();
293 } 293 }
294 294
295 void DrawFrame() { 295 void DrawFrame() {
296 LayerTreeHostImpl::FrameData frame; 296 LayerTreeHostImpl::FrameData frame;
297 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 297 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
298 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
299 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 298 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
300 host_impl_->DidDrawAllLayers(frame); 299 host_impl_->DidDrawAllLayers(frame);
301 } 300 }
302 301
303 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); 302 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor);
304 void pinch_zoom_pan_viewport_test(float device_scale_factor); 303 void pinch_zoom_pan_viewport_test(float device_scale_factor);
305 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); 304 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor);
306 void pinch_zoom_pan_viewport_and_scroll_boundary_test( 305 void pinch_zoom_pan_viewport_and_scroll_boundary_test(
307 float device_scale_factor); 306 float device_scale_factor);
308 307
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1634 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1636 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( 1635 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(
1637 host_impl_->active_tree()->root_layer()); 1636 host_impl_->active_tree()->root_layer());
1638 1637
1639 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); 1638 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2));
1640 DidDrawCheckLayer* layer = 1639 DidDrawCheckLayer* layer =
1641 static_cast<DidDrawCheckLayer*>(root->children()[0]); 1640 static_cast<DidDrawCheckLayer*>(root->children()[0]);
1642 1641
1643 { 1642 {
1644 LayerTreeHostImpl::FrameData frame; 1643 LayerTreeHostImpl::FrameData frame;
1645 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1644 EXPECT_EQ(DRAW_SUCCESS,
1646 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1645 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1647 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1646 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1648 host_impl_->DidDrawAllLayers(frame); 1647 host_impl_->DidDrawAllLayers(frame);
1649 1648
1650 EXPECT_TRUE(layer->will_draw_called()); 1649 EXPECT_TRUE(layer->will_draw_called());
1651 EXPECT_TRUE(layer->append_quads_called()); 1650 EXPECT_TRUE(layer->append_quads_called());
1652 EXPECT_TRUE(layer->did_draw_called()); 1651 EXPECT_TRUE(layer->did_draw_called());
1653 } 1652 }
1654 1653
1655 { 1654 {
1656 LayerTreeHostImpl::FrameData frame; 1655 LayerTreeHostImpl::FrameData frame;
1657 1656
1658 layer->set_will_draw_returns_false(); 1657 layer->set_will_draw_returns_false();
1659 layer->ClearDidDrawCheck(); 1658 layer->ClearDidDrawCheck();
1660 1659
1661 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1660 EXPECT_EQ(DRAW_SUCCESS,
1662 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10))); 1661 host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
1663 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1662 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1664 host_impl_->DidDrawAllLayers(frame); 1663 host_impl_->DidDrawAllLayers(frame);
1665 1664
1666 EXPECT_TRUE(layer->will_draw_called()); 1665 EXPECT_TRUE(layer->will_draw_called());
1667 EXPECT_FALSE(layer->append_quads_called()); 1666 EXPECT_FALSE(layer->append_quads_called());
1668 EXPECT_FALSE(layer->did_draw_called()); 1667 EXPECT_FALSE(layer->did_draw_called());
1669 } 1668 }
1670 } 1669 }
1671 1670
(...skipping 12 matching lines...) Expand all
1684 // Ensure visible_content_rect for layer is empty. 1683 // Ensure visible_content_rect for layer is empty.
1685 layer->SetPosition(gfx::PointF(100.f, 100.f)); 1684 layer->SetPosition(gfx::PointF(100.f, 100.f));
1686 layer->SetBounds(gfx::Size(10, 10)); 1685 layer->SetBounds(gfx::Size(10, 10));
1687 layer->SetContentBounds(gfx::Size(10, 10)); 1686 layer->SetContentBounds(gfx::Size(10, 10));
1688 1687
1689 LayerTreeHostImpl::FrameData frame; 1688 LayerTreeHostImpl::FrameData frame;
1690 1689
1691 EXPECT_FALSE(layer->will_draw_called()); 1690 EXPECT_FALSE(layer->will_draw_called());
1692 EXPECT_FALSE(layer->did_draw_called()); 1691 EXPECT_FALSE(layer->did_draw_called());
1693 1692
1694 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1693 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1695 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1696 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1694 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1697 host_impl_->DidDrawAllLayers(frame); 1695 host_impl_->DidDrawAllLayers(frame);
1698 1696
1699 EXPECT_FALSE(layer->will_draw_called()); 1697 EXPECT_FALSE(layer->will_draw_called());
1700 EXPECT_FALSE(layer->did_draw_called()); 1698 EXPECT_FALSE(layer->did_draw_called());
1701 1699
1702 EXPECT_TRUE(layer->visible_content_rect().IsEmpty()); 1700 EXPECT_TRUE(layer->visible_content_rect().IsEmpty());
1703 1701
1704 // Ensure visible_content_rect for layer is not empty 1702 // Ensure visible_content_rect for layer is not empty
1705 layer->SetPosition(gfx::PointF()); 1703 layer->SetPosition(gfx::PointF());
1706 1704
1707 EXPECT_FALSE(layer->will_draw_called()); 1705 EXPECT_FALSE(layer->will_draw_called());
1708 EXPECT_FALSE(layer->did_draw_called()); 1706 EXPECT_FALSE(layer->did_draw_called());
1709 1707
1710 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1708 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1711 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1712 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1709 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1713 host_impl_->DidDrawAllLayers(frame); 1710 host_impl_->DidDrawAllLayers(frame);
1714 1711
1715 EXPECT_TRUE(layer->will_draw_called()); 1712 EXPECT_TRUE(layer->will_draw_called());
1716 EXPECT_TRUE(layer->did_draw_called()); 1713 EXPECT_TRUE(layer->did_draw_called());
1717 1714
1718 EXPECT_FALSE(layer->visible_content_rect().IsEmpty()); 1715 EXPECT_FALSE(layer->visible_content_rect().IsEmpty());
1719 } 1716 }
1720 1717
1721 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { 1718 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) {
(...skipping 18 matching lines...) Expand all
1740 top_layer->SetContentBounds(big_size); 1737 top_layer->SetContentBounds(big_size);
1741 top_layer->SetContentsOpaque(true); 1738 top_layer->SetContentsOpaque(true);
1742 1739
1743 LayerTreeHostImpl::FrameData frame; 1740 LayerTreeHostImpl::FrameData frame;
1744 1741
1745 EXPECT_FALSE(occluded_layer->will_draw_called()); 1742 EXPECT_FALSE(occluded_layer->will_draw_called());
1746 EXPECT_FALSE(occluded_layer->did_draw_called()); 1743 EXPECT_FALSE(occluded_layer->did_draw_called());
1747 EXPECT_FALSE(top_layer->will_draw_called()); 1744 EXPECT_FALSE(top_layer->will_draw_called());
1748 EXPECT_FALSE(top_layer->did_draw_called()); 1745 EXPECT_FALSE(top_layer->did_draw_called());
1749 1746
1750 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1747 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1751 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1752 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1748 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1753 host_impl_->DidDrawAllLayers(frame); 1749 host_impl_->DidDrawAllLayers(frame);
1754 1750
1755 EXPECT_FALSE(occluded_layer->will_draw_called()); 1751 EXPECT_FALSE(occluded_layer->will_draw_called());
1756 EXPECT_FALSE(occluded_layer->did_draw_called()); 1752 EXPECT_FALSE(occluded_layer->did_draw_called());
1757 EXPECT_TRUE(top_layer->will_draw_called()); 1753 EXPECT_TRUE(top_layer->will_draw_called());
1758 EXPECT_TRUE(top_layer->did_draw_called()); 1754 EXPECT_TRUE(top_layer->did_draw_called());
1759 } 1755 }
1760 1756
1761 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { 1757 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) {
(...skipping 11 matching lines...) Expand all
1773 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); 1769 static_cast<DidDrawCheckLayer*>(layer1->children()[0]);
1774 1770
1775 layer1->SetOpacity(0.3f); 1771 layer1->SetOpacity(0.3f);
1776 layer1->SetShouldFlattenTransform(true); 1772 layer1->SetShouldFlattenTransform(true);
1777 1773
1778 EXPECT_FALSE(root->did_draw_called()); 1774 EXPECT_FALSE(root->did_draw_called());
1779 EXPECT_FALSE(layer1->did_draw_called()); 1775 EXPECT_FALSE(layer1->did_draw_called());
1780 EXPECT_FALSE(layer2->did_draw_called()); 1776 EXPECT_FALSE(layer2->did_draw_called());
1781 1777
1782 LayerTreeHostImpl::FrameData frame; 1778 LayerTreeHostImpl::FrameData frame;
1783 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1779 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1784 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1785 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1780 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1786 host_impl_->DidDrawAllLayers(frame); 1781 host_impl_->DidDrawAllLayers(frame);
1787 1782
1788 EXPECT_TRUE(root->did_draw_called()); 1783 EXPECT_TRUE(root->did_draw_called());
1789 EXPECT_TRUE(layer1->did_draw_called()); 1784 EXPECT_TRUE(layer1->did_draw_called());
1790 EXPECT_TRUE(layer2->did_draw_called()); 1785 EXPECT_TRUE(layer2->did_draw_called());
1791 1786
1792 EXPECT_NE(root->render_surface(), layer1->render_surface()); 1787 EXPECT_NE(root->render_surface(), layer1->render_surface());
1793 EXPECT_TRUE(!!layer1->render_surface()); 1788 EXPECT_TRUE(!!layer1->render_surface());
1794 } 1789 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 root->AddChild( 1854 root->AddChild(
1860 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1855 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1861 2, 1856 2,
1862 tile_missing, 1857 tile_missing,
1863 skips_draw, 1858 skips_draw,
1864 is_animating, 1859 is_animating,
1865 host_impl_->resource_provider())); 1860 host_impl_->resource_provider()));
1866 1861
1867 LayerTreeHostImpl::FrameData frame; 1862 LayerTreeHostImpl::FrameData frame;
1868 1863
1869 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1864 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1870 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1871 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1865 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1872 host_impl_->DidDrawAllLayers(frame); 1866 host_impl_->DidDrawAllLayers(frame);
1873 } 1867 }
1874 1868
1875 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { 1869 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) {
1876 host_impl_->active_tree()->SetRootLayer( 1870 host_impl_->active_tree()->SetRootLayer(
1877 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1871 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1878 DidDrawCheckLayer* root = 1872 DidDrawCheckLayer* root =
1879 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1873 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1880 bool tile_missing = false; 1874 bool tile_missing = false;
1881 bool skips_draw = false; 1875 bool skips_draw = false;
1882 bool is_animating = true; 1876 bool is_animating = true;
1883 root->AddChild( 1877 root->AddChild(
1884 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1878 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1885 2, 1879 2,
1886 tile_missing, 1880 tile_missing,
1887 skips_draw, 1881 skips_draw,
1888 is_animating, 1882 is_animating,
1889 host_impl_->resource_provider())); 1883 host_impl_->resource_provider()));
1890 1884
1891 LayerTreeHostImpl::FrameData frame; 1885 LayerTreeHostImpl::FrameData frame;
1892 1886
1893 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1887 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1894 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1895 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1888 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1896 host_impl_->DidDrawAllLayers(frame); 1889 host_impl_->DidDrawAllLayers(frame);
1897 } 1890 }
1898 1891
1899 TEST_F(LayerTreeHostImplTest, 1892 TEST_F(LayerTreeHostImplTest,
1900 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) { 1893 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) {
1901 // When a texture is missing and we're not animating, we draw as usual with 1894 // When a texture is missing and we're not animating, we draw as usual with
1902 // checkerboarding. 1895 // checkerboarding.
1903 host_impl_->active_tree()->SetRootLayer( 1896 host_impl_->active_tree()->SetRootLayer(
1904 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1897 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1905 DidDrawCheckLayer* root = 1898 DidDrawCheckLayer* root =
1906 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1899 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1907 1900
1908 bool tile_missing = true; 1901 bool tile_missing = true;
1909 bool skips_draw = false; 1902 bool skips_draw = false;
1910 bool is_animating = false; 1903 bool is_animating = false;
1911 root->AddChild( 1904 root->AddChild(
1912 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1905 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1913 4, 1906 4,
1914 tile_missing, 1907 tile_missing,
1915 skips_draw, 1908 skips_draw,
1916 is_animating, 1909 is_animating,
1917 host_impl_->resource_provider())); 1910 host_impl_->resource_provider()));
1918 LayerTreeHostImpl::FrameData frame; 1911 LayerTreeHostImpl::FrameData frame;
1919 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 1912 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1920 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1921 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1913 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1922 host_impl_->DidDrawAllLayers(frame); 1914 host_impl_->DidDrawAllLayers(frame);
1923 } 1915 }
1924 1916
1925 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { 1917 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) {
1926 // When a texture is missing and we're animating, we don't want to draw 1918 // When a texture is missing and we're animating, we don't want to draw
1927 // anything. 1919 // anything.
1928 host_impl_->active_tree()->SetRootLayer( 1920 host_impl_->active_tree()->SetRootLayer(
1929 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 1921 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
1930 DidDrawCheckLayer* root = 1922 DidDrawCheckLayer* root =
1931 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1923 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1932 bool tile_missing = true; 1924 bool tile_missing = true;
1933 bool skips_draw = false; 1925 bool skips_draw = false;
1934 bool is_animating = true; 1926 bool is_animating = true;
1935 root->AddChild( 1927 root->AddChild(
1936 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1928 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1937 6, 1929 6,
1938 tile_missing, 1930 tile_missing,
1939 skips_draw, 1931 skips_draw,
1940 is_animating, 1932 is_animating,
1941 host_impl_->resource_provider())); 1933 host_impl_->resource_provider()));
1942 LayerTreeHostImpl::FrameData frame; 1934 LayerTreeHostImpl::FrameData frame;
1943 EXPECT_EQ(DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, 1935 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
1944 host_impl_->PrepareToDraw(&frame, gfx::Rect())); 1936 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
1945 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1937 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1946 host_impl_->DidDrawAllLayers(frame); 1938 host_impl_->DidDrawAllLayers(frame);
1947 } 1939 }
1948 1940
1949 TEST_F(LayerTreeHostImplTest, 1941 TEST_F(LayerTreeHostImplTest,
1950 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) { 1942 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) {
1951 // When the layer skips draw and we're animating, we still draw the frame. 1943 // When the layer skips draw and we're animating, we still draw the frame.
1952 host_impl_->active_tree()->SetRootLayer( 1944 host_impl_->active_tree()->SetRootLayer(
1953 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 1945 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
1954 DidDrawCheckLayer* root = 1946 DidDrawCheckLayer* root =
1955 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1947 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1956 bool tile_missing = false; 1948 bool tile_missing = false;
1957 bool skips_draw = true; 1949 bool skips_draw = true;
1958 bool is_animating = true; 1950 bool is_animating = true;
1959 root->AddChild( 1951 root->AddChild(
1960 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1952 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1961 8, 1953 8,
1962 tile_missing, 1954 tile_missing,
1963 skips_draw, 1955 skips_draw,
1964 is_animating, 1956 is_animating,
1965 host_impl_->resource_provider())); 1957 host_impl_->resource_provider()));
1966 LayerTreeHostImpl::FrameData frame; 1958 LayerTreeHostImpl::FrameData frame;
1967 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), 1959 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), DRAW_SUCCESS);
1968 DrawSwapReadbackResult::DRAW_SUCCESS);
1969 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1960 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1970 host_impl_->DidDrawAllLayers(frame); 1961 host_impl_->DidDrawAllLayers(frame);
1971 } 1962 }
1972 1963
1973 TEST_F(LayerTreeHostImplTest, 1964 TEST_F(LayerTreeHostImplTest,
1974 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) { 1965 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) {
1975 // When the layer skips draw and we're animating, we still draw the frame. 1966 // When the layer skips draw and we're animating, we still draw the frame.
1976 host_impl_->active_tree()->SetRootLayer( 1967 host_impl_->active_tree()->SetRootLayer(
1977 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 1968 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
1978 DidDrawCheckLayer* root = 1969 DidDrawCheckLayer* root =
1979 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1970 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1980 bool tile_missing = false; 1971 bool tile_missing = false;
1981 bool skips_draw = false; 1972 bool skips_draw = false;
1982 bool is_animating = false; 1973 bool is_animating = false;
1983 root->AddChild( 1974 root->AddChild(
1984 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1975 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1985 8, 1976 8,
1986 tile_missing, 1977 tile_missing,
1987 skips_draw, 1978 skips_draw,
1988 is_animating, 1979 is_animating,
1989 host_impl_->resource_provider())); 1980 host_impl_->resource_provider()));
1990 host_impl_->active_tree()->SetRequiresHighResToDraw(); 1981 host_impl_->active_tree()->SetRequiresHighResToDraw();
1991 LayerTreeHostImpl::FrameData frame; 1982 LayerTreeHostImpl::FrameData frame;
1992 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), 1983 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), DRAW_SUCCESS);
1993 DrawSwapReadbackResult::DRAW_SUCCESS);
1994 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1984 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1995 host_impl_->DidDrawAllLayers(frame); 1985 host_impl_->DidDrawAllLayers(frame);
1996 } 1986 }
1997 1987
1998 TEST_F(LayerTreeHostImplTest, 1988 TEST_F(LayerTreeHostImplTest,
1999 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) { 1989 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) {
2000 // When the layer skips draw and we're animating, we still draw the frame. 1990 // When the layer skips draw and we're animating, we still draw the frame.
2001 host_impl_->active_tree()->SetRootLayer( 1991 host_impl_->active_tree()->SetRootLayer(
2002 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 1992 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2003 DidDrawCheckLayer* root = 1993 DidDrawCheckLayer* root =
2004 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1994 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2005 bool tile_missing = true; 1995 bool tile_missing = true;
2006 bool skips_draw = false; 1996 bool skips_draw = false;
2007 bool is_animating = false; 1997 bool is_animating = false;
2008 root->AddChild( 1998 root->AddChild(
2009 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1999 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2010 8, 2000 8,
2011 tile_missing, 2001 tile_missing,
2012 skips_draw, 2002 skips_draw,
2013 is_animating, 2003 is_animating,
2014 host_impl_->resource_provider())); 2004 host_impl_->resource_provider()));
2015 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2005 host_impl_->active_tree()->SetRequiresHighResToDraw();
2016 LayerTreeHostImpl::FrameData frame; 2006 LayerTreeHostImpl::FrameData frame;
2017 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()), 2007 EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()),
2018 DrawSwapReadbackResult::DRAW_ABORTED_MISSING_HIGH_RES_CONTENT); 2008 DRAW_ABORTED_MISSING_HIGH_RES_CONTENT);
2019 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2009 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2020 host_impl_->DidDrawAllLayers(frame); 2010 host_impl_->DidDrawAllLayers(frame);
2021 } 2011 }
2022 2012
2023 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 2013 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
2024 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2014 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2025 root->SetScrollClipLayer(Layer::INVALID_ID); 2015 root->SetScrollClipLayer(Layer::INVALID_ID);
2026 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2016 host_impl_->active_tree()->SetRootLayer(root.Pass());
2027 DrawFrame(); 2017 DrawFrame();
2028 2018
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2460 EXPECT_EQ(1.f, scroll->contents_scale_x()); 2450 EXPECT_EQ(1.f, scroll->contents_scale_x());
2461 EXPECT_EQ(1.f, scroll->contents_scale_y()); 2451 EXPECT_EQ(1.f, scroll->contents_scale_y());
2462 EXPECT_EQ(1.f, child->contents_scale_x()); 2452 EXPECT_EQ(1.f, child->contents_scale_x());
2463 EXPECT_EQ(1.f, child->contents_scale_y()); 2453 EXPECT_EQ(1.f, child->contents_scale_y());
2464 EXPECT_EQ(1.f, grand_child->contents_scale_x()); 2454 EXPECT_EQ(1.f, grand_child->contents_scale_x());
2465 EXPECT_EQ(1.f, grand_child->contents_scale_y()); 2455 EXPECT_EQ(1.f, grand_child->contents_scale_y());
2466 2456
2467 // Make sure all the layers are drawn with the page scale delta applied, i.e., 2457 // Make sure all the layers are drawn with the page scale delta applied, i.e.,
2468 // the page scale delta on the root layer is applied hierarchically. 2458 // the page scale delta on the root layer is applied hierarchically.
2469 LayerTreeHostImpl::FrameData frame; 2459 LayerTreeHostImpl::FrameData frame;
2470 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 2460 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2471 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
2472 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2461 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2473 host_impl_->DidDrawAllLayers(frame); 2462 host_impl_->DidDrawAllLayers(frame);
2474 2463
2475 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0)); 2464 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(0, 0));
2476 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1)); 2465 EXPECT_EQ(1.f, root->draw_transform().matrix().getDouble(1, 1));
2477 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0)); 2466 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(0, 0));
2478 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1)); 2467 EXPECT_EQ(new_page_scale, scroll->draw_transform().matrix().getDouble(1, 1));
2479 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0)); 2468 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(0, 0));
2480 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1)); 2469 EXPECT_EQ(new_page_scale, child->draw_transform().matrix().getDouble(1, 1));
2481 EXPECT_EQ(new_page_scale, 2470 EXPECT_EQ(new_page_scale,
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
3449 BlendStateCheckLayer* layer1 = 3438 BlendStateCheckLayer* layer1 =
3450 static_cast<BlendStateCheckLayer*>(root->children()[0]); 3439 static_cast<BlendStateCheckLayer*>(root->children()[0]);
3451 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 3440 layer1->SetPosition(gfx::PointF(2.f, 2.f));
3452 3441
3453 LayerTreeHostImpl::FrameData frame; 3442 LayerTreeHostImpl::FrameData frame;
3454 3443
3455 // Opaque layer, drawn without blending. 3444 // Opaque layer, drawn without blending.
3456 layer1->SetContentsOpaque(true); 3445 layer1->SetContentsOpaque(true);
3457 layer1->SetExpectation(false, false); 3446 layer1->SetExpectation(false, false);
3458 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3447 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3459 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3448 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3460 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3461 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3449 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3462 EXPECT_TRUE(layer1->quads_appended()); 3450 EXPECT_TRUE(layer1->quads_appended());
3463 host_impl_->DidDrawAllLayers(frame); 3451 host_impl_->DidDrawAllLayers(frame);
3464 3452
3465 // Layer with translucent content and painting, so drawn with blending. 3453 // Layer with translucent content and painting, so drawn with blending.
3466 layer1->SetContentsOpaque(false); 3454 layer1->SetContentsOpaque(false);
3467 layer1->SetExpectation(true, false); 3455 layer1->SetExpectation(true, false);
3468 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3456 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3469 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3457 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3470 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3471 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3458 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3472 EXPECT_TRUE(layer1->quads_appended()); 3459 EXPECT_TRUE(layer1->quads_appended());
3473 host_impl_->DidDrawAllLayers(frame); 3460 host_impl_->DidDrawAllLayers(frame);
3474 3461
3475 // Layer with translucent opacity, drawn with blending. 3462 // Layer with translucent opacity, drawn with blending.
3476 layer1->SetContentsOpaque(true); 3463 layer1->SetContentsOpaque(true);
3477 layer1->SetOpacity(0.5f); 3464 layer1->SetOpacity(0.5f);
3478 layer1->SetExpectation(true, false); 3465 layer1->SetExpectation(true, false);
3479 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3466 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3480 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3467 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3481 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3482 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3468 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3483 EXPECT_TRUE(layer1->quads_appended()); 3469 EXPECT_TRUE(layer1->quads_appended());
3484 host_impl_->DidDrawAllLayers(frame); 3470 host_impl_->DidDrawAllLayers(frame);
3485 3471
3486 // Layer with translucent opacity and painting, drawn with blending. 3472 // Layer with translucent opacity and painting, drawn with blending.
3487 layer1->SetContentsOpaque(true); 3473 layer1->SetContentsOpaque(true);
3488 layer1->SetOpacity(0.5f); 3474 layer1->SetOpacity(0.5f);
3489 layer1->SetExpectation(true, false); 3475 layer1->SetExpectation(true, false);
3490 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3476 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3491 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3477 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3492 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3493 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3478 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3494 EXPECT_TRUE(layer1->quads_appended()); 3479 EXPECT_TRUE(layer1->quads_appended());
3495 host_impl_->DidDrawAllLayers(frame); 3480 host_impl_->DidDrawAllLayers(frame);
3496 3481
3497 layer1->AddChild( 3482 layer1->AddChild(
3498 BlendStateCheckLayer::Create(host_impl_->active_tree(), 3483 BlendStateCheckLayer::Create(host_impl_->active_tree(),
3499 3, 3484 3,
3500 host_impl_->resource_provider())); 3485 host_impl_->resource_provider()));
3501 BlendStateCheckLayer* layer2 = 3486 BlendStateCheckLayer* layer2 =
3502 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); 3487 static_cast<BlendStateCheckLayer*>(layer1->children()[0]);
3503 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 3488 layer2->SetPosition(gfx::PointF(4.f, 4.f));
3504 3489
3505 // 2 opaque layers, drawn without blending. 3490 // 2 opaque layers, drawn without blending.
3506 layer1->SetContentsOpaque(true); 3491 layer1->SetContentsOpaque(true);
3507 layer1->SetOpacity(1.f); 3492 layer1->SetOpacity(1.f);
3508 layer1->SetExpectation(false, false); 3493 layer1->SetExpectation(false, false);
3509 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3494 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3510 layer2->SetContentsOpaque(true); 3495 layer2->SetContentsOpaque(true);
3511 layer2->SetOpacity(1.f); 3496 layer2->SetOpacity(1.f);
3512 layer2->SetExpectation(false, false); 3497 layer2->SetExpectation(false, false);
3513 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3498 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3514 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3499 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3515 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3516 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3500 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3517 EXPECT_TRUE(layer1->quads_appended()); 3501 EXPECT_TRUE(layer1->quads_appended());
3518 EXPECT_TRUE(layer2->quads_appended()); 3502 EXPECT_TRUE(layer2->quads_appended());
3519 host_impl_->DidDrawAllLayers(frame); 3503 host_impl_->DidDrawAllLayers(frame);
3520 3504
3521 // Parent layer with translucent content, drawn with blending. 3505 // Parent layer with translucent content, drawn with blending.
3522 // Child layer with opaque content, drawn without blending. 3506 // Child layer with opaque content, drawn without blending.
3523 layer1->SetContentsOpaque(false); 3507 layer1->SetContentsOpaque(false);
3524 layer1->SetExpectation(true, false); 3508 layer1->SetExpectation(true, false);
3525 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3509 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3526 layer2->SetExpectation(false, false); 3510 layer2->SetExpectation(false, false);
3527 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3511 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3528 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3512 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3529 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3530 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3513 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3531 EXPECT_TRUE(layer1->quads_appended()); 3514 EXPECT_TRUE(layer1->quads_appended());
3532 EXPECT_TRUE(layer2->quads_appended()); 3515 EXPECT_TRUE(layer2->quads_appended());
3533 host_impl_->DidDrawAllLayers(frame); 3516 host_impl_->DidDrawAllLayers(frame);
3534 3517
3535 // Parent layer with translucent content but opaque painting, drawn without 3518 // Parent layer with translucent content but opaque painting, drawn without
3536 // blending. 3519 // blending.
3537 // Child layer with opaque content, drawn without blending. 3520 // Child layer with opaque content, drawn without blending.
3538 layer1->SetContentsOpaque(true); 3521 layer1->SetContentsOpaque(true);
3539 layer1->SetExpectation(false, false); 3522 layer1->SetExpectation(false, false);
3540 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3523 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3541 layer2->SetExpectation(false, false); 3524 layer2->SetExpectation(false, false);
3542 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3525 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3543 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3526 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3544 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3545 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3527 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3546 EXPECT_TRUE(layer1->quads_appended()); 3528 EXPECT_TRUE(layer1->quads_appended());
3547 EXPECT_TRUE(layer2->quads_appended()); 3529 EXPECT_TRUE(layer2->quads_appended());
3548 host_impl_->DidDrawAllLayers(frame); 3530 host_impl_->DidDrawAllLayers(frame);
3549 3531
3550 // Parent layer with translucent opacity and opaque content. Since it has a 3532 // Parent layer with translucent opacity and opaque content. Since it has a
3551 // drawing child, it's drawn to a render surface which carries the opacity, 3533 // drawing child, it's drawn to a render surface which carries the opacity,
3552 // so it's itself drawn without blending. 3534 // so it's itself drawn without blending.
3553 // Child layer with opaque content, drawn without blending (parent surface 3535 // Child layer with opaque content, drawn without blending (parent surface
3554 // carries the inherited opacity). 3536 // carries the inherited opacity).
3555 layer1->SetContentsOpaque(true); 3537 layer1->SetContentsOpaque(true);
3556 layer1->SetOpacity(0.5f); 3538 layer1->SetOpacity(0.5f);
3557 layer1->SetExpectation(false, true); 3539 layer1->SetExpectation(false, true);
3558 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3540 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3559 layer2->SetExpectation(false, false); 3541 layer2->SetExpectation(false, false);
3560 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3542 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3561 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3543 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3562 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3563 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3544 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3564 EXPECT_TRUE(layer1->quads_appended()); 3545 EXPECT_TRUE(layer1->quads_appended());
3565 EXPECT_TRUE(layer2->quads_appended()); 3546 EXPECT_TRUE(layer2->quads_appended());
3566 host_impl_->DidDrawAllLayers(frame); 3547 host_impl_->DidDrawAllLayers(frame);
3567 3548
3568 // Draw again, but with child non-opaque, to make sure 3549 // Draw again, but with child non-opaque, to make sure
3569 // layer1 not culled. 3550 // layer1 not culled.
3570 layer1->SetContentsOpaque(true); 3551 layer1->SetContentsOpaque(true);
3571 layer1->SetOpacity(1.f); 3552 layer1->SetOpacity(1.f);
3572 layer1->SetExpectation(false, false); 3553 layer1->SetExpectation(false, false);
3573 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3554 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3574 layer2->SetContentsOpaque(true); 3555 layer2->SetContentsOpaque(true);
3575 layer2->SetOpacity(0.5f); 3556 layer2->SetOpacity(0.5f);
3576 layer2->SetExpectation(true, false); 3557 layer2->SetExpectation(true, false);
3577 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3558 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3578 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3559 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3579 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3580 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3560 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3581 EXPECT_TRUE(layer1->quads_appended()); 3561 EXPECT_TRUE(layer1->quads_appended());
3582 EXPECT_TRUE(layer2->quads_appended()); 3562 EXPECT_TRUE(layer2->quads_appended());
3583 host_impl_->DidDrawAllLayers(frame); 3563 host_impl_->DidDrawAllLayers(frame);
3584 3564
3585 // A second way of making the child non-opaque. 3565 // A second way of making the child non-opaque.
3586 layer1->SetContentsOpaque(true); 3566 layer1->SetContentsOpaque(true);
3587 layer1->SetOpacity(1.f); 3567 layer1->SetOpacity(1.f);
3588 layer1->SetExpectation(false, false); 3568 layer1->SetExpectation(false, false);
3589 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3569 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3590 layer2->SetContentsOpaque(false); 3570 layer2->SetContentsOpaque(false);
3591 layer2->SetOpacity(1.f); 3571 layer2->SetOpacity(1.f);
3592 layer2->SetExpectation(true, false); 3572 layer2->SetExpectation(true, false);
3593 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3573 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3594 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3574 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3595 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3596 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3575 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3597 EXPECT_TRUE(layer1->quads_appended()); 3576 EXPECT_TRUE(layer1->quads_appended());
3598 EXPECT_TRUE(layer2->quads_appended()); 3577 EXPECT_TRUE(layer2->quads_appended());
3599 host_impl_->DidDrawAllLayers(frame); 3578 host_impl_->DidDrawAllLayers(frame);
3600 3579
3601 // And when the layer says its not opaque but is painted opaque, it is not 3580 // And when the layer says its not opaque but is painted opaque, it is not
3602 // blended. 3581 // blended.
3603 layer1->SetContentsOpaque(true); 3582 layer1->SetContentsOpaque(true);
3604 layer1->SetOpacity(1.f); 3583 layer1->SetOpacity(1.f);
3605 layer1->SetExpectation(false, false); 3584 layer1->SetExpectation(false, false);
3606 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3585 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3607 layer2->SetContentsOpaque(true); 3586 layer2->SetContentsOpaque(true);
3608 layer2->SetOpacity(1.f); 3587 layer2->SetOpacity(1.f);
3609 layer2->SetExpectation(false, false); 3588 layer2->SetExpectation(false, false);
3610 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3589 layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3611 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3590 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3612 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3613 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3591 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3614 EXPECT_TRUE(layer1->quads_appended()); 3592 EXPECT_TRUE(layer1->quads_appended());
3615 EXPECT_TRUE(layer2->quads_appended()); 3593 EXPECT_TRUE(layer2->quads_appended());
3616 host_impl_->DidDrawAllLayers(frame); 3594 host_impl_->DidDrawAllLayers(frame);
3617 3595
3618 // Layer with partially opaque contents, drawn with blending. 3596 // Layer with partially opaque contents, drawn with blending.
3619 layer1->SetContentsOpaque(false); 3597 layer1->SetContentsOpaque(false);
3620 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3598 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3621 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 3599 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
3622 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3600 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3623 layer1->SetExpectation(true, false); 3601 layer1->SetExpectation(true, false);
3624 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3602 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3625 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3603 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3626 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3627 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3604 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3628 EXPECT_TRUE(layer1->quads_appended()); 3605 EXPECT_TRUE(layer1->quads_appended());
3629 host_impl_->DidDrawAllLayers(frame); 3606 host_impl_->DidDrawAllLayers(frame);
3630 3607
3631 // Layer with partially opaque contents partially culled, drawn with blending. 3608 // Layer with partially opaque contents partially culled, drawn with blending.
3632 layer1->SetContentsOpaque(false); 3609 layer1->SetContentsOpaque(false);
3633 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3610 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3634 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 3611 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
3635 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3612 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3636 layer1->SetExpectation(true, false); 3613 layer1->SetExpectation(true, false);
3637 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3614 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3638 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3615 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3639 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3640 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3616 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3641 EXPECT_TRUE(layer1->quads_appended()); 3617 EXPECT_TRUE(layer1->quads_appended());
3642 host_impl_->DidDrawAllLayers(frame); 3618 host_impl_->DidDrawAllLayers(frame);
3643 3619
3644 // Layer with partially opaque contents culled, drawn with blending. 3620 // Layer with partially opaque contents culled, drawn with blending.
3645 layer1->SetContentsOpaque(false); 3621 layer1->SetContentsOpaque(false);
3646 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3622 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3647 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 3623 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
3648 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3624 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3649 layer1->SetExpectation(true, false); 3625 layer1->SetExpectation(true, false);
3650 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3626 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3651 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3627 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3652 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3653 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3628 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3654 EXPECT_TRUE(layer1->quads_appended()); 3629 EXPECT_TRUE(layer1->quads_appended());
3655 host_impl_->DidDrawAllLayers(frame); 3630 host_impl_->DidDrawAllLayers(frame);
3656 3631
3657 // Layer with partially opaque contents and translucent contents culled, drawn 3632 // Layer with partially opaque contents and translucent contents culled, drawn
3658 // without blending. 3633 // without blending.
3659 layer1->SetContentsOpaque(false); 3634 layer1->SetContentsOpaque(false);
3660 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 3635 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
3661 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 3636 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
3662 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 3637 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
3663 layer1->SetExpectation(false, false); 3638 layer1->SetExpectation(false, false);
3664 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); 3639 layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
3665 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3640 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3666 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3667 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3641 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3668 EXPECT_TRUE(layer1->quads_appended()); 3642 EXPECT_TRUE(layer1->quads_appended());
3669 host_impl_->DidDrawAllLayers(frame); 3643 host_impl_->DidDrawAllLayers(frame);
3670 } 3644 }
3671 3645
3672 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { 3646 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
3673 protected: 3647 protected:
3674 LayerTreeHostImplViewportCoveredTest() : 3648 LayerTreeHostImplViewportCoveredTest() :
3675 gutter_quad_material_(DrawQuad::SOLID_COLOR), 3649 gutter_quad_material_(DrawQuad::SOLID_COLOR),
3676 child_(NULL), 3650 child_(NULL),
(...skipping 24 matching lines...) Expand all
3701 // Expect no gutter rects. 3675 // Expect no gutter rects.
3702 void TestLayerCoversFullViewport() { 3676 void TestLayerCoversFullViewport() {
3703 gfx::Rect layer_rect(viewport_size_); 3677 gfx::Rect layer_rect(viewport_size_);
3704 child_->SetPosition(layer_rect.origin()); 3678 child_->SetPosition(layer_rect.origin());
3705 child_->SetBounds(layer_rect.size()); 3679 child_->SetBounds(layer_rect.size());
3706 child_->SetContentBounds(layer_rect.size()); 3680 child_->SetContentBounds(layer_rect.size());
3707 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3681 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3708 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3682 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3709 3683
3710 LayerTreeHostImpl::FrameData frame; 3684 LayerTreeHostImpl::FrameData frame;
3711 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3685 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3712 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3713 ASSERT_EQ(1u, frame.render_passes.size()); 3686 ASSERT_EQ(1u, frame.render_passes.size());
3714 3687
3715 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3688 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list));
3716 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 3689 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
3717 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3690 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3718 3691
3719 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 3692 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
3720 host_impl_->DidDrawAllLayers(frame); 3693 host_impl_->DidDrawAllLayers(frame);
3721 } 3694 }
3722 3695
3723 // Expect fullscreen gutter rect. 3696 // Expect fullscreen gutter rect.
3724 void TestEmptyLayer() { 3697 void TestEmptyLayer() {
3725 gfx::Rect layer_rect(0, 0, 0, 0); 3698 gfx::Rect layer_rect(0, 0, 0, 0);
3726 child_->SetPosition(layer_rect.origin()); 3699 child_->SetPosition(layer_rect.origin());
3727 child_->SetBounds(layer_rect.size()); 3700 child_->SetBounds(layer_rect.size());
3728 child_->SetContentBounds(layer_rect.size()); 3701 child_->SetContentBounds(layer_rect.size());
3729 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3702 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3730 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3703 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3731 3704
3732 LayerTreeHostImpl::FrameData frame; 3705 LayerTreeHostImpl::FrameData frame;
3733 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3706 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3734 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3735 ASSERT_EQ(1u, frame.render_passes.size()); 3707 ASSERT_EQ(1u, frame.render_passes.size());
3736 3708
3737 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3709 EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list));
3738 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 3710 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
3739 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3711 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3740 3712
3741 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 3713 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
3742 host_impl_->DidDrawAllLayers(frame); 3714 host_impl_->DidDrawAllLayers(frame);
3743 } 3715 }
3744 3716
3745 // Expect four surrounding gutter rects. 3717 // Expect four surrounding gutter rects.
3746 void TestLayerInMiddleOfViewport() { 3718 void TestLayerInMiddleOfViewport() {
3747 gfx::Rect layer_rect(500, 500, 200, 200); 3719 gfx::Rect layer_rect(500, 500, 200, 200);
3748 child_->SetPosition(layer_rect.origin()); 3720 child_->SetPosition(layer_rect.origin());
3749 child_->SetBounds(layer_rect.size()); 3721 child_->SetBounds(layer_rect.size());
3750 child_->SetContentBounds(layer_rect.size()); 3722 child_->SetContentBounds(layer_rect.size());
3751 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3723 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3752 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3724 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3753 3725
3754 LayerTreeHostImpl::FrameData frame; 3726 LayerTreeHostImpl::FrameData frame;
3755 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3727 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3756 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3757 ASSERT_EQ(1u, frame.render_passes.size()); 3728 ASSERT_EQ(1u, frame.render_passes.size());
3758 3729
3759 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3730 EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list));
3760 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size()); 3731 EXPECT_EQ(5u, frame.render_passes[0]->quad_list.size());
3761 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3732 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3762 3733
3763 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list); 3734 VerifyQuadsExactlyCoverViewport(frame.render_passes[0]->quad_list);
3764 host_impl_->DidDrawAllLayers(frame); 3735 host_impl_->DidDrawAllLayers(frame);
3765 } 3736 }
3766 3737
3767 // Expect no gutter rects. 3738 // Expect no gutter rects.
3768 void TestLayerIsLargerThanViewport() { 3739 void TestLayerIsLargerThanViewport() {
3769 gfx::Rect layer_rect(viewport_size_.width() + 10, 3740 gfx::Rect layer_rect(viewport_size_.width() + 10,
3770 viewport_size_.height() + 10); 3741 viewport_size_.height() + 10);
3771 child_->SetPosition(layer_rect.origin()); 3742 child_->SetPosition(layer_rect.origin());
3772 child_->SetBounds(layer_rect.size()); 3743 child_->SetBounds(layer_rect.size());
3773 child_->SetContentBounds(layer_rect.size()); 3744 child_->SetContentBounds(layer_rect.size());
3774 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 3745 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
3775 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 3746 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
3776 3747
3777 LayerTreeHostImpl::FrameData frame; 3748 LayerTreeHostImpl::FrameData frame;
3778 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3749 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3779 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3780 ASSERT_EQ(1u, frame.render_passes.size()); 3750 ASSERT_EQ(1u, frame.render_passes.size());
3781 3751
3782 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list)); 3752 EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list));
3783 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size()); 3753 EXPECT_EQ(1u, frame.render_passes[0]->quad_list.size());
3784 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list); 3754 ValidateTextureDrawQuads(frame.render_passes[0]->quad_list);
3785 3755
3786 host_impl_->DidDrawAllLayers(frame); 3756 host_impl_->DidDrawAllLayers(frame);
3787 } 3757 }
3788 3758
3789 virtual void DidActivatePendingTree() OVERRIDE { 3759 virtual void DidActivatePendingTree() OVERRIDE {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3984 root->SetBounds(gfx::Size(10, 10)); 3954 root->SetBounds(gfx::Size(10, 10));
3985 root->SetContentBounds(gfx::Size(10, 10)); 3955 root->SetContentBounds(gfx::Size(10, 10));
3986 root->SetDrawsContent(true); 3956 root->SetDrawsContent(true);
3987 host_impl_->active_tree()->SetRootLayer(root.Pass()); 3957 host_impl_->active_tree()->SetRootLayer(root.Pass());
3988 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); 3958 EXPECT_FALSE(provider->TestContext3d()->reshape_called());
3989 provider->TestContext3d()->clear_reshape_called(); 3959 provider->TestContext3d()->clear_reshape_called();
3990 3960
3991 LayerTreeHostImpl::FrameData frame; 3961 LayerTreeHostImpl::FrameData frame;
3992 host_impl_->SetViewportSize(gfx::Size(10, 10)); 3962 host_impl_->SetViewportSize(gfx::Size(10, 10));
3993 host_impl_->SetDeviceScaleFactor(1.f); 3963 host_impl_->SetDeviceScaleFactor(1.f);
3994 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3964 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3995 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
3996 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3965 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
3997 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 3966 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
3998 EXPECT_EQ(provider->TestContext3d()->width(), 10); 3967 EXPECT_EQ(provider->TestContext3d()->width(), 10);
3999 EXPECT_EQ(provider->TestContext3d()->height(), 10); 3968 EXPECT_EQ(provider->TestContext3d()->height(), 10);
4000 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); 3969 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
4001 host_impl_->DidDrawAllLayers(frame); 3970 host_impl_->DidDrawAllLayers(frame);
4002 provider->TestContext3d()->clear_reshape_called(); 3971 provider->TestContext3d()->clear_reshape_called();
4003 3972
4004 host_impl_->SetViewportSize(gfx::Size(20, 30)); 3973 host_impl_->SetViewportSize(gfx::Size(20, 30));
4005 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3974 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4006 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4007 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3975 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4008 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 3976 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4009 EXPECT_EQ(provider->TestContext3d()->width(), 20); 3977 EXPECT_EQ(provider->TestContext3d()->width(), 20);
4010 EXPECT_EQ(provider->TestContext3d()->height(), 30); 3978 EXPECT_EQ(provider->TestContext3d()->height(), 30);
4011 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); 3979 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f);
4012 host_impl_->DidDrawAllLayers(frame); 3980 host_impl_->DidDrawAllLayers(frame);
4013 provider->TestContext3d()->clear_reshape_called(); 3981 provider->TestContext3d()->clear_reshape_called();
4014 3982
4015 host_impl_->SetDeviceScaleFactor(2.f); 3983 host_impl_->SetDeviceScaleFactor(2.f);
4016 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 3984 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4017 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4018 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 3985 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4019 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); 3986 EXPECT_TRUE(provider->TestContext3d()->reshape_called());
4020 EXPECT_EQ(provider->TestContext3d()->width(), 20); 3987 EXPECT_EQ(provider->TestContext3d()->width(), 20);
4021 EXPECT_EQ(provider->TestContext3d()->height(), 30); 3988 EXPECT_EQ(provider->TestContext3d()->height(), 30);
4022 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); 3989 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f);
4023 host_impl_->DidDrawAllLayers(frame); 3990 host_impl_->DidDrawAllLayers(frame);
4024 provider->TestContext3d()->clear_reshape_called(); 3991 provider->TestContext3d()->clear_reshape_called();
4025 } 3992 }
4026 3993
4027 // Make sure damage tracking propagates all the way to the graphics context, 3994 // Make sure damage tracking propagates all the way to the graphics context,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4063 root->SetAnchorPoint(gfx::PointF()); 4030 root->SetAnchorPoint(gfx::PointF());
4064 root->SetBounds(gfx::Size(500, 500)); 4031 root->SetBounds(gfx::Size(500, 500));
4065 root->SetContentBounds(gfx::Size(500, 500)); 4032 root->SetContentBounds(gfx::Size(500, 500));
4066 root->SetDrawsContent(true); 4033 root->SetDrawsContent(true);
4067 root->AddChild(child.Pass()); 4034 root->AddChild(child.Pass());
4068 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass()); 4035 layer_tree_host_impl->active_tree()->SetRootLayer(root.Pass());
4069 4036
4070 LayerTreeHostImpl::FrameData frame; 4037 LayerTreeHostImpl::FrameData frame;
4071 4038
4072 // First frame, the entire screen should get swapped. 4039 // First frame, the entire screen should get swapped.
4073 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4040 EXPECT_EQ(DRAW_SUCCESS,
4074 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 4041 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4075 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4042 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4076 layer_tree_host_impl->DidDrawAllLayers(frame); 4043 layer_tree_host_impl->DidDrawAllLayers(frame);
4077 layer_tree_host_impl->SwapBuffers(frame); 4044 layer_tree_host_impl->SwapBuffers(frame);
4078 EXPECT_EQ(TestContextSupport::SWAP, 4045 EXPECT_EQ(TestContextSupport::SWAP,
4079 context_provider->support()->last_swap_type()); 4046 context_provider->support()->last_swap_type());
4080 4047
4081 // Second frame, only the damaged area should get swapped. Damage should be 4048 // Second frame, only the damaged area should get swapped. Damage should be
4082 // the union of old and new child rects. 4049 // the union of old and new child rects.
4083 // expected damage rect: gfx::Rect(26, 28); 4050 // expected damage rect: gfx::Rect(26, 28);
4084 // expected swap rect: vertically flipped, with origin at bottom left corner. 4051 // expected swap rect: vertically flipped, with origin at bottom left corner.
4085 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( 4052 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition(
4086 gfx::PointF()); 4053 gfx::PointF());
4087 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4054 EXPECT_EQ(DRAW_SUCCESS,
4088 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 4055 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4089 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4056 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4090 host_impl_->DidDrawAllLayers(frame); 4057 host_impl_->DidDrawAllLayers(frame);
4091 layer_tree_host_impl->SwapBuffers(frame); 4058 layer_tree_host_impl->SwapBuffers(frame);
4092 4059
4093 // Make sure that partial swap is constrained to the viewport dimensions 4060 // Make sure that partial swap is constrained to the viewport dimensions
4094 // expected damage rect: gfx::Rect(500, 500); 4061 // expected damage rect: gfx::Rect(500, 500);
4095 // expected swap rect: flipped damage rect, but also clamped to viewport 4062 // expected swap rect: flipped damage rect, but also clamped to viewport
4096 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP, 4063 EXPECT_EQ(TestContextSupport::PARTIAL_SWAP,
4097 context_provider->support()->last_swap_type()); 4064 context_provider->support()->last_swap_type());
4098 gfx::Rect expected_swap_rect(0, 500-28, 26, 28); 4065 gfx::Rect expected_swap_rect(0, 500-28, 26, 28);
4099 EXPECT_EQ(expected_swap_rect.ToString(), 4066 EXPECT_EQ(expected_swap_rect.ToString(),
4100 context_provider->support()-> 4067 context_provider->support()->
4101 last_partial_swap_rect().ToString()); 4068 last_partial_swap_rect().ToString());
4102 4069
4103 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); 4070 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10));
4104 // This will damage everything. 4071 // This will damage everything.
4105 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor( 4072 layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor(
4106 SK_ColorBLACK); 4073 SK_ColorBLACK);
4107 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4074 EXPECT_EQ(DRAW_SUCCESS,
4108 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect())); 4075 layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4109 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4076 layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4110 host_impl_->DidDrawAllLayers(frame); 4077 host_impl_->DidDrawAllLayers(frame);
4111 layer_tree_host_impl->SwapBuffers(frame); 4078 layer_tree_host_impl->SwapBuffers(frame);
4112 4079
4113 EXPECT_EQ(TestContextSupport::SWAP, 4080 EXPECT_EQ(TestContextSupport::SWAP,
4114 context_provider->support()->last_swap_type()); 4081 context_provider->support()->last_swap_type());
4115 } 4082 }
4116 4083
4117 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { 4084 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) {
4118 scoped_ptr<LayerImpl> root = 4085 scoped_ptr<LayerImpl> root =
4119 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); 4086 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
4120 scoped_ptr<LayerImpl> child = 4087 scoped_ptr<LayerImpl> child =
4121 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2); 4088 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
4122 child->SetAnchorPoint(gfx::PointF()); 4089 child->SetAnchorPoint(gfx::PointF());
4123 child->SetBounds(gfx::Size(10, 10)); 4090 child->SetBounds(gfx::Size(10, 10));
4124 child->SetContentBounds(gfx::Size(10, 10)); 4091 child->SetContentBounds(gfx::Size(10, 10));
4125 child->SetDrawsContent(true); 4092 child->SetDrawsContent(true);
4126 root->SetAnchorPoint(gfx::PointF()); 4093 root->SetAnchorPoint(gfx::PointF());
4127 root->SetBounds(gfx::Size(10, 10)); 4094 root->SetBounds(gfx::Size(10, 10));
4128 root->SetContentBounds(gfx::Size(10, 10)); 4095 root->SetContentBounds(gfx::Size(10, 10));
4129 root->SetDrawsContent(true); 4096 root->SetDrawsContent(true);
4130 root->SetForceRenderSurface(true); 4097 root->SetForceRenderSurface(true);
4131 root->AddChild(child.Pass()); 4098 root->AddChild(child.Pass());
4132 4099
4133 host_impl_->active_tree()->SetRootLayer(root.Pass()); 4100 host_impl_->active_tree()->SetRootLayer(root.Pass());
4134 4101
4135 LayerTreeHostImpl::FrameData frame; 4102 LayerTreeHostImpl::FrameData frame;
4136 4103
4137 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4104 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4138 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4139 EXPECT_EQ(1u, frame.render_surface_layer_list->size()); 4105 EXPECT_EQ(1u, frame.render_surface_layer_list->size());
4140 EXPECT_EQ(1u, frame.render_passes.size()); 4106 EXPECT_EQ(1u, frame.render_passes.size());
4141 host_impl_->DidDrawAllLayers(frame); 4107 host_impl_->DidDrawAllLayers(frame);
4142 } 4108 }
4143 4109
4144 class FakeLayerWithQuads : public LayerImpl { 4110 class FakeLayerWithQuads : public LayerImpl {
4145 public: 4111 public:
4146 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 4112 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
4147 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id)); 4113 return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id));
4148 } 4114 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4265 LayerTreeSettings settings = DefaultSettings(); 4231 LayerTreeSettings settings = DefaultSettings();
4266 settings.partial_swap_enabled = false; 4232 settings.partial_swap_enabled = false;
4267 CreateHostImpl(settings, output_surface.Pass()); 4233 CreateHostImpl(settings, output_surface.Pass());
4268 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 4234 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
4269 4235
4270 // Without partial swap, and no clipping, no scissor is set. 4236 // Without partial swap, and no clipping, no scissor is set.
4271 harness.MustDrawSolidQuad(); 4237 harness.MustDrawSolidQuad();
4272 harness.MustSetNoScissor(); 4238 harness.MustSetNoScissor();
4273 { 4239 {
4274 LayerTreeHostImpl::FrameData frame; 4240 LayerTreeHostImpl::FrameData frame;
4275 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4241 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4276 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4277 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4242 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4278 host_impl_->DidDrawAllLayers(frame); 4243 host_impl_->DidDrawAllLayers(frame);
4279 } 4244 }
4280 Mock::VerifyAndClearExpectations(&mock_context); 4245 Mock::VerifyAndClearExpectations(&mock_context);
4281 4246
4282 // Without partial swap, but a layer does clip its subtree, one scissor is 4247 // Without partial swap, but a layer does clip its subtree, one scissor is
4283 // set. 4248 // set.
4284 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true); 4249 host_impl_->active_tree()->root_layer()->SetMasksToBounds(true);
4285 harness.MustDrawSolidQuad(); 4250 harness.MustDrawSolidQuad();
4286 harness.MustSetScissor(0, 0, 10, 10); 4251 harness.MustSetScissor(0, 0, 10, 10);
4287 { 4252 {
4288 LayerTreeHostImpl::FrameData frame; 4253 LayerTreeHostImpl::FrameData frame;
4289 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4254 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4290 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4291 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4255 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4292 host_impl_->DidDrawAllLayers(frame); 4256 host_impl_->DidDrawAllLayers(frame);
4293 } 4257 }
4294 Mock::VerifyAndClearExpectations(&mock_context); 4258 Mock::VerifyAndClearExpectations(&mock_context);
4295 } 4259 }
4296 4260
4297 TEST_F(LayerTreeHostImplTest, PartialSwap) { 4261 TEST_F(LayerTreeHostImplTest, PartialSwap) {
4298 scoped_ptr<MockContext> context_owned(new MockContext); 4262 scoped_ptr<MockContext> context_owned(new MockContext);
4299 MockContext* mock_context = context_owned.get(); 4263 MockContext* mock_context = context_owned.get();
4300 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( 4264 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
4301 context_owned.PassAs<TestWebGraphicsContext3D>())); 4265 context_owned.PassAs<TestWebGraphicsContext3D>()));
4302 MockContextHarness harness(mock_context); 4266 MockContextHarness harness(mock_context);
4303 4267
4304 LayerTreeSettings settings = DefaultSettings(); 4268 LayerTreeSettings settings = DefaultSettings();
4305 settings.partial_swap_enabled = true; 4269 settings.partial_swap_enabled = true;
4306 CreateHostImpl(settings, output_surface.Pass()); 4270 CreateHostImpl(settings, output_surface.Pass());
4307 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 4271 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
4308 4272
4309 // The first frame is not a partially-swapped one. 4273 // The first frame is not a partially-swapped one.
4310 harness.MustSetScissor(0, 0, 10, 10); 4274 harness.MustSetScissor(0, 0, 10, 10);
4311 harness.MustDrawSolidQuad(); 4275 harness.MustDrawSolidQuad();
4312 { 4276 {
4313 LayerTreeHostImpl::FrameData frame; 4277 LayerTreeHostImpl::FrameData frame;
4314 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4278 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4315 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4316 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4279 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4317 host_impl_->DidDrawAllLayers(frame); 4280 host_impl_->DidDrawAllLayers(frame);
4318 } 4281 }
4319 Mock::VerifyAndClearExpectations(&mock_context); 4282 Mock::VerifyAndClearExpectations(&mock_context);
4320 4283
4321 // Damage a portion of the frame. 4284 // Damage a portion of the frame.
4322 host_impl_->active_tree()->root_layer()->SetUpdateRect( 4285 host_impl_->active_tree()->root_layer()->SetUpdateRect(
4323 gfx::Rect(0, 0, 2, 3)); 4286 gfx::Rect(0, 0, 2, 3));
4324 4287
4325 // The second frame will be partially-swapped (the y coordinates are flipped). 4288 // The second frame will be partially-swapped (the y coordinates are flipped).
4326 harness.MustSetScissor(0, 7, 2, 3); 4289 harness.MustSetScissor(0, 7, 2, 3);
4327 harness.MustDrawSolidQuad(); 4290 harness.MustDrawSolidQuad();
4328 { 4291 {
4329 LayerTreeHostImpl::FrameData frame; 4292 LayerTreeHostImpl::FrameData frame;
4330 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4293 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4331 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4332 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4294 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4333 host_impl_->DidDrawAllLayers(frame); 4295 host_impl_->DidDrawAllLayers(frame);
4334 } 4296 }
4335 Mock::VerifyAndClearExpectations(&mock_context); 4297 Mock::VerifyAndClearExpectations(&mock_context);
4336 } 4298 }
4337 4299
4338 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( 4300 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity(
4339 bool partial_swap, 4301 bool partial_swap,
4340 LayerTreeHostImplClient* client, 4302 LayerTreeHostImplClient* client,
4341 Proxy* proxy, 4303 Proxy* proxy,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 4381 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
4420 new TestSharedBitmapManager()); 4382 new TestSharedBitmapManager());
4421 scoped_ptr<LayerTreeHostImpl> my_host_impl = 4383 scoped_ptr<LayerTreeHostImpl> my_host_impl =
4422 SetupLayersForOpacity(true, 4384 SetupLayersForOpacity(true,
4423 this, 4385 this,
4424 &proxy_, 4386 &proxy_,
4425 shared_bitmap_manager.get(), 4387 shared_bitmap_manager.get(),
4426 &stats_instrumentation_); 4388 &stats_instrumentation_);
4427 { 4389 {
4428 LayerTreeHostImpl::FrameData frame; 4390 LayerTreeHostImpl::FrameData frame;
4429 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4391 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4430 my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4431 4392
4432 // Verify all quads have been computed 4393 // Verify all quads have been computed
4433 ASSERT_EQ(2U, frame.render_passes.size()); 4394 ASSERT_EQ(2U, frame.render_passes.size());
4434 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 4395 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
4435 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 4396 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
4436 EXPECT_EQ(DrawQuad::SOLID_COLOR, 4397 EXPECT_EQ(DrawQuad::SOLID_COLOR,
4437 frame.render_passes[0]->quad_list[0]->material); 4398 frame.render_passes[0]->quad_list[0]->material);
4438 EXPECT_EQ(DrawQuad::RENDER_PASS, 4399 EXPECT_EQ(DrawQuad::RENDER_PASS,
4439 frame.render_passes[1]->quad_list[0]->material); 4400 frame.render_passes[1]->quad_list[0]->material);
4440 4401
4441 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); 4402 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
4442 my_host_impl->DidDrawAllLayers(frame); 4403 my_host_impl->DidDrawAllLayers(frame);
4443 } 4404 }
4444 } 4405 }
4445 4406
4446 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { 4407 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) {
4447 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 4408 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
4448 new TestSharedBitmapManager()); 4409 new TestSharedBitmapManager());
4449 scoped_ptr<LayerTreeHostImpl> my_host_impl = 4410 scoped_ptr<LayerTreeHostImpl> my_host_impl =
4450 SetupLayersForOpacity(false, 4411 SetupLayersForOpacity(false,
4451 this, 4412 this,
4452 &proxy_, 4413 &proxy_,
4453 shared_bitmap_manager.get(), 4414 shared_bitmap_manager.get(),
4454 &stats_instrumentation_); 4415 &stats_instrumentation_);
4455 { 4416 {
4456 LayerTreeHostImpl::FrameData frame; 4417 LayerTreeHostImpl::FrameData frame;
4457 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4418 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4458 my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
4459 4419
4460 // Verify all quads have been computed 4420 // Verify all quads have been computed
4461 ASSERT_EQ(2U, frame.render_passes.size()); 4421 ASSERT_EQ(2U, frame.render_passes.size());
4462 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); 4422 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size());
4463 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); 4423 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size());
4464 EXPECT_EQ(DrawQuad::SOLID_COLOR, 4424 EXPECT_EQ(DrawQuad::SOLID_COLOR,
4465 frame.render_passes[0]->quad_list[0]->material); 4425 frame.render_passes[0]->quad_list[0]->material);
4466 EXPECT_EQ(DrawQuad::RENDER_PASS, 4426 EXPECT_EQ(DrawQuad::RENDER_PASS,
4467 frame.render_passes[1]->quad_list[0]->material); 4427 frame.render_passes[1]->quad_list[0]->material);
4468 4428
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4504 io_surface_layer->SetContentBounds(gfx::Size(10, 10)); 4464 io_surface_layer->SetContentBounds(gfx::Size(10, 10));
4505 io_surface_layer->SetDrawsContent(true); 4465 io_surface_layer->SetDrawsContent(true);
4506 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10)); 4466 io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
4507 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>()); 4467 root_layer->AddChild(io_surface_layer.PassAs<LayerImpl>());
4508 4468
4509 host_impl_->active_tree()->SetRootLayer(root_layer.Pass()); 4469 host_impl_->active_tree()->SetRootLayer(root_layer.Pass());
4510 4470
4511 EXPECT_EQ(0u, context3d->NumTextures()); 4471 EXPECT_EQ(0u, context3d->NumTextures());
4512 4472
4513 LayerTreeHostImpl::FrameData frame; 4473 LayerTreeHostImpl::FrameData frame;
4514 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4474 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4515 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4516 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4475 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4517 host_impl_->DidDrawAllLayers(frame); 4476 host_impl_->DidDrawAllLayers(frame);
4518 host_impl_->SwapBuffers(frame); 4477 host_impl_->SwapBuffers(frame);
4519 4478
4520 EXPECT_GT(context3d->NumTextures(), 0u); 4479 EXPECT_GT(context3d->NumTextures(), 0u);
4521 4480
4522 // Kill the layer tree. 4481 // Kill the layer tree.
4523 host_impl_->active_tree()->SetRootLayer( 4482 host_impl_->active_tree()->SetRootLayer(
4524 LayerImpl::Create(host_impl_->active_tree(), 100)); 4483 LayerImpl::Create(host_impl_->active_tree(), 100));
4525 // There should be no textures left in use after. 4484 // There should be no textures left in use after.
(...skipping 24 matching lines...) Expand all
4550 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 4509 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
4551 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); 4510 host_impl_->active_tree()->set_background_color(SK_ColorWHITE);
4552 4511
4553 // Verify one quad is drawn when transparent background set is not set. 4512 // Verify one quad is drawn when transparent background set is not set.
4554 host_impl_->active_tree()->set_has_transparent_background(false); 4513 host_impl_->active_tree()->set_has_transparent_background(false);
4555 EXPECT_CALL(*mock_context, useProgram(_)) 4514 EXPECT_CALL(*mock_context, useProgram(_))
4556 .Times(1); 4515 .Times(1);
4557 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) 4516 EXPECT_CALL(*mock_context, drawElements(_, _, _, _))
4558 .Times(1); 4517 .Times(1);
4559 LayerTreeHostImpl::FrameData frame; 4518 LayerTreeHostImpl::FrameData frame;
4560 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4519 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4561 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4562 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4520 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4563 host_impl_->DidDrawAllLayers(frame); 4521 host_impl_->DidDrawAllLayers(frame);
4564 Mock::VerifyAndClearExpectations(&mock_context); 4522 Mock::VerifyAndClearExpectations(&mock_context);
4565 4523
4566 // Verify no quads are drawn when transparent background is set. 4524 // Verify no quads are drawn when transparent background is set.
4567 host_impl_->active_tree()->set_has_transparent_background(true); 4525 host_impl_->active_tree()->set_has_transparent_background(true);
4568 host_impl_->SetFullRootLayerDamage(); 4526 host_impl_->SetFullRootLayerDamage();
4569 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4527 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4570 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4571 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4528 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4572 host_impl_->DidDrawAllLayers(frame); 4529 host_impl_->DidDrawAllLayers(frame);
4573 Mock::VerifyAndClearExpectations(&mock_context); 4530 Mock::VerifyAndClearExpectations(&mock_context);
4574 } 4531 }
4575 4532
4576 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) { 4533 TEST_F(LayerTreeHostImplTest, ReleaseContentsTextureShouldTriggerCommit) {
4577 set_reduce_memory_result(false); 4534 set_reduce_memory_result(false);
4578 4535
4579 // If changing the memory limit wouldn't result in changing what was 4536 // If changing the memory limit wouldn't result in changing what was
4580 // committed, then no commit should be requested. 4537 // committed, then no commit should be requested.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4617 : public LayerTreeHostImplTest { 4574 : public LayerTreeHostImplTest {
4618 protected: 4575 protected:
4619 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { 4576 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
4620 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>(); 4577 return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
4621 } 4578 }
4622 4579
4623 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) { 4580 void DrawFrameAndTestDamage(const gfx::RectF& expected_damage) {
4624 bool expect_to_draw = !expected_damage.IsEmpty(); 4581 bool expect_to_draw = !expected_damage.IsEmpty();
4625 4582
4626 LayerTreeHostImpl::FrameData frame; 4583 LayerTreeHostImpl::FrameData frame;
4627 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4584 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4628 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4629 4585
4630 if (!expect_to_draw) { 4586 if (!expect_to_draw) {
4631 // With no damage, we don't draw, and no quads are created. 4587 // With no damage, we don't draw, and no quads are created.
4632 ASSERT_EQ(0u, frame.render_passes.size()); 4588 ASSERT_EQ(0u, frame.render_passes.size());
4633 } else { 4589 } else {
4634 ASSERT_EQ(1u, frame.render_passes.size()); 4590 ASSERT_EQ(1u, frame.render_passes.size());
4635 4591
4636 // Verify the damage rect for the root render pass. 4592 // Verify the damage rect for the root render pass.
4637 const RenderPass* root_render_pass = frame.render_passes.back(); 4593 const RenderPass* root_render_pass = frame.render_passes.back();
4638 EXPECT_RECT_EQ(expected_damage, root_render_pass->damage_rect); 4594 EXPECT_RECT_EQ(expected_damage, root_render_pass->damage_rect);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
4777 mask_layer->SetDrawsContent(true); 4733 mask_layer->SetDrawsContent(true);
4778 4734
4779 4735
4780 // Check that the tree scaling is correctly taken into account for the mask, 4736 // Check that the tree scaling is correctly taken into account for the mask,
4781 // that should fully map onto the quad. 4737 // that should fully map onto the quad.
4782 float device_scale_factor = 1.f; 4738 float device_scale_factor = 1.f;
4783 host_impl_->SetViewportSize(root_size); 4739 host_impl_->SetViewportSize(root_size);
4784 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4740 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4785 { 4741 {
4786 LayerTreeHostImpl::FrameData frame; 4742 LayerTreeHostImpl::FrameData frame;
4787 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4743 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4788 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4789 4744
4790 ASSERT_EQ(1u, frame.render_passes.size()); 4745 ASSERT_EQ(1u, frame.render_passes.size());
4791 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4746 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4792 ASSERT_EQ(DrawQuad::RENDER_PASS, 4747 ASSERT_EQ(DrawQuad::RENDER_PASS,
4793 frame.render_passes[0]->quad_list[0]->material); 4748 frame.render_passes[0]->quad_list[0]->material);
4794 const RenderPassDrawQuad* render_pass_quad = 4749 const RenderPassDrawQuad* render_pass_quad =
4795 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4750 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4796 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4751 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4797 render_pass_quad->rect.ToString()); 4752 render_pass_quad->rect.ToString());
4798 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4753 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4799 render_pass_quad->mask_uv_rect.ToString()); 4754 render_pass_quad->mask_uv_rect.ToString());
4800 4755
4801 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4756 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4802 host_impl_->DidDrawAllLayers(frame); 4757 host_impl_->DidDrawAllLayers(frame);
4803 } 4758 }
4804 4759
4805 4760
4806 // Applying a DSF should change the render surface size, but won't affect 4761 // Applying a DSF should change the render surface size, but won't affect
4807 // which part of the mask is used. 4762 // which part of the mask is used.
4808 device_scale_factor = 2.f; 4763 device_scale_factor = 2.f;
4809 gfx::Size device_viewport = 4764 gfx::Size device_viewport =
4810 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4765 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4811 host_impl_->SetViewportSize(device_viewport); 4766 host_impl_->SetViewportSize(device_viewport);
4812 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4767 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4813 host_impl_->active_tree()->set_needs_update_draw_properties(); 4768 host_impl_->active_tree()->set_needs_update_draw_properties();
4814 { 4769 {
4815 LayerTreeHostImpl::FrameData frame; 4770 LayerTreeHostImpl::FrameData frame;
4816 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4771 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4817 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4818 4772
4819 ASSERT_EQ(1u, frame.render_passes.size()); 4773 ASSERT_EQ(1u, frame.render_passes.size());
4820 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4774 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4821 ASSERT_EQ(DrawQuad::RENDER_PASS, 4775 ASSERT_EQ(DrawQuad::RENDER_PASS,
4822 frame.render_passes[0]->quad_list[0]->material); 4776 frame.render_passes[0]->quad_list[0]->material);
4823 const RenderPassDrawQuad* render_pass_quad = 4777 const RenderPassDrawQuad* render_pass_quad =
4824 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4778 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4825 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4779 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4826 render_pass_quad->rect.ToString()); 4780 render_pass_quad->rect.ToString());
4827 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4781 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4828 render_pass_quad->mask_uv_rect.ToString()); 4782 render_pass_quad->mask_uv_rect.ToString());
4829 4783
4830 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4784 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4831 host_impl_->DidDrawAllLayers(frame); 4785 host_impl_->DidDrawAllLayers(frame);
4832 } 4786 }
4833 4787
4834 4788
4835 // Applying an equivalent content scale on the content layer and the mask 4789 // Applying an equivalent content scale on the content layer and the mask
4836 // should still result in the same part of the mask being used. 4790 // should still result in the same part of the mask being used.
4837 gfx::Size content_bounds = 4791 gfx::Size content_bounds =
4838 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size, 4792 gfx::ToRoundedSize(gfx::ScaleSize(scaling_layer_size,
4839 device_scale_factor)); 4793 device_scale_factor));
4840 content_layer->SetContentBounds(content_bounds); 4794 content_layer->SetContentBounds(content_bounds);
4841 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4795 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4842 mask_layer->SetContentBounds(content_bounds); 4796 mask_layer->SetContentBounds(content_bounds);
4843 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4797 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4844 host_impl_->active_tree()->set_needs_update_draw_properties(); 4798 host_impl_->active_tree()->set_needs_update_draw_properties();
4845 { 4799 {
4846 LayerTreeHostImpl::FrameData frame; 4800 LayerTreeHostImpl::FrameData frame;
4847 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4801 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4848 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4849 4802
4850 ASSERT_EQ(1u, frame.render_passes.size()); 4803 ASSERT_EQ(1u, frame.render_passes.size());
4851 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4804 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4852 ASSERT_EQ(DrawQuad::RENDER_PASS, 4805 ASSERT_EQ(DrawQuad::RENDER_PASS,
4853 frame.render_passes[0]->quad_list[0]->material); 4806 frame.render_passes[0]->quad_list[0]->material);
4854 const RenderPassDrawQuad* render_pass_quad = 4807 const RenderPassDrawQuad* render_pass_quad =
4855 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4808 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4856 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), 4809 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
4857 render_pass_quad->rect.ToString()); 4810 render_pass_quad->rect.ToString());
4858 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4811 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
4901 mask_layer->SetPosition(gfx::PointF()); 4854 mask_layer->SetPosition(gfx::PointF());
4902 mask_layer->SetAnchorPoint(gfx::PointF()); 4855 mask_layer->SetAnchorPoint(gfx::PointF());
4903 mask_layer->SetDrawsContent(true); 4856 mask_layer->SetDrawsContent(true);
4904 4857
4905 // Check that the mask fills the surface. 4858 // Check that the mask fills the surface.
4906 float device_scale_factor = 1.f; 4859 float device_scale_factor = 1.f;
4907 host_impl_->SetViewportSize(root_size); 4860 host_impl_->SetViewportSize(root_size);
4908 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4861 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4909 { 4862 {
4910 LayerTreeHostImpl::FrameData frame; 4863 LayerTreeHostImpl::FrameData frame;
4911 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4864 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4912 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4913 4865
4914 ASSERT_EQ(1u, frame.render_passes.size()); 4866 ASSERT_EQ(1u, frame.render_passes.size());
4915 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4867 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4916 ASSERT_EQ(DrawQuad::RENDER_PASS, 4868 ASSERT_EQ(DrawQuad::RENDER_PASS,
4917 frame.render_passes[0]->quad_list[0]->material); 4869 frame.render_passes[0]->quad_list[0]->material);
4918 const RenderPassDrawQuad* render_pass_quad = 4870 const RenderPassDrawQuad* render_pass_quad =
4919 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4871 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4920 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 4872 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
4921 render_pass_quad->rect.ToString()); 4873 render_pass_quad->rect.ToString());
4922 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4874 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4923 render_pass_quad->mask_uv_rect.ToString()); 4875 render_pass_quad->mask_uv_rect.ToString());
4924 4876
4925 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4877 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4926 host_impl_->DidDrawAllLayers(frame); 4878 host_impl_->DidDrawAllLayers(frame);
4927 } 4879 }
4928 4880
4929 // Applying a DSF should change the render surface size, but won't affect 4881 // Applying a DSF should change the render surface size, but won't affect
4930 // which part of the mask is used. 4882 // which part of the mask is used.
4931 device_scale_factor = 2.f; 4883 device_scale_factor = 2.f;
4932 gfx::Size device_viewport = 4884 gfx::Size device_viewport =
4933 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 4885 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
4934 host_impl_->SetViewportSize(device_viewport); 4886 host_impl_->SetViewportSize(device_viewport);
4935 host_impl_->SetDeviceScaleFactor(device_scale_factor); 4887 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4936 host_impl_->active_tree()->set_needs_update_draw_properties(); 4888 host_impl_->active_tree()->set_needs_update_draw_properties();
4937 { 4889 {
4938 LayerTreeHostImpl::FrameData frame; 4890 LayerTreeHostImpl::FrameData frame;
4939 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4891 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4940 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4941 4892
4942 ASSERT_EQ(1u, frame.render_passes.size()); 4893 ASSERT_EQ(1u, frame.render_passes.size());
4943 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4894 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4944 ASSERT_EQ(DrawQuad::RENDER_PASS, 4895 ASSERT_EQ(DrawQuad::RENDER_PASS,
4945 frame.render_passes[0]->quad_list[0]->material); 4896 frame.render_passes[0]->quad_list[0]->material);
4946 const RenderPassDrawQuad* render_pass_quad = 4897 const RenderPassDrawQuad* render_pass_quad =
4947 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4898 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4948 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4899 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4949 render_pass_quad->rect.ToString()); 4900 render_pass_quad->rect.ToString());
4950 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4901 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4951 render_pass_quad->mask_uv_rect.ToString()); 4902 render_pass_quad->mask_uv_rect.ToString());
4952 4903
4953 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4904 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4954 host_impl_->DidDrawAllLayers(frame); 4905 host_impl_->DidDrawAllLayers(frame);
4955 } 4906 }
4956 4907
4957 // Applying an equivalent content scale on the content layer and the mask 4908 // Applying an equivalent content scale on the content layer and the mask
4958 // should still result in the same part of the mask being used. 4909 // should still result in the same part of the mask being used.
4959 gfx::Size layer_size_large = 4910 gfx::Size layer_size_large =
4960 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 4911 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
4961 content_layer->SetContentBounds(layer_size_large); 4912 content_layer->SetContentBounds(layer_size_large);
4962 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4913 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4963 gfx::Size mask_size_large = 4914 gfx::Size mask_size_large =
4964 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 4915 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
4965 mask_layer->SetContentBounds(mask_size_large); 4916 mask_layer->SetContentBounds(mask_size_large);
4966 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 4917 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
4967 host_impl_->active_tree()->set_needs_update_draw_properties(); 4918 host_impl_->active_tree()->set_needs_update_draw_properties();
4968 { 4919 {
4969 LayerTreeHostImpl::FrameData frame; 4920 LayerTreeHostImpl::FrameData frame;
4970 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4921 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4971 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4972 4922
4973 ASSERT_EQ(1u, frame.render_passes.size()); 4923 ASSERT_EQ(1u, frame.render_passes.size());
4974 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4924 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
4975 ASSERT_EQ(DrawQuad::RENDER_PASS, 4925 ASSERT_EQ(DrawQuad::RENDER_PASS,
4976 frame.render_passes[0]->quad_list[0]->material); 4926 frame.render_passes[0]->quad_list[0]->material);
4977 const RenderPassDrawQuad* render_pass_quad = 4927 const RenderPassDrawQuad* render_pass_quad =
4978 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4928 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
4979 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4929 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
4980 render_pass_quad->rect.ToString()); 4930 render_pass_quad->rect.ToString());
4981 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4931 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
4982 render_pass_quad->mask_uv_rect.ToString()); 4932 render_pass_quad->mask_uv_rect.ToString());
4983 4933
4984 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 4934 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
4985 host_impl_->DidDrawAllLayers(frame); 4935 host_impl_->DidDrawAllLayers(frame);
4986 } 4936 }
4987 4937
4988 // Applying a different contents scale to the mask layer means it will have 4938 // Applying a different contents scale to the mask layer means it will have
4989 // a larger texture, but it should use the same tex coords to cover the 4939 // a larger texture, but it should use the same tex coords to cover the
4990 // layer it masks. 4940 // layer it masks.
4991 mask_layer->SetContentBounds(mask_size); 4941 mask_layer->SetContentBounds(mask_size);
4992 mask_layer->SetContentsScale(1.f, 1.f); 4942 mask_layer->SetContentsScale(1.f, 1.f);
4993 host_impl_->active_tree()->set_needs_update_draw_properties(); 4943 host_impl_->active_tree()->set_needs_update_draw_properties();
4994 { 4944 {
4995 LayerTreeHostImpl::FrameData frame; 4945 LayerTreeHostImpl::FrameData frame;
4996 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 4946 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4997 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
4998 4947
4999 ASSERT_EQ(1u, frame.render_passes.size()); 4948 ASSERT_EQ(1u, frame.render_passes.size());
5000 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 4949 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5001 ASSERT_EQ(DrawQuad::RENDER_PASS, 4950 ASSERT_EQ(DrawQuad::RENDER_PASS,
5002 frame.render_passes[0]->quad_list[0]->material); 4951 frame.render_passes[0]->quad_list[0]->material);
5003 const RenderPassDrawQuad* render_pass_quad = 4952 const RenderPassDrawQuad* render_pass_quad =
5004 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 4953 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5005 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 4954 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5006 render_pass_quad->rect.ToString()); 4955 render_pass_quad->rect.ToString());
5007 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 4956 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
5055 mask_layer->SetPosition(gfx::PointF()); 5004 mask_layer->SetPosition(gfx::PointF());
5056 mask_layer->SetAnchorPoint(gfx::PointF()); 5005 mask_layer->SetAnchorPoint(gfx::PointF());
5057 mask_layer->SetDrawsContent(true); 5006 mask_layer->SetDrawsContent(true);
5058 5007
5059 // Check that the mask fills the surface. 5008 // Check that the mask fills the surface.
5060 float device_scale_factor = 1.f; 5009 float device_scale_factor = 1.f;
5061 host_impl_->SetViewportSize(root_size); 5010 host_impl_->SetViewportSize(root_size);
5062 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5011 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5063 { 5012 {
5064 LayerTreeHostImpl::FrameData frame; 5013 LayerTreeHostImpl::FrameData frame;
5065 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5014 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5066 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5067 5015
5068 ASSERT_EQ(1u, frame.render_passes.size()); 5016 ASSERT_EQ(1u, frame.render_passes.size());
5069 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5017 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5070 ASSERT_EQ(DrawQuad::RENDER_PASS, 5018 ASSERT_EQ(DrawQuad::RENDER_PASS,
5071 frame.render_passes[0]->quad_list[1]->material); 5019 frame.render_passes[0]->quad_list[1]->material);
5072 const RenderPassDrawQuad* replica_quad = 5020 const RenderPassDrawQuad* replica_quad =
5073 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5021 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5074 EXPECT_TRUE(replica_quad->is_replica); 5022 EXPECT_TRUE(replica_quad->is_replica);
5075 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 5023 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
5076 replica_quad->rect.ToString()); 5024 replica_quad->rect.ToString());
5077 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5025 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5078 replica_quad->mask_uv_rect.ToString()); 5026 replica_quad->mask_uv_rect.ToString());
5079 5027
5080 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5028 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5081 host_impl_->DidDrawAllLayers(frame); 5029 host_impl_->DidDrawAllLayers(frame);
5082 } 5030 }
5083 5031
5084 // Applying a DSF should change the render surface size, but won't affect 5032 // Applying a DSF should change the render surface size, but won't affect
5085 // which part of the mask is used. 5033 // which part of the mask is used.
5086 device_scale_factor = 2.f; 5034 device_scale_factor = 2.f;
5087 gfx::Size device_viewport = 5035 gfx::Size device_viewport =
5088 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor)); 5036 gfx::ToFlooredSize(gfx::ScaleSize(root_size, device_scale_factor));
5089 host_impl_->SetViewportSize(device_viewport); 5037 host_impl_->SetViewportSize(device_viewport);
5090 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5038 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5091 host_impl_->active_tree()->set_needs_update_draw_properties(); 5039 host_impl_->active_tree()->set_needs_update_draw_properties();
5092 { 5040 {
5093 LayerTreeHostImpl::FrameData frame; 5041 LayerTreeHostImpl::FrameData frame;
5094 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5042 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5095 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5096 5043
5097 ASSERT_EQ(1u, frame.render_passes.size()); 5044 ASSERT_EQ(1u, frame.render_passes.size());
5098 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5045 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5099 ASSERT_EQ(DrawQuad::RENDER_PASS, 5046 ASSERT_EQ(DrawQuad::RENDER_PASS,
5100 frame.render_passes[0]->quad_list[1]->material); 5047 frame.render_passes[0]->quad_list[1]->material);
5101 const RenderPassDrawQuad* replica_quad = 5048 const RenderPassDrawQuad* replica_quad =
5102 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5049 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5103 EXPECT_TRUE(replica_quad->is_replica); 5050 EXPECT_TRUE(replica_quad->is_replica);
5104 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5051 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5105 replica_quad->rect.ToString()); 5052 replica_quad->rect.ToString());
(...skipping 10 matching lines...) Expand all
5116 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor)); 5063 gfx::ToRoundedSize(gfx::ScaleSize(layer_size, device_scale_factor));
5117 content_layer->SetContentBounds(layer_size_large); 5064 content_layer->SetContentBounds(layer_size_large);
5118 content_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5065 content_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5119 gfx::Size mask_size_large = 5066 gfx::Size mask_size_large =
5120 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor)); 5067 gfx::ToRoundedSize(gfx::ScaleSize(mask_size, device_scale_factor));
5121 mask_layer->SetContentBounds(mask_size_large); 5068 mask_layer->SetContentBounds(mask_size_large);
5122 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor); 5069 mask_layer->SetContentsScale(device_scale_factor, device_scale_factor);
5123 host_impl_->active_tree()->set_needs_update_draw_properties(); 5070 host_impl_->active_tree()->set_needs_update_draw_properties();
5124 { 5071 {
5125 LayerTreeHostImpl::FrameData frame; 5072 LayerTreeHostImpl::FrameData frame;
5126 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5073 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5127 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5128 5074
5129 ASSERT_EQ(1u, frame.render_passes.size()); 5075 ASSERT_EQ(1u, frame.render_passes.size());
5130 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5076 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5131 ASSERT_EQ(DrawQuad::RENDER_PASS, 5077 ASSERT_EQ(DrawQuad::RENDER_PASS,
5132 frame.render_passes[0]->quad_list[1]->material); 5078 frame.render_passes[0]->quad_list[1]->material);
5133 const RenderPassDrawQuad* replica_quad = 5079 const RenderPassDrawQuad* replica_quad =
5134 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5080 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5135 EXPECT_TRUE(replica_quad->is_replica); 5081 EXPECT_TRUE(replica_quad->is_replica);
5136 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5082 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5137 replica_quad->rect.ToString()); 5083 replica_quad->rect.ToString());
5138 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5084 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5139 replica_quad->mask_uv_rect.ToString()); 5085 replica_quad->mask_uv_rect.ToString());
5140 5086
5141 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5087 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5142 host_impl_->DidDrawAllLayers(frame); 5088 host_impl_->DidDrawAllLayers(frame);
5143 } 5089 }
5144 5090
5145 // Applying a different contents scale to the mask layer means it will have 5091 // Applying a different contents scale to the mask layer means it will have
5146 // a larger texture, but it should use the same tex coords to cover the 5092 // a larger texture, but it should use the same tex coords to cover the
5147 // layer it masks. 5093 // layer it masks.
5148 mask_layer->SetContentBounds(mask_size); 5094 mask_layer->SetContentBounds(mask_size);
5149 mask_layer->SetContentsScale(1.f, 1.f); 5095 mask_layer->SetContentsScale(1.f, 1.f);
5150 host_impl_->active_tree()->set_needs_update_draw_properties(); 5096 host_impl_->active_tree()->set_needs_update_draw_properties();
5151 { 5097 {
5152 LayerTreeHostImpl::FrameData frame; 5098 LayerTreeHostImpl::FrameData frame;
5153 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5099 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5154 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5155 5100
5156 ASSERT_EQ(1u, frame.render_passes.size()); 5101 ASSERT_EQ(1u, frame.render_passes.size());
5157 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5102 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5158 ASSERT_EQ(DrawQuad::RENDER_PASS, 5103 ASSERT_EQ(DrawQuad::RENDER_PASS,
5159 frame.render_passes[0]->quad_list[1]->material); 5104 frame.render_passes[0]->quad_list[1]->material);
5160 const RenderPassDrawQuad* replica_quad = 5105 const RenderPassDrawQuad* replica_quad =
5161 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]); 5106 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
5162 EXPECT_TRUE(replica_quad->is_replica); 5107 EXPECT_TRUE(replica_quad->is_replica);
5163 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5108 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5164 replica_quad->rect.ToString()); 5109 replica_quad->rect.ToString());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5224 mask_layer->SetContentBounds(mask_size); 5169 mask_layer->SetContentBounds(mask_size);
5225 mask_layer->SetPosition(gfx::PointF()); 5170 mask_layer->SetPosition(gfx::PointF());
5226 mask_layer->SetAnchorPoint(gfx::PointF()); 5171 mask_layer->SetAnchorPoint(gfx::PointF());
5227 mask_layer->SetDrawsContent(true); 5172 mask_layer->SetDrawsContent(true);
5228 5173
5229 float device_scale_factor = 1.f; 5174 float device_scale_factor = 1.f;
5230 host_impl_->SetViewportSize(root_size); 5175 host_impl_->SetViewportSize(root_size);
5231 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5176 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5232 { 5177 {
5233 LayerTreeHostImpl::FrameData frame; 5178 LayerTreeHostImpl::FrameData frame;
5234 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5179 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5235 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5236 5180
5237 ASSERT_EQ(1u, frame.render_passes.size()); 5181 ASSERT_EQ(1u, frame.render_passes.size());
5238 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5182 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5239 5183
5240 // The surface is 100x50. 5184 // The surface is 100x50.
5241 ASSERT_EQ(DrawQuad::RENDER_PASS, 5185 ASSERT_EQ(DrawQuad::RENDER_PASS,
5242 frame.render_passes[0]->quad_list[0]->material); 5186 frame.render_passes[0]->quad_list[0]->material);
5243 const RenderPassDrawQuad* render_pass_quad = 5187 const RenderPassDrawQuad* render_pass_quad =
5244 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5188 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5245 EXPECT_FALSE(render_pass_quad->is_replica); 5189 EXPECT_FALSE(render_pass_quad->is_replica);
(...skipping 13 matching lines...) Expand all
5259 5203
5260 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5204 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5261 host_impl_->DidDrawAllLayers(frame); 5205 host_impl_->DidDrawAllLayers(frame);
5262 } 5206 }
5263 5207
5264 // Move the child to (-50, 0) instead. Now the mask should be moved to still 5208 // Move the child to (-50, 0) instead. Now the mask should be moved to still
5265 // cover the layer being replicated. 5209 // cover the layer being replicated.
5266 content_child_layer->SetPosition(gfx::Point(-50, 0)); 5210 content_child_layer->SetPosition(gfx::Point(-50, 0));
5267 { 5211 {
5268 LayerTreeHostImpl::FrameData frame; 5212 LayerTreeHostImpl::FrameData frame;
5269 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5213 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5270 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5271 5214
5272 ASSERT_EQ(1u, frame.render_passes.size()); 5215 ASSERT_EQ(1u, frame.render_passes.size());
5273 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size()); 5216 ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
5274 5217
5275 // The surface is 100x50 with its origin at (-50, 0). 5218 // The surface is 100x50 with its origin at (-50, 0).
5276 ASSERT_EQ(DrawQuad::RENDER_PASS, 5219 ASSERT_EQ(DrawQuad::RENDER_PASS,
5277 frame.render_passes[0]->quad_list[0]->material); 5220 frame.render_passes[0]->quad_list[0]->material);
5278 const RenderPassDrawQuad* render_pass_quad = 5221 const RenderPassDrawQuad* render_pass_quad =
5279 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5222 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5280 EXPECT_FALSE(render_pass_quad->is_replica); 5223 EXPECT_FALSE(render_pass_quad->is_replica);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5359 mask_layer->SetContentBounds(mask_size); 5302 mask_layer->SetContentBounds(mask_size);
5360 mask_layer->SetPosition(gfx::PointF()); 5303 mask_layer->SetPosition(gfx::PointF());
5361 mask_layer->SetAnchorPoint(gfx::PointF()); 5304 mask_layer->SetAnchorPoint(gfx::PointF());
5362 mask_layer->SetDrawsContent(true); 5305 mask_layer->SetDrawsContent(true);
5363 5306
5364 float device_scale_factor = 1.f; 5307 float device_scale_factor = 1.f;
5365 host_impl_->SetViewportSize(root_size); 5308 host_impl_->SetViewportSize(root_size);
5366 host_impl_->SetDeviceScaleFactor(device_scale_factor); 5309 host_impl_->SetDeviceScaleFactor(device_scale_factor);
5367 { 5310 {
5368 LayerTreeHostImpl::FrameData frame; 5311 LayerTreeHostImpl::FrameData frame;
5369 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5312 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5370 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5371 5313
5372 ASSERT_EQ(1u, frame.render_passes.size()); 5314 ASSERT_EQ(1u, frame.render_passes.size());
5373 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size()); 5315 ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
5374 5316
5375 // The surface is clipped to 10x20. 5317 // The surface is clipped to 10x20.
5376 ASSERT_EQ(DrawQuad::RENDER_PASS, 5318 ASSERT_EQ(DrawQuad::RENDER_PASS,
5377 frame.render_passes[0]->quad_list[0]->material); 5319 frame.render_passes[0]->quad_list[0]->material);
5378 const RenderPassDrawQuad* render_pass_quad = 5320 const RenderPassDrawQuad* render_pass_quad =
5379 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]); 5321 RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
5380 EXPECT_FALSE(render_pass_quad->is_replica); 5322 EXPECT_FALSE(render_pass_quad->is_replica);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5441 gfx::Vector2d scroll_offset(100000, 0); 5383 gfx::Vector2d scroll_offset(100000, 0);
5442 scrolling_layer->SetScrollClipLayer(root->id()); 5384 scrolling_layer->SetScrollClipLayer(root->id());
5443 scrolling_layer->SetScrollOffset(scroll_offset); 5385 scrolling_layer->SetScrollOffset(scroll_offset);
5444 5386
5445 host_impl_->ActivatePendingTree(); 5387 host_impl_->ActivatePendingTree();
5446 5388
5447 host_impl_->active_tree()->UpdateDrawProperties(); 5389 host_impl_->active_tree()->UpdateDrawProperties();
5448 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); 5390 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
5449 5391
5450 LayerTreeHostImpl::FrameData frame; 5392 LayerTreeHostImpl::FrameData frame;
5451 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5393 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5452 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5453 5394
5454 ASSERT_EQ(1u, frame.render_passes.size()); 5395 ASSERT_EQ(1u, frame.render_passes.size());
5455 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); 5396 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
5456 const DrawQuad* quad = frame.render_passes[0]->quad_list[0]; 5397 const DrawQuad* quad = frame.render_passes[0]->quad_list[0];
5457 5398
5458 float edge[24]; 5399 float edge[24];
5459 gfx::QuadF device_layer_quad; 5400 gfx::QuadF device_layer_quad;
5460 bool antialiased = 5401 bool antialiased =
5461 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing( 5402 GLRendererWithSetupQuadForAntialiasing::SetupQuadForAntialiasing(
5462 quad->quadTransform(), quad, &device_layer_quad, edge); 5403 quad->quadTransform(), quad, &device_layer_quad, edge);
(...skipping 13 matching lines...) Expand all
5476 swap_buffers_complete_++; 5417 swap_buffers_complete_++;
5477 } 5418 }
5478 5419
5479 int swap_buffers_complete_; 5420 int swap_buffers_complete_;
5480 }; 5421 };
5481 5422
5482 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) { 5423 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) {
5483 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); 5424 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
5484 { 5425 {
5485 LayerTreeHostImpl::FrameData frame; 5426 LayerTreeHostImpl::FrameData frame;
5486 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5427 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5487 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5488 host_impl_->DrawLayers(&frame, base::TimeTicks()); 5428 host_impl_->DrawLayers(&frame, base::TimeTicks());
5489 host_impl_->DidDrawAllLayers(frame); 5429 host_impl_->DidDrawAllLayers(frame);
5490 } 5430 }
5491 CompositorFrameAck ack; 5431 CompositorFrameAck ack;
5492 host_impl_->ReclaimResources(&ack); 5432 host_impl_->ReclaimResources(&ack);
5493 host_impl_->DidSwapBuffersComplete(); 5433 host_impl_->DidSwapBuffersComplete();
5494 EXPECT_EQ(swap_buffers_complete_, 1); 5434 EXPECT_EQ(swap_buffers_complete_, 1);
5495 } 5435 }
5496 5436
5497 class CountingSoftwareDevice : public SoftwareOutputDevice { 5437 class CountingSoftwareDevice : public SoftwareOutputDevice {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5557 FakeVideoFrameProvider provider; 5497 FakeVideoFrameProvider provider;
5558 scoped_ptr<VideoLayerImpl> video_layer = 5498 scoped_ptr<VideoLayerImpl> video_layer =
5559 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider); 5499 VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
5560 video_layer->SetBounds(gfx::Size(10, 10)); 5500 video_layer->SetBounds(gfx::Size(10, 10));
5561 video_layer->SetContentBounds(gfx::Size(10, 10)); 5501 video_layer->SetContentBounds(gfx::Size(10, 10));
5562 video_layer->SetDrawsContent(true); 5502 video_layer->SetDrawsContent(true);
5563 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); 5503 root_layer->AddChild(video_layer.PassAs<LayerImpl>());
5564 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); 5504 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
5565 5505
5566 LayerTreeHostImpl::FrameData frame; 5506 LayerTreeHostImpl::FrameData frame;
5567 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5507 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5568 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5569 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5508 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5570 host_impl_->DidDrawAllLayers(frame); 5509 host_impl_->DidDrawAllLayers(frame);
5571 5510
5572 EXPECT_EQ(1u, frame.will_draw_layers.size()); 5511 EXPECT_EQ(1u, frame.will_draw_layers.size());
5573 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]); 5512 EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]);
5574 } 5513 }
5575 5514
5576 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest { 5515 class LayerTreeHostImplTestDeferredInitialize : public LayerTreeHostImplTest {
5577 protected: 5516 protected:
5578 virtual void SetUp() OVERRIDE { 5517 virtual void SetUp() OVERRIDE {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
5822 5761
5823 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); 5762 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1));
5824 5763
5825 ScopedPtrVector<CopyOutputRequest> requests; 5764 ScopedPtrVector<CopyOutputRequest> requests;
5826 requests.push_back(CopyOutputRequest::CreateRequest( 5765 requests.push_back(CopyOutputRequest::CreateRequest(
5827 base::Bind(&ShutdownReleasesContext_Callback))); 5766 base::Bind(&ShutdownReleasesContext_Callback)));
5828 5767
5829 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests); 5768 host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests);
5830 5769
5831 LayerTreeHostImpl::FrameData frame; 5770 LayerTreeHostImpl::FrameData frame;
5832 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 5771 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5833 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5834 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 5772 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
5835 host_impl_->DidDrawAllLayers(frame); 5773 host_impl_->DidDrawAllLayers(frame);
5836 5774
5837 // The CopyOutputResult's callback has a ref on the ContextProvider and a 5775 // The CopyOutputResult's callback has a ref on the ContextProvider and a
5838 // texture in a texture mailbox. 5776 // texture in a texture mailbox.
5839 EXPECT_FALSE(context_provider->HasOneRef()); 5777 EXPECT_FALSE(context_provider->HasOneRef());
5840 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); 5778 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures());
5841 5779
5842 host_impl_.reset(); 5780 host_impl_.reset();
5843 5781
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
6098 ui::LatencyInfo latency_info; 6036 ui::LatencyInfo latency_info;
6099 latency_info.AddLatencyNumber( 6037 latency_info.AddLatencyNumber(
6100 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); 6038 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0);
6101 scoped_ptr<SwapPromise> swap_promise( 6039 scoped_ptr<SwapPromise> swap_promise(
6102 new LatencyInfoSwapPromise(latency_info)); 6040 new LatencyInfoSwapPromise(latency_info));
6103 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); 6041 host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
6104 host_impl_->SetNeedsRedraw(); 6042 host_impl_->SetNeedsRedraw();
6105 6043
6106 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); 6044 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
6107 LayerTreeHostImpl::FrameData frame; 6045 LayerTreeHostImpl::FrameData frame;
6108 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, 6046 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame, gfx::Rect()));
6109 host_impl_->PrepareToDraw(&frame, gfx::Rect()));
6110 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 6047 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
6111 host_impl_->DidDrawAllLayers(frame); 6048 host_impl_->DidDrawAllLayers(frame);
6112 EXPECT_TRUE(host_impl_->SwapBuffers(frame)); 6049 EXPECT_TRUE(host_impl_->SwapBuffers(frame));
6113 6050
6114 const std::vector<ui::LatencyInfo>& metadata_latency_after = 6051 const std::vector<ui::LatencyInfo>& metadata_latency_after =
6115 fake_output_surface->last_sent_frame().metadata.latency_info; 6052 fake_output_surface->last_sent_frame().metadata.latency_info;
6116 EXPECT_EQ(1u, metadata_latency_after.size()); 6053 EXPECT_EQ(1u, metadata_latency_after.size());
6117 EXPECT_TRUE(metadata_latency_after[0].FindLatency( 6054 EXPECT_TRUE(metadata_latency_after[0].FindLatency(
6118 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL)); 6055 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL));
6119 } 6056 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
6396 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, 6333 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes,
6397 300u * 1024u * 1024u); 6334 300u * 1024u * 1024u);
6398 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, 6335 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes,
6399 150u * 1024u * 1024u); 6336 150u * 1024u * 1024u);
6400 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, 6337 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes,
6401 75u * 1024u * 1024u); 6338 75u * 1024u * 1024u);
6402 } 6339 }
6403 6340
6404 } // namespace 6341 } // namespace
6405 } // namespace cc 6342 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698