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

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

Issue 322793002: cc: Use LayerImpl instead of TiledLayerImpl in LTHI test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments updated Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 host_impl_->MakeCompositorFrameMetadata(); 1634 host_impl_->MakeCompositorFrameMetadata();
1635 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); 1635 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset);
1636 EXPECT_EQ(4.f, metadata.page_scale_factor); 1636 EXPECT_EQ(4.f, metadata.page_scale_factor);
1637 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size); 1637 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size);
1638 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); 1638 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
1639 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); 1639 EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
1640 EXPECT_EQ(4.f, metadata.max_page_scale_factor); 1640 EXPECT_EQ(4.f, metadata.max_page_scale_factor);
1641 } 1641 }
1642 } 1642 }
1643 1643
1644 // TODO(enne): Convert this to PictureLayerImpl 1644 class DidDrawCheckLayer : public LayerImpl {
1645 class DidDrawCheckLayer : public TiledLayerImpl {
1646 public: 1645 public:
1647 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 1646 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
1648 return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id)); 1647 return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id));
1649 } 1648 }
1650 1649
1651 virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) 1650 virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider)
1652 OVERRIDE { 1651 OVERRIDE {
1653 will_draw_called_ = true; 1652 will_draw_called_ = true;
1654 if (will_draw_returns_false_) 1653 if (will_draw_returns_false_)
1655 return false; 1654 return false;
1656 return TiledLayerImpl::WillDraw(draw_mode, provider); 1655 return LayerImpl::WillDraw(draw_mode, provider);
1657 } 1656 }
1658 1657
1659 virtual void AppendQuads(QuadSink* quad_sink, 1658 virtual void AppendQuads(QuadSink* quad_sink,
1660 AppendQuadsData* append_quads_data) OVERRIDE { 1659 AppendQuadsData* append_quads_data) OVERRIDE {
1661 append_quads_called_ = true; 1660 append_quads_called_ = true;
1662 TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); 1661 LayerImpl::AppendQuads(quad_sink, append_quads_data);
1663 } 1662 }
1664 1663
1665 virtual void DidDraw(ResourceProvider* provider) OVERRIDE { 1664 virtual void DidDraw(ResourceProvider* provider) OVERRIDE {
1666 did_draw_called_ = true; 1665 did_draw_called_ = true;
1667 TiledLayerImpl::DidDraw(provider); 1666 LayerImpl::DidDraw(provider);
1668 } 1667 }
1669 1668
1670 bool will_draw_called() const { return will_draw_called_; } 1669 bool will_draw_called() const { return will_draw_called_; }
1671 bool append_quads_called() const { return append_quads_called_; } 1670 bool append_quads_called() const { return append_quads_called_; }
1672 bool did_draw_called() const { return did_draw_called_; } 1671 bool did_draw_called() const { return did_draw_called_; }
1673 1672
1674 void set_will_draw_returns_false() { will_draw_returns_false_ = true; } 1673 void set_will_draw_returns_false() { will_draw_returns_false_ = true; }
1675 1674
1676 void ClearDidDrawCheck() { 1675 void ClearDidDrawCheck() {
1677 will_draw_called_ = false; 1676 will_draw_called_ = false;
1678 append_quads_called_ = false; 1677 append_quads_called_ = false;
1679 did_draw_called_ = false; 1678 did_draw_called_ = false;
1680 } 1679 }
1681 1680
1682 protected: 1681 protected:
1683 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) 1682 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id)
1684 : TiledLayerImpl(tree_impl, id), 1683 : LayerImpl(tree_impl, id),
1685 will_draw_returns_false_(false), 1684 will_draw_returns_false_(false),
1686 will_draw_called_(false), 1685 will_draw_called_(false),
1687 append_quads_called_(false), 1686 append_quads_called_(false),
1688 did_draw_called_(false) { 1687 did_draw_called_(false) {
1689 SetBounds(gfx::Size(10, 10)); 1688 SetBounds(gfx::Size(10, 10));
1690 SetContentBounds(gfx::Size(10, 10)); 1689 SetContentBounds(gfx::Size(10, 10));
1691 SetDrawsContent(true); 1690 SetDrawsContent(true);
1692 set_skips_draw(false);
1693 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); 1691 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
1694
1695 scoped_ptr<LayerTilingData> tiler =
1696 LayerTilingData::Create(gfx::Size(100, 100),
1697 LayerTilingData::HAS_BORDER_TEXELS);
1698 tiler->SetTilingRect(gfx::Rect(content_bounds()));
1699 SetTilingData(*tiler.get());
1700 } 1692 }
1701 1693
1702 private: 1694 private:
1703 bool will_draw_returns_false_; 1695 bool will_draw_returns_false_;
1704 bool will_draw_called_; 1696 bool will_draw_called_;
1705 bool append_quads_called_; 1697 bool append_quads_called_;
1706 bool did_draw_called_; 1698 bool did_draw_called_;
1707 }; 1699 };
1708 1700
1709 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { 1701 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 1857
1866 EXPECT_NE(root->render_surface(), layer1->render_surface()); 1858 EXPECT_NE(root->render_surface(), layer1->render_surface());
1867 EXPECT_TRUE(!!layer1->render_surface()); 1859 EXPECT_TRUE(!!layer1->render_surface());
1868 } 1860 }
1869 1861
1870 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { 1862 class MissingTextureAnimatingLayer : public DidDrawCheckLayer {
1871 public: 1863 public:
1872 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, 1864 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl,
1873 int id, 1865 int id,
1874 bool tile_missing, 1866 bool tile_missing,
1875 bool skips_draw, 1867 bool had_incomplete_tile,
1876 bool animating, 1868 bool animating,
1877 ResourceProvider* resource_provider) { 1869 ResourceProvider* resource_provider) {
1878 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer( 1870 return scoped_ptr<LayerImpl>(
1879 tree_impl, 1871 new MissingTextureAnimatingLayer(tree_impl,
1880 id, 1872 id,
1881 tile_missing, 1873 tile_missing,
1882 skips_draw, 1874 had_incomplete_tile,
1883 animating, 1875 animating,
1884 resource_provider)); 1876 resource_provider));
1885 } 1877 }
1886 1878
1887 virtual void AppendQuads(QuadSink* quad_sink, 1879 virtual void AppendQuads(QuadSink* quad_sink,
1888 AppendQuadsData* append_quads_data) OVERRIDE { 1880 AppendQuadsData* append_quads_data) OVERRIDE {
1889 TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); 1881 LayerImpl::AppendQuads(quad_sink, append_quads_data);
1882 if (had_incomplete_tile_)
1883 append_quads_data->had_incomplete_tile = true;
1890 if (tile_missing_) 1884 if (tile_missing_)
1891 append_quads_data->had_incomplete_tile = true; 1885 append_quads_data->num_missing_tiles++;
1892 } 1886 }
1893 1887
1894 private: 1888 private:
1895 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, 1889 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl,
1896 int id, 1890 int id,
1897 bool tile_missing, 1891 bool tile_missing,
1898 bool skips_draw, 1892 bool had_incomplete_tile,
1899 bool animating, 1893 bool animating,
1900 ResourceProvider* resource_provider) 1894 ResourceProvider* resource_provider)
1901 : DidDrawCheckLayer(tree_impl, id), tile_missing_(tile_missing) { 1895 : DidDrawCheckLayer(tree_impl, id),
1902 scoped_ptr<LayerTilingData> tiling_data = 1896 tile_missing_(tile_missing),
1903 LayerTilingData::Create(gfx::Size(10, 10), 1897 had_incomplete_tile_(had_incomplete_tile) {
1904 LayerTilingData::NO_BORDER_TEXELS);
1905 tiling_data->SetTilingRect(gfx::Rect(bounds()));
1906 SetTilingData(*tiling_data.get());
1907 set_skips_draw(skips_draw);
1908 if (!tile_missing) {
1909 ResourceProvider::ResourceId resource =
1910 resource_provider->CreateResource(gfx::Size(1, 1),
1911 GL_CLAMP_TO_EDGE,
1912 ResourceProvider::TextureUsageAny,
1913 RGBA_8888);
1914 resource_provider->AllocateForTesting(resource);
1915 PushTileProperties(0, 0, resource, gfx::Rect(), false);
1916 }
1917 if (animating) 1898 if (animating)
1918 AddAnimatedTransformToLayer(this, 10.0, 3, 0); 1899 AddAnimatedTransformToLayer(this, 10.0, 3, 0);
1919 } 1900 }
1920 1901
1921 bool tile_missing_; 1902 bool tile_missing_;
1903 bool had_incomplete_tile_;
1922 }; 1904 };
1923 1905
1924 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenNoTexturesMissing) { 1906 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) {
1925 host_impl_->active_tree()->SetRootLayer( 1907 host_impl_->active_tree()->SetRootLayer(
1926 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1908 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1927 DidDrawCheckLayer* root = 1909 DidDrawCheckLayer* root =
1928 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1910 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1929 1911
1930 bool tile_missing = false; 1912 bool tile_missing = false;
1931 bool skips_draw = false; 1913 bool had_incomplete_tile = false;
1932 bool is_animating = false; 1914 bool is_animating = false;
1933 root->AddChild( 1915 root->AddChild(
1934 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1916 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1935 2, 1917 2,
1936 tile_missing, 1918 tile_missing,
1937 skips_draw, 1919 had_incomplete_tile,
1938 is_animating, 1920 is_animating,
1939 host_impl_->resource_provider())); 1921 host_impl_->resource_provider()));
1940 1922
1941 LayerTreeHostImpl::FrameData frame; 1923 LayerTreeHostImpl::FrameData frame;
1942 1924
1943 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1925 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1944 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1926 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1945 host_impl_->DidDrawAllLayers(frame); 1927 host_impl_->DidDrawAllLayers(frame);
1946 } 1928 }
1947 1929
1948 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { 1930 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) {
1949 host_impl_->active_tree()->SetRootLayer( 1931 host_impl_->active_tree()->SetRootLayer(
1950 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1932 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1951 DidDrawCheckLayer* root = 1933 DidDrawCheckLayer* root =
1952 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1934 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1953 bool tile_missing = false; 1935 bool tile_missing = false;
1954 bool skips_draw = false; 1936 bool had_incomplete_tile = false;
1955 bool is_animating = true; 1937 bool is_animating = true;
1956 root->AddChild( 1938 root->AddChild(
1957 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1939 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1958 2, 1940 2,
1959 tile_missing, 1941 tile_missing,
1960 skips_draw, 1942 had_incomplete_tile,
1961 is_animating, 1943 is_animating,
1962 host_impl_->resource_provider())); 1944 host_impl_->resource_provider()));
1963 1945
1964 LayerTreeHostImpl::FrameData frame; 1946 LayerTreeHostImpl::FrameData frame;
1965 1947
1966 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1948 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1967 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1949 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1968 host_impl_->DidDrawAllLayers(frame); 1950 host_impl_->DidDrawAllLayers(frame);
1969 } 1951 }
1970 1952
1971 TEST_F(LayerTreeHostImplTest, 1953 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) {
1972 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) {
1973 // When a texture is missing and we're not animating, we draw as usual with
1974 // checkerboarding.
1975 host_impl_->active_tree()->SetRootLayer( 1954 host_impl_->active_tree()->SetRootLayer(
1976 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1955 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1977 DidDrawCheckLayer* root = 1956 DidDrawCheckLayer* root =
1978 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1957 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1979 1958
1980 bool tile_missing = true; 1959 bool tile_missing = true;
1981 bool skips_draw = false; 1960 bool had_incomplete_tile = false;
1982 bool is_animating = false; 1961 bool is_animating = false;
1983 root->AddChild( 1962 root->AddChild(
1984 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1963 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1985 4, 1964 4,
1986 tile_missing, 1965 tile_missing,
1987 skips_draw, 1966 had_incomplete_tile,
1988 is_animating, 1967 is_animating,
1989 host_impl_->resource_provider())); 1968 host_impl_->resource_provider()));
1990 LayerTreeHostImpl::FrameData frame; 1969 LayerTreeHostImpl::FrameData frame;
1970 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1971 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1972 host_impl_->DidDrawAllLayers(frame);
1973 }
1974
1975 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) {
1976 host_impl_->active_tree()->SetRootLayer(
1977 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1978 DidDrawCheckLayer* root =
1979 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1980
1981 bool tile_missing = false;
1982 bool had_incomplete_tile = true;
1983 bool is_animating = false;
1984 root->AddChild(
1985 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1986 4,
1987 tile_missing,
1988 had_incomplete_tile,
1989 is_animating,
1990 host_impl_->resource_provider()));
1991 LayerTreeHostImpl::FrameData frame;
1991 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1992 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1992 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1993 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1993 host_impl_->DidDrawAllLayers(frame); 1994 host_impl_->DidDrawAllLayers(frame);
1994 } 1995 }
1995 1996
1996 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { 1997 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) {
1997 // When a texture is missing and we're animating, we don't want to draw
1998 // anything.
1999 host_impl_->active_tree()->SetRootLayer( 1998 host_impl_->active_tree()->SetRootLayer(
2000 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 1999 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
2001 DidDrawCheckLayer* root = 2000 DidDrawCheckLayer* root =
2002 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2001 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2003 bool tile_missing = true; 2002 bool tile_missing = true;
2004 bool skips_draw = false; 2003 bool had_incomplete_tile = true;
danakj 2014/06/11 17:51:03 false here
sohanjg 2014/06/12 11:27:12 Done.
2005 bool is_animating = true; 2004 bool is_animating = true;
2006 root->AddChild( 2005 root->AddChild(
2007 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2006 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2008 6, 2007 6,
2009 tile_missing, 2008 tile_missing,
2010 skips_draw, 2009 had_incomplete_tile,
2011 is_animating, 2010 is_animating,
2012 host_impl_->resource_provider())); 2011 host_impl_->resource_provider()));
2013 LayerTreeHostImpl::FrameData frame; 2012 LayerTreeHostImpl::FrameData frame;
2014 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, 2013 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
2015 host_impl_->PrepareToDraw(&frame)); 2014 host_impl_->PrepareToDraw(&frame));
2016 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2015 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2017 host_impl_->DidDrawAllLayers(frame); 2016 host_impl_->DidDrawAllLayers(frame);
2018 } 2017 }
2019 2018
2020 TEST_F(LayerTreeHostImplTest, 2019 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWithAnimationAndMissingTiles) {
2021 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) { 2020 host_impl_->active_tree()->SetRootLayer(
2022 // When the layer skips draw and we're animating, we still draw the frame. 2021 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
2022 DidDrawCheckLayer* root =
2023 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2024 bool tile_missing = true;
danakj 2014/06/11 17:51:03 false here
sohanjg 2014/06/12 11:27:12 Done.
2025 bool had_incomplete_tile = false;
danakj 2014/06/11 17:51:03 true here
sohanjg 2014/06/12 11:27:12 Done.
2026 bool is_animating = true;
2027 root->AddChild(
2028 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2029 6,
2030 tile_missing,
2031 had_incomplete_tile,
2032 is_animating,
2033 host_impl_->resource_provider()));
2034 LayerTreeHostImpl::FrameData frame;
2035 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
2036 host_impl_->PrepareToDraw(&frame));
2037 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2038 host_impl_->DidDrawAllLayers(frame);
2039 }
2040
2041 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) {
2023 host_impl_->active_tree()->SetRootLayer( 2042 host_impl_->active_tree()->SetRootLayer(
2024 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2043 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2025 DidDrawCheckLayer* root = 2044 DidDrawCheckLayer* root =
2026 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2045 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2027 bool tile_missing = false; 2046 bool tile_missing = false;
2028 bool skips_draw = true; 2047 bool had_incomplete_tile = false;
2029 bool is_animating = true; 2048 bool is_animating = false;
2030 root->AddChild( 2049 root->AddChild(
2031 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2050 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2032 8, 2051 8,
2033 tile_missing, 2052 tile_missing,
2034 skips_draw, 2053 had_incomplete_tile,
2035 is_animating, 2054 is_animating,
2036 host_impl_->resource_provider())); 2055 host_impl_->resource_provider()));
2056 host_impl_->active_tree()->SetRequiresHighResToDraw();
2037 LayerTreeHostImpl::FrameData frame; 2057 LayerTreeHostImpl::FrameData frame;
2038 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2058 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2039 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2059 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2040 host_impl_->DidDrawAllLayers(frame); 2060 host_impl_->DidDrawAllLayers(frame);
2041 } 2061 }
2042 2062
2043 TEST_F(LayerTreeHostImplTest, 2063 TEST_F(LayerTreeHostImplTest,
2044 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) { 2064 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) {
2045 // When the layer skips draw and we're animating, we still draw the frame.
2046 host_impl_->active_tree()->SetRootLayer( 2065 host_impl_->active_tree()->SetRootLayer(
2047 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2066 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2048 DidDrawCheckLayer* root = 2067 DidDrawCheckLayer* root =
2049 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2068 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2050 bool tile_missing = false; 2069 bool tile_missing = false;
2051 bool skips_draw = false; 2070 bool had_incomplete_tile = true;
2052 bool is_animating = false; 2071 bool is_animating = false;
2053 root->AddChild( 2072 root->AddChild(
2054 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2073 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2055 8, 2074 8,
2056 tile_missing, 2075 tile_missing,
2057 skips_draw, 2076 had_incomplete_tile,
2058 is_animating,
2059 host_impl_->resource_provider()));
2060 host_impl_->active_tree()->SetRequiresHighResToDraw();
2061 LayerTreeHostImpl::FrameData frame;
2062 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2063 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2064 host_impl_->DidDrawAllLayers(frame);
2065 }
2066
2067 TEST_F(LayerTreeHostImplTest,
2068 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) {
2069 // When the layer skips draw and we're animating, we still draw the frame.
2070 host_impl_->active_tree()->SetRootLayer(
2071 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2072 DidDrawCheckLayer* root =
2073 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2074 bool tile_missing = true;
2075 bool skips_draw = false;
2076 bool is_animating = false;
2077 root->AddChild(
2078 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2079 8,
2080 tile_missing,
2081 skips_draw,
2082 is_animating, 2077 is_animating,
2083 host_impl_->resource_provider())); 2078 host_impl_->resource_provider()));
2084 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2079 host_impl_->active_tree()->SetRequiresHighResToDraw();
2085 LayerTreeHostImpl::FrameData frame; 2080 LayerTreeHostImpl::FrameData frame;
2086 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, 2081 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2087 host_impl_->PrepareToDraw(&frame)); 2082 host_impl_->PrepareToDraw(&frame));
2088 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2083 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2089 host_impl_->DidDrawAllLayers(frame); 2084 host_impl_->DidDrawAllLayers(frame);
2090 } 2085 }
2086
2087 TEST_F(LayerTreeHostImplTest,
2088 PrepareToDrawSucceedsWhenHighResRequiredAndMissingTile) {
2089 host_impl_->active_tree()->SetRootLayer(
2090 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2091 DidDrawCheckLayer* root =
2092 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2093 bool tile_missing = true;
2094 bool had_incomplete_tile = false;
2095 bool is_animating = false;
2096 root->AddChild(
2097 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2098 8,
2099 tile_missing,
2100 had_incomplete_tile,
2101 is_animating,
2102 host_impl_->resource_provider()));
2103 host_impl_->active_tree()->SetRequiresHighResToDraw();
2104 LayerTreeHostImpl::FrameData frame;
2105 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2106 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2107 host_impl_->DidDrawAllLayers(frame);
2108 }
2091 2109
2092 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 2110 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
2093 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2111 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2094 root->SetScrollClipLayer(Layer::INVALID_ID); 2112 root->SetScrollClipLayer(Layer::INVALID_ID);
2095 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2113 host_impl_->active_tree()->SetRootLayer(root.Pass());
2096 DrawFrame(); 2114 DrawFrame();
2097 2115
2098 // Scroll event is ignored because layer is not scrollable. 2116 // Scroll event is ignored because layer is not scrollable.
2099 EXPECT_EQ(InputHandler::ScrollIgnored, 2117 EXPECT_EQ(InputHandler::ScrollIgnored,
2100 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); 2118 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
(...skipping 4466 matching lines...) Expand 10 before | Expand all | Expand 10 after
6567 FakePictureLayerImpl* active_mask_content = 6585 FakePictureLayerImpl* active_mask_content =
6568 static_cast<FakePictureLayerImpl*>( 6586 static_cast<FakePictureLayerImpl*>(
6569 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); 6587 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer());
6570 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); 6588 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority();
6571 6589
6572 ASSERT_TRUE(!r2.IsEmpty()); 6590 ASSERT_TRUE(!r2.IsEmpty());
6573 } 6591 }
6574 6592
6575 } // namespace 6593 } // namespace
6576 } // namespace cc 6594 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698