Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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); | 1898 if (!tile_missing || !had_incomplete_tile_) { |
| 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 = | 1899 ResourceProvider::ResourceId resource = |
|
danakj
2014/06/10 19:41:51
we don't use this resource anymore, it can go away
sohanjg
2014/06/11 10:53:16
Done.
| |
| 1910 resource_provider->CreateResource(gfx::Size(1, 1), | 1900 resource_provider->CreateResource(gfx::Size(1, 1), |
| 1911 GL_CLAMP_TO_EDGE, | 1901 GL_CLAMP_TO_EDGE, |
| 1912 ResourceProvider::TextureUsageAny, | 1902 ResourceProvider::TextureUsageAny, |
| 1913 RGBA_8888); | 1903 RGBA_8888); |
| 1914 resource_provider->AllocateForTesting(resource); | 1904 resource_provider->AllocateForTesting(resource); |
| 1915 PushTileProperties(0, 0, resource, gfx::Rect(), false); | |
| 1916 } | 1905 } |
| 1917 if (animating) | 1906 if (animating) |
| 1918 AddAnimatedTransformToLayer(this, 10.0, 3, 0); | 1907 AddAnimatedTransformToLayer(this, 10.0, 3, 0); |
| 1919 } | 1908 } |
| 1920 | 1909 |
| 1921 bool tile_missing_; | 1910 bool tile_missing_; |
| 1911 bool had_incomplete_tile_; | |
| 1922 }; | 1912 }; |
| 1923 | 1913 |
| 1924 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenNoTexturesMissing) { | 1914 TEST_F(LayerTreeHostImplTest, |
| 1915 PrepareToDrawSucceedsWhenNoTexturesMissingAndNoIncompleteTile) { | |
| 1925 host_impl_->active_tree()->SetRootLayer( | 1916 host_impl_->active_tree()->SetRootLayer( |
| 1926 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1917 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1927 DidDrawCheckLayer* root = | 1918 DidDrawCheckLayer* root = |
| 1928 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1919 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1929 | 1920 |
| 1930 bool tile_missing = false; | 1921 bool tile_missing = false; |
| 1931 bool skips_draw = false; | 1922 bool had_incomplete_tile = false; |
| 1932 bool is_animating = false; | 1923 bool is_animating = false; |
| 1933 root->AddChild( | 1924 root->AddChild( |
| 1934 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1925 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1935 2, | 1926 2, |
| 1936 tile_missing, | 1927 tile_missing, |
| 1937 skips_draw, | 1928 had_incomplete_tile, |
| 1938 is_animating, | 1929 is_animating, |
| 1939 host_impl_->resource_provider())); | 1930 host_impl_->resource_provider())); |
| 1940 | 1931 |
| 1932 LayerTreeHostImpl::FrameData frame; | |
| 1933 | |
| 1934 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
| 1935 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | |
| 1936 host_impl_->DidDrawAllLayers(frame); | |
| 1937 } | |
| 1938 | |
| 1939 TEST_F(LayerTreeHostImplTest, | |
| 1940 PrepareToDrawSucceedsWhenNoTexturesMissingAndIncompleteTile) { | |
|
danakj
2014/06/10 19:41:51
This is the same test as PrepareToDrawSucceedsWith
sohanjg
2014/06/11 10:53:16
Done.
| |
| 1941 host_impl_->active_tree()->SetRootLayer( | |
| 1942 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | |
| 1943 DidDrawCheckLayer* root = | |
| 1944 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | |
| 1945 | |
| 1946 bool tile_missing = false; | |
| 1947 bool had_incomplete_tile = true; | |
| 1948 bool is_animating = false; | |
| 1949 root->AddChild( | |
| 1950 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | |
| 1951 2, | |
| 1952 tile_missing, | |
| 1953 had_incomplete_tile, | |
| 1954 is_animating, | |
| 1955 host_impl_->resource_provider())); | |
| 1956 | |
| 1941 LayerTreeHostImpl::FrameData frame; | 1957 LayerTreeHostImpl::FrameData frame; |
| 1942 | 1958 |
| 1943 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1959 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1944 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1960 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1945 host_impl_->DidDrawAllLayers(frame); | 1961 host_impl_->DidDrawAllLayers(frame); |
| 1946 } | 1962 } |
| 1947 | 1963 |
| 1948 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { | 1964 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { |
| 1949 host_impl_->active_tree()->SetRootLayer( | 1965 host_impl_->active_tree()->SetRootLayer( |
| 1950 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 1966 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 1951 DidDrawCheckLayer* root = | 1967 DidDrawCheckLayer* root = |
| 1952 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1968 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1953 bool tile_missing = false; | 1969 bool tile_missing = false; |
| 1954 bool skips_draw = false; | 1970 bool had_incomplete_tile = false; |
| 1955 bool is_animating = true; | 1971 bool is_animating = true; |
| 1956 root->AddChild( | 1972 root->AddChild( |
| 1957 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1973 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1958 2, | 1974 2, |
| 1959 tile_missing, | 1975 tile_missing, |
| 1960 skips_draw, | 1976 had_incomplete_tile, |
| 1961 is_animating, | 1977 is_animating, |
| 1962 host_impl_->resource_provider())); | 1978 host_impl_->resource_provider())); |
| 1963 | 1979 |
| 1964 LayerTreeHostImpl::FrameData frame; | 1980 LayerTreeHostImpl::FrameData frame; |
| 1965 | 1981 |
| 1966 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1982 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1967 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1983 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1968 host_impl_->DidDrawAllLayers(frame); | 1984 host_impl_->DidDrawAllLayers(frame); |
| 1969 } | 1985 } |
| 1970 | 1986 |
| 1971 TEST_F(LayerTreeHostImplTest, | 1987 TEST_F(LayerTreeHostImplTest, |
| 1972 PrepareToDrawSucceedsWithNonAnimatedMissingTexture) { | 1988 PrepareToDrawSucceedsWithNonAnimatedMissingTextureAndNoIncompleteTile) { |
| 1973 // When a texture is missing and we're not animating, we draw as usual with | 1989 // When a texture is missing and we're not animating, we draw as usual with |
| 1974 // checkerboarding. | 1990 // checkerboarding. |
| 1975 host_impl_->active_tree()->SetRootLayer( | 1991 host_impl_->active_tree()->SetRootLayer( |
| 1976 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1992 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 1977 DidDrawCheckLayer* root = | 1993 DidDrawCheckLayer* root = |
| 1978 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1994 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 1979 | 1995 |
| 1980 bool tile_missing = true; | 1996 bool tile_missing = true; |
| 1981 bool skips_draw = false; | 1997 bool had_incomplete_tile = false; |
| 1982 bool is_animating = false; | 1998 bool is_animating = false; |
| 1983 root->AddChild( | 1999 root->AddChild( |
| 1984 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2000 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 1985 4, | 2001 4, |
| 1986 tile_missing, | 2002 tile_missing, |
| 1987 skips_draw, | 2003 had_incomplete_tile, |
| 1988 is_animating, | 2004 is_animating, |
| 1989 host_impl_->resource_provider())); | 2005 host_impl_->resource_provider())); |
| 1990 LayerTreeHostImpl::FrameData frame; | 2006 LayerTreeHostImpl::FrameData frame; |
| 2007 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
| 2008 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | |
| 2009 host_impl_->DidDrawAllLayers(frame); | |
| 2010 } | |
| 2011 | |
| 2012 TEST_F(LayerTreeHostImplTest, | |
| 2013 PrepareToDrawSucceedsWithNonAnimatedIncompleteTile) { | |
| 2014 // When a texture is missing and we're not animating, we draw as usual with | |
| 2015 // checkerboarding. | |
| 2016 host_impl_->active_tree()->SetRootLayer( | |
| 2017 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | |
| 2018 DidDrawCheckLayer* root = | |
| 2019 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | |
| 2020 | |
| 2021 bool tile_missing = false; | |
| 2022 bool had_incomplete_tile = true; | |
| 2023 bool is_animating = false; | |
| 2024 root->AddChild( | |
| 2025 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | |
| 2026 4, | |
| 2027 tile_missing, | |
| 2028 had_incomplete_tile, | |
| 2029 is_animating, | |
| 2030 host_impl_->resource_provider())); | |
| 2031 LayerTreeHostImpl::FrameData frame; | |
| 1991 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2032 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1992 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2033 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1993 host_impl_->DidDrawAllLayers(frame); | 2034 host_impl_->DidDrawAllLayers(frame); |
| 1994 } | 2035 } |
| 1995 | 2036 |
| 1996 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { | 2037 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { |
| 1997 // When a texture is missing and we're animating, we don't want to draw | 2038 // When a texture is missing and we're animating, we don't want to draw |
| 1998 // anything. | 2039 // anything. |
| 1999 host_impl_->active_tree()->SetRootLayer( | 2040 host_impl_->active_tree()->SetRootLayer( |
| 2000 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2041 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 2001 DidDrawCheckLayer* root = | 2042 DidDrawCheckLayer* root = |
| 2002 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2043 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2003 bool tile_missing = true; | 2044 bool tile_missing = true; |
| 2004 bool skips_draw = false; | 2045 bool had_incomplete_tile = true; |
|
danakj
2014/06/10 19:41:51
add a case for this being false please
sohanjg
2014/06/11 10:53:16
Done.
| |
| 2005 bool is_animating = true; | 2046 bool is_animating = true; |
| 2006 root->AddChild( | 2047 root->AddChild( |
| 2007 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2048 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2008 6, | 2049 6, |
| 2009 tile_missing, | 2050 tile_missing, |
| 2010 skips_draw, | 2051 had_incomplete_tile, |
| 2011 is_animating, | 2052 is_animating, |
| 2012 host_impl_->resource_provider())); | 2053 host_impl_->resource_provider())); |
| 2013 LayerTreeHostImpl::FrameData frame; | 2054 LayerTreeHostImpl::FrameData frame; |
| 2014 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, | 2055 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, |
| 2015 host_impl_->PrepareToDraw(&frame)); | 2056 host_impl_->PrepareToDraw(&frame)); |
| 2016 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2057 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2017 host_impl_->DidDrawAllLayers(frame); | 2058 host_impl_->DidDrawAllLayers(frame); |
| 2018 } | 2059 } |
| 2019 | 2060 |
| 2020 TEST_F(LayerTreeHostImplTest, | 2061 TEST_F( |
| 2021 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) { | 2062 LayerTreeHostImplTest, |
| 2022 // When the layer skips draw and we're animating, we still draw the frame. | 2063 PrepareToDrawSucceedsWithAnimationAndNoMissingTextureAndNoIncompleteTile) { |
|
danakj
2014/06/10 19:41:51
This is the same as PrepareToDrawSucceedsWithAnima
sohanjg
2014/06/11 10:53:16
Done.
| |
| 2064 // When we're animating, we draw the frame. | |
| 2023 host_impl_->active_tree()->SetRootLayer( | 2065 host_impl_->active_tree()->SetRootLayer( |
| 2024 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2066 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2025 DidDrawCheckLayer* root = | 2067 DidDrawCheckLayer* root = |
| 2026 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2068 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2027 bool tile_missing = false; | 2069 bool tile_missing = false; |
| 2028 bool skips_draw = true; | 2070 bool had_incomplete_tile = false; |
| 2029 bool is_animating = true; | 2071 bool is_animating = true; |
| 2030 root->AddChild( | 2072 root->AddChild( |
| 2031 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2073 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2032 8, | 2074 8, |
| 2033 tile_missing, | 2075 tile_missing, |
| 2034 skips_draw, | 2076 had_incomplete_tile, |
| 2035 is_animating, | 2077 is_animating, |
| 2036 host_impl_->resource_provider())); | 2078 host_impl_->resource_provider())); |
| 2037 LayerTreeHostImpl::FrameData frame; | 2079 LayerTreeHostImpl::FrameData frame; |
| 2038 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2080 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2039 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2081 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2040 host_impl_->DidDrawAllLayers(frame); | 2082 host_impl_->DidDrawAllLayers(frame); |
| 2041 } | 2083 } |
| 2042 | 2084 |
| 2043 TEST_F(LayerTreeHostImplTest, | 2085 TEST_F( |
| 2044 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) { | 2086 LayerTreeHostImplTest, |
| 2045 // When the layer skips draw and we're animating, we still draw the frame. | 2087 PrepareToDrawFailsWhenHighResRequiredButNoMissingTexturesAndIncompleteTile) { |
|
danakj
2014/06/10 19:41:51
This says fails, but the draw is succeeding. And t
sohanjg
2014/06/11 10:53:16
Done.
| |
| 2088 // When we're not animating, we draw the frame. | |
| 2046 host_impl_->active_tree()->SetRootLayer( | 2089 host_impl_->active_tree()->SetRootLayer( |
| 2047 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2090 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2048 DidDrawCheckLayer* root = | 2091 DidDrawCheckLayer* root = |
| 2049 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2092 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2050 bool tile_missing = false; | 2093 bool tile_missing = false; |
| 2051 bool skips_draw = false; | 2094 bool had_incomplete_tile = false; |
| 2052 bool is_animating = false; | 2095 bool is_animating = false; |
| 2053 root->AddChild( | 2096 root->AddChild( |
| 2054 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2097 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2055 8, | 2098 8, |
| 2056 tile_missing, | 2099 tile_missing, |
| 2057 skips_draw, | 2100 had_incomplete_tile, |
| 2058 is_animating, | 2101 is_animating, |
| 2059 host_impl_->resource_provider())); | 2102 host_impl_->resource_provider())); |
| 2060 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2103 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2061 LayerTreeHostImpl::FrameData frame; | 2104 LayerTreeHostImpl::FrameData frame; |
| 2062 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2105 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2063 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2106 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2064 host_impl_->DidDrawAllLayers(frame); | 2107 host_impl_->DidDrawAllLayers(frame); |
| 2065 } | 2108 } |
| 2066 | 2109 |
| 2067 TEST_F(LayerTreeHostImplTest, | 2110 TEST_F(LayerTreeHostImplTest, |
| 2068 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) { | 2111 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTile) { |
| 2069 // When the layer skips draw and we're animating, we still draw the frame. | 2112 // When we're not animating, we draw the frame. |
| 2070 host_impl_->active_tree()->SetRootLayer( | 2113 host_impl_->active_tree()->SetRootLayer( |
| 2071 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2114 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2072 DidDrawCheckLayer* root = | 2115 DidDrawCheckLayer* root = |
| 2073 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2116 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2074 bool tile_missing = true; | 2117 bool tile_missing = false; |
| 2075 bool skips_draw = false; | 2118 bool had_incomplete_tile = true; |
| 2076 bool is_animating = false; | 2119 bool is_animating = false; |
| 2077 root->AddChild( | 2120 root->AddChild( |
| 2078 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2121 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2079 8, | 2122 8, |
| 2080 tile_missing, | 2123 tile_missing, |
| 2081 skips_draw, | 2124 had_incomplete_tile, |
| 2082 is_animating, | 2125 is_animating, |
| 2083 host_impl_->resource_provider())); | 2126 host_impl_->resource_provider())); |
| 2084 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2127 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2085 LayerTreeHostImpl::FrameData frame; | 2128 LayerTreeHostImpl::FrameData frame; |
| 2086 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2129 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
| 2087 host_impl_->PrepareToDraw(&frame)); | 2130 host_impl_->PrepareToDraw(&frame)); |
| 2088 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2131 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2089 host_impl_->DidDrawAllLayers(frame); | 2132 host_impl_->DidDrawAllLayers(frame); |
| 2090 } | 2133 } |
| 2091 | 2134 |
| 2135 TEST_F( | |
| 2136 LayerTreeHostImplTest, | |
| 2137 PrepareToDrawFailsWhenHighResRequiredAndMissingTexturesButNoIncompleteTile) { | |
| 2138 // When a texture is missing and we're not animating, we dont draw the frame | |
| 2139 // if we Set RequiresHighResToDraw. | |
| 2140 host_impl_->active_tree()->SetRootLayer( | |
| 2141 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | |
| 2142 DidDrawCheckLayer* root = | |
| 2143 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | |
| 2144 bool tile_missing = true; | |
| 2145 bool had_incomplete_tile = false; | |
| 2146 bool is_animating = false; | |
| 2147 root->AddChild( | |
| 2148 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | |
| 2149 8, | |
| 2150 tile_missing, | |
| 2151 had_incomplete_tile, | |
| 2152 is_animating, | |
| 2153 host_impl_->resource_provider())); | |
| 2154 host_impl_->active_tree()->SetRequiresHighResToDraw(); | |
| 2155 LayerTreeHostImpl::FrameData frame; | |
| 2156 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
|
enne (OOO)
2014/06/10 18:35:09
The comment above does not agree with this asserti
danakj
2014/06/10 19:41:51
Ya, we do draw when we're missing a tile entirely,
sohanjg
2014/06/11 10:53:16
Done.
| |
| 2157 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | |
| 2158 host_impl_->DidDrawAllLayers(frame); | |
| 2159 } | |
| 2160 | |
| 2092 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2161 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 2093 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2162 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2094 root->SetScrollClipLayer(Layer::INVALID_ID); | 2163 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 2095 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2164 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2096 DrawFrame(); | 2165 DrawFrame(); |
| 2097 | 2166 |
| 2098 // Scroll event is ignored because layer is not scrollable. | 2167 // Scroll event is ignored because layer is not scrollable. |
| 2099 EXPECT_EQ(InputHandler::ScrollIgnored, | 2168 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 2100 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 2169 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 2101 EXPECT_FALSE(did_request_redraw_); | 2170 EXPECT_FALSE(did_request_redraw_); |
| (...skipping 4465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6567 FakePictureLayerImpl* active_mask_content = | 6636 FakePictureLayerImpl* active_mask_content = |
| 6568 static_cast<FakePictureLayerImpl*>( | 6637 static_cast<FakePictureLayerImpl*>( |
| 6569 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); | 6638 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); |
| 6570 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); | 6639 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); |
| 6571 | 6640 |
| 6572 ASSERT_TRUE(!r2.IsEmpty()); | 6641 ASSERT_TRUE(!r2.IsEmpty()); |
| 6573 } | 6642 } |
| 6574 | 6643 |
| 6575 } // namespace | 6644 } // namespace |
| 6576 } // namespace cc | 6645 } // namespace cc |
| OLD | NEW |