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

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 98113005: Revert "cc: Added tile bundles" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "cc/layers/append_quads_data.h" 9 #include "cc/layers/append_quads_data.h"
10 #include "cc/layers/picture_layer.h" 10 #include "cc/layers/picture_layer.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 void SetupTrees( 86 void SetupTrees(
87 scoped_refptr<PicturePileImpl> pending_pile, 87 scoped_refptr<PicturePileImpl> pending_pile,
88 scoped_refptr<PicturePileImpl> active_pile) { 88 scoped_refptr<PicturePileImpl> active_pile) {
89 SetupPendingTree(active_pile); 89 SetupPendingTree(active_pile);
90 ActivateTree(); 90 ActivateTree();
91 SetupPendingTree(pending_pile); 91 SetupPendingTree(pending_pile);
92 } 92 }
93 93
94 void CreateHighLowResAndSetAllTilesVisible() { 94 void CreateHighLowResAndSetAllTilesVisible() {
95 // Active layer must get updated first so pending layer can share from it. 95 // Active layer must get updated first so pending layer can share from it.
96 active_layer_->CreateDefaultTilingsAndTiles(ACTIVE_TREE); 96 active_layer_->CreateDefaultTilingsAndTiles();
97 active_layer_->SetAllTilesVisible(); 97 active_layer_->SetAllTilesVisible();
98 pending_layer_->CreateDefaultTilingsAndTiles(PENDING_TREE); 98 pending_layer_->CreateDefaultTilingsAndTiles();
99 pending_layer_->SetAllTilesVisible(); 99 pending_layer_->SetAllTilesVisible();
100 } 100 }
101 101
102 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { 102 void AddDefaultTilingsWithInvalidation(const Region& invalidation) {
103 active_layer_->AddTiling(2.3f); 103 active_layer_->AddTiling(2.3f);
104 active_layer_->AddTiling(1.0f); 104 active_layer_->AddTiling(1.0f);
105 active_layer_->AddTiling(0.5f); 105 active_layer_->AddTiling(0.5f);
106 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i) { 106 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i)
107 active_layer_->tilings()->tiling_at(i)->CreateTilesForTesting( 107 active_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting();
108 ACTIVE_TREE);
109 }
110 pending_layer_->set_invalidation(invalidation); 108 pending_layer_->set_invalidation(invalidation);
111 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i) { 109 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i)
112 pending_layer_->tilings() 110 pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting();
113 ->tiling_at(i)
114 ->CreateTilesForTesting(PENDING_TREE);
115 }
116 } 111 }
117 112
118 void SetupPendingTree( 113 void SetupPendingTree(
119 scoped_refptr<PicturePileImpl> pile) { 114 scoped_refptr<PicturePileImpl> pile) {
120 host_impl_.CreatePendingTree(); 115 host_impl_.CreatePendingTree();
121 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 116 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
122 // Clear recycled tree. 117 // Clear recycled tree.
123 pending_tree->DetachLayerTree(); 118 pending_tree->DetachLayerTree();
124 119
125 scoped_ptr<FakePictureLayerImpl> pending_layer = 120 scoped_ptr<FakePictureLayerImpl> pending_layer =
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 &result_scale_y, 162 &result_scale_y,
168 &result_bounds); 163 &result_bounds);
169 } 164 }
170 165
171 void ResetTilingsAndRasterScales() { 166 void ResetTilingsAndRasterScales() {
172 pending_layer_->DidLoseOutputSurface(); 167 pending_layer_->DidLoseOutputSurface();
173 active_layer_->DidLoseOutputSurface(); 168 active_layer_->DidLoseOutputSurface();
174 } 169 }
175 170
176 void AssertAllTilesRequired(PictureLayerTiling* tiling) { 171 void AssertAllTilesRequired(PictureLayerTiling* tiling) {
177 std::vector<Tile*> tiles = tiling->TilesForTesting(PENDING_TREE); 172 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
178 for (size_t i = 0; i < tiles.size(); ++i) 173 for (size_t i = 0; i < tiles.size(); ++i)
179 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; 174 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i;
180 EXPECT_GT(tiles.size(), 0u); 175 EXPECT_GT(tiles.size(), 0u);
181 } 176 }
182 177
183 void AssertNoTilesRequired(PictureLayerTiling* tiling) { 178 void AssertNoTilesRequired(PictureLayerTiling* tiling) {
184 std::vector<Tile*> tiles = tiling->TilesForTesting(PENDING_TREE); 179 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
185 for (size_t i = 0; i < tiles.size(); ++i) 180 for (size_t i = 0; i < tiles.size(); ++i)
186 EXPECT_FALSE(tiles[i]->required_for_activation()) << "i: " << i; 181 EXPECT_FALSE(tiles[i]->required_for_activation()) << "i: " << i;
187 EXPECT_GT(tiles.size(), 0u); 182 EXPECT_GT(tiles.size(), 0u);
188 } 183 }
189 184
190 protected: 185 protected:
191 void TestTileGridAlignmentCommon() { 186 void TestTileGridAlignmentCommon() {
192 // Layer to span 4 raster tiles in x and in y 187 // Layer to span 4 raster tiles in x and in y
193 ImplSidePaintingSettings settings; 188 ImplSidePaintingSettings settings;
194 gfx::Size layer_size( 189 gfx::Size layer_size(
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 // Fake set priorities. 1210 // Fake set priorities.
1216 int tile_count = 0; 1211 int tile_count = 0;
1217 for (PictureLayerTiling::CoverageIterator iter( 1212 for (PictureLayerTiling::CoverageIterator iter(
1218 tiling, 1213 tiling,
1219 pending_layer_->contents_scale_x(), 1214 pending_layer_->contents_scale_x(),
1220 gfx::Rect(pending_layer_->visible_content_rect())); 1215 gfx::Rect(pending_layer_->visible_content_rect()));
1221 iter; 1216 iter;
1222 ++iter) { 1217 ++iter) {
1223 if (!*iter) 1218 if (!*iter)
1224 continue; 1219 continue;
1220 Tile* tile = *iter;
1225 TilePriority priority; 1221 TilePriority priority;
1226 priority.resolution = HIGH_RESOLUTION; 1222 priority.resolution = HIGH_RESOLUTION;
1227 if (++tile_count % 2) { 1223 if (++tile_count % 2) {
1228 priority.time_to_visible_in_seconds = 0.f; 1224 priority.time_to_visible_in_seconds = 0.f;
1229 priority.distance_to_visible_in_pixels = 0.f; 1225 priority.distance_to_visible_in_pixels = 0.f;
1230 } else { 1226 } else {
1231 priority.time_to_visible_in_seconds = 1.f; 1227 priority.time_to_visible_in_seconds = 1.f;
1232 priority.distance_to_visible_in_pixels = 1.f; 1228 priority.distance_to_visible_in_pixels = 1.f;
1233 } 1229 }
1234 iter.SetPriorityForTesting(priority); 1230 tile->SetPriority(PENDING_TREE, priority);
1235 } 1231 }
1236 1232
1237 pending_layer_->MarkVisibleResourcesAsRequired(); 1233 pending_layer_->MarkVisibleResourcesAsRequired();
1238 1234
1239 int num_visible = 0; 1235 int num_visible = 0;
1240 int num_offscreen = 0; 1236 int num_offscreen = 0;
1241 1237
1242 for (PictureLayerTiling::CoverageIterator iter( 1238 for (PictureLayerTiling::CoverageIterator iter(
1243 tiling, 1239 tiling,
1244 pending_layer_->contents_scale_x(), 1240 pending_layer_->contents_scale_x(),
1245 gfx::Rect(pending_layer_->visible_content_rect())); 1241 gfx::Rect(pending_layer_->visible_content_rect()));
1246 iter; 1242 iter;
1247 ++iter) { 1243 ++iter) {
1248 if (!*iter) 1244 if (!*iter)
1249 continue; 1245 continue;
1250 const Tile* tile = *iter; 1246 const Tile* tile = *iter;
1251 if (iter.priority().distance_to_visible_in_pixels == 0.f) { 1247 if (tile->priority(PENDING_TREE).distance_to_visible_in_pixels == 0.f) {
1252 EXPECT_TRUE(tile->required_for_activation()); 1248 EXPECT_TRUE(tile->required_for_activation());
1253 num_visible++; 1249 num_visible++;
1254 } else { 1250 } else {
1255 EXPECT_FALSE(tile->required_for_activation()); 1251 EXPECT_FALSE(tile->required_for_activation());
1256 num_offscreen++; 1252 num_offscreen++;
1257 } 1253 }
1258 } 1254 }
1259 1255
1260 EXPECT_GT(num_visible, 0); 1256 EXPECT_GT(num_visible, 0);
1261 EXPECT_GT(num_offscreen, 0); 1257 EXPECT_GT(num_offscreen, 0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 tile_size, layer_bounds, active_recorded_region); 1308 tile_size, layer_bounds, active_recorded_region);
1313 SetupTrees(pending_pile, active_pile); 1309 SetupTrees(pending_pile, active_pile);
1314 pending_layer_->set_fixed_tile_size(tile_size); 1310 pending_layer_->set_fixed_tile_size(tile_size);
1315 active_layer_->set_fixed_tile_size(tile_size); 1311 active_layer_->set_fixed_tile_size(tile_size);
1316 1312
1317 CreateHighLowResAndSetAllTilesVisible(); 1313 CreateHighLowResAndSetAllTilesVisible();
1318 1314
1319 // Active layer has tilings, but no tiles due to missing recordings. 1315 // Active layer has tilings, but no tiles due to missing recordings.
1320 EXPECT_TRUE(active_layer_->CanHaveTilings()); 1316 EXPECT_TRUE(active_layer_->CanHaveTilings());
1321 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); 1317 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u);
1322 EXPECT_EQ(active_layer_->HighResTiling()->TilesForTesting(ACTIVE_TREE).size(), 1318 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
1323 0u);
1324 1319
1325 // Since the active layer has no tiles at all, the pending layer doesn't 1320 // Since the active layer has no tiles at all, the pending layer doesn't
1326 // need content in order to activate. This is attempting to simulate 1321 // need content in order to activate. This is attempting to simulate
1327 // scrolling past the end of recorded content on the active layer. 1322 // scrolling past the end of recorded content on the active layer.
1328 pending_layer_->MarkVisibleResourcesAsRequired(); 1323 pending_layer_->MarkVisibleResourcesAsRequired();
1329 AssertNoTilesRequired(pending_layer_->HighResTiling()); 1324 AssertNoTilesRequired(pending_layer_->HighResTiling());
1330 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1325 AssertNoTilesRequired(pending_layer_->LowResTiling());
1331 } 1326 }
1332 1327
1333 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { 1328 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 TestContextProvider::Create(), NULL)); 1552 TestContextProvider::Create(), NULL));
1558 1553
1559 // These will crash PictureLayerImpl if this is not true. 1554 // These will crash PictureLayerImpl if this is not true.
1560 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); 1555 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties());
1561 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); 1556 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties());
1562 host_impl_.active_tree()->UpdateDrawProperties(); 1557 host_impl_.active_tree()->UpdateDrawProperties();
1563 } 1558 }
1564 1559
1565 } // namespace 1560 } // namespace
1566 } // namespace cc 1561 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698