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); | |
| 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; |
| 1991 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1970 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 1992 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1971 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 1993 host_impl_->DidDrawAllLayers(frame); | 1972 host_impl_->DidDrawAllLayers(frame); |
| 1994 } | 1973 } |
| 1995 | 1974 |
| 1996 TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) { | 1975 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
| 1997 // When a texture is missing and we're animating, we don't want to draw | 1976 host_impl_->active_tree()->SetRootLayer( |
| 1998 // anything. | 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; | |
| 1992 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
| 1993 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | |
| 1994 host_impl_->DidDrawAllLayers(frame); | |
| 1995 } | |
| 1996 | |
| 1997 TEST_F(LayerTreeHostImplTest, | |
| 1998 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { | |
| 1999 host_impl_->active_tree()->SetRootLayer( | 1999 host_impl_->active_tree()->SetRootLayer( |
| 2000 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2000 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 2001 DidDrawCheckLayer* root = | 2001 DidDrawCheckLayer* root = |
| 2002 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2002 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2003 bool tile_missing = true; | 2003 bool tile_missing = true; |
| 2004 bool skips_draw = false; | 2004 bool had_incomplete_tile = false; |
| 2005 bool is_animating = true; | 2005 bool is_animating = true; |
| 2006 root->AddChild( | 2006 root->AddChild( |
| 2007 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2007 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2008 6, | 2008 6, |
| 2009 tile_missing, | 2009 tile_missing, |
| 2010 skips_draw, | 2010 had_incomplete_tile, |
| 2011 is_animating, | 2011 is_animating, |
| 2012 host_impl_->resource_provider())); | 2012 host_impl_->resource_provider())); |
| 2013 LayerTreeHostImpl::FrameData frame; | 2013 LayerTreeHostImpl::FrameData frame; |
| 2014 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, | 2014 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, |
| 2015 host_impl_->PrepareToDraw(&frame)); | 2015 host_impl_->PrepareToDraw(&frame)); |
| 2016 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2016 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2017 host_impl_->DidDrawAllLayers(frame); | 2017 host_impl_->DidDrawAllLayers(frame); |
| 2018 } | 2018 } |
| 2019 | 2019 |
| 2020 TEST_F(LayerTreeHostImplTest, | 2020 TEST_F(LayerTreeHostImplTest, |
| 2021 PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) { | 2021 PrepareToSucceedsWithAnimationAndIncompleteTiles) { |
|
danakj
2014/06/12 16:09:39
PrepareToDrawSucceeds...
| |
| 2022 // When the layer skips draw and we're animating, we still draw the frame. | |
| 2023 host_impl_->active_tree()->SetRootLayer( | 2022 host_impl_->active_tree()->SetRootLayer( |
| 2024 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2023 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
| 2025 DidDrawCheckLayer* root = | 2024 DidDrawCheckLayer* root = |
| 2026 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2025 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2027 bool tile_missing = false; | 2026 bool tile_missing = false; |
| 2028 bool skips_draw = true; | 2027 bool had_incomplete_tile = true; |
| 2029 bool is_animating = true; | 2028 bool is_animating = true; |
| 2030 root->AddChild( | 2029 root->AddChild( |
| 2031 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2030 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2032 8, | 2031 6, |
| 2033 tile_missing, | 2032 tile_missing, |
| 2034 skips_draw, | 2033 had_incomplete_tile, |
| 2035 is_animating, | 2034 is_animating, |
| 2036 host_impl_->resource_provider())); | 2035 host_impl_->resource_provider())); |
| 2037 LayerTreeHostImpl::FrameData frame; | 2036 LayerTreeHostImpl::FrameData frame; |
| 2038 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2037 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2039 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2038 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2040 host_impl_->DidDrawAllLayers(frame); | 2039 host_impl_->DidDrawAllLayers(frame); |
| 2041 } | 2040 } |
| 2042 | 2041 |
| 2043 TEST_F(LayerTreeHostImplTest, | 2042 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { |
| 2044 PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) { | |
| 2045 // When the layer skips draw and we're animating, we still draw the frame. | |
| 2046 host_impl_->active_tree()->SetRootLayer( | 2043 host_impl_->active_tree()->SetRootLayer( |
| 2047 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2044 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2048 DidDrawCheckLayer* root = | 2045 DidDrawCheckLayer* root = |
| 2049 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2046 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2050 bool tile_missing = false; | 2047 bool tile_missing = false; |
| 2051 bool skips_draw = false; | 2048 bool had_incomplete_tile = false; |
| 2052 bool is_animating = false; | 2049 bool is_animating = false; |
| 2053 root->AddChild( | 2050 root->AddChild( |
| 2054 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2051 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2055 8, | 2052 8, |
| 2056 tile_missing, | 2053 tile_missing, |
| 2057 skips_draw, | 2054 had_incomplete_tile, |
| 2058 is_animating, | 2055 is_animating, |
| 2059 host_impl_->resource_provider())); | 2056 host_impl_->resource_provider())); |
| 2060 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2057 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2061 LayerTreeHostImpl::FrameData frame; | 2058 LayerTreeHostImpl::FrameData frame; |
| 2062 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2059 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 2063 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2060 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2064 host_impl_->DidDrawAllLayers(frame); | 2061 host_impl_->DidDrawAllLayers(frame); |
| 2065 } | 2062 } |
| 2066 | 2063 |
| 2067 TEST_F(LayerTreeHostImplTest, | 2064 TEST_F(LayerTreeHostImplTest, |
| 2068 PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) { | 2065 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { |
| 2069 // When the layer skips draw and we're animating, we still draw the frame. | |
| 2070 host_impl_->active_tree()->SetRootLayer( | 2066 host_impl_->active_tree()->SetRootLayer( |
| 2071 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2067 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
| 2072 DidDrawCheckLayer* root = | 2068 DidDrawCheckLayer* root = |
| 2073 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2069 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 2074 bool tile_missing = true; | 2070 bool tile_missing = false; |
| 2075 bool skips_draw = false; | 2071 bool had_incomplete_tile = true; |
| 2076 bool is_animating = false; | 2072 bool is_animating = false; |
| 2077 root->AddChild( | 2073 root->AddChild( |
| 2078 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2074 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
| 2079 8, | 2075 8, |
| 2080 tile_missing, | 2076 tile_missing, |
| 2081 skips_draw, | 2077 had_incomplete_tile, |
| 2082 is_animating, | 2078 is_animating, |
| 2083 host_impl_->resource_provider())); | 2079 host_impl_->resource_provider())); |
| 2084 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2080 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
| 2085 LayerTreeHostImpl::FrameData frame; | 2081 LayerTreeHostImpl::FrameData frame; |
| 2086 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, | 2082 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, |
| 2087 host_impl_->PrepareToDraw(&frame)); | 2083 host_impl_->PrepareToDraw(&frame)); |
| 2088 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2084 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 2089 host_impl_->DidDrawAllLayers(frame); | 2085 host_impl_->DidDrawAllLayers(frame); |
| 2090 } | 2086 } |
| 2091 | 2087 |
| 2088 TEST_F(LayerTreeHostImplTest, | |
| 2089 PrepareToDrawSucceedsWhenHighResRequiredAndMissingTile) { | |
| 2090 host_impl_->active_tree()->SetRootLayer( | |
| 2091 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | |
| 2092 DidDrawCheckLayer* root = | |
| 2093 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | |
| 2094 bool tile_missing = true; | |
| 2095 bool had_incomplete_tile = false; | |
| 2096 bool is_animating = false; | |
| 2097 root->AddChild( | |
| 2098 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | |
| 2099 8, | |
| 2100 tile_missing, | |
| 2101 had_incomplete_tile, | |
| 2102 is_animating, | |
| 2103 host_impl_->resource_provider())); | |
| 2104 host_impl_->active_tree()->SetRequiresHighResToDraw(); | |
| 2105 LayerTreeHostImpl::FrameData frame; | |
| 2106 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
| 2107 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | |
| 2108 host_impl_->DidDrawAllLayers(frame); | |
| 2109 } | |
| 2110 | |
| 2092 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2111 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 2093 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2112 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2094 root->SetScrollClipLayer(Layer::INVALID_ID); | 2113 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 2095 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2114 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2096 DrawFrame(); | 2115 DrawFrame(); |
| 2097 | 2116 |
| 2098 // Scroll event is ignored because layer is not scrollable. | 2117 // Scroll event is ignored because layer is not scrollable. |
| 2099 EXPECT_EQ(InputHandler::ScrollIgnored, | 2118 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 2100 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 2119 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 2101 EXPECT_FALSE(did_request_redraw_); | 2120 EXPECT_FALSE(did_request_redraw_); |
| (...skipping 4465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6567 FakePictureLayerImpl* active_mask_content = | 6586 FakePictureLayerImpl* active_mask_content = |
| 6568 static_cast<FakePictureLayerImpl*>( | 6587 static_cast<FakePictureLayerImpl*>( |
| 6569 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); | 6588 host_impl_->active_tree()->root_layer()->children()[0]->mask_layer()); |
| 6570 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); | 6589 gfx::Rect r2 = active_mask_content->visible_rect_for_tile_priority(); |
| 6571 | 6590 |
| 6572 ASSERT_TRUE(!r2.IsEmpty()); | 6591 ASSERT_TRUE(!r2.IsEmpty()); |
| 6573 } | 6592 } |
| 6574 | 6593 |
| 6575 } // namespace | 6594 } // namespace |
| 6576 } // namespace cc | 6595 } // namespace cc |
| OLD | NEW |