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

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: remove unused includes 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 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 host_impl_->MakeCompositorFrameMetadata(); 1639 host_impl_->MakeCompositorFrameMetadata();
1640 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); 1640 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset);
1641 EXPECT_EQ(4.f, metadata.page_scale_factor); 1641 EXPECT_EQ(4.f, metadata.page_scale_factor);
1642 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size); 1642 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size);
1643 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); 1643 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
1644 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); 1644 EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
1645 EXPECT_EQ(4.f, metadata.max_page_scale_factor); 1645 EXPECT_EQ(4.f, metadata.max_page_scale_factor);
1646 } 1646 }
1647 } 1647 }
1648 1648
1649 // TODO(enne): Convert this to PictureLayerImpl 1649 class DidDrawCheckLayer : public LayerImpl {
1650 class DidDrawCheckLayer : public TiledLayerImpl {
1651 public: 1650 public:
1652 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { 1651 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
1653 return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id)); 1652 return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id));
1654 } 1653 }
1655 1654
1656 virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider) 1655 virtual bool WillDraw(DrawMode draw_mode, ResourceProvider* provider)
1657 OVERRIDE { 1656 OVERRIDE {
1658 will_draw_called_ = true; 1657 will_draw_called_ = true;
1659 if (will_draw_returns_false_) 1658 if (will_draw_returns_false_)
1660 return false; 1659 return false;
1661 return TiledLayerImpl::WillDraw(draw_mode, provider); 1660 return LayerImpl::WillDraw(draw_mode, provider);
1662 } 1661 }
1663 1662
1664 virtual void AppendQuads(QuadSink* quad_sink, 1663 virtual void AppendQuads(QuadSink* quad_sink,
1665 AppendQuadsData* append_quads_data) OVERRIDE { 1664 AppendQuadsData* append_quads_data) OVERRIDE {
1666 append_quads_called_ = true; 1665 append_quads_called_ = true;
1667 TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); 1666 LayerImpl::AppendQuads(quad_sink, append_quads_data);
1668 } 1667 }
1669 1668
1670 virtual void DidDraw(ResourceProvider* provider) OVERRIDE { 1669 virtual void DidDraw(ResourceProvider* provider) OVERRIDE {
1671 did_draw_called_ = true; 1670 did_draw_called_ = true;
1672 TiledLayerImpl::DidDraw(provider); 1671 LayerImpl::DidDraw(provider);
1673 } 1672 }
1674 1673
1675 bool will_draw_called() const { return will_draw_called_; } 1674 bool will_draw_called() const { return will_draw_called_; }
1676 bool append_quads_called() const { return append_quads_called_; } 1675 bool append_quads_called() const { return append_quads_called_; }
1677 bool did_draw_called() const { return did_draw_called_; } 1676 bool did_draw_called() const { return did_draw_called_; }
1678 1677
1679 void set_will_draw_returns_false() { will_draw_returns_false_ = true; } 1678 void set_will_draw_returns_false() { will_draw_returns_false_ = true; }
1680 1679
1681 void ClearDidDrawCheck() { 1680 void ClearDidDrawCheck() {
1682 will_draw_called_ = false; 1681 will_draw_called_ = false;
1683 append_quads_called_ = false; 1682 append_quads_called_ = false;
1684 did_draw_called_ = false; 1683 did_draw_called_ = false;
1685 } 1684 }
1686 1685
1687 protected: 1686 protected:
1688 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id) 1687 DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id)
1689 : TiledLayerImpl(tree_impl, id), 1688 : LayerImpl(tree_impl, id),
1690 will_draw_returns_false_(false), 1689 will_draw_returns_false_(false),
1691 will_draw_called_(false), 1690 will_draw_called_(false),
1692 append_quads_called_(false), 1691 append_quads_called_(false),
1693 did_draw_called_(false) { 1692 did_draw_called_(false) {
1694 SetAnchorPoint(gfx::PointF()); 1693 SetAnchorPoint(gfx::PointF());
1695 SetBounds(gfx::Size(10, 10)); 1694 SetBounds(gfx::Size(10, 10));
1696 SetContentBounds(gfx::Size(10, 10)); 1695 SetContentBounds(gfx::Size(10, 10));
1697 SetDrawsContent(true); 1696 SetDrawsContent(true);
1698 set_skips_draw(false);
1699 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); 1697 draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
1700
1701 scoped_ptr<LayerTilingData> tiler =
1702 LayerTilingData::Create(gfx::Size(100, 100),
1703 LayerTilingData::HAS_BORDER_TEXELS);
1704 tiler->SetTilingRect(gfx::Rect(content_bounds()));
1705 SetTilingData(*tiler.get());
1706 } 1698 }
1707 1699
1708 private: 1700 private:
1709 bool will_draw_returns_false_; 1701 bool will_draw_returns_false_;
1710 bool will_draw_called_; 1702 bool will_draw_called_;
1711 bool append_quads_called_; 1703 bool append_quads_called_;
1712 bool did_draw_called_; 1704 bool did_draw_called_;
1713 }; 1705 };
1714 1706
1715 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { 1707 TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 1863
1872 EXPECT_NE(root->render_surface(), layer1->render_surface()); 1864 EXPECT_NE(root->render_surface(), layer1->render_surface());
1873 EXPECT_TRUE(!!layer1->render_surface()); 1865 EXPECT_TRUE(!!layer1->render_surface());
1874 } 1866 }
1875 1867
1876 class MissingTextureAnimatingLayer : public DidDrawCheckLayer { 1868 class MissingTextureAnimatingLayer : public DidDrawCheckLayer {
1877 public: 1869 public:
1878 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, 1870 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl,
1879 int id, 1871 int id,
1880 bool tile_missing, 1872 bool tile_missing,
1881 bool skips_draw,
1882 bool animating, 1873 bool animating,
1883 ResourceProvider* resource_provider) { 1874 ResourceProvider* resource_provider) {
1884 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer( 1875 return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(
1885 tree_impl, 1876 tree_impl,
1886 id, 1877 id,
1887 tile_missing, 1878 tile_missing,
1888 skips_draw,
1889 animating, 1879 animating,
1890 resource_provider)); 1880 resource_provider));
1891 } 1881 }
1892 1882
1893 virtual void AppendQuads(QuadSink* quad_sink, 1883 virtual void AppendQuads(QuadSink* quad_sink,
1894 AppendQuadsData* append_quads_data) OVERRIDE { 1884 AppendQuadsData* append_quads_data) OVERRIDE {
1895 TiledLayerImpl::AppendQuads(quad_sink, append_quads_data); 1885 LayerImpl::AppendQuads(quad_sink, append_quads_data);
1896 if (tile_missing_) 1886 if (tile_missing_) {
1897 append_quads_data->had_incomplete_tile = true; 1887 append_quads_data->had_incomplete_tile = true;
1888 append_quads_data->num_missing_tiles = true;
danakj 2014/06/09 17:03:40 num_missing_tiles is not a bool it's a count. it
sohanjg 2014/06/10 14:12:44 Done.
1889 }
1898 } 1890 }
1899 1891
1900 private: 1892 private:
1901 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl, 1893 MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl,
1902 int id, 1894 int id,
1903 bool tile_missing, 1895 bool tile_missing,
1904 bool skips_draw,
1905 bool animating, 1896 bool animating,
1906 ResourceProvider* resource_provider) 1897 ResourceProvider* resource_provider)
1907 : DidDrawCheckLayer(tree_impl, id), tile_missing_(tile_missing) { 1898 : DidDrawCheckLayer(tree_impl, id), tile_missing_(tile_missing) {
1908 scoped_ptr<LayerTilingData> tiling_data =
1909 LayerTilingData::Create(gfx::Size(10, 10),
1910 LayerTilingData::NO_BORDER_TEXELS);
1911 tiling_data->SetTilingRect(gfx::Rect(bounds()));
1912 SetTilingData(*tiling_data.get());
1913 set_skips_draw(skips_draw);
1914 if (!tile_missing) { 1899 if (!tile_missing) {
1915 ResourceProvider::ResourceId resource = 1900 ResourceProvider::ResourceId resource =
1916 resource_provider->CreateResource(gfx::Size(1, 1), 1901 resource_provider->CreateResource(gfx::Size(1, 1),
1917 GL_CLAMP_TO_EDGE, 1902 GL_CLAMP_TO_EDGE,
1918 ResourceProvider::TextureUsageAny, 1903 ResourceProvider::TextureUsageAny,
1919 RGBA_8888); 1904 RGBA_8888);
1920 resource_provider->AllocateForTesting(resource); 1905 resource_provider->AllocateForTesting(resource);
1921 PushTileProperties(0, 0, resource, gfx::Rect(), false);
1922 } 1906 }
1923 if (animating) 1907 if (animating)
1924 AddAnimatedTransformToLayer(this, 10.0, 3, 0); 1908 AddAnimatedTransformToLayer(this, 10.0, 3, 0);
1925 } 1909 }
1926 1910
1927 bool tile_missing_; 1911 bool tile_missing_;
1928 }; 1912 };
1929 1913
1930 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenNoTexturesMissing) { 1914 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenNoTexturesMissing) {
1931 host_impl_->active_tree()->SetRootLayer( 1915 host_impl_->active_tree()->SetRootLayer(
1932 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1916 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1933 DidDrawCheckLayer* root = 1917 DidDrawCheckLayer* root =
1934 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1918 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1935 1919
1936 bool tile_missing = false; 1920 bool tile_missing = false;
1937 bool skips_draw = false;
1938 bool is_animating = false; 1921 bool is_animating = false;
1939 root->AddChild( 1922 root->AddChild(
1940 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1923 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1941 2, 1924 2,
1942 tile_missing, 1925 tile_missing,
1943 skips_draw,
1944 is_animating, 1926 is_animating,
1945 host_impl_->resource_provider())); 1927 host_impl_->resource_provider()));
1946 1928
1947 LayerTreeHostImpl::FrameData frame; 1929 LayerTreeHostImpl::FrameData frame;
1948 1930
1949 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1931 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1950 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1932 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1951 host_impl_->DidDrawAllLayers(frame); 1933 host_impl_->DidDrawAllLayers(frame);
1952 } 1934 }
1953 1935
1954 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { 1936 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) {
1955 host_impl_->active_tree()->SetRootLayer( 1937 host_impl_->active_tree()->SetRootLayer(
1956 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); 1938 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
1957 DidDrawCheckLayer* root = 1939 DidDrawCheckLayer* root =
1958 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1940 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1959 bool tile_missing = false; 1941 bool tile_missing = false;
1960 bool skips_draw = false;
1961 bool is_animating = true; 1942 bool is_animating = true;
1962 root->AddChild( 1943 root->AddChild(
1963 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1944 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1964 2, 1945 2,
1965 tile_missing, 1946 tile_missing,
1966 skips_draw,
1967 is_animating, 1947 is_animating,
1968 host_impl_->resource_provider())); 1948 host_impl_->resource_provider()));
1969 1949
1970 LayerTreeHostImpl::FrameData frame; 1950 LayerTreeHostImpl::FrameData frame;
1971 1951
1972 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1952 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1973 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1953 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1974 host_impl_->DidDrawAllLayers(frame); 1954 host_impl_->DidDrawAllLayers(frame);
1975 } 1955 }
1976 1956
1977 TEST_F(LayerTreeHostImplTest, 1957 TEST_F(LayerTreeHostImplTest,
1978 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) { 1958 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) {
1979 // When a texture is missing and we're not animating, we draw as usual with 1959 // When a texture is missing and we're not animating, we draw as usual with
1980 // checkerboarding. 1960 // checkerboarding.
1981 host_impl_->active_tree()->SetRootLayer( 1961 host_impl_->active_tree()->SetRootLayer(
1982 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); 1962 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
1983 DidDrawCheckLayer* root = 1963 DidDrawCheckLayer* root =
1984 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1964 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
1985 1965
1986 bool tile_missing = true; 1966 bool tile_missing = true;
1987 bool skips_draw = false;
1988 bool is_animating = false; 1967 bool is_animating = false;
1989 root->AddChild( 1968 root->AddChild(
1990 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1969 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
1991 4, 1970 4,
1992 tile_missing, 1971 tile_missing,
1993 skips_draw,
1994 is_animating, 1972 is_animating,
1995 host_impl_->resource_provider())); 1973 host_impl_->resource_provider()));
1996 LayerTreeHostImpl::FrameData frame; 1974 LayerTreeHostImpl::FrameData frame;
1997 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 1975 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
1998 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1976 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
1999 host_impl_->DidDrawAllLayers(frame); 1977 host_impl_->DidDrawAllLayers(frame);
2000 } 1978 }
2001 1979
2002 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { 1980 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) {
2003 // When a texture is missing and we're animating, we don't want to draw 1981 // When a texture is missing and we're animating, we don't want to draw
2004 // anything. 1982 // anything.
2005 host_impl_->active_tree()->SetRootLayer( 1983 host_impl_->active_tree()->SetRootLayer(
2006 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); 1984 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
2007 DidDrawCheckLayer* root = 1985 DidDrawCheckLayer* root =
2008 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 1986 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2009 bool tile_missing = true; 1987 bool tile_missing = true;
2010 bool skips_draw = false;
2011 bool is_animating = true; 1988 bool is_animating = true;
2012 root->AddChild( 1989 root->AddChild(
2013 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 1990 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2014 6, 1991 6,
2015 tile_missing, 1992 tile_missing,
2016 skips_draw,
2017 is_animating, 1993 is_animating,
2018 host_impl_->resource_provider())); 1994 host_impl_->resource_provider()));
2019 LayerTreeHostImpl::FrameData frame; 1995 LayerTreeHostImpl::FrameData frame;
2020 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, 1996 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
2021 host_impl_->PrepareToDraw(&frame)); 1997 host_impl_->PrepareToDraw(&frame));
2022 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 1998 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2023 host_impl_->DidDrawAllLayers(frame); 1999 host_impl_->DidDrawAllLayers(frame);
2024 } 2000 }
2025 2001
2026 TEST_F(LayerTreeHostImplTest, 2002 TEST_F(LayerTreeHostImplTest,
2027 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) { 2003 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) {
2028 // When the layer skips draw and we're animating, we still draw the frame. 2004 // When we're animating, we draw the frame.
2029 host_impl_->active_tree()->SetRootLayer( 2005 host_impl_->active_tree()->SetRootLayer(
2030 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2006 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2031 DidDrawCheckLayer* root = 2007 DidDrawCheckLayer* root =
2032 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2008 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2033 bool tile_missing = false; 2009 bool tile_missing = false;
2034 bool skips_draw = true;
2035 bool is_animating = true; 2010 bool is_animating = true;
2036 root->AddChild( 2011 root->AddChild(
2037 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2012 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2038 8, 2013 8,
2039 tile_missing, 2014 tile_missing,
2040 skips_draw,
2041 is_animating, 2015 is_animating,
2042 host_impl_->resource_provider())); 2016 host_impl_->resource_provider()));
2043 LayerTreeHostImpl::FrameData frame; 2017 LayerTreeHostImpl::FrameData frame;
2044 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2018 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2045 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2019 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2046 host_impl_->DidDrawAllLayers(frame); 2020 host_impl_->DidDrawAllLayers(frame);
2047 } 2021 }
2048 2022
2049 TEST_F(LayerTreeHostImplTest, 2023 TEST_F(LayerTreeHostImplTest,
2050 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) { 2024 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) {
2051 // When the layer skips draw and we're animating, we still draw the frame. 2025 // When we're not animating, we draw the frame.
2052 host_impl_->active_tree()->SetRootLayer( 2026 host_impl_->active_tree()->SetRootLayer(
2053 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2027 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2054 DidDrawCheckLayer* root = 2028 DidDrawCheckLayer* root =
2055 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2029 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2056 bool tile_missing = false; 2030 bool tile_missing = false;
2057 bool skips_draw = false;
2058 bool is_animating = false; 2031 bool is_animating = false;
2059 root->AddChild( 2032 root->AddChild(
2060 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2033 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2061 8, 2034 8,
2062 tile_missing, 2035 tile_missing,
2063 skips_draw,
2064 is_animating, 2036 is_animating,
2065 host_impl_->resource_provider())); 2037 host_impl_->resource_provider()));
2066 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2038 host_impl_->active_tree()->SetRequiresHighResToDraw();
2067 LayerTreeHostImpl::FrameData frame; 2039 LayerTreeHostImpl::FrameData frame;
2068 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2040 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2069 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2041 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2070 host_impl_->DidDrawAllLayers(frame); 2042 host_impl_->DidDrawAllLayers(frame);
2071 } 2043 }
2072 2044
2073 TEST_F(LayerTreeHostImplTest, 2045 TEST_F(LayerTreeHostImplTest,
2074 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) { 2046 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) {
2075 // When the layer skips draw and we're animating, we still draw the frame. 2047 // When a texture is missing and we're not animating, we dont draw the frame
2048 // if we Set RequiresHighResToDraw.
2076 host_impl_->active_tree()->SetRootLayer( 2049 host_impl_->active_tree()->SetRootLayer(
2077 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2050 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2078 DidDrawCheckLayer* root = 2051 DidDrawCheckLayer* root =
2079 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2052 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2080 bool tile_missing = true; 2053 bool tile_missing = true;
2081 bool skips_draw = false;
2082 bool is_animating = false; 2054 bool is_animating = false;
2083 root->AddChild( 2055 root->AddChild(
2084 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2056 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2085 8, 2057 8,
2086 tile_missing, 2058 tile_missing,
2087 skips_draw,
2088 is_animating, 2059 is_animating,
2089 host_impl_->resource_provider())); 2060 host_impl_->resource_provider()));
2090 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2061 host_impl_->active_tree()->SetRequiresHighResToDraw();
2091 LayerTreeHostImpl::FrameData frame; 2062 LayerTreeHostImpl::FrameData frame;
2092 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, 2063 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2093 host_impl_->PrepareToDraw(&frame)); 2064 host_impl_->PrepareToDraw(&frame));
2094 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2065 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2095 host_impl_->DidDrawAllLayers(frame); 2066 host_impl_->DidDrawAllLayers(frame);
2096 } 2067 }
2097 2068
(...skipping 4518 matching lines...) Expand 10 before | Expand all | Expand 10 after
6616 FakePictureLayerImpl* active_mask_content = 6587 FakePictureLayerImpl* active_mask_content =
6617 static_cast<FakePictureLayerImpl*>( 6588 static_cast<FakePictureLayerImpl*>(
6618 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); 6589 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer());
6619 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); 6590 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority();
6620 6591
6621 ASSERT_TRUE(!r2.IsEmpty()); 6592 ASSERT_TRUE(!r2.IsEmpty());
6622 } 6593 }
6623 6594
6624 } // namespace 6595 } // namespace
6625 } // namespace cc 6596 } // 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