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

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

Issue 62283012: cc: Added tile bundles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review 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
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 scoped_refptr<PicturePileImpl> active_pile) { 81 scoped_refptr<PicturePileImpl> active_pile) {
82 SetupPendingTree(active_pile); 82 SetupPendingTree(active_pile);
83 ActivateTree(); 83 ActivateTree();
84 SetupPendingTree(pending_pile); 84 SetupPendingTree(pending_pile);
85 } 85 }
86 86
87 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { 87 void AddDefaultTilingsWithInvalidation(const Region& invalidation) {
88 active_layer_->AddTiling(2.3f); 88 active_layer_->AddTiling(2.3f);
89 active_layer_->AddTiling(1.0f); 89 active_layer_->AddTiling(1.0f);
90 active_layer_->AddTiling(0.5f); 90 active_layer_->AddTiling(0.5f);
91 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i) 91 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i) {
92 active_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); 92 active_layer_->tilings()->tiling_at(i)->CreateTilesForTesting(
93 ACTIVE_TREE);
94 }
93 pending_layer_->set_invalidation(invalidation); 95 pending_layer_->set_invalidation(invalidation);
94 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i) 96 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i) {
95 pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); 97 pending_layer_->tilings()
98 ->tiling_at(i)
99 ->CreateTilesForTesting(PENDING_TREE);
100 }
96 } 101 }
97 102
98 void SetupPendingTree( 103 void SetupPendingTree(
99 scoped_refptr<PicturePileImpl> pile) { 104 scoped_refptr<PicturePileImpl> pile) {
100 host_impl_.CreatePendingTree(); 105 host_impl_.CreatePendingTree();
101 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 106 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
102 // Clear recycled tree. 107 // Clear recycled tree.
103 pending_tree->DetachLayerTree(); 108 pending_tree->DetachLayerTree();
104 109
105 scoped_ptr<FakePictureLayerImpl> pending_layer = 110 scoped_ptr<FakePictureLayerImpl> pending_layer =
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 // Fake set priorities. 1186 // Fake set priorities.
1182 int tile_count = 0; 1187 int tile_count = 0;
1183 for (PictureLayerTiling::CoverageIterator iter( 1188 for (PictureLayerTiling::CoverageIterator iter(
1184 tiling, 1189 tiling,
1185 pending_layer_->contents_scale_x(), 1190 pending_layer_->contents_scale_x(),
1186 gfx::Rect(pending_layer_->visible_content_rect())); 1191 gfx::Rect(pending_layer_->visible_content_rect()));
1187 iter; 1192 iter;
1188 ++iter) { 1193 ++iter) {
1189 if (!*iter) 1194 if (!*iter)
1190 continue; 1195 continue;
1191 Tile* tile = *iter;
1192 TilePriority priority; 1196 TilePriority priority;
1193 priority.resolution = HIGH_RESOLUTION; 1197 priority.resolution = HIGH_RESOLUTION;
1194 if (++tile_count % 2) { 1198 if (++tile_count % 2) {
1195 priority.time_to_visible_in_seconds = 0.f; 1199 priority.time_to_visible_in_seconds = 0.f;
1196 priority.distance_to_visible_in_pixels = 0.f; 1200 priority.distance_to_visible_in_pixels = 0.f;
1197 } else { 1201 } else {
1198 priority.time_to_visible_in_seconds = 1.f; 1202 priority.time_to_visible_in_seconds = 1.f;
1199 priority.distance_to_visible_in_pixels = 1.f; 1203 priority.distance_to_visible_in_pixels = 1.f;
1200 } 1204 }
1201 tile->SetPriority(PENDING_TREE, priority); 1205 iter.SetPriorityForTesting(priority);
1202 } 1206 }
1203 1207
1204 pending_layer_->MarkVisibleResourcesAsRequired(); 1208 pending_layer_->MarkVisibleResourcesAsRequired();
1205 1209
1206 int num_visible = 0; 1210 int num_visible = 0;
1207 int num_offscreen = 0; 1211 int num_offscreen = 0;
1208 1212
1209 for (PictureLayerTiling::CoverageIterator iter( 1213 for (PictureLayerTiling::CoverageIterator iter(
1210 tiling, 1214 tiling,
1211 pending_layer_->contents_scale_x(), 1215 pending_layer_->contents_scale_x(),
1212 gfx::Rect(pending_layer_->visible_content_rect())); 1216 gfx::Rect(pending_layer_->visible_content_rect()));
1213 iter; 1217 iter;
1214 ++iter) { 1218 ++iter) {
1215 if (!*iter) 1219 if (!*iter)
1216 continue; 1220 continue;
1217 const Tile* tile = *iter; 1221 const Tile* tile = *iter;
1218 if (tile->priority(PENDING_TREE).distance_to_visible_in_pixels == 0.f) { 1222 if (iter.priority().distance_to_visible_in_pixels == 0.f) {
1219 EXPECT_TRUE(tile->required_for_activation()); 1223 EXPECT_TRUE(tile->required_for_activation());
1220 num_visible++; 1224 num_visible++;
1221 } else { 1225 } else {
1222 EXPECT_FALSE(tile->required_for_activation()); 1226 EXPECT_FALSE(tile->required_for_activation());
1223 num_offscreen++; 1227 num_offscreen++;
1224 } 1228 }
1225 } 1229 }
1226 1230
1227 EXPECT_GT(num_visible, 0); 1231 EXPECT_GT(num_visible, 0);
1228 EXPECT_GT(num_offscreen, 0); 1232 EXPECT_GT(num_offscreen, 0);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 TestContextProvider::Create(), NULL)); 1346 TestContextProvider::Create(), NULL));
1343 1347
1344 // These will crash PictureLayerImpl if this is not true. 1348 // These will crash PictureLayerImpl if this is not true.
1345 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); 1349 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties());
1346 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); 1350 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties());
1347 host_impl_.active_tree()->UpdateDrawProperties(); 1351 host_impl_.active_tree()->UpdateDrawProperties();
1348 } 1352 }
1349 1353
1350 } // namespace 1354 } // namespace
1351 } // namespace cc 1355 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698