| 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; |
| 2013 bool had_incomplete_tile = false; | 2035 bool had_incomplete_tile = false; |
| 2014 bool is_animating = false; | 2036 bool is_animating = false; |
| (...skipping 3740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5755 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); | 5777 EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_); |
| 5756 | 5778 |
| 5757 host_impl_->SetVisible(false); | 5779 host_impl_->SetVisible(false); |
| 5758 EXPECT_EQ(0u, current_limit_bytes_); | 5780 EXPECT_EQ(0u, current_limit_bytes_); |
| 5759 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); | 5781 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); |
| 5760 } | 5782 } |
| 5761 | 5783 |
| 5762 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { | 5784 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { |
| 5763 ASSERT_TRUE(host_impl_->active_tree()); | 5785 ASSERT_TRUE(host_impl_->active_tree()); |
| 5764 | 5786 |
| 5765 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5787 // RequiresHighResToDraw is set when new output surface is used. |
| 5788 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5789 |
| 5790 host_impl_->ActivateSyncTree(); |
| 5791 |
| 5766 host_impl_->SetVisible(false); | 5792 host_impl_->SetVisible(false); |
| 5767 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5793 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5768 host_impl_->SetVisible(true); | 5794 host_impl_->SetVisible(true); |
| 5769 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5795 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5770 host_impl_->SetVisible(false); | 5796 host_impl_->SetVisible(false); |
| 5771 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5797 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5772 | 5798 |
| 5773 host_impl_->CreatePendingTree(); | 5799 host_impl_->CreatePendingTree(); |
| 5774 host_impl_->ActivateSyncTree(); | 5800 host_impl_->ActivateSyncTree(); |
| 5775 | 5801 |
| 5776 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5802 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5777 host_impl_->SetVisible(true); | 5803 host_impl_->SetVisible(true); |
| 5778 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5804 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5779 } | 5805 } |
| 5780 | 5806 |
| 5781 TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) { | 5807 TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) { |
| 5782 ASSERT_TRUE(host_impl_->active_tree()); | 5808 ASSERT_TRUE(host_impl_->active_tree()); |
| 5783 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 5809 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 5784 | 5810 |
| 5785 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5811 // RequiresHighResToDraw is set when new output surface is used. |
| 5812 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5813 |
| 5814 host_impl_->ActivateSyncTree(); |
| 5815 |
| 5786 host_impl_->SetUseGpuRasterization(false); | 5816 host_impl_->SetUseGpuRasterization(false); |
| 5787 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5817 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5788 host_impl_->SetUseGpuRasterization(true); | 5818 host_impl_->SetUseGpuRasterization(true); |
| 5789 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5819 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5790 host_impl_->SetUseGpuRasterization(false); | 5820 host_impl_->SetUseGpuRasterization(false); |
| 5791 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); | 5821 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); |
| 5792 | 5822 |
| 5793 host_impl_->CreatePendingTree(); | 5823 host_impl_->CreatePendingTree(); |
| 5794 host_impl_->ActivateSyncTree(); | 5824 host_impl_->ActivateSyncTree(); |
| 5795 | 5825 |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6988 host_impl_->DidLoseOutputSurface(); | 7018 host_impl_->DidLoseOutputSurface(); |
| 6989 EXPECT_TRUE(host_impl_->IsContextLost()); | 7019 EXPECT_TRUE(host_impl_->IsContextLost()); |
| 6990 EXPECT_EQ(1, num_lost_surfaces_); | 7020 EXPECT_EQ(1, num_lost_surfaces_); |
| 6991 host_impl_->DidLoseOutputSurface(); | 7021 host_impl_->DidLoseOutputSurface(); |
| 6992 EXPECT_TRUE(host_impl_->IsContextLost()); | 7022 EXPECT_TRUE(host_impl_->IsContextLost()); |
| 6993 EXPECT_EQ(1, num_lost_surfaces_); | 7023 EXPECT_EQ(1, num_lost_surfaces_); |
| 6994 } | 7024 } |
| 6995 | 7025 |
| 6996 } // namespace | 7026 } // namespace |
| 6997 } // namespace cc | 7027 } // namespace cc |
| OLD | NEW |