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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 640873002: cc: Move RequiresHighResToDraw from tree to lthi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | 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 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 bool tile_missing = false; 2145 bool tile_missing = false;
2146 bool had_incomplete_tile = false; 2146 bool had_incomplete_tile = false;
2147 bool is_animating = false; 2147 bool is_animating = false;
2148 root->AddChild( 2148 root->AddChild(
2149 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2149 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2150 8, 2150 8,
2151 tile_missing, 2151 tile_missing,
2152 had_incomplete_tile, 2152 had_incomplete_tile,
2153 is_animating, 2153 is_animating,
2154 host_impl_->resource_provider())); 2154 host_impl_->resource_provider()));
2155 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2155 host_impl_->SetRequiresHighResToDraw();
2156 LayerTreeHostImpl::FrameData frame2; 2156 LayerTreeHostImpl::FrameData frame2;
2157 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2)); 2157 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame2));
2158 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2158 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2159 host_impl_->DidDrawAllLayers(frame2); 2159 host_impl_->DidDrawAllLayers(frame2);
2160 } 2160 }
2161 2161
2162 TEST_F(LayerTreeHostImplTest, 2162 TEST_F(LayerTreeHostImplTest,
2163 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) { 2163 PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) {
2164 host_impl_->active_tree()->SetRootLayer( 2164 host_impl_->active_tree()->SetRootLayer(
2165 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); 2165 DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
2166 DidDrawCheckLayer* root = 2166 DidDrawCheckLayer* root =
2167 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); 2167 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
2168 2168
2169 LayerTreeHostImpl::FrameData frame; 2169 LayerTreeHostImpl::FrameData frame;
2170 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 2170 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
2171 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); 2171 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
2172 host_impl_->DidDrawAllLayers(frame); 2172 host_impl_->DidDrawAllLayers(frame);
2173 host_impl_->SwapBuffers(frame); 2173 host_impl_->SwapBuffers(frame);
2174 2174
2175 bool tile_missing = false; 2175 bool tile_missing = false;
2176 bool had_incomplete_tile = true; 2176 bool had_incomplete_tile = true;
2177 bool is_animating = false; 2177 bool is_animating = false;
2178 root->AddChild( 2178 root->AddChild(
2179 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2179 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2180 8, 2180 8,
2181 tile_missing, 2181 tile_missing,
2182 had_incomplete_tile, 2182 had_incomplete_tile,
2183 is_animating, 2183 is_animating,
2184 host_impl_->resource_provider())); 2184 host_impl_->resource_provider()));
2185 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2185 host_impl_->SetRequiresHighResToDraw();
2186 LayerTreeHostImpl::FrameData frame2; 2186 LayerTreeHostImpl::FrameData frame2;
2187 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, 2187 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2188 host_impl_->PrepareToDraw(&frame2)); 2188 host_impl_->PrepareToDraw(&frame2));
2189 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2189 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2190 host_impl_->DidDrawAllLayers(frame2); 2190 host_impl_->DidDrawAllLayers(frame2);
2191 } 2191 }
2192 2192
2193 TEST_F(LayerTreeHostImplTest, 2193 TEST_F(LayerTreeHostImplTest,
2194 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) { 2194 PrepareToDrawFailsWhenHighResRequiredAndMissingTile) {
2195 host_impl_->active_tree()->SetRootLayer( 2195 host_impl_->active_tree()->SetRootLayer(
(...skipping 10 matching lines...) Expand all
2206 bool tile_missing = true; 2206 bool tile_missing = true;
2207 bool had_incomplete_tile = false; 2207 bool had_incomplete_tile = false;
2208 bool is_animating = false; 2208 bool is_animating = false;
2209 root->AddChild( 2209 root->AddChild(
2210 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(), 2210 MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2211 8, 2211 8,
2212 tile_missing, 2212 tile_missing,
2213 had_incomplete_tile, 2213 had_incomplete_tile,
2214 is_animating, 2214 is_animating,
2215 host_impl_->resource_provider())); 2215 host_impl_->resource_provider()));
2216 host_impl_->active_tree()->SetRequiresHighResToDraw(); 2216 host_impl_->SetRequiresHighResToDraw();
2217 LayerTreeHostImpl::FrameData frame2; 2217 LayerTreeHostImpl::FrameData frame2;
2218 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT, 2218 EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
2219 host_impl_->PrepareToDraw(&frame2)); 2219 host_impl_->PrepareToDraw(&frame2));
2220 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now()); 2220 host_impl_->DrawLayers(&frame2, gfx::FrameTime::Now());
2221 host_impl_->DidDrawAllLayers(frame2); 2221 host_impl_->DidDrawAllLayers(frame2);
2222 } 2222 }
2223 2223
2224 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { 2224 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) {
2225 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 2225 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
2226 root->SetScrollClipLayer(Layer::INVALID_ID); 2226 root->SetScrollClipLayer(Layer::INVALID_ID);
(...skipping 3806 matching lines...) Expand 10 before | Expand all | Expand 10 after
6033 6033
6034 host_impl_->SetVisible(false); 6034 host_impl_->SetVisible(false);
6035 EXPECT_EQ(0u, current_limit_bytes_); 6035 EXPECT_EQ(0u, current_limit_bytes_);
6036 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); 6036 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_);
6037 } 6037 }
6038 6038
6039 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { 6039 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) {
6040 ASSERT_TRUE(host_impl_->active_tree()); 6040 ASSERT_TRUE(host_impl_->active_tree());
6041 6041
6042 // RequiresHighResToDraw is set when new output surface is used. 6042 // RequiresHighResToDraw is set when new output surface is used.
6043 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); 6043 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
6044 6044
6045 host_impl_->active_tree()->ResetRequiresHighResToDraw(); 6045 host_impl_->ResetRequiresHighResToDraw();
6046 6046
6047 host_impl_->SetVisible(false); 6047 host_impl_->SetVisible(false);
6048 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); 6048 EXPECT_FALSE(host_impl_->RequiresHighResToDraw());
6049 host_impl_->SetVisible(true); 6049 host_impl_->SetVisible(true);
6050 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); 6050 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
6051 host_impl_->SetVisible(false); 6051 host_impl_->SetVisible(false);
6052 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); 6052 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
6053 6053
6054 host_impl_->active_tree()->ResetRequiresHighResToDraw(); 6054 host_impl_->ResetRequiresHighResToDraw();
6055 6055
6056 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); 6056 EXPECT_FALSE(host_impl_->RequiresHighResToDraw());
6057 host_impl_->SetVisible(true); 6057 host_impl_->SetVisible(true);
6058 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); 6058 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
6059 } 6059 }
6060 6060
6061 TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) { 6061 TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) {
6062 ASSERT_TRUE(host_impl_->active_tree()); 6062 ASSERT_TRUE(host_impl_->active_tree());
6063 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 6063 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
6064 6064
6065 // RequiresHighResToDraw is set when new output surface is used. 6065 // RequiresHighResToDraw is set when new output surface is used.
6066 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); 6066 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
6067 6067
6068 host_impl_->active_tree()->ResetRequiresHighResToDraw(); 6068 host_impl_->ResetRequiresHighResToDraw();
6069 6069
6070 host_impl_->SetUseGpuRasterization(false); 6070 host_impl_->SetUseGpuRasterization(false);
6071 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); 6071 EXPECT_FALSE(host_impl_->RequiresHighResToDraw());
6072 host_impl_->SetUseGpuRasterization(true); 6072 host_impl_->SetUseGpuRasterization(true);
6073 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); 6073 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
6074 host_impl_->SetUseGpuRasterization(false); 6074 host_impl_->SetUseGpuRasterization(false);
6075 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); 6075 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
6076 6076
6077 host_impl_->active_tree()->ResetRequiresHighResToDraw(); 6077 host_impl_->ResetRequiresHighResToDraw();
6078 6078
6079 EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); 6079 EXPECT_FALSE(host_impl_->RequiresHighResToDraw());
6080 host_impl_->SetUseGpuRasterization(true); 6080 host_impl_->SetUseGpuRasterization(true);
6081 EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); 6081 EXPECT_TRUE(host_impl_->RequiresHighResToDraw());
6082 } 6082 }
6083 6083
6084 class LayerTreeHostImplTestManageTiles : public LayerTreeHostImplTest { 6084 class LayerTreeHostImplTestManageTiles : public LayerTreeHostImplTest {
6085 public: 6085 public:
6086 virtual void SetUp() override { 6086 virtual void SetUp() override {
6087 LayerTreeSettings settings; 6087 LayerTreeSettings settings;
6088 settings.impl_side_painting = true; 6088 settings.impl_side_painting = true;
6089 6089
6090 fake_host_impl_ = new FakeLayerTreeHostImpl( 6090 fake_host_impl_ = new FakeLayerTreeHostImpl(
6091 settings, &proxy_, shared_bitmap_manager_.get()); 6091 settings, &proxy_, shared_bitmap_manager_.get());
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
7267 // surface. 7267 // surface.
7268 EXPECT_EQ(0, num_lost_surfaces_); 7268 EXPECT_EQ(0, num_lost_surfaces_);
7269 host_impl_->DidLoseOutputSurface(); 7269 host_impl_->DidLoseOutputSurface();
7270 EXPECT_EQ(1, num_lost_surfaces_); 7270 EXPECT_EQ(1, num_lost_surfaces_);
7271 host_impl_->DidLoseOutputSurface(); 7271 host_impl_->DidLoseOutputSurface();
7272 EXPECT_LE(1, num_lost_surfaces_); 7272 EXPECT_LE(1, num_lost_surfaces_);
7273 } 7273 }
7274 7274
7275 } // namespace 7275 } // namespace
7276 } // namespace cc 7276 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698