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

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

Issue 235753002: cc: Give TilingData a Rect instead of a Size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | 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 <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "cc/layers/append_quads_data.h" 10 #include "cc/layers/append_quads_data.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 void SetupDefaultTrees(const gfx::Size& layer_bounds) { 70 void SetupDefaultTrees(const gfx::Size& layer_bounds) {
71 gfx::Size tile_size(100, 100); 71 gfx::Size tile_size(100, 100);
72 72
73 scoped_refptr<FakePicturePileImpl> pending_pile = 73 scoped_refptr<FakePicturePileImpl> pending_pile =
74 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 74 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
75 scoped_refptr<FakePicturePileImpl> active_pile = 75 scoped_refptr<FakePicturePileImpl> active_pile =
76 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 76 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
77 77
78 SetupTrees(pending_pile, active_pile); 78 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
79 } 79 }
80 80
81 void ActivateTree() { 81 void ActivateTree() {
82 host_impl_.ActivatePendingTree(); 82 host_impl_.ActivatePendingTree();
83 CHECK(!host_impl_.pending_tree()); 83 CHECK(!host_impl_.pending_tree());
84 pending_layer_ = NULL; 84 pending_layer_ = NULL;
85 active_layer_ = static_cast<FakePictureLayerImpl*>( 85 active_layer_ = static_cast<FakePictureLayerImpl*>(
86 host_impl_.active_tree()->LayerById(id_)); 86 host_impl_.active_tree()->LayerById(id_));
87 } 87 }
88 88
89 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, 89 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds,
90 const gfx::Size& tile_size) { 90 const gfx::Size& tile_size) {
91 SetupDefaultTrees(layer_bounds); 91 SetupDefaultTrees(layer_bounds);
92 pending_layer_->set_fixed_tile_size(tile_size); 92 pending_layer_->set_fixed_tile_size(tile_size);
93 active_layer_->set_fixed_tile_size(tile_size); 93 active_layer_->set_fixed_tile_size(tile_size);
94 } 94 }
95 95
96 void SetupTrees( 96 void SetupTrees(
97 scoped_refptr<PicturePileImpl> pending_pile, 97 scoped_refptr<PicturePileImpl> pending_pile,
98 scoped_refptr<PicturePileImpl> active_pile) { 98 scoped_refptr<PicturePileImpl> active_pile,
99 SetupPendingTree(active_pile); 99 const gfx::Size& pending_layer_bounds,
100 const gfx::Size& active_layer_bounds) {
101 SetupPendingTree(active_pile, active_layer_bounds);
100 ActivateTree(); 102 ActivateTree();
101 SetupPendingTree(pending_pile); 103 SetupPendingTree(pending_pile, pending_layer_bounds);
102 } 104 }
103 105
104 void CreateHighLowResAndSetAllTilesVisible() { 106 void CreateHighLowResAndSetAllTilesVisible() {
105 // Active layer must get updated first so pending layer can share from it. 107 // Active layer must get updated first so pending layer can share from it.
106 active_layer_->CreateDefaultTilingsAndTiles(); 108 active_layer_->CreateDefaultTilingsAndTiles();
107 active_layer_->SetAllTilesVisible(); 109 active_layer_->SetAllTilesVisible();
108 pending_layer_->CreateDefaultTilingsAndTiles(); 110 pending_layer_->CreateDefaultTilingsAndTiles();
109 pending_layer_->SetAllTilesVisible(); 111 pending_layer_->SetAllTilesVisible();
110 } 112 }
111 113
112 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { 114 void AddDefaultTilingsWithInvalidation(const Region& invalidation) {
113 active_layer_->AddTiling(2.3f); 115 active_layer_->AddTiling(2.3f);
114 active_layer_->AddTiling(1.0f); 116 active_layer_->AddTiling(1.0f);
115 active_layer_->AddTiling(0.5f); 117 active_layer_->AddTiling(0.5f);
116 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i) 118 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i)
117 active_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); 119 active_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting();
118 pending_layer_->set_invalidation(invalidation); 120 pending_layer_->set_invalidation(invalidation);
119 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i) 121 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i)
120 pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); 122 pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting();
121 } 123 }
122 124
123 void SetupPendingTree( 125 void SetupPendingTree(
124 scoped_refptr<PicturePileImpl> pile) { 126 scoped_refptr<PicturePileImpl> pile, const gfx::Size& layer_bounds) {
125 host_impl_.CreatePendingTree(); 127 host_impl_.CreatePendingTree();
126 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 128 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
127 // Clear recycled tree. 129 // Clear recycled tree.
128 pending_tree->DetachLayerTree(); 130 pending_tree->DetachLayerTree();
129 131
130 scoped_ptr<FakePictureLayerImpl> pending_layer = 132 scoped_ptr<FakePictureLayerImpl> pending_layer =
131 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); 133 FakePictureLayerImpl::CreateWithPile(
134 pending_tree, id_, pile, layer_bounds);
enne (OOO) 2014/04/11 20:19:51 Maybe don't add another parameter here, and just m
ernstm 2014/04/11 23:43:51 Done. Added a separate CreateWithPartialPile for p
132 pending_layer->SetDrawsContent(true); 135 pending_layer->SetDrawsContent(true);
133 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); 136 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>());
134 137
135 pending_layer_ = static_cast<FakePictureLayerImpl*>( 138 pending_layer_ = static_cast<FakePictureLayerImpl*>(
136 host_impl_.pending_tree()->LayerById(id_)); 139 host_impl_.pending_tree()->LayerById(id_));
137 pending_layer_->DoPostCommitInitializationIfNeeded(); 140 pending_layer_->DoPostCommitInitializationIfNeeded();
138 } 141 }
139 142
140 static void VerifyAllTilesExistAndHavePile( 143 static void VerifyAllTilesExistAndHavePile(
141 const PictureLayerTiling* tiling, 144 const PictureLayerTiling* tiling,
142 PicturePileImpl* pile) { 145 PicturePileImpl* pile) {
143 for (PictureLayerTiling::CoverageIterator 146 for (PictureLayerTiling::CoverageIterator
144 iter(tiling, tiling->contents_scale(), tiling->ContentRect()); 147 iter(tiling, tiling->contents_scale(), tiling->TilingRect());
145 iter; 148 iter;
146 ++iter) { 149 ++iter) {
147 EXPECT_TRUE(*iter); 150 EXPECT_TRUE(*iter);
148 EXPECT_EQ(pile, iter->picture_pile()); 151 EXPECT_EQ(pile, iter->picture_pile());
149 } 152 }
150 } 153 }
151 154
152 void SetContentsScaleOnBothLayers(float contents_scale, 155 void SetContentsScaleOnBothLayers(float contents_scale,
153 float device_scale_factor, 156 float device_scale_factor,
154 float page_scale_factor, 157 float page_scale_factor,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 ImplSidePaintingSettings settings; 201 ImplSidePaintingSettings settings;
199 gfx::Size layer_size( 202 gfx::Size layer_size(
200 settings.default_tile_size.width() * 7 / 2, 203 settings.default_tile_size.width() * 7 / 2,
201 settings.default_tile_size.height() * 7 / 2); 204 settings.default_tile_size.height() * 7 / 2);
202 205
203 scoped_refptr<FakePicturePileImpl> pending_pile = 206 scoped_refptr<FakePicturePileImpl> pending_pile =
204 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); 207 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size);
205 scoped_refptr<FakePicturePileImpl> active_pile = 208 scoped_refptr<FakePicturePileImpl> active_pile =
206 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); 209 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size);
207 210
208 SetupTrees(pending_pile, active_pile); 211 SetupTrees(pending_pile, active_pile, layer_size, layer_size);
209 212
210 float result_scale_x, result_scale_y; 213 float result_scale_x, result_scale_y;
211 gfx::Size result_bounds; 214 gfx::Size result_bounds;
212 active_layer_->CalculateContentsScale( 215 active_layer_->CalculateContentsScale(
213 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); 216 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds);
214 217
215 // Add 1x1 rects at the centers of each tile, then re-record pile contents 218 // Add 1x1 rects at the centers of each tile, then re-record pile contents
216 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 219 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
217 std::vector<Tile*> tiles = 220 std::vector<Tile*> tiles =
218 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 221 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 271
269 TEST_F(PictureLayerImplTest, CloneNoInvalidation) { 272 TEST_F(PictureLayerImplTest, CloneNoInvalidation) {
270 gfx::Size tile_size(100, 100); 273 gfx::Size tile_size(100, 100);
271 gfx::Size layer_bounds(400, 400); 274 gfx::Size layer_bounds(400, 400);
272 275
273 scoped_refptr<FakePicturePileImpl> pending_pile = 276 scoped_refptr<FakePicturePileImpl> pending_pile =
274 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 277 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
275 scoped_refptr<FakePicturePileImpl> active_pile = 278 scoped_refptr<FakePicturePileImpl> active_pile =
276 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 279 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
277 280
278 SetupTrees(pending_pile, active_pile); 281 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
279 282
280 Region invalidation; 283 Region invalidation;
281 AddDefaultTilingsWithInvalidation(invalidation); 284 AddDefaultTilingsWithInvalidation(invalidation);
282 285
283 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), 286 EXPECT_EQ(pending_layer_->tilings()->num_tilings(),
284 active_layer_->tilings()->num_tilings()); 287 active_layer_->tilings()->num_tilings());
285 288
286 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 289 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
287 EXPECT_GT(tilings->num_tilings(), 0u); 290 EXPECT_GT(tilings->num_tilings(), 0u);
288 for (size_t i = 0; i < tilings->num_tilings(); ++i) 291 for (size_t i = 0; i < tilings->num_tilings(); ++i)
289 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), active_pile.get()); 292 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), active_pile.get());
290 } 293 }
291 294
292 TEST_F(PictureLayerImplTest, TileManagerRegisterUnregister) { 295 TEST_F(PictureLayerImplTest, TileManagerRegisterUnregister) {
293 gfx::Size tile_size(100, 100); 296 gfx::Size tile_size(100, 100);
294 gfx::Size layer_bounds(400, 400); 297 gfx::Size layer_bounds(400, 400);
295 298
296 scoped_refptr<FakePicturePileImpl> pending_pile = 299 scoped_refptr<FakePicturePileImpl> pending_pile =
297 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 300 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
298 scoped_refptr<FakePicturePileImpl> active_pile = 301 scoped_refptr<FakePicturePileImpl> active_pile =
299 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 302 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
300 303
301 SetupTrees(pending_pile, active_pile); 304 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
302 305
303 std::vector<TileManager::PairedPictureLayer> paired_layers; 306 std::vector<TileManager::PairedPictureLayer> paired_layers;
304 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); 307 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers);
305 EXPECT_EQ(0u, paired_layers.size()); 308 EXPECT_EQ(0u, paired_layers.size());
306 309
307 // Update tile priorities will force the layer to register itself. 310 // Update tile priorities will force the layer to register itself.
308 float dummy_contents_scale_x; 311 float dummy_contents_scale_x;
309 float dummy_contents_scale_y; 312 float dummy_contents_scale_y;
310 gfx::Size dummy_content_bounds; 313 gfx::Size dummy_content_bounds;
311 active_layer_->CalculateContentsScale(1.f, 314 active_layer_->CalculateContentsScale(1.f,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 host_impl_.SetCurrentFrameTimeTicks(time_ticks); 373 host_impl_.SetCurrentFrameTimeTicks(time_ticks);
371 374
372 gfx::Size tile_size(100, 100); 375 gfx::Size tile_size(100, 100);
373 gfx::Size layer_bounds(400, 400); 376 gfx::Size layer_bounds(400, 400);
374 377
375 scoped_refptr<FakePicturePileImpl> pending_pile = 378 scoped_refptr<FakePicturePileImpl> pending_pile =
376 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 379 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
377 scoped_refptr<FakePicturePileImpl> active_pile = 380 scoped_refptr<FakePicturePileImpl> active_pile =
378 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 381 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
379 382
380 SetupTrees(pending_pile, active_pile); 383 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
381 384
382 Region invalidation; 385 Region invalidation;
383 AddDefaultTilingsWithInvalidation(invalidation); 386 AddDefaultTilingsWithInvalidation(invalidation);
384 float dummy_contents_scale_x; 387 float dummy_contents_scale_x;
385 float dummy_contents_scale_y; 388 float dummy_contents_scale_y;
386 gfx::Size dummy_content_bounds; 389 gfx::Size dummy_content_bounds;
387 active_layer_->CalculateContentsScale(1.f, 390 active_layer_->CalculateContentsScale(1.f,
388 1.f, 391 1.f,
389 1.f, 392 1.f,
390 false, 393 false,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { 427 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) {
425 gfx::Size tile_size(100, 100); 428 gfx::Size tile_size(100, 100);
426 gfx::Size layer_bounds(400, 400); 429 gfx::Size layer_bounds(400, 400);
427 gfx::Rect layer_invalidation(150, 200, 30, 180); 430 gfx::Rect layer_invalidation(150, 200, 30, 180);
428 431
429 scoped_refptr<FakePicturePileImpl> pending_pile = 432 scoped_refptr<FakePicturePileImpl> pending_pile =
430 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 433 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
431 scoped_refptr<FakePicturePileImpl> active_pile = 434 scoped_refptr<FakePicturePileImpl> active_pile =
432 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 435 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
433 436
434 SetupTrees(pending_pile, active_pile); 437 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
435 438
436 Region invalidation(layer_invalidation); 439 Region invalidation(layer_invalidation);
437 AddDefaultTilingsWithInvalidation(invalidation); 440 AddDefaultTilingsWithInvalidation(invalidation);
438 441
439 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 442 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
440 EXPECT_GT(tilings->num_tilings(), 0u); 443 EXPECT_GT(tilings->num_tilings(), 0u);
441 for (size_t i = 0; i < tilings->num_tilings(); ++i) { 444 for (size_t i = 0; i < tilings->num_tilings(); ++i) {
442 const PictureLayerTiling* tiling = tilings->tiling_at(i); 445 const PictureLayerTiling* tiling = tilings->tiling_at(i);
443 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( 446 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect(
444 layer_invalidation, 447 layer_invalidation,
445 tiling->contents_scale()); 448 tiling->contents_scale());
446 for (PictureLayerTiling::CoverageIterator 449 for (PictureLayerTiling::CoverageIterator
447 iter(tiling, 450 iter(tiling,
448 tiling->contents_scale(), 451 tiling->contents_scale(),
449 tiling->ContentRect()); 452 tiling->TilingRect());
450 iter; 453 iter;
451 ++iter) { 454 ++iter) {
452 EXPECT_TRUE(*iter); 455 EXPECT_TRUE(*iter);
453 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); 456 EXPECT_FALSE(iter.geometry_rect().IsEmpty());
454 if (iter.geometry_rect().Intersects(content_invalidation)) 457 if (iter.geometry_rect().Intersects(content_invalidation))
455 EXPECT_EQ(pending_pile, iter->picture_pile()); 458 EXPECT_EQ(pending_pile, iter->picture_pile());
456 else 459 else
457 EXPECT_EQ(active_pile, iter->picture_pile()); 460 EXPECT_EQ(active_pile, iter->picture_pile());
458 } 461 }
459 } 462 }
460 } 463 }
461 464
462 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { 465 TEST_F(PictureLayerImplTest, CloneFullInvalidation) {
463 gfx::Size tile_size(90, 80); 466 gfx::Size tile_size(90, 80);
464 gfx::Size layer_bounds(300, 500); 467 gfx::Size layer_bounds(300, 500);
465 468
466 scoped_refptr<FakePicturePileImpl> pending_pile = 469 scoped_refptr<FakePicturePileImpl> pending_pile =
467 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 470 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
468 scoped_refptr<FakePicturePileImpl> active_pile = 471 scoped_refptr<FakePicturePileImpl> active_pile =
469 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 472 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
470 473
471 SetupTrees(pending_pile, active_pile); 474 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
472 475
473 Region invalidation((gfx::Rect(layer_bounds))); 476 Region invalidation((gfx::Rect(layer_bounds)));
474 AddDefaultTilingsWithInvalidation(invalidation); 477 AddDefaultTilingsWithInvalidation(invalidation);
475 478
476 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), 479 EXPECT_EQ(pending_layer_->tilings()->num_tilings(),
477 active_layer_->tilings()->num_tilings()); 480 active_layer_->tilings()->num_tilings());
478 481
479 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 482 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
480 EXPECT_GT(tilings->num_tilings(), 0u); 483 EXPECT_GT(tilings->num_tilings(), 0u);
481 for (size_t i = 0; i < tilings->num_tilings(); ++i) 484 for (size_t i = 0; i < tilings->num_tilings(); ++i)
482 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); 485 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get());
483 } 486 }
484 487
485 TEST_F(PictureLayerImplTest, NoInvalidationBoundsChange) { 488 TEST_F(PictureLayerImplTest, NoInvalidationBoundsChange) {
486 gfx::Size tile_size(90, 80); 489 gfx::Size tile_size(90, 80);
487 gfx::Size active_layer_bounds(300, 500); 490 gfx::Size active_layer_bounds(300, 500);
488 gfx::Size pending_layer_bounds(400, 800); 491 gfx::Size pending_layer_bounds(400, 800);
489 492
490 scoped_refptr<FakePicturePileImpl> pending_pile = 493 scoped_refptr<FakePicturePileImpl> pending_pile =
491 FakePicturePileImpl::CreateFilledPile(tile_size, 494 FakePicturePileImpl::CreateFilledPile(tile_size,
492 pending_layer_bounds); 495 pending_layer_bounds);
493 scoped_refptr<FakePicturePileImpl> active_pile = 496 scoped_refptr<FakePicturePileImpl> active_pile =
494 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); 497 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds);
495 498
496 SetupTrees(pending_pile, active_pile); 499 SetupTrees(pending_pile, active_pile,
500 active_layer_bounds, pending_layer_bounds);
497 pending_layer_->set_fixed_tile_size(gfx::Size(100, 100)); 501 pending_layer_->set_fixed_tile_size(gfx::Size(100, 100));
498 502
499 Region invalidation; 503 Region invalidation;
500 AddDefaultTilingsWithInvalidation(invalidation); 504 AddDefaultTilingsWithInvalidation(invalidation);
501 505
502 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 506 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
503 EXPECT_GT(tilings->num_tilings(), 0u); 507 EXPECT_GT(tilings->num_tilings(), 0u);
504 for (size_t i = 0; i < tilings->num_tilings(); ++i) { 508 for (size_t i = 0; i < tilings->num_tilings(); ++i) {
505 const PictureLayerTiling* tiling = tilings->tiling_at(i); 509 const PictureLayerTiling* tiling = tilings->tiling_at(i);
506 gfx::Rect active_content_bounds = gfx::ScaleToEnclosingRect( 510 gfx::Rect active_content_bounds = gfx::ScaleToEnclosingRect(
507 gfx::Rect(active_layer_bounds), 511 gfx::Rect(active_layer_bounds),
508 tiling->contents_scale()); 512 tiling->contents_scale());
509 for (PictureLayerTiling::CoverageIterator 513 for (PictureLayerTiling::CoverageIterator
510 iter(tiling, 514 iter(tiling,
511 tiling->contents_scale(), 515 tiling->contents_scale(),
512 tiling->ContentRect()); 516 tiling->TilingRect());
513 iter; 517 iter;
514 ++iter) { 518 ++iter) {
515 EXPECT_TRUE(*iter); 519 EXPECT_TRUE(*iter);
516 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); 520 EXPECT_FALSE(iter.geometry_rect().IsEmpty());
517 std::vector<Tile*> active_tiles = 521 std::vector<Tile*> active_tiles =
518 active_layer_->tilings()->tiling_at(i)->AllTilesForTesting(); 522 active_layer_->tilings()->tiling_at(i)->AllTilesForTesting();
519 std::vector<Tile*> pending_tiles = tiling->AllTilesForTesting(); 523 std::vector<Tile*> pending_tiles = tiling->AllTilesForTesting();
520 if (iter.geometry_rect().right() >= active_content_bounds.width() || 524 if (iter.geometry_rect().right() >= active_content_bounds.width() ||
521 iter.geometry_rect().bottom() >= active_content_bounds.height() || 525 iter.geometry_rect().bottom() >= active_content_bounds.height() ||
522 active_tiles[0]->content_rect().size() != 526 active_tiles[0]->content_rect().size() !=
(...skipping 23 matching lines...) Expand all
546 pending_pile->AddRecordingAt(x, y); 550 pending_pile->AddRecordingAt(x, y);
547 active_pile->AddRecordingAt(x, y); 551 active_pile->AddRecordingAt(x, y);
548 } else { 552 } else {
549 hole_count++; 553 hole_count++;
550 if (hole_count % 2) 554 if (hole_count % 2)
551 pending_pile->AddRecordingAt(x, y); 555 pending_pile->AddRecordingAt(x, y);
552 } 556 }
553 } 557 }
554 } 558 }
555 559
556 SetupTrees(pending_pile, active_pile); 560 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
557 Region invalidation; 561 Region invalidation;
558 AddDefaultTilingsWithInvalidation(invalidation); 562 AddDefaultTilingsWithInvalidation(invalidation);
559 563
560 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 564 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
561 EXPECT_GT(tilings->num_tilings(), 0u); 565 EXPECT_GT(tilings->num_tilings(), 0u);
562 for (size_t i = 0; i < tilings->num_tilings(); ++i) { 566 for (size_t i = 0; i < tilings->num_tilings(); ++i) {
563 const PictureLayerTiling* tiling = tilings->tiling_at(i); 567 const PictureLayerTiling* tiling = tilings->tiling_at(i);
564 568
565 for (PictureLayerTiling::CoverageIterator 569 for (PictureLayerTiling::CoverageIterator
566 iter(tiling, 570 iter(tiling,
567 tiling->contents_scale(), 571 tiling->contents_scale(),
568 tiling->ContentRect()); 572 tiling->TilingRect());
569 iter; 573 iter;
570 ++iter) { 574 ++iter) {
571 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); 575 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty());
572 // Ensure there is a recording for this tile. 576 // Ensure there is a recording for this tile.
573 bool in_pending = pending_pile->CanRaster(tiling->contents_scale(), 577 bool in_pending = pending_pile->CanRaster(tiling->contents_scale(),
574 iter.full_tile_geometry_rect()); 578 iter.full_tile_geometry_rect());
575 bool in_active = active_pile->CanRaster(tiling->contents_scale(), 579 bool in_active = active_pile->CanRaster(tiling->contents_scale(),
576 iter.full_tile_geometry_rect()); 580 iter.full_tile_geometry_rect());
577 581
578 if (in_pending && !in_active) 582 if (in_pending && !in_active)
(...skipping 11 matching lines...) Expand all
590 gfx::Size layer_bounds(1300, 1900); 594 gfx::Size layer_bounds(1300, 1900);
591 595
592 scoped_refptr<FakePicturePileImpl> pending_pile = 596 scoped_refptr<FakePicturePileImpl> pending_pile =
593 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 597 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
594 scoped_refptr<FakePicturePileImpl> active_pile = 598 scoped_refptr<FakePicturePileImpl> active_pile =
595 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 599 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
596 600
597 float result_scale_x, result_scale_y; 601 float result_scale_x, result_scale_y;
598 gfx::Size result_bounds; 602 gfx::Size result_bounds;
599 603
600 SetupTrees(pending_pile, active_pile); 604 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
601 605
602 pending_layer_->CalculateContentsScale( 606 pending_layer_->CalculateContentsScale(
603 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); 607 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds);
604 608
605 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 609 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
606 } 610 }
607 611
608 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { 612 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) {
609 gfx::Size tile_size(400, 400); 613 gfx::Size tile_size(400, 400);
610 gfx::Size layer_bounds(1300, 1900); 614 gfx::Size layer_bounds(1300, 1900);
611 615
612 scoped_refptr<FakePicturePileImpl> pending_pile = 616 scoped_refptr<FakePicturePileImpl> pending_pile =
613 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 617 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
614 scoped_refptr<FakePicturePileImpl> active_pile = 618 scoped_refptr<FakePicturePileImpl> active_pile =
615 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 619 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
616 620
617 float result_scale_x, result_scale_y; 621 float result_scale_x, result_scale_y;
618 gfx::Size result_bounds; 622 gfx::Size result_bounds;
619 623
620 SetupTrees(pending_pile, active_pile); 624 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
621 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 625 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
622 626
623 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 627 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
624 EXPECT_LT(low_res_factor, 1.f); 628 EXPECT_LT(low_res_factor, 1.f);
625 629
626 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale 630 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale
627 1.7f, // device scale 631 1.7f, // device scale
628 3.2f, // page cale 632 3.2f, // page cale
629 false, 633 false,
630 &result_scale_x, 634 &result_scale_x,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 724 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
721 EXPECT_LT(low_res_factor, 1.f); 725 EXPECT_LT(low_res_factor, 1.f);
722 726
723 float high_res_scale = 1.3f; 727 float high_res_scale = 1.3f;
724 float low_res_scale = high_res_scale * low_res_factor; 728 float low_res_scale = high_res_scale * low_res_factor;
725 float device_scale = 1.7f; 729 float device_scale = 1.7f;
726 float page_scale = 3.2f; 730 float page_scale = 3.2f;
727 float result_scale_x, result_scale_y; 731 float result_scale_x, result_scale_y;
728 gfx::Size result_bounds; 732 gfx::Size result_bounds;
729 733
730 SetupPendingTree(valid_pile); 734 SetupPendingTree(valid_pile, layer_bounds);
731 pending_layer_->CalculateContentsScale(high_res_scale, 735 pending_layer_->CalculateContentsScale(high_res_scale,
732 device_scale, 736 device_scale,
733 page_scale, 737 page_scale,
734 false, 738 false,
735 &result_scale_x, 739 &result_scale_x,
736 &result_scale_y, 740 &result_scale_y,
737 &result_bounds); 741 &result_bounds);
738 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); 742 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
739 EXPECT_FLOAT_EQ(high_res_scale, 743 EXPECT_FLOAT_EQ(high_res_scale,
740 pending_layer_->HighResTiling()->contents_scale()); 744 pending_layer_->HighResTiling()->contents_scale());
741 EXPECT_FLOAT_EQ(low_res_scale, 745 EXPECT_FLOAT_EQ(low_res_scale,
742 pending_layer_->LowResTiling()->contents_scale()); 746 pending_layer_->LowResTiling()->contents_scale());
743 747
744 ActivateTree(); 748 ActivateTree();
745 SetupPendingTree(empty_pile); 749 SetupPendingTree(empty_pile, layer_bounds);
746 pending_layer_->CalculateContentsScale(high_res_scale, 750 pending_layer_->CalculateContentsScale(high_res_scale,
747 device_scale, 751 device_scale,
748 page_scale, 752 page_scale,
749 false, 753 false,
750 &result_scale_x, 754 &result_scale_x,
751 &result_scale_y, 755 &result_scale_y,
752 &result_bounds); 756 &result_bounds);
753 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); 757 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
754 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); 758 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings());
755 759
756 ActivateTree(); 760 ActivateTree();
757 active_layer_->CalculateContentsScale(high_res_scale, 761 active_layer_->CalculateContentsScale(high_res_scale,
758 device_scale, 762 device_scale,
759 page_scale, 763 page_scale,
760 false, 764 false,
761 &result_scale_x, 765 &result_scale_x,
762 &result_scale_y, 766 &result_scale_y,
763 &result_bounds); 767 &result_bounds);
764 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); 768 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
765 769
766 SetupPendingTree(valid_pile); 770 SetupPendingTree(valid_pile, layer_bounds);
767 pending_layer_->CalculateContentsScale(high_res_scale, 771 pending_layer_->CalculateContentsScale(high_res_scale,
768 device_scale, 772 device_scale,
769 page_scale, 773 page_scale,
770 false, 774 false,
771 &result_scale_x, 775 &result_scale_x,
772 &result_scale_y, 776 &result_scale_y,
773 &result_bounds); 777 &result_bounds);
774 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); 778 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
775 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); 779 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
776 EXPECT_FLOAT_EQ(high_res_scale, 780 EXPECT_FLOAT_EQ(high_res_scale,
777 pending_layer_->HighResTiling()->contents_scale()); 781 pending_layer_->HighResTiling()->contents_scale());
778 EXPECT_FLOAT_EQ(low_res_scale, 782 EXPECT_FLOAT_EQ(low_res_scale,
779 pending_layer_->LowResTiling()->contents_scale()); 783 pending_layer_->LowResTiling()->contents_scale());
780 } 784 }
781 785
782 TEST_F(PictureLayerImplTest, ZoomOutCrash) { 786 TEST_F(PictureLayerImplTest, ZoomOutCrash) {
783 gfx::Size tile_size(400, 400); 787 gfx::Size tile_size(400, 400);
784 gfx::Size layer_bounds(1300, 1900); 788 gfx::Size layer_bounds(1300, 1900);
785 789
786 // Set up the high and low res tilings before pinch zoom. 790 // Set up the high and low res tilings before pinch zoom.
787 scoped_refptr<FakePicturePileImpl> pending_pile = 791 scoped_refptr<FakePicturePileImpl> pending_pile =
788 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 792 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
789 scoped_refptr<FakePicturePileImpl> active_pile = 793 scoped_refptr<FakePicturePileImpl> active_pile =
790 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 794 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
791 795
792 SetupTrees(pending_pile, active_pile); 796 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
793 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 797 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
794 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, false); 798 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, false);
795 host_impl_.PinchGestureBegin(); 799 host_impl_.PinchGestureBegin();
796 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false); 800 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false);
797 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false); 801 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false);
798 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); 802 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1);
799 } 803 }
800 804
801 TEST_F(PictureLayerImplTest, PinchGestureTilings) { 805 TEST_F(PictureLayerImplTest, PinchGestureTilings) {
802 gfx::Size tile_size(400, 400); 806 gfx::Size tile_size(400, 400);
803 gfx::Size layer_bounds(1300, 1900); 807 gfx::Size layer_bounds(1300, 1900);
804 808
805 scoped_refptr<FakePicturePileImpl> pending_pile = 809 scoped_refptr<FakePicturePileImpl> pending_pile =
806 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 810 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
807 scoped_refptr<FakePicturePileImpl> active_pile = 811 scoped_refptr<FakePicturePileImpl> active_pile =
808 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 812 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
809 813
810 // Set up the high and low res tilings before pinch zoom. 814 // Set up the high and low res tilings before pinch zoom.
811 SetupTrees(pending_pile, active_pile); 815 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
812 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 816 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
813 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false); 817 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false);
814 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 818 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
815 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); 819 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings());
816 EXPECT_FLOAT_EQ( 820 EXPECT_FLOAT_EQ(
817 1.0f, 821 1.0f,
818 active_layer_->tilings()->tiling_at(0)->contents_scale()); 822 active_layer_->tilings()->tiling_at(0)->contents_scale());
819 EXPECT_FLOAT_EQ( 823 EXPECT_FLOAT_EQ(
820 1.0f * low_res_factor, 824 1.0f * low_res_factor,
821 active_layer_->tilings()->tiling_at(1)->contents_scale()); 825 active_layer_->tilings()->tiling_at(1)->contents_scale());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 866
863 scoped_refptr<FakePicturePileImpl> pending_pile = 867 scoped_refptr<FakePicturePileImpl> pending_pile =
864 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 868 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
865 scoped_refptr<FakePicturePileImpl> active_pile = 869 scoped_refptr<FakePicturePileImpl> active_pile =
866 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 870 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
867 871
868 float result_scale_x, result_scale_y; 872 float result_scale_x, result_scale_y;
869 gfx::Size result_bounds; 873 gfx::Size result_bounds;
870 std::vector<PictureLayerTiling*> used_tilings; 874 std::vector<PictureLayerTiling*> used_tilings;
871 875
872 SetupTrees(pending_pile, active_pile); 876 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
873 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 877 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
874 878
875 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 879 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
876 EXPECT_LT(low_res_factor, 1.f); 880 EXPECT_LT(low_res_factor, 1.f);
877 881
878 float device_scale = 1.7f; 882 float device_scale = 1.7f;
879 float page_scale = 3.2f; 883 float page_scale = 3.2f;
880 884
881 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, false); 885 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, false);
882 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); 886 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 gfx::Size layer_bounds(1300, 1900); 1082 gfx::Size layer_bounds(1300, 1900);
1079 1083
1080 scoped_refptr<FakePicturePileImpl> pending_pile = 1084 scoped_refptr<FakePicturePileImpl> pending_pile =
1081 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1085 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1082 scoped_refptr<FakePicturePileImpl> active_pile = 1086 scoped_refptr<FakePicturePileImpl> active_pile =
1083 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1087 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1084 1088
1085 float result_scale_x, result_scale_y; 1089 float result_scale_x, result_scale_y;
1086 gfx::Size result_bounds; 1090 gfx::Size result_bounds;
1087 1091
1088 SetupTrees(pending_pile, active_pile); 1092 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
1089 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 1093 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
1090 1094
1091 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale 1095 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale
1092 2.7f, // device scale 1096 2.7f, // device scale
1093 3.2f, // page cale 1097 3.2f, // page cale
1094 false, 1098 false,
1095 &result_scale_x, 1099 &result_scale_x,
1096 &result_scale_y, 1100 &result_scale_y,
1097 &result_bounds); 1101 &result_bounds);
1098 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); 1102 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
(...skipping 21 matching lines...) Expand all
1120 gfx::Size layer_bounds(5000, 5000); 1124 gfx::Size layer_bounds(5000, 5000);
1121 1125
1122 scoped_refptr<FakePicturePileImpl> pending_pile = 1126 scoped_refptr<FakePicturePileImpl> pending_pile =
1123 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1127 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1124 scoped_refptr<FakePicturePileImpl> active_pile = 1128 scoped_refptr<FakePicturePileImpl> active_pile =
1125 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1129 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1126 1130
1127 float result_scale_x, result_scale_y; 1131 float result_scale_x, result_scale_y;
1128 gfx::Size result_bounds; 1132 gfx::Size result_bounds;
1129 1133
1130 SetupTrees(pending_pile, active_pile); 1134 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
1131 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 1135 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
1132 1136
1133 pending_layer_->CalculateContentsScale( 1137 pending_layer_->CalculateContentsScale(
1134 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); 1138 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds);
1135 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); 1139 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
1136 1140
1137 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1141 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1138 1142
1139 // The default value. 1143 // The default value.
1140 EXPECT_EQ(gfx::Size(256, 256).ToString(), 1144 EXPECT_EQ(gfx::Size(256, 256).ToString(),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 gfx::Size layer_bounds(500, 500); 1176 gfx::Size layer_bounds(500, 500);
1173 1177
1174 scoped_refptr<FakePicturePileImpl> pending_pile = 1178 scoped_refptr<FakePicturePileImpl> pending_pile =
1175 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1179 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1176 scoped_refptr<FakePicturePileImpl> active_pile = 1180 scoped_refptr<FakePicturePileImpl> active_pile =
1177 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1181 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1178 1182
1179 float result_scale_x, result_scale_y; 1183 float result_scale_x, result_scale_y;
1180 gfx::Size result_bounds; 1184 gfx::Size result_bounds;
1181 1185
1182 SetupTrees(pending_pile, active_pile); 1186 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
1183 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 1187 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
1184 1188
1185 pending_layer_->CalculateContentsScale( 1189 pending_layer_->CalculateContentsScale(
1186 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); 1190 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds);
1187 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); 1191 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings());
1188 1192
1189 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1193 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1190 1194
1191 // The default value. The layer is smaller than this. 1195 // The default value. The layer is smaller than this.
1192 EXPECT_EQ(gfx::Size(512, 512).ToString(), 1196 EXPECT_EQ(gfx::Size(512, 512).ToString(),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 MockQuadCuller quad_culler; 1231 MockQuadCuller quad_culler;
1228 1232
1229 gfx::Size tile_size(400, 400); 1233 gfx::Size tile_size(400, 400);
1230 gfx::Size layer_bounds(1300, 1900); 1234 gfx::Size layer_bounds(1300, 1900);
1231 1235
1232 scoped_refptr<FakePicturePileImpl> pending_pile = 1236 scoped_refptr<FakePicturePileImpl> pending_pile =
1233 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1237 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1234 scoped_refptr<FakePicturePileImpl> active_pile = 1238 scoped_refptr<FakePicturePileImpl> active_pile =
1235 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1239 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1236 1240
1237 SetupTrees(pending_pile, active_pile); 1241 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
1238 1242
1239 active_layer_->SetContentBounds(layer_bounds); 1243 active_layer_->SetContentBounds(layer_bounds);
1240 active_layer_->draw_properties().visible_content_rect = 1244 active_layer_->draw_properties().visible_content_rect =
1241 gfx::Rect(layer_bounds); 1245 gfx::Rect(layer_bounds);
1242 1246
1243 gfx::Rect layer_invalidation(150, 200, 30, 180); 1247 gfx::Rect layer_invalidation(150, 200, 30, 180);
1244 Region invalidation(layer_invalidation); 1248 Region invalidation(layer_invalidation);
1245 AddDefaultTilingsWithInvalidation(invalidation); 1249 AddDefaultTilingsWithInvalidation(invalidation);
1246 1250
1247 AppendQuadsData data; 1251 AppendQuadsData data;
1248 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); 1252 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL);
1249 active_layer_->AppendQuads(&quad_culler, &data); 1253 active_layer_->AppendQuads(&quad_culler, &data);
1250 active_layer_->DidDraw(NULL); 1254 active_layer_->DidDraw(NULL);
1251 1255
1252 ASSERT_EQ(1U, quad_culler.quad_list().size()); 1256 ASSERT_EQ(1U, quad_culler.quad_list().size());
1253 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, quad_culler.quad_list()[0]->material); 1257 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, quad_culler.quad_list()[0]->material);
1254 } 1258 }
1255 1259
1256 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { 1260 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) {
1257 gfx::Size tile_size(100, 100); 1261 gfx::Size tile_size(100, 100);
1258 gfx::Size layer_bounds(1000, 1000); 1262 gfx::Size layer_bounds(1000, 1000);
1259 1263
1260 scoped_refptr<FakePicturePileImpl> pending_pile = 1264 scoped_refptr<FakePicturePileImpl> pending_pile =
1261 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 1265 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
1262 // Layers with entirely empty piles can't get tilings. 1266 // Layers with entirely empty piles can't get tilings.
1263 pending_pile->AddRecordingAt(0, 0); 1267 pending_pile->AddRecordingAt(0, 0);
1264 1268
1265 SetupPendingTree(pending_pile); 1269 SetupPendingTree(pending_pile, layer_bounds);
1266 1270
1267 ASSERT_TRUE(pending_layer_->CanHaveTilings()); 1271 ASSERT_TRUE(pending_layer_->CanHaveTilings());
1268 pending_layer_->AddTiling(1.0f); 1272 pending_layer_->AddTiling(1.0f);
1269 pending_layer_->AddTiling(2.0f); 1273 pending_layer_->AddTiling(2.0f);
1270 1274
1271 // It should be safe to call this (and MarkVisibleResourcesAsRequired) 1275 // It should be safe to call this (and MarkVisibleResourcesAsRequired)
1272 // on a layer with no recordings. 1276 // on a layer with no recordings.
1273 host_impl_.pending_tree()->UpdateDrawProperties(); 1277 host_impl_.pending_tree()->UpdateDrawProperties();
1274 pending_layer_->MarkVisibleResourcesAsRequired(); 1278 pending_layer_->MarkVisibleResourcesAsRequired();
1275 } 1279 }
1276 1280
1277 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { 1281 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) {
1278 gfx::Size tile_size(100, 100); 1282 gfx::Size tile_size(100, 100);
1279 gfx::Size layer_bounds(200, 200); 1283 gfx::Size layer_bounds(200, 200);
1280 1284
1281 scoped_refptr<FakePicturePileImpl> pending_pile = 1285 scoped_refptr<FakePicturePileImpl> pending_pile =
1282 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1286 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1283 SetupPendingTree(pending_pile); 1287 SetupPendingTree(pending_pile, layer_bounds);
1284 1288
1285 pending_layer_->set_fixed_tile_size(tile_size); 1289 pending_layer_->set_fixed_tile_size(tile_size);
1286 ASSERT_TRUE(pending_layer_->CanHaveTilings()); 1290 ASSERT_TRUE(pending_layer_->CanHaveTilings());
1287 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); 1291 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f);
1288 host_impl_.pending_tree()->UpdateDrawProperties(); 1292 host_impl_.pending_tree()->UpdateDrawProperties();
1289 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); 1293 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION);
1290 1294
1291 pending_layer_->draw_properties().visible_content_rect = 1295 pending_layer_->draw_properties().visible_content_rect =
1292 gfx::Rect(0, 0, 100, 200); 1296 gfx::Rect(0, 0, 100, 200);
1293 1297
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 gfx::Size tile_size(100, 100); 1404 gfx::Size tile_size(100, 100);
1401 scoped_refptr<FakePicturePileImpl> pending_pile = 1405 scoped_refptr<FakePicturePileImpl> pending_pile =
1402 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1406 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1403 // This pile will create tilings, but has no recordings so will not create any 1407 // This pile will create tilings, but has no recordings so will not create any
1404 // tiles. This is attempting to simulate scrolling past the end of recorded 1408 // tiles. This is attempting to simulate scrolling past the end of recorded
1405 // content on the active layer, where the recordings are so far away that 1409 // content on the active layer, where the recordings are so far away that
1406 // no tiles are created. 1410 // no tiles are created.
1407 scoped_refptr<FakePicturePileImpl> active_pile = 1411 scoped_refptr<FakePicturePileImpl> active_pile =
1408 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( 1412 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
1409 tile_size, layer_bounds); 1413 tile_size, layer_bounds);
1410 SetupTrees(pending_pile, active_pile); 1414 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
1411 pending_layer_->set_fixed_tile_size(tile_size); 1415 pending_layer_->set_fixed_tile_size(tile_size);
1412 active_layer_->set_fixed_tile_size(tile_size); 1416 active_layer_->set_fixed_tile_size(tile_size);
1413 1417
1414 CreateHighLowResAndSetAllTilesVisible(); 1418 CreateHighLowResAndSetAllTilesVisible();
1415 1419
1416 // Active layer has tilings, but no tiles due to missing recordings. 1420 // Active layer has tilings, but no tiles due to missing recordings.
1417 EXPECT_TRUE(active_layer_->CanHaveTilings()); 1421 EXPECT_TRUE(active_layer_->CanHaveTilings());
1418 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); 1422 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u);
1419 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 1423 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
1420 1424
1421 // Since the active layer has no tiles at all, the pending layer doesn't 1425 // Since the active layer has no tiles at all, the pending layer doesn't
1422 // need content in order to activate. 1426 // need content in order to activate.
1423 pending_layer_->MarkVisibleResourcesAsRequired(); 1427 pending_layer_->MarkVisibleResourcesAsRequired();
1424 AssertNoTilesRequired(pending_layer_->HighResTiling()); 1428 AssertNoTilesRequired(pending_layer_->HighResTiling());
1425 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1429 AssertNoTilesRequired(pending_layer_->LowResTiling());
1426 } 1430 }
1427 1431
1428 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { 1432 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {
1429 gfx::Size layer_bounds(400, 400); 1433 gfx::Size layer_bounds(400, 400);
1430 gfx::Size tile_size(100, 100); 1434 gfx::Size tile_size(100, 100);
1431 scoped_refptr<FakePicturePileImpl> pending_pile = 1435 scoped_refptr<FakePicturePileImpl> pending_pile =
1432 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1436 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1433 scoped_refptr<FakePicturePileImpl> active_pile = 1437 scoped_refptr<FakePicturePileImpl> active_pile =
1434 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 1438 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
1435 SetupTrees(pending_pile, active_pile); 1439 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
1436 pending_layer_->set_fixed_tile_size(tile_size); 1440 pending_layer_->set_fixed_tile_size(tile_size);
1437 active_layer_->set_fixed_tile_size(tile_size); 1441 active_layer_->set_fixed_tile_size(tile_size);
1438 1442
1439 CreateHighLowResAndSetAllTilesVisible(); 1443 CreateHighLowResAndSetAllTilesVisible();
1440 1444
1441 // Active layer can't have tiles. 1445 // Active layer can't have tiles.
1442 EXPECT_FALSE(active_layer_->CanHaveTilings()); 1446 EXPECT_FALSE(active_layer_->CanHaveTilings());
1443 1447
1444 // All high res tiles required. This should be considered identical 1448 // All high res tiles required. This should be considered identical
1445 // to the case where there is no active layer, to avoid flashing content. 1449 // to the case where there is no active layer, to avoid flashing content.
1446 // This can happen if a layer exists for a while and switches from 1450 // This can happen if a layer exists for a while and switches from
1447 // not being able to have content to having content. 1451 // not being able to have content to having content.
1448 pending_layer_->MarkVisibleResourcesAsRequired(); 1452 pending_layer_->MarkVisibleResourcesAsRequired();
1449 AssertAllTilesRequired(pending_layer_->HighResTiling()); 1453 AssertAllTilesRequired(pending_layer_->HighResTiling());
1450 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1454 AssertNoTilesRequired(pending_layer_->LowResTiling());
1451 } 1455 }
1452 1456
1453 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { 1457 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
1454 gfx::Size tile_size(100, 100); 1458 gfx::Size tile_size(100, 100);
1455 gfx::Size layer_bounds(400, 400); 1459 gfx::Size layer_bounds(400, 400);
1456 scoped_refptr<FakePicturePileImpl> pending_pile = 1460 scoped_refptr<FakePicturePileImpl> pending_pile =
1457 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1461 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1458 1462
1459 host_impl_.CreatePendingTree(); 1463 host_impl_.CreatePendingTree();
1460 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 1464 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
1461 1465
1462 scoped_ptr<FakePictureLayerImpl> pending_layer = 1466 scoped_ptr<FakePictureLayerImpl> pending_layer =
1463 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pending_pile); 1467 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pending_pile,
1468 layer_bounds);
1464 pending_layer->SetDrawsContent(true); 1469 pending_layer->SetDrawsContent(true);
1465 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); 1470 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>());
1466 1471
1467 pending_layer_ = static_cast<FakePictureLayerImpl*>( 1472 pending_layer_ = static_cast<FakePictureLayerImpl*>(
1468 host_impl_.pending_tree()->LayerById(id_)); 1473 host_impl_.pending_tree()->LayerById(id_));
1469 1474
1470 // Set some state on the pending layer, make sure it is not clobbered 1475 // Set some state on the pending layer, make sure it is not clobbered
1471 // by a sync from the active layer. This could happen because if the 1476 // by a sync from the active layer. This could happen because if the
1472 // pending layer has not been post-commit initialized it will attempt 1477 // pending layer has not been post-commit initialized it will attempt
1473 // to sync from the active layer. 1478 // to sync from the active layer.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 1601
1597 // Create some default active and pending trees. 1602 // Create some default active and pending trees.
1598 gfx::Size tile_size(100, 100); 1603 gfx::Size tile_size(100, 100);
1599 gfx::Size layer_bounds(400, 400); 1604 gfx::Size layer_bounds(400, 400);
1600 1605
1601 scoped_refptr<FakePicturePileImpl> pending_pile = 1606 scoped_refptr<FakePicturePileImpl> pending_pile =
1602 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1607 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1603 scoped_refptr<FakePicturePileImpl> active_pile = 1608 scoped_refptr<FakePicturePileImpl> active_pile =
1604 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1609 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1605 1610
1606 SetupTrees(pending_pile, active_pile); 1611 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds);
1607 } 1612 }
1608 }; 1613 };
1609 1614
1610 // This test is really a LayerTreeHostImpl test, in that it makes sure 1615 // This test is really a LayerTreeHostImpl test, in that it makes sure
1611 // that trees need update draw properties after deferred initialization. 1616 // that trees need update draw properties after deferred initialization.
1612 // However, this is also a regression test for PictureLayerImpl in that 1617 // However, this is also a regression test for PictureLayerImpl in that
1613 // not having this update will cause a crash. 1618 // not having this update will cause a crash.
1614 TEST_F(DeferredInitPictureLayerImplTest, 1619 TEST_F(DeferredInitPictureLayerImplTest,
1615 PreventUpdateTilePrioritiesDuringLostContext) { 1620 PreventUpdateTilePrioritiesDuringLostContext) {
1616 host_impl_.pending_tree()->UpdateDrawProperties(); 1621 host_impl_.pending_tree()->UpdateDrawProperties();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 1768 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
1764 } 1769 }
1765 1770
1766 TEST_F(PictureLayerImplTest, LayerRasterTileIterator) { 1771 TEST_F(PictureLayerImplTest, LayerRasterTileIterator) {
1767 gfx::Size tile_size(100, 100); 1772 gfx::Size tile_size(100, 100);
1768 gfx::Size layer_bounds(1000, 1000); 1773 gfx::Size layer_bounds(1000, 1000);
1769 1774
1770 scoped_refptr<FakePicturePileImpl> pending_pile = 1775 scoped_refptr<FakePicturePileImpl> pending_pile =
1771 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1776 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1772 1777
1773 SetupPendingTree(pending_pile); 1778 SetupPendingTree(pending_pile, layer_bounds);
1774 1779
1775 ASSERT_TRUE(pending_layer_->CanHaveTilings()); 1780 ASSERT_TRUE(pending_layer_->CanHaveTilings());
1776 1781
1777 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 1782 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
1778 1783
1779 pending_layer_->AddTiling(low_res_factor); 1784 pending_layer_->AddTiling(low_res_factor);
1780 pending_layer_->AddTiling(0.3f); 1785 pending_layer_->AddTiling(0.3f);
1781 pending_layer_->AddTiling(0.7f); 1786 pending_layer_->AddTiling(0.7f);
1782 PictureLayerTiling* high_res_tiling = pending_layer_->AddTiling(1.0f); 1787 PictureLayerTiling* high_res_tiling = pending_layer_->AddTiling(1.0f);
1783 pending_layer_->AddTiling(2.0f); 1788 pending_layer_->AddTiling(2.0f);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 high_res_tile_count += priority.resolution == HIGH_RESOLUTION; 1856 high_res_tile_count += priority.resolution == HIGH_RESOLUTION;
1852 } 1857 }
1853 1858
1854 EXPECT_EQ(0u, non_ideal_tile_count); 1859 EXPECT_EQ(0u, non_ideal_tile_count);
1855 EXPECT_EQ(1u, low_res_tile_count); 1860 EXPECT_EQ(1u, low_res_tile_count);
1856 EXPECT_EQ(0u, high_res_tile_count); 1861 EXPECT_EQ(0u, high_res_tile_count);
1857 } 1862 }
1858 1863
1859 } // namespace 1864 } // namespace
1860 } // namespace cc 1865 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698