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 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1914 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1914 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
1915 host_impl_->DidDrawAllLayers(frame); | 1915 host_impl_->DidDrawAllLayers(frame); |
1916 } | 1916 } |
1917 | 1917 |
1918 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { | 1918 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { |
1919 host_impl_->active_tree()->SetRootLayer( | 1919 host_impl_->active_tree()->SetRootLayer( |
1920 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1920 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
1921 DidDrawCheckLayer* root = | 1921 DidDrawCheckLayer* root = |
1922 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1922 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1923 | 1923 |
1924 LayerTreeHostImpl::FrameData frame; | |
1925 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
1926 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | |
1927 host_impl_->DidDrawAllLayers(frame); | |
1928 | |
1924 bool tile_missing = true; | 1929 bool tile_missing = true; |
1925 bool had_incomplete_tile = false; | 1930 bool had_incomplete_tile = false; |
1926 bool is_animating = false; | 1931 bool is_animating = false; |
1927 root->AddChild( | 1932 root->AddChild( |
1928 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1933 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1929 4, | 1934 4, |
1930 tile_missing, | 1935 tile_missing, |
1931 had_incomplete_tile, | 1936 had_incomplete_tile, |
1932 is_animating, | 1937 is_animating, |
1933 host_impl_->resource_provider())); | 1938 host_impl_->resource_provider())); |
1934 LayerTreeHostImpl::FrameData frame; | 1939 LayerTreeHostImpl::FrameData frame2; |
1935 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1940 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
1936 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1941 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
1937 host_impl_->DidDrawAllLayers(frame); | 1942 host_impl_->DidDrawAllLayers(frame2); |
1938 } | 1943 } |
1939 | 1944 |
1940 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { | 1945 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { |
1941 host_impl_->active_tree()->SetRootLayer( | 1946 host_impl_->active_tree()->SetRootLayer( |
1942 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 1947 DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
1943 DidDrawCheckLayer* root = | 1948 DidDrawCheckLayer* root = |
1944 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1949 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1945 | 1950 |
1951 LayerTreeHostImpl::FrameData frame; | |
1952 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
1953 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | |
1954 host_impl_->DidDrawAllLayers(frame); | |
1955 | |
1946 bool tile_missing = false; | 1956 bool tile_missing = false; |
1947 bool had_incomplete_tile = true; | 1957 bool had_incomplete_tile = true; |
1948 bool is_animating = false; | 1958 bool is_animating = false; |
1949 root->AddChild( | 1959 root->AddChild( |
1950 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1960 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1951 4, | 1961 4, |
1952 tile_missing, | 1962 tile_missing, |
1953 had_incomplete_tile, | 1963 had_incomplete_tile, |
1954 is_animating, | 1964 is_animating, |
1955 host_impl_->resource_provider())); | 1965 host_impl_->resource_provider())); |
1956 LayerTreeHostImpl::FrameData frame; | 1966 LayerTreeHostImpl::FrameData frame2; |
1957 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 1967 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
1958 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1968 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
1959 host_impl_->DidDrawAllLayers(frame); | 1969 host_impl_->DidDrawAllLayers(frame2); |
1960 } | 1970 } |
1961 | 1971 |
1962 TEST_F(LayerTreeHostImplTest, | 1972 TEST_F(LayerTreeHostImplTest, |
1963 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { | 1973 PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) { |
1964 host_impl_->active_tree()->SetRootLayer( | 1974 host_impl_->active_tree()->SetRootLayer( |
1965 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 1975 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
1966 DidDrawCheckLayer* root = | 1976 DidDrawCheckLayer* root = |
1967 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 1977 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
1978 | |
1979 LayerTreeHostImpl::FrameData frame; | |
1980 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
1981 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | |
1982 host_impl_->DidDrawAllLayers(frame); | |
1983 | |
1968 bool tile_missing = true; | 1984 bool tile_missing = true; |
1969 bool had_incomplete_tile = false; | 1985 bool had_incomplete_tile = false; |
1970 bool is_animating = true; | 1986 bool is_animating = true; |
1971 root->AddChild( | 1987 root->AddChild( |
1972 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 1988 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1973 6, | 1989 6, |
1974 tile_missing, | 1990 tile_missing, |
1975 had_incomplete_tile, | 1991 had_incomplete_tile, |
1976 is_animating, | 1992 is_animating, |
1977 host_impl_->resource_provider())); | 1993 host_impl_->resource_provider())); |
1978 LayerTreeHostImpl::FrameData frame; | 1994 LayerTreeHostImpl::FrameData frame2; |
1979 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, | 1995 EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS, |
1980 host_impl_->PrepareToDraw(&frame)); | 1996 host_impl_->PrepareToDraw(&frame2)); |
1981 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 1997 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
1982 host_impl_->DidDrawAllLayers(frame); | 1998 host_impl_->DidDrawAllLayers(frame2); |
1983 } | 1999 } |
1984 | 2000 |
1985 TEST_F(LayerTreeHostImplTest, | 2001 TEST_F(LayerTreeHostImplTest, |
1986 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { | 2002 PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) { |
1987 host_impl_->active_tree()->SetRootLayer( | 2003 host_impl_->active_tree()->SetRootLayer( |
1988 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); | 2004 DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); |
1989 DidDrawCheckLayer* root = | 2005 DidDrawCheckLayer* root = |
1990 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2006 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
2007 | |
2008 LayerTreeHostImpl::FrameData frame; | |
2009 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
2010 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | |
2011 host_impl_->DidDrawAllLayers(frame); | |
2012 | |
1991 bool tile_missing = false; | 2013 bool tile_missing = false; |
1992 bool had_incomplete_tile = true; | 2014 bool had_incomplete_tile = true; |
1993 bool is_animating = true; | 2015 bool is_animating = true; |
1994 root->AddChild( | 2016 root->AddChild( |
1995 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2017 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
1996 6, | 2018 6, |
1997 tile_missing, | 2019 tile_missing, |
1998 had_incomplete_tile, | 2020 had_incomplete_tile, |
1999 is_animating, | 2021 is_animating, |
2000 host_impl_->resource_provider())); | 2022 host_impl_->resource_provider())); |
2001 LayerTreeHostImpl::FrameData frame; | 2023 LayerTreeHostImpl::FrameData frame2; |
2002 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2024 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); |
2003 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2025 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); |
2004 host_impl_->DidDrawAllLayers(frame); | 2026 host_impl_->DidDrawAllLayers(frame2); |
2005 } | 2027 } |
2006 | 2028 |
2007 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { | 2029 TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { |
2008 host_impl_->active_tree()->SetRootLayer( | 2030 host_impl_->active_tree()->SetRootLayer( |
2009 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2031 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
2010 DidDrawCheckLayer* root = | 2032 DidDrawCheckLayer* root = |
2011 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2033 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
2012 bool tile_missing = false; | 2034 bool tile_missing = false; |
danakj
2014/09/10 16:03:32
can you add a pre-draw to these other tests too, s
sohanjg
2014/09/11 06:07:57
Done.
| |
2013 bool had_incomplete_tile = false; | 2035 bool had_incomplete_tile = false; |
2014 bool is_animating = false; | 2036 bool is_animating = false; |
2015 root->AddChild( | 2037 root->AddChild( |
2016 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2038 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2017 8, | 2039 8, |
2018 tile_missing, | 2040 tile_missing, |
2019 had_incomplete_tile, | 2041 had_incomplete_tile, |
2020 is_animating, | 2042 is_animating, |
2021 host_impl_->resource_provider())); | 2043 host_impl_->resource_provider())); |
2022 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2044 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
2023 LayerTreeHostImpl::FrameData frame; | 2045 LayerTreeHostImpl::FrameData frame; |
2024 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 2046 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
2025 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 2047 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
2026 host_impl_->DidDrawAllLayers(frame); | 2048 host_impl_->DidDrawAllLayers(frame); |
2027 } | 2049 } |
2028 | 2050 |
2029 TEST_F(LayerTreeHostImplTest, | 2051 TEST_F(LayerTreeHostImplTest, |
2030 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { | 2052 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { |
2031 host_impl_->active_tree()->SetRootLayer( | 2053 host_impl_->active_tree()->SetRootLayer( |
2032 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); | 2054 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); |
2033 DidDrawCheckLayer* root = | 2055 DidDrawCheckLayer* root = |
2034 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 2056 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
2035 bool tile_missing = false; | 2057 bool tile_missing = false; |
danakj
2014/09/10 16:03:32
and here, etc
sohanjg
2014/09/11 06:07:57
Done.
| |
2036 bool had_incomplete_tile = true; | 2058 bool had_incomplete_tile = true; |
2037 bool is_animating = false; | 2059 bool is_animating = false; |
2038 root->AddChild( | 2060 root->AddChild( |
2039 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), | 2061 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), |
2040 8, | 2062 8, |
2041 tile_missing, | 2063 tile_missing, |
2042 had_incomplete_tile, | 2064 had_incomplete_tile, |
2043 is_animating, | 2065 is_animating, |
2044 host_impl_->resource_provider())); | 2066 host_impl_->resource_provider())); |
2045 host_impl_->active_tree()->SetRequiresHighResToDraw(); | 2067 host_impl_->active_tree()->SetRequiresHighResToDraw(); |
(...skipping 3831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5877 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); | 5899 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); |
5878 | 5900 |
5879 host_impl_->SetVisible(false); | 5901 host_impl_->SetVisible(false); |
5880 EXPECT_EQ(0u, current_limit_bytes_); | 5902 EXPECT_EQ(0u, current_limit_bytes_); |
5881 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); | 5903 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); |
5882 } | 5904 } |
5883 | 5905 |
5884 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { | 5906 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { |
5885 ASSERT_TRUE(host_impl_->active_tree()); | 5907 ASSERT_TRUE(host_impl_->active_tree()); |
5886 | 5908 |
5887 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5909 // RequiresHighResToDraw is set when new output surface is used. |
5910 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | |
5911 | |
5912 host_impl_->ActivateSyncTree(); | |
danakj
2014/09/10 16:03:32
can you change this to just host_impl_->active_tre
sohanjg
2014/09/11 06:07:57
Done.
| |
5913 | |
5888 host_impl_->SetVisible(false); | 5914 host_impl_->SetVisible(false); |
5889 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5915 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5890 host_impl_->SetVisible(true); | 5916 host_impl_->SetVisible(true); |
5891 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5917 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5892 host_impl_->SetVisible(false); | 5918 host_impl_->SetVisible(false); |
5893 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5919 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5894 | 5920 |
5895 host_impl_->CreatePendingTree(); | 5921 host_impl_->CreatePendingTree(); |
danakj
2014/09/10 16:03:32
can you change this to just host_impl_->active_tre
sohanjg
2014/09/11 06:07:57
Done.
| |
5896 host_impl_->ActivateSyncTree(); | 5922 host_impl_->ActivateSyncTree(); |
5897 | 5923 |
5898 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5924 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5899 host_impl_->SetVisible(true); | 5925 host_impl_->SetVisible(true); |
5900 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5926 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5901 } | 5927 } |
5902 | 5928 |
5903 TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) { | 5929 TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) { |
5904 ASSERT_TRUE(host_impl_->active_tree()); | 5930 ASSERT_TRUE(host_impl_->active_tree()); |
5905 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 5931 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
5906 | 5932 |
5907 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5933 // RequiresHighResToDraw is set when new output surface is used. |
5934 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | |
5935 | |
5936 host_impl_->ActivateSyncTree(); | |
danakj
2014/09/10 16:03:32
can you change this to just host_impl_->active_tre
sohanjg
2014/09/11 06:07:57
Done.
| |
5937 | |
5908 host_impl_->SetUseGpuRasterization(false); | 5938 host_impl_->SetUseGpuRasterization(false); |
5909 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5939 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5910 host_impl_->SetUseGpuRasterization(true); | 5940 host_impl_->SetUseGpuRasterization(true); |
5911 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5941 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5912 host_impl_->SetUseGpuRasterization(false); | 5942 host_impl_->SetUseGpuRasterization(false); |
5913 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5943 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5914 | 5944 |
5915 host_impl_->CreatePendingTree(); | 5945 host_impl_->CreatePendingTree(); |
danakj
2014/09/10 16:03:32
can you change this to just host_impl_->active_tre
sohanjg
2014/09/11 06:07:57
Done.
| |
5916 host_impl_->ActivateSyncTree(); | 5946 host_impl_->ActivateSyncTree(); |
5917 | 5947 |
5918 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5948 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5919 host_impl_->SetUseGpuRasterization(true); | 5949 host_impl_->SetUseGpuRasterization(true); |
5920 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5950 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
5921 } | 5951 } |
5922 | 5952 |
5923 class LayerTreeHostImplTestManageTiles : public LayerTreeHostImplTest { | 5953 class LayerTreeHostImplTestManageTiles : public LayerTreeHostImplTest { |
5924 public: | 5954 public: |
5925 virtual void SetUp() OVERRIDE { | 5955 virtual void SetUp() OVERRIDE { |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7101 // surface. | 7131 // surface. |
7102 EXPECT_EQ(0, num_lost_surfaces_); | 7132 EXPECT_EQ(0, num_lost_surfaces_); |
7103 host_impl_->DidLoseOutputSurface(); | 7133 host_impl_->DidLoseOutputSurface(); |
7104 EXPECT_EQ(1, num_lost_surfaces_); | 7134 EXPECT_EQ(1, num_lost_surfaces_); |
7105 host_impl_->DidLoseOutputSurface(); | 7135 host_impl_->DidLoseOutputSurface(); |
7106 EXPECT_LE(1, num_lost_surfaces_); | 7136 EXPECT_LE(1, num_lost_surfaces_); |
7107 } | 7137 } |
7108 | 7138 |
7109 } // namespace | 7139 } // namespace |
7110 } // namespace cc | 7140 } // namespace cc |
OLD | NEW |