Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); | 133 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); |
| 134 pending_layer->SetDrawsContent(true); | 134 pending_layer->SetDrawsContent(true); |
| 135 pending_layer->SetAnchorPoint(gfx::PointF()); | 135 pending_layer->SetAnchorPoint(gfx::PointF()); |
| 136 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); | 136 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
| 137 | 137 |
| 138 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 138 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 139 host_impl_.pending_tree()->LayerById(id_)); | 139 host_impl_.pending_tree()->LayerById(id_)); |
| 140 pending_layer_->DoPostCommitInitializationIfNeeded(); | 140 pending_layer_->DoPostCommitInitializationIfNeeded(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void SetupDrawPropertiesAndUpdateTilePriorities( | |
| 144 FakePictureLayerImpl* layer, | |
| 145 float ideal_contents_scale, | |
| 146 float device_scale_factor, | |
| 147 float page_scale_factor, | |
| 148 float maximum_animation_contents_scale, | |
| 149 bool animating_transform_to_screen) { | |
| 150 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; | |
| 151 layer->draw_properties().device_scale = device_scale_factor; | |
| 152 layer->draw_properties().page_scale = page_scale_factor; | |
| 153 layer->draw_properties().maximum_animation_contents_scale = | |
| 154 maximum_animation_contents_scale; | |
| 155 layer->draw_properties().screen_space_transform_is_animating = | |
| 156 animating_transform_to_screen; | |
| 157 layer->UpdateTilePriorities(); | |
| 158 } | |
| 143 static void VerifyAllTilesExistAndHavePile( | 159 static void VerifyAllTilesExistAndHavePile( |
| 144 const PictureLayerTiling* tiling, | 160 const PictureLayerTiling* tiling, |
| 145 PicturePileImpl* pile) { | 161 PicturePileImpl* pile) { |
| 146 for (PictureLayerTiling::CoverageIterator iter( | 162 for (PictureLayerTiling::CoverageIterator iter( |
| 147 tiling, tiling->contents_scale(), tiling->TilingRect()); | 163 tiling, tiling->contents_scale(), tiling->TilingRect()); |
| 148 iter; | 164 iter; |
| 149 ++iter) { | 165 ++iter) { |
| 150 EXPECT_TRUE(*iter); | 166 EXPECT_TRUE(*iter); |
| 151 EXPECT_EQ(pile, iter->picture_pile()); | 167 EXPECT_EQ(pile, iter->picture_pile()); |
| 152 } | 168 } |
| 153 } | 169 } |
| 154 | 170 |
| 155 void SetContentsScaleOnBothLayers(float contents_scale, | 171 void SetContentsScaleOnBothLayers(float contents_scale, |
| 156 float device_scale_factor, | 172 float device_scale_factor, |
| 157 float page_scale_factor, | 173 float page_scale_factor, |
| 158 float maximum_animation_contents_scale, | 174 float maximum_animation_contents_scale, |
| 159 bool animating_transform) { | 175 bool animating_transform) { |
| 160 float result_scale_x, result_scale_y; | 176 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 161 gfx::Size result_bounds; | 177 contents_scale, |
| 162 pending_layer_->CalculateContentsScale(contents_scale, | 178 device_scale_factor, |
| 163 device_scale_factor, | 179 page_scale_factor, |
| 164 page_scale_factor, | 180 maximum_animation_contents_scale, |
| 165 maximum_animation_contents_scale, | 181 animating_transform); |
| 166 animating_transform, | 182 |
| 167 &result_scale_x, | 183 SetupDrawPropertiesAndUpdateTilePriorities(active_layer_, |
| 168 &result_scale_y, | 184 contents_scale, |
| 169 &result_bounds); | 185 device_scale_factor, |
| 170 active_layer_->CalculateContentsScale(contents_scale, | 186 page_scale_factor, |
| 171 device_scale_factor, | 187 maximum_animation_contents_scale, |
| 172 page_scale_factor, | 188 animating_transform); |
| 173 maximum_animation_contents_scale, | |
| 174 animating_transform, | |
| 175 &result_scale_x, | |
| 176 &result_scale_y, | |
| 177 &result_bounds); | |
| 178 } | 189 } |
| 179 | 190 |
| 180 void ResetTilingsAndRasterScales() { | 191 void ResetTilingsAndRasterScales() { |
| 181 pending_layer_->ReleaseResources(); | 192 pending_layer_->ReleaseResources(); |
| 182 active_layer_->ReleaseResources(); | 193 active_layer_->ReleaseResources(); |
| 183 } | 194 } |
| 184 | 195 |
| 185 void AssertAllTilesRequired(PictureLayerTiling* tiling) { | 196 void AssertAllTilesRequired(PictureLayerTiling* tiling) { |
| 186 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 197 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
| 187 for (size_t i = 0; i < tiles.size(); ++i) | 198 for (size_t i = 0; i < tiles.size(); ++i) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 204 settings.default_tile_size.width() * 7 / 2, | 215 settings.default_tile_size.width() * 7 / 2, |
| 205 settings.default_tile_size.height() * 7 / 2); | 216 settings.default_tile_size.height() * 7 / 2); |
| 206 | 217 |
| 207 scoped_refptr<FakePicturePileImpl> pending_pile = | 218 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 208 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 219 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 209 scoped_refptr<FakePicturePileImpl> active_pile = | 220 scoped_refptr<FakePicturePileImpl> active_pile = |
| 210 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 221 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 211 | 222 |
| 212 SetupTrees(pending_pile, active_pile); | 223 SetupTrees(pending_pile, active_pile); |
| 213 | 224 |
| 214 float result_scale_x, result_scale_y; | 225 SetupDrawPropertiesAndUpdateTilePriorities( |
| 215 gfx::Size result_bounds; | 226 active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 216 active_layer_->CalculateContentsScale(1.f, | |
| 217 1.f, | |
| 218 1.f, | |
| 219 1.f, | |
| 220 false, | |
| 221 &result_scale_x, | |
| 222 &result_scale_y, | |
| 223 &result_bounds); | |
| 224 | 227 |
| 225 // Add 1x1 rects at the centers of each tile, then re-record pile contents | 228 // Add 1x1 rects at the centers of each tile, then re-record pile contents |
| 226 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 229 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 227 std::vector<Tile*> tiles = | 230 std::vector<Tile*> tiles = |
| 228 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 231 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 229 EXPECT_EQ(16u, tiles.size()); | 232 EXPECT_EQ(16u, tiles.size()); |
| 230 std::vector<SkRect> rects; | 233 std::vector<SkRect> rects; |
| 231 std::vector<Tile*>::const_iterator tile_iter; | 234 std::vector<Tile*>::const_iterator tile_iter; |
| 232 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | 235 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
| 233 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); | 236 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 scoped_refptr<FakePicturePileImpl> active_pile = | 311 scoped_refptr<FakePicturePileImpl> active_pile = |
| 309 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 312 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 310 | 313 |
| 311 SetupTrees(pending_pile, active_pile); | 314 SetupTrees(pending_pile, active_pile); |
| 312 | 315 |
| 313 std::vector<TileManager::PairedPictureLayer> paired_layers; | 316 std::vector<TileManager::PairedPictureLayer> paired_layers; |
| 314 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 317 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
| 315 EXPECT_EQ(0u, paired_layers.size()); | 318 EXPECT_EQ(0u, paired_layers.size()); |
| 316 | 319 |
| 317 // Update tile priorities will force the layer to register itself. | 320 // Update tile priorities will force the layer to register itself. |
| 318 float dummy_contents_scale_x; | 321 SetupDrawPropertiesAndUpdateTilePriorities( |
| 319 float dummy_contents_scale_y; | 322 active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 320 gfx::Size dummy_content_bounds; | 323 SetupDrawPropertiesAndUpdateTilePriorities( |
| 321 active_layer_->CalculateContentsScale(1.f, | 324 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 322 1.f, | |
| 323 1.f, | |
| 324 1.f, | |
| 325 false, | |
| 326 &dummy_contents_scale_x, | |
| 327 &dummy_contents_scale_y, | |
| 328 &dummy_content_bounds); | |
| 329 active_layer_->UpdateTilePriorities(); | |
| 330 host_impl_.pending_tree()->UpdateDrawProperties(); | |
| 331 pending_layer_->CalculateContentsScale(1.f, | |
| 332 1.f, | |
| 333 1.f, | |
| 334 1.f, | |
| 335 false, | |
| 336 &dummy_contents_scale_x, | |
| 337 &dummy_contents_scale_y, | |
| 338 &dummy_content_bounds); | |
| 339 pending_layer_->UpdateTilePriorities(); | |
| 340 | 325 |
| 341 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 326 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
| 342 EXPECT_EQ(1u, paired_layers.size()); | 327 EXPECT_EQ(1u, paired_layers.size()); |
| 343 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | 328 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); |
| 344 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | 329 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); |
| 345 | 330 |
| 346 // Destroy and recreate tile manager. | 331 // Destroy and recreate tile manager. |
| 347 host_impl_.DidLoseOutputSurface(); | 332 host_impl_.DidLoseOutputSurface(); |
| 348 scoped_ptr<TestWebGraphicsContext3D> context = | 333 scoped_ptr<TestWebGraphicsContext3D> context = |
| 349 TestWebGraphicsContext3D::Create(); | 334 TestWebGraphicsContext3D::Create(); |
| 350 host_impl_.InitializeRenderer( | 335 host_impl_.InitializeRenderer( |
| 351 FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); | 336 FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>()); |
| 352 | 337 |
| 353 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 338 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
| 354 EXPECT_EQ(0u, paired_layers.size()); | 339 EXPECT_EQ(0u, paired_layers.size()); |
| 355 | 340 |
| 356 active_layer_->CalculateContentsScale(1.f, | 341 SetupDrawPropertiesAndUpdateTilePriorities( |
| 357 1.f, | 342 active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 358 1.f, | |
| 359 1.f, | |
| 360 false, | |
| 361 &dummy_contents_scale_x, | |
| 362 &dummy_contents_scale_y, | |
| 363 &dummy_content_bounds); | |
| 364 active_layer_->UpdateTilePriorities(); | |
| 365 host_impl_.pending_tree()->UpdateDrawProperties(); | 343 host_impl_.pending_tree()->UpdateDrawProperties(); |
|
danakj
2014/05/21 15:01:00
this needed anymore?
| |
| 366 pending_layer_->CalculateContentsScale(1.f, | 344 SetupDrawPropertiesAndUpdateTilePriorities( |
| 367 1.f, | 345 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 368 1.f, | |
| 369 1.f, | |
| 370 false, | |
| 371 &dummy_contents_scale_x, | |
| 372 &dummy_contents_scale_y, | |
| 373 &dummy_content_bounds); | |
| 374 pending_layer_->UpdateTilePriorities(); | |
| 375 | 346 |
| 376 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); | 347 host_impl_.tile_manager()->GetPairedPictureLayers(&paired_layers); |
| 377 EXPECT_EQ(1u, paired_layers.size()); | 348 EXPECT_EQ(1u, paired_layers.size()); |
| 378 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); | 349 EXPECT_EQ(active_layer_, paired_layers[0].active_layer); |
| 379 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); | 350 EXPECT_EQ(pending_layer_, paired_layers[0].pending_layer); |
| 380 } | 351 } |
| 381 | 352 |
| 382 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { | 353 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
| 383 base::TimeTicks time_ticks; | 354 base::TimeTicks time_ticks; |
| 384 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | 355 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
| 385 | 356 |
| 386 gfx::Size tile_size(100, 100); | 357 gfx::Size tile_size(100, 100); |
| 387 gfx::Size layer_bounds(400, 400); | 358 gfx::Size layer_bounds(400, 400); |
| 388 | 359 |
| 389 scoped_refptr<FakePicturePileImpl> pending_pile = | 360 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 390 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 361 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 391 scoped_refptr<FakePicturePileImpl> active_pile = | 362 scoped_refptr<FakePicturePileImpl> active_pile = |
| 392 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 363 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 393 | 364 |
| 394 SetupTrees(pending_pile, active_pile); | 365 SetupTrees(pending_pile, active_pile); |
| 395 | 366 |
| 396 Region invalidation; | 367 Region invalidation; |
| 397 AddDefaultTilingsWithInvalidation(invalidation); | 368 AddDefaultTilingsWithInvalidation(invalidation); |
| 398 float dummy_contents_scale_x; | 369 SetupDrawPropertiesAndUpdateTilePriorities( |
| 399 float dummy_contents_scale_y; | 370 active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 400 gfx::Size dummy_content_bounds; | |
| 401 active_layer_->CalculateContentsScale(1.f, | |
| 402 1.f, | |
| 403 1.f, | |
| 404 1.f, | |
| 405 false, | |
| 406 &dummy_contents_scale_x, | |
| 407 &dummy_contents_scale_y, | |
| 408 &dummy_content_bounds); | |
| 409 | 371 |
| 410 // UpdateTilePriorities with valid viewport. Should update tile viewport. | 372 // UpdateTilePriorities with valid viewport. Should update tile viewport. |
| 411 bool valid_for_tile_management = true; | 373 bool valid_for_tile_management = true; |
| 412 gfx::Rect viewport = gfx::Rect(layer_bounds); | 374 gfx::Rect viewport = gfx::Rect(layer_bounds); |
| 413 gfx::Transform transform; | 375 gfx::Transform transform; |
| 414 host_impl_.SetExternalDrawConstraints( | 376 host_impl_.SetExternalDrawConstraints( |
| 415 transform, viewport, viewport, valid_for_tile_management); | 377 transform, viewport, viewport, valid_for_tile_management); |
| 416 active_layer_->draw_properties().visible_content_rect = viewport; | 378 active_layer_->draw_properties().visible_content_rect = viewport; |
| 417 active_layer_->draw_properties().screen_space_transform = transform; | 379 active_layer_->draw_properties().screen_space_transform = transform; |
| 418 active_layer_->UpdateTilePriorities(); | 380 active_layer_->UpdateTilePriorities(); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 | 617 |
| 656 TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { | 618 TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { |
| 657 gfx::Size tile_size(400, 400); | 619 gfx::Size tile_size(400, 400); |
| 658 gfx::Size layer_bounds(1300, 1900); | 620 gfx::Size layer_bounds(1300, 1900); |
| 659 | 621 |
| 660 scoped_refptr<FakePicturePileImpl> pending_pile = | 622 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 661 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 623 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 662 scoped_refptr<FakePicturePileImpl> active_pile = | 624 scoped_refptr<FakePicturePileImpl> active_pile = |
| 663 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 625 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 664 | 626 |
| 665 float result_scale_x, result_scale_y; | |
| 666 gfx::Size result_bounds; | |
| 667 | |
| 668 SetupTrees(pending_pile, active_pile); | 627 SetupTrees(pending_pile, active_pile); |
| 669 | 628 |
| 670 pending_layer_->CalculateContentsScale(1.f, | 629 SetupDrawPropertiesAndUpdateTilePriorities( |
| 671 1.f, | 630 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 672 1.f, | |
| 673 1.f, | |
| 674 false, | |
| 675 &result_scale_x, | |
| 676 &result_scale_y, | |
| 677 &result_bounds); | |
| 678 | 631 |
| 679 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 632 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 680 } | 633 } |
| 681 | 634 |
| 682 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { | 635 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
| 683 gfx::Size tile_size(400, 400); | 636 gfx::Size tile_size(400, 400); |
| 684 gfx::Size layer_bounds(1300, 1900); | 637 gfx::Size layer_bounds(1300, 1900); |
| 685 | 638 |
| 686 scoped_refptr<FakePicturePileImpl> pending_pile = | 639 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 687 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 640 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 688 scoped_refptr<FakePicturePileImpl> active_pile = | 641 scoped_refptr<FakePicturePileImpl> active_pile = |
| 689 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 642 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 690 | 643 |
| 691 float result_scale_x, result_scale_y; | |
| 692 gfx::Size result_bounds; | |
| 693 | |
| 694 SetupTrees(pending_pile, active_pile); | 644 SetupTrees(pending_pile, active_pile); |
| 695 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 645 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 696 | 646 |
| 697 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 647 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 698 EXPECT_LT(low_res_factor, 1.f); | 648 EXPECT_LT(low_res_factor, 1.f); |
| 699 | 649 |
| 700 pending_layer_->CalculateContentsScale(6.f, // ideal contents scale | 650 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 701 3.f, // device scale | 651 6.f, // ideal contents scale |
| 702 2.f, // page scale | 652 3.f, // device scale |
| 703 1.f, // maximum animation scale | 653 2.f, // page scale |
| 704 false, | 654 1.f, // maximum animation scale |
| 705 &result_scale_x, | 655 false); |
| 706 &result_scale_y, | |
| 707 &result_bounds); | |
| 708 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 656 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 709 EXPECT_FLOAT_EQ(6.f, | 657 EXPECT_FLOAT_EQ(6.f, |
| 710 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 658 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 711 EXPECT_FLOAT_EQ(6.f * low_res_factor, | 659 EXPECT_FLOAT_EQ(6.f * low_res_factor, |
| 712 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 660 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 713 | 661 |
| 714 // If we change the page scale factor, then we should get new tilings. | 662 // If we change the page scale factor, then we should get new tilings. |
| 715 pending_layer_->CalculateContentsScale(6.6f, // ideal contents scale | 663 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 716 3.f, // device scale | 664 6.6f, // ideal contents scale |
| 717 2.2f, // page scale | 665 3.f, // device scale |
| 718 1.f, // maximum animation scale | 666 2.2f, // page scale |
| 719 false, | 667 1.f, // maximum animation scale |
| 720 &result_scale_x, | 668 false); |
| 721 &result_scale_y, | |
| 722 &result_bounds); | |
| 723 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); | 669 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); |
| 724 EXPECT_FLOAT_EQ(6.6f, | 670 EXPECT_FLOAT_EQ(6.6f, |
| 725 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 671 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 726 EXPECT_FLOAT_EQ(6.6f * low_res_factor, | 672 EXPECT_FLOAT_EQ(6.6f * low_res_factor, |
| 727 pending_layer_->tilings()->tiling_at(2)->contents_scale()); | 673 pending_layer_->tilings()->tiling_at(2)->contents_scale()); |
| 728 | 674 |
| 729 // If we change the device scale factor, then we should get new tilings. | 675 // If we change the device scale factor, then we should get new tilings. |
| 730 pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale | 676 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 731 3.3f, // device scale | 677 7.26f, // ideal contents scale |
| 732 2.2f, // page scale | 678 3.3f, // device scale |
| 733 1.f, // maximum animation scale | 679 2.2f, // page scale |
| 734 false, | 680 1.f, // maximum animation scale |
| 735 &result_scale_x, | 681 false); |
| 736 &result_scale_y, | |
| 737 &result_bounds); | |
| 738 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 682 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
| 739 EXPECT_FLOAT_EQ(7.26f, | 683 EXPECT_FLOAT_EQ(7.26f, |
| 740 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 684 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 741 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 685 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
| 742 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | 686 pending_layer_->tilings()->tiling_at(3)->contents_scale()); |
| 743 | 687 |
| 744 // If we change the device scale factor, but end up at the same total scale | 688 // If we change the device scale factor, but end up at the same total scale |
| 745 // factor somehow, then we don't get new tilings. | 689 // factor somehow, then we don't get new tilings. |
| 746 pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale | 690 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 747 2.2f, // device scale | 691 7.26f, // ideal contents scale |
| 748 3.3f, // page scale | 692 2.2f, // device scale |
| 749 1.f, // maximum animation scale | 693 3.3f, // page scale |
| 750 false, | 694 1.f, // maximum animation scale |
| 751 &result_scale_x, | 695 false); |
| 752 &result_scale_y, | |
| 753 &result_bounds); | |
| 754 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 696 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
| 755 EXPECT_FLOAT_EQ(7.26f, | 697 EXPECT_FLOAT_EQ(7.26f, |
| 756 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 698 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 757 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 699 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
| 758 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | 700 pending_layer_->tilings()->tiling_at(3)->contents_scale()); |
| 759 } | 701 } |
| 760 | 702 |
| 761 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { | 703 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
| 762 // This test makes sure that if a layer can have tilings, then a commit makes | 704 // This test makes sure that if a layer can have tilings, then a commit makes |
| 763 // it not able to have tilings (empty size), and then a future commit that | 705 // it not able to have tilings (empty size), and then a future commit that |
| 764 // makes it valid again should be able to create tilings. | 706 // makes it valid again should be able to create tilings. |
| 765 gfx::Size tile_size(400, 400); | 707 gfx::Size tile_size(400, 400); |
| 766 gfx::Size layer_bounds(1300, 1900); | 708 gfx::Size layer_bounds(1300, 1900); |
| 767 | 709 |
| 768 scoped_refptr<FakePicturePileImpl> empty_pile = | 710 scoped_refptr<FakePicturePileImpl> empty_pile = |
| 769 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 711 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 770 scoped_refptr<FakePicturePileImpl> valid_pile = | 712 scoped_refptr<FakePicturePileImpl> valid_pile = |
| 771 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 713 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 772 | 714 |
| 773 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 715 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 774 EXPECT_LT(low_res_factor, 1.f); | 716 EXPECT_LT(low_res_factor, 1.f); |
| 775 | 717 |
| 776 float high_res_scale = 1.3f; | 718 float high_res_scale = 1.3f; |
| 777 float low_res_scale = high_res_scale * low_res_factor; | 719 float low_res_scale = high_res_scale * low_res_factor; |
| 778 float device_scale = 1.7f; | 720 float device_scale = 1.7f; |
| 779 float page_scale = 3.2f; | 721 float page_scale = 3.2f; |
| 780 float maximum_animation_scale = 1.f; | 722 float maximum_animation_scale = 1.f; |
| 781 float result_scale_x, result_scale_y; | |
| 782 gfx::Size result_bounds; | |
| 783 | 723 |
| 784 SetupPendingTree(valid_pile); | 724 SetupPendingTree(valid_pile); |
| 785 pending_layer_->CalculateContentsScale(high_res_scale, | 725 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 786 device_scale, | 726 high_res_scale, |
| 787 page_scale, | 727 device_scale, |
| 788 maximum_animation_scale, | 728 page_scale, |
| 789 false, | 729 maximum_animation_scale, |
| 790 &result_scale_x, | 730 false); |
| 791 &result_scale_y, | |
| 792 &result_bounds); | |
| 793 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 731 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 794 EXPECT_FLOAT_EQ(high_res_scale, | 732 EXPECT_FLOAT_EQ(high_res_scale, |
| 795 pending_layer_->HighResTiling()->contents_scale()); | 733 pending_layer_->HighResTiling()->contents_scale()); |
| 796 EXPECT_FLOAT_EQ(low_res_scale, | 734 EXPECT_FLOAT_EQ(low_res_scale, |
| 797 pending_layer_->LowResTiling()->contents_scale()); | 735 pending_layer_->LowResTiling()->contents_scale()); |
| 798 | 736 |
| 799 ActivateTree(); | 737 ActivateTree(); |
| 800 SetupPendingTree(empty_pile); | 738 SetupPendingTree(empty_pile); |
| 801 pending_layer_->CalculateContentsScale(high_res_scale, | 739 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 802 device_scale, | 740 high_res_scale, |
| 803 page_scale, | 741 device_scale, |
| 804 maximum_animation_scale, | 742 page_scale, |
| 805 false, | 743 maximum_animation_scale, |
| 806 &result_scale_x, | 744 false); |
| 807 &result_scale_y, | |
| 808 &result_bounds); | |
| 809 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 745 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 810 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 746 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 811 | 747 |
| 812 ActivateTree(); | 748 ActivateTree(); |
| 813 active_layer_->CalculateContentsScale(high_res_scale, | 749 SetupDrawPropertiesAndUpdateTilePriorities(active_layer_, |
| 814 device_scale, | 750 high_res_scale, |
| 815 page_scale, | 751 device_scale, |
| 816 maximum_animation_scale, | 752 page_scale, |
| 817 false, | 753 maximum_animation_scale, |
| 818 &result_scale_x, | 754 false); |
| 819 &result_scale_y, | |
| 820 &result_bounds); | |
| 821 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 755 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 822 | 756 |
| 823 SetupPendingTree(valid_pile); | 757 SetupPendingTree(valid_pile); |
| 824 pending_layer_->CalculateContentsScale(high_res_scale, | 758 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 825 device_scale, | 759 high_res_scale, |
| 826 page_scale, | 760 device_scale, |
| 827 maximum_animation_scale, | 761 page_scale, |
| 828 false, | 762 maximum_animation_scale, |
| 829 &result_scale_x, | 763 false); |
| 830 &result_scale_y, | |
| 831 &result_bounds); | |
| 832 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 764 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 833 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 765 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 834 EXPECT_FLOAT_EQ(high_res_scale, | 766 EXPECT_FLOAT_EQ(high_res_scale, |
| 835 pending_layer_->HighResTiling()->contents_scale()); | 767 pending_layer_->HighResTiling()->contents_scale()); |
| 836 EXPECT_FLOAT_EQ(low_res_scale, | 768 EXPECT_FLOAT_EQ(low_res_scale, |
| 837 pending_layer_->LowResTiling()->contents_scale()); | 769 pending_layer_->LowResTiling()->contents_scale()); |
| 838 } | 770 } |
| 839 | 771 |
| 840 TEST_F(PictureLayerImplTest, ZoomOutCrash) { | 772 TEST_F(PictureLayerImplTest, ZoomOutCrash) { |
| 841 gfx::Size tile_size(400, 400); | 773 gfx::Size tile_size(400, 400); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 955 | 887 |
| 956 TEST_F(PictureLayerImplTest, CleanUpTilings) { | 888 TEST_F(PictureLayerImplTest, CleanUpTilings) { |
| 957 gfx::Size tile_size(400, 400); | 889 gfx::Size tile_size(400, 400); |
| 958 gfx::Size layer_bounds(1300, 1900); | 890 gfx::Size layer_bounds(1300, 1900); |
| 959 | 891 |
| 960 scoped_refptr<FakePicturePileImpl> pending_pile = | 892 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 961 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 893 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 962 scoped_refptr<FakePicturePileImpl> active_pile = | 894 scoped_refptr<FakePicturePileImpl> active_pile = |
| 963 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 895 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 964 | 896 |
| 965 float result_scale_x, result_scale_y; | |
| 966 gfx::Size result_bounds; | |
| 967 std::vector<PictureLayerTiling*> used_tilings; | 897 std::vector<PictureLayerTiling*> used_tilings; |
| 968 | 898 |
| 969 SetupTrees(pending_pile, active_pile); | 899 SetupTrees(pending_pile, active_pile); |
| 970 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 900 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 971 | 901 |
| 972 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 902 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 973 EXPECT_LT(low_res_factor, 1.f); | 903 EXPECT_LT(low_res_factor, 1.f); |
| 974 | 904 |
| 975 float device_scale = 1.7f; | 905 float device_scale = 1.7f; |
| 976 float page_scale = 3.2f; | 906 float page_scale = 3.2f; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1030 // Now move the ideal scale to 1.0. Our target stays 1.2. | 960 // Now move the ideal scale to 1.0. Our target stays 1.2. |
| 1031 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); | 961 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); |
| 1032 | 962 |
| 1033 // All the tilings are between are target and the ideal, so they are not | 963 // All the tilings are between are target and the ideal, so they are not |
| 1034 // removed. | 964 // removed. |
| 1035 used_tilings.clear(); | 965 used_tilings.clear(); |
| 1036 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 966 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1037 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 967 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1038 | 968 |
| 1039 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 969 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
| 1040 active_layer_->CalculateContentsScale(1.1f, | 970 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1041 device_scale, | 971 active_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
| 1042 page_scale, | |
| 1043 1.f, | |
| 1044 false, | |
| 1045 &result_scale_x, | |
| 1046 &result_scale_y, | |
| 1047 &result_bounds); | |
| 1048 | 972 |
| 1049 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 973 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
| 1050 // in the range [1.0,1.2] and are kept. | 974 // in the range [1.0,1.2] and are kept. |
| 1051 used_tilings.clear(); | 975 used_tilings.clear(); |
| 1052 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 976 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1053 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 977 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1054 | 978 |
| 1055 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 979 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
| 1056 // 1.2 still. | 980 // 1.2 still. |
| 1057 pending_layer_->CalculateContentsScale(1.1f, | 981 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1058 device_scale, | 982 pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
| 1059 page_scale, | |
| 1060 1.f, | |
| 1061 false, | |
| 1062 &result_scale_x, | |
| 1063 &result_scale_y, | |
| 1064 &result_bounds); | |
| 1065 | 983 |
| 1066 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 984 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
| 1067 // target raster scale. But it is in our used tilings set, so nothing is | 985 // target raster scale. But it is in our used tilings set, so nothing is |
| 1068 // deleted. | 986 // deleted. |
| 1069 used_tilings.clear(); | 987 used_tilings.clear(); |
| 1070 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 988 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
| 1071 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 989 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 1072 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 990 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 1073 | 991 |
| 1074 // If we remove it from our used tilings set, it is outside the range to keep | 992 // If we remove it from our used tilings set, it is outside the range to keep |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1208 | 1126 |
| 1209 TEST_F(PictureLayerImplTest, ReleaseResources) { | 1127 TEST_F(PictureLayerImplTest, ReleaseResources) { |
| 1210 gfx::Size tile_size(400, 400); | 1128 gfx::Size tile_size(400, 400); |
| 1211 gfx::Size layer_bounds(1300, 1900); | 1129 gfx::Size layer_bounds(1300, 1900); |
| 1212 | 1130 |
| 1213 scoped_refptr<FakePicturePileImpl> pending_pile = | 1131 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1214 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1132 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1215 scoped_refptr<FakePicturePileImpl> active_pile = | 1133 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1216 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1134 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1217 | 1135 |
| 1218 float result_scale_x, result_scale_y; | |
| 1219 gfx::Size result_bounds; | |
| 1220 | |
| 1221 SetupTrees(pending_pile, active_pile); | 1136 SetupTrees(pending_pile, active_pile); |
| 1222 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1137 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1223 | 1138 |
| 1224 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale | 1139 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 1225 2.7f, // device scale | 1140 1.3f, // ideal contents scale |
| 1226 3.2f, // page scale | 1141 2.7f, // device scale |
| 1227 1.f, // maximum animation scale | 1142 3.2f, // page scale |
| 1228 false, | 1143 1.f, // maximum animation scale |
| 1229 &result_scale_x, | 1144 false); |
| 1230 &result_scale_y, | |
| 1231 &result_bounds); | |
| 1232 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1145 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1233 | 1146 |
| 1234 // All tilings should be removed when losing output surface. | 1147 // All tilings should be removed when losing output surface. |
| 1235 active_layer_->ReleaseResources(); | 1148 active_layer_->ReleaseResources(); |
| 1236 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 1149 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 1237 pending_layer_->ReleaseResources(); | 1150 pending_layer_->ReleaseResources(); |
| 1238 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1151 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1239 | 1152 |
| 1240 // This should create new tilings. | 1153 // This should create new tilings. |
| 1241 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale | 1154 SetupDrawPropertiesAndUpdateTilePriorities(pending_layer_, |
| 1242 2.7f, // device scale | 1155 1.3f, // ideal contents scale |
| 1243 3.2f, // page scale | 1156 2.7f, // device scale |
| 1244 1.f, // maximum animation scale | 1157 3.2f, // page scale |
| 1245 false, | 1158 1.f, // maximum animation scale |
| 1246 &result_scale_x, | 1159 false); |
| 1247 &result_scale_y, | |
| 1248 &result_bounds); | |
| 1249 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1160 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1250 } | 1161 } |
| 1251 | 1162 |
| 1252 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { | 1163 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { |
| 1253 // The default max tile size is larger than 400x400. | 1164 // The default max tile size is larger than 400x400. |
| 1254 gfx::Size tile_size(400, 400); | 1165 gfx::Size tile_size(400, 400); |
| 1255 gfx::Size layer_bounds(5000, 5000); | 1166 gfx::Size layer_bounds(5000, 5000); |
| 1256 | 1167 |
| 1257 scoped_refptr<FakePicturePileImpl> pending_pile = | 1168 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1258 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1169 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1259 scoped_refptr<FakePicturePileImpl> active_pile = | 1170 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1260 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1171 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1261 | 1172 |
| 1262 float result_scale_x, result_scale_y; | |
| 1263 gfx::Size result_bounds; | |
| 1264 | |
| 1265 SetupTrees(pending_pile, active_pile); | 1173 SetupTrees(pending_pile, active_pile); |
| 1266 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1174 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1267 | 1175 |
| 1268 pending_layer_->CalculateContentsScale(1.f, | 1176 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1269 1.f, | 1177 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1270 1.f, | |
| 1271 1.f, | |
| 1272 false, | |
| 1273 &result_scale_x, | |
| 1274 &result_scale_y, | |
| 1275 &result_bounds); | |
| 1276 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1178 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1277 | 1179 |
| 1278 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1180 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1279 | 1181 |
| 1280 // The default value. | 1182 // The default value. |
| 1281 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1183 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1282 host_impl_.settings().default_tile_size.ToString()); | 1184 host_impl_.settings().default_tile_size.ToString()); |
| 1283 | 1185 |
| 1284 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1186 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1285 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1187 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1286 tile->content_rect().size().ToString()); | 1188 tile->content_rect().size().ToString()); |
| 1287 | 1189 |
| 1288 pending_layer_->ReleaseResources(); | 1190 pending_layer_->ReleaseResources(); |
| 1289 | 1191 |
| 1290 // Change the max texture size on the output surface context. | 1192 // Change the max texture size on the output surface context. |
| 1291 scoped_ptr<TestWebGraphicsContext3D> context = | 1193 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1292 TestWebGraphicsContext3D::Create(); | 1194 TestWebGraphicsContext3D::Create(); |
| 1293 context->set_max_texture_size(140); | 1195 context->set_max_texture_size(140); |
| 1294 host_impl_.DidLoseOutputSurface(); | 1196 host_impl_.DidLoseOutputSurface(); |
| 1295 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1197 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
| 1296 context.Pass()).PassAs<OutputSurface>()); | 1198 context.Pass()).PassAs<OutputSurface>()); |
| 1297 | 1199 |
| 1298 pending_layer_->CalculateContentsScale(1.f, | 1200 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1299 1.f, | 1201 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1300 1.f, | |
| 1301 1.f, | |
| 1302 false, | |
| 1303 &result_scale_x, | |
| 1304 &result_scale_y, | |
| 1305 &result_bounds); | |
| 1306 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1202 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1307 | 1203 |
| 1308 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1204 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1309 | 1205 |
| 1310 // Verify the tiles are not larger than the context's max texture size. | 1206 // Verify the tiles are not larger than the context's max texture size. |
| 1311 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1207 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1312 EXPECT_GE(140, tile->content_rect().width()); | 1208 EXPECT_GE(140, tile->content_rect().width()); |
| 1313 EXPECT_GE(140, tile->content_rect().height()); | 1209 EXPECT_GE(140, tile->content_rect().height()); |
| 1314 } | 1210 } |
| 1315 | 1211 |
| 1316 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { | 1212 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { |
| 1317 // The default max tile size is larger than 400x400. | 1213 // The default max tile size is larger than 400x400. |
| 1318 gfx::Size tile_size(400, 400); | 1214 gfx::Size tile_size(400, 400); |
| 1319 gfx::Size layer_bounds(500, 500); | 1215 gfx::Size layer_bounds(500, 500); |
| 1320 | 1216 |
| 1321 scoped_refptr<FakePicturePileImpl> pending_pile = | 1217 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1322 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1218 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1323 scoped_refptr<FakePicturePileImpl> active_pile = | 1219 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1324 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1220 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1325 | 1221 |
| 1326 float result_scale_x, result_scale_y; | |
| 1327 gfx::Size result_bounds; | |
| 1328 | |
| 1329 SetupTrees(pending_pile, active_pile); | 1222 SetupTrees(pending_pile, active_pile); |
| 1330 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1223 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1331 | 1224 |
| 1332 pending_layer_->CalculateContentsScale(1.f, | 1225 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1333 1.f, | 1226 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1334 1.f, | |
| 1335 1.f, | |
| 1336 false, | |
| 1337 &result_scale_x, | |
| 1338 &result_scale_y, | |
| 1339 &result_bounds); | |
| 1340 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1227 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
| 1341 | 1228 |
| 1342 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1229 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1343 | 1230 |
| 1344 // The default value. The layer is smaller than this. | 1231 // The default value. The layer is smaller than this. |
| 1345 EXPECT_EQ(gfx::Size(512, 512).ToString(), | 1232 EXPECT_EQ(gfx::Size(512, 512).ToString(), |
| 1346 host_impl_.settings().max_untiled_layer_size.ToString()); | 1233 host_impl_.settings().max_untiled_layer_size.ToString()); |
| 1347 | 1234 |
| 1348 // There should be a single tile since the layer is small. | 1235 // There should be a single tile since the layer is small. |
| 1349 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1236 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
| 1350 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1237 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1351 | 1238 |
| 1352 pending_layer_->ReleaseResources(); | 1239 pending_layer_->ReleaseResources(); |
| 1353 | 1240 |
| 1354 // Change the max texture size on the output surface context. | 1241 // Change the max texture size on the output surface context. |
| 1355 scoped_ptr<TestWebGraphicsContext3D> context = | 1242 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1356 TestWebGraphicsContext3D::Create(); | 1243 TestWebGraphicsContext3D::Create(); |
| 1357 context->set_max_texture_size(140); | 1244 context->set_max_texture_size(140); |
| 1358 host_impl_.DidLoseOutputSurface(); | 1245 host_impl_.DidLoseOutputSurface(); |
| 1359 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1246 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
| 1360 context.Pass()).PassAs<OutputSurface>()); | 1247 context.Pass()).PassAs<OutputSurface>()); |
| 1361 | 1248 |
| 1362 pending_layer_->CalculateContentsScale(1.f, | 1249 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1363 1.f, | 1250 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1364 1.f, | |
| 1365 1.f, | |
| 1366 false, | |
| 1367 &result_scale_x, | |
| 1368 &result_scale_y, | |
| 1369 &result_bounds); | |
| 1370 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | 1251 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
| 1371 | 1252 |
| 1372 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1253 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1373 | 1254 |
| 1374 // There should be more than one tile since the max texture size won't cover | 1255 // There should be more than one tile since the max texture size won't cover |
| 1375 // the layer. | 1256 // the layer. |
| 1376 high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1257 high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
| 1377 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); | 1258 EXPECT_LT(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1378 | 1259 |
| 1379 // Verify the tiles are not larger than the context's max texture size. | 1260 // Verify the tiles are not larger than the context's max texture size. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1437 gfx::Size tile_size(100, 100); | 1318 gfx::Size tile_size(100, 100); |
| 1438 gfx::Size layer_bounds(200, 200); | 1319 gfx::Size layer_bounds(200, 200); |
| 1439 | 1320 |
| 1440 scoped_refptr<FakePicturePileImpl> pending_pile = | 1321 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1441 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1322 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1442 SetupPendingTree(pending_pile); | 1323 SetupPendingTree(pending_pile); |
| 1443 | 1324 |
| 1444 pending_layer_->set_fixed_tile_size(tile_size); | 1325 pending_layer_->set_fixed_tile_size(tile_size); |
| 1445 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 1326 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
| 1446 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); | 1327 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); |
| 1328 pending_layer_->SetContentBounds(layer_bounds); | |
|
danakj
2014/05/21 15:01:00
FakePictureLayerImpl constructor sets its bounds.
| |
| 1447 host_impl_.pending_tree()->UpdateDrawProperties(); | 1329 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 1448 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); | 1330 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); |
| 1449 | 1331 |
| 1450 pending_layer_->draw_properties().visible_content_rect = | 1332 pending_layer_->draw_properties().visible_content_rect = |
| 1451 gfx::Rect(0, 0, 100, 200); | 1333 gfx::Rect(0, 0, 100, 200); |
| 1452 | 1334 |
| 1453 // Fake set priorities. | 1335 // Fake set priorities. |
| 1454 for (PictureLayerTiling::CoverageIterator iter( | 1336 for (PictureLayerTiling::CoverageIterator iter( |
| 1455 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); | 1337 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); |
| 1456 iter; | 1338 iter; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1497 } | 1379 } |
| 1498 | 1380 |
| 1499 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { | 1381 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { |
| 1500 gfx::Size layer_bounds(400, 400); | 1382 gfx::Size layer_bounds(400, 400); |
| 1501 gfx::Size tile_size(100, 100); | 1383 gfx::Size tile_size(100, 100); |
| 1502 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1384 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
| 1503 | 1385 |
| 1504 // No tiles shared. | 1386 // No tiles shared. |
| 1505 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); | 1387 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); |
| 1506 | 1388 |
| 1389 pending_layer_->SetContentBounds(layer_bounds); | |
| 1390 | |
| 1507 CreateHighLowResAndSetAllTilesVisible(); | 1391 CreateHighLowResAndSetAllTilesVisible(); |
| 1508 | 1392 |
| 1509 active_layer_->SetAllTilesReady(); | 1393 active_layer_->SetAllTilesReady(); |
| 1510 | 1394 |
| 1511 // No shared tiles and all active tiles ready, so pending can only | 1395 // No shared tiles and all active tiles ready, so pending can only |
| 1512 // activate with all high res tiles. | 1396 // activate with all high res tiles. |
| 1513 pending_layer_->MarkVisibleResourcesAsRequired(); | 1397 pending_layer_->MarkVisibleResourcesAsRequired(); |
| 1514 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1398 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| 1515 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1399 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| 1516 } | 1400 } |
| 1517 | 1401 |
| 1518 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { | 1402 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
| 1519 gfx::Size layer_bounds(400, 400); | 1403 gfx::Size layer_bounds(400, 400); |
| 1520 gfx::Size tile_size(100, 100); | 1404 gfx::Size tile_size(100, 100); |
| 1521 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1405 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
| 1522 | 1406 |
| 1407 pending_layer_->SetContentBounds(layer_bounds); | |
| 1523 // All tiles shared (no invalidation). | 1408 // All tiles shared (no invalidation). |
| 1524 CreateHighLowResAndSetAllTilesVisible(); | 1409 CreateHighLowResAndSetAllTilesVisible(); |
| 1525 | 1410 |
| 1526 // Verify active tree not ready. | 1411 // Verify active tree not ready. |
| 1527 Tile* some_active_tile = | 1412 Tile* some_active_tile = |
| 1528 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1413 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
| 1529 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1414 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
| 1530 | 1415 |
| 1531 // When high res are required, even if the active tree is not ready, | 1416 // When high res are required, even if the active tree is not ready, |
| 1532 // the high res tiles must be ready. | 1417 // the high res tiles must be ready. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1587 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { | 1472 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { |
| 1588 gfx::Size layer_bounds(400, 400); | 1473 gfx::Size layer_bounds(400, 400); |
| 1589 gfx::Size tile_size(100, 100); | 1474 gfx::Size tile_size(100, 100); |
| 1590 scoped_refptr<FakePicturePileImpl> pending_pile = | 1475 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1591 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1476 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1592 scoped_refptr<FakePicturePileImpl> active_pile = | 1477 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1593 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 1478 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 1594 SetupTrees(pending_pile, active_pile); | 1479 SetupTrees(pending_pile, active_pile); |
| 1595 pending_layer_->set_fixed_tile_size(tile_size); | 1480 pending_layer_->set_fixed_tile_size(tile_size); |
| 1596 active_layer_->set_fixed_tile_size(tile_size); | 1481 active_layer_->set_fixed_tile_size(tile_size); |
| 1597 | 1482 pending_layer_->SetContentBounds(layer_bounds); |
| 1598 CreateHighLowResAndSetAllTilesVisible(); | 1483 CreateHighLowResAndSetAllTilesVisible(); |
| 1599 | 1484 |
| 1600 // Active layer can't have tiles. | 1485 // Active layer can't have tiles. |
| 1601 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 1486 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
| 1602 | 1487 |
| 1603 // All high res tiles required. This should be considered identical | 1488 // All high res tiles required. This should be considered identical |
| 1604 // to the case where there is no active layer, to avoid flashing content. | 1489 // to the case where there is no active layer, to avoid flashing content. |
| 1605 // This can happen if a layer exists for a while and switches from | 1490 // This can happen if a layer exists for a while and switches from |
| 1606 // not being able to have content to having content. | 1491 // not being able to have content to having content. |
| 1607 pending_layer_->MarkVisibleResourcesAsRequired(); | 1492 pending_layer_->MarkVisibleResourcesAsRequired(); |
| 1608 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1493 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| 1609 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1494 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| 1610 } | 1495 } |
| 1611 | 1496 |
| 1612 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { | 1497 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { |
| 1613 gfx::Size layer_bounds(200, 200); | 1498 gfx::Size layer_bounds(200, 200); |
| 1614 gfx::Size tile_size(100, 100); | 1499 gfx::Size tile_size(100, 100); |
| 1615 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | 1500 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); |
| 1616 | 1501 |
| 1617 gfx::Size pending_layer_bounds(400, 400); | 1502 gfx::Size pending_layer_bounds(400, 400); |
| 1618 pending_layer_->SetBounds(pending_layer_bounds); | 1503 pending_layer_->SetBounds(pending_layer_bounds); |
| 1504 pending_layer_->SetContentBounds(pending_layer_bounds); | |
| 1619 | 1505 |
| 1620 CreateHighLowResAndSetAllTilesVisible(); | 1506 CreateHighLowResAndSetAllTilesVisible(); |
| 1621 | 1507 |
| 1622 active_layer_->SetAllTilesReady(); | 1508 active_layer_->SetAllTilesReady(); |
| 1623 | 1509 |
| 1624 // Since the active layer has different bounds, the pending layer needs all | 1510 // Since the active layer has different bounds, the pending layer needs all |
| 1625 // high res tiles in order to activate. | 1511 // high res tiles in order to activate. |
| 1626 pending_layer_->MarkVisibleResourcesAsRequired(); | 1512 pending_layer_->MarkVisibleResourcesAsRequired(); |
| 1627 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1513 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
| 1628 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1514 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1778 pending_layer_->tilings()->TilingAtScale(1.0f)->resolution()); | 1664 pending_layer_->tilings()->TilingAtScale(1.0f)->resolution()); |
| 1779 ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.5f)); | 1665 ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.5f)); |
| 1780 EXPECT_EQ(NON_IDEAL_RESOLUTION, | 1666 EXPECT_EQ(NON_IDEAL_RESOLUTION, |
| 1781 pending_layer_->tilings()->TilingAtScale(1.5f)->resolution()); | 1667 pending_layer_->tilings()->TilingAtScale(1.5f)->resolution()); |
| 1782 } | 1668 } |
| 1783 | 1669 |
| 1784 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { | 1670 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { |
| 1785 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 1671 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
| 1786 gfx::Size layer_bounds(default_tile_size.width() * 4, | 1672 gfx::Size layer_bounds(default_tile_size.width() * 4, |
| 1787 default_tile_size.height() * 4); | 1673 default_tile_size.height() * 4); |
| 1788 float result_scale_x, result_scale_y; | |
| 1789 gfx::Size result_bounds; | |
| 1790 | 1674 |
| 1791 SetupDefaultTrees(layer_bounds); | 1675 SetupDefaultTrees(layer_bounds); |
| 1792 EXPECT_FALSE(pending_layer_->use_gpu_rasterization()); | 1676 EXPECT_FALSE(pending_layer_->use_gpu_rasterization()); |
| 1793 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1677 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 1794 pending_layer_->CalculateContentsScale(1.f, | 1678 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1795 1.f, | 1679 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1796 1.f, | |
| 1797 1.f, | |
| 1798 false, | |
| 1799 &result_scale_x, | |
| 1800 &result_scale_y, | |
| 1801 &result_bounds); | |
| 1802 // Should have a low-res and a high-res tiling. | 1680 // Should have a low-res and a high-res tiling. |
| 1803 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1681 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
| 1804 | 1682 |
| 1805 ResetTilingsAndRasterScales(); | 1683 ResetTilingsAndRasterScales(); |
| 1806 | 1684 |
| 1807 host_impl_.pending_tree()->SetUseGpuRasterization(true); | 1685 host_impl_.pending_tree()->SetUseGpuRasterization(true); |
| 1808 EXPECT_TRUE(pending_layer_->use_gpu_rasterization()); | 1686 EXPECT_TRUE(pending_layer_->use_gpu_rasterization()); |
| 1809 pending_layer_->CalculateContentsScale(1.f, | 1687 SetupDrawPropertiesAndUpdateTilePriorities( |
| 1810 1.f, | 1688 pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 1811 1.f, | |
| 1812 1.f, | |
| 1813 false, | |
| 1814 &result_scale_x, | |
| 1815 &result_scale_y, | |
| 1816 &result_bounds); | |
| 1817 // Should only have the high-res tiling. | 1689 // Should only have the high-res tiling. |
| 1818 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1690 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 1819 } | 1691 } |
| 1820 | 1692 |
| 1821 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { | 1693 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { |
| 1822 // Set up layers with tilings. | 1694 // Set up layers with tilings. |
| 1823 SetupDefaultTrees(gfx::Size(10, 10)); | 1695 SetupDefaultTrees(gfx::Size(10, 10)); |
| 1824 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); | 1696 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); |
| 1825 pending_layer_->PushPropertiesTo(active_layer_); | 1697 pending_layer_->PushPropertiesTo(active_layer_); |
| 1826 EXPECT_TRUE(pending_layer_->DrawsContent()); | 1698 EXPECT_TRUE(pending_layer_->DrawsContent()); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2037 | 1909 |
| 2038 // No tilings. | 1910 // No tilings. |
| 2039 it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 1911 it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
| 2040 EXPECT_FALSE(it); | 1912 EXPECT_FALSE(it); |
| 2041 | 1913 |
| 2042 pending_layer_->AddTiling(low_res_factor); | 1914 pending_layer_->AddTiling(low_res_factor); |
| 2043 pending_layer_->AddTiling(0.3f); | 1915 pending_layer_->AddTiling(0.3f); |
| 2044 pending_layer_->AddTiling(0.7f); | 1916 pending_layer_->AddTiling(0.7f); |
| 2045 PictureLayerTiling* high_res_tiling = pending_layer_->AddTiling(1.0f); | 1917 PictureLayerTiling* high_res_tiling = pending_layer_->AddTiling(1.0f); |
| 2046 pending_layer_->AddTiling(2.0f); | 1918 pending_layer_->AddTiling(2.0f); |
| 1919 pending_layer_->SetContentBounds(layer_bounds); | |
| 2047 | 1920 |
| 2048 host_impl_.SetViewportSize(gfx::Size(500, 500)); | 1921 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
| 2049 host_impl_.pending_tree()->UpdateDrawProperties(); | 1922 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2050 | 1923 |
| 2051 std::set<Tile*> unique_tiles; | 1924 std::set<Tile*> unique_tiles; |
| 2052 bool reached_prepaint = false; | 1925 bool reached_prepaint = false; |
| 2053 size_t non_ideal_tile_count = 0u; | 1926 size_t non_ideal_tile_count = 0u; |
| 2054 size_t low_res_tile_count = 0u; | 1927 size_t low_res_tile_count = 0u; |
| 2055 size_t high_res_tile_count = 0u; | 1928 size_t high_res_tile_count = 0u; |
| 2056 for (it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 1929 for (it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2129 | 2002 |
| 2130 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 2003 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 2131 | 2004 |
| 2132 std::vector<PictureLayerTiling*> tilings; | 2005 std::vector<PictureLayerTiling*> tilings; |
| 2133 tilings.push_back(pending_layer_->AddTiling(low_res_factor)); | 2006 tilings.push_back(pending_layer_->AddTiling(low_res_factor)); |
| 2134 tilings.push_back(pending_layer_->AddTiling(0.3f)); | 2007 tilings.push_back(pending_layer_->AddTiling(0.3f)); |
| 2135 tilings.push_back(pending_layer_->AddTiling(0.7f)); | 2008 tilings.push_back(pending_layer_->AddTiling(0.7f)); |
| 2136 tilings.push_back(pending_layer_->AddTiling(1.0f)); | 2009 tilings.push_back(pending_layer_->AddTiling(1.0f)); |
| 2137 tilings.push_back(pending_layer_->AddTiling(2.0f)); | 2010 tilings.push_back(pending_layer_->AddTiling(2.0f)); |
| 2138 | 2011 |
| 2012 float max_scale = pending_layer_->MaximumTilingContentScale(); | |
| 2013 pending_layer_->SetContentsScale(max_scale, max_scale); | |
|
danakj
2014/05/21 15:01:00
This is wrong, the layer's contents scale should a
| |
| 2014 pending_layer_->SetContentBounds(layer_bounds); | |
| 2139 host_impl_.SetViewportSize(gfx::Size(500, 500)); | 2015 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
| 2140 host_impl_.pending_tree()->UpdateDrawProperties(); | 2016 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2141 | 2017 |
| 2142 std::vector<Tile*> all_tiles; | 2018 std::vector<Tile*> all_tiles; |
| 2143 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 2019 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = |
| 2144 tilings.begin(); | 2020 tilings.begin(); |
| 2145 tiling_iterator != tilings.end(); | 2021 tiling_iterator != tilings.end(); |
| 2146 ++tiling_iterator) { | 2022 ++tiling_iterator) { |
| 2147 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | 2023 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); |
| 2148 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); | 2024 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2167 // Empty iterator. | 2043 // Empty iterator. |
| 2168 PictureLayerImpl::LayerEvictionTileIterator it; | 2044 PictureLayerImpl::LayerEvictionTileIterator it; |
| 2169 EXPECT_FALSE(it); | 2045 EXPECT_FALSE(it); |
| 2170 | 2046 |
| 2171 // Tiles don't have resources yet. | 2047 // Tiles don't have resources yet. |
| 2172 it = PictureLayerImpl::LayerEvictionTileIterator( | 2048 it = PictureLayerImpl::LayerEvictionTileIterator( |
| 2173 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); | 2049 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); |
| 2174 EXPECT_FALSE(it); | 2050 EXPECT_FALSE(it); |
| 2175 | 2051 |
| 2176 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 2052 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 2053 pending_layer_->SetContentBounds(layer_bounds); | |
| 2177 | 2054 |
| 2178 std::set<Tile*> unique_tiles; | 2055 std::set<Tile*> unique_tiles; |
| 2179 float expected_scales[] = {2.0f, 0.3f, 0.7f, low_res_factor, 1.0f}; | 2056 float expected_scales[] = {2.0f, 0.3f, 0.7f, low_res_factor, 1.0f}; |
| 2180 size_t scale_index = 0; | 2057 size_t scale_index = 0; |
| 2181 bool reached_visible = false; | 2058 bool reached_visible = false; |
| 2182 bool reached_required = false; | 2059 bool reached_required = false; |
| 2183 Tile* last_tile = NULL; | 2060 Tile* last_tile = NULL; |
| 2184 for (it = PictureLayerImpl::LayerEvictionTileIterator( | 2061 for (it = PictureLayerImpl::LayerEvictionTileIterator( |
| 2185 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); | 2062 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); |
| 2186 it; | 2063 it; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2267 TEST_F(PictureLayerImplTest, Occlusion) { | 2144 TEST_F(PictureLayerImplTest, Occlusion) { |
| 2268 gfx::Size tile_size(102, 102); | 2145 gfx::Size tile_size(102, 102); |
| 2269 gfx::Size layer_bounds(1000, 1000); | 2146 gfx::Size layer_bounds(1000, 1000); |
| 2270 gfx::Size viewport_size(1000, 1000); | 2147 gfx::Size viewport_size(1000, 1000); |
| 2271 | 2148 |
| 2272 LayerTestCommon::LayerImplTest impl; | 2149 LayerTestCommon::LayerImplTest impl; |
| 2273 | 2150 |
| 2274 scoped_refptr<FakePicturePileImpl> pending_pile = | 2151 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2275 FakePicturePileImpl::CreateFilledPile(layer_bounds, layer_bounds); | 2152 FakePicturePileImpl::CreateFilledPile(layer_bounds, layer_bounds); |
| 2276 SetupPendingTree(pending_pile); | 2153 SetupPendingTree(pending_pile); |
| 2154 pending_layer_->SetContentBounds(layer_bounds); | |
| 2277 pending_layer_->SetBounds(layer_bounds); | 2155 pending_layer_->SetBounds(layer_bounds); |
| 2278 ActivateTree(); | 2156 ActivateTree(); |
| 2279 active_layer_->set_fixed_tile_size(tile_size); | 2157 active_layer_->set_fixed_tile_size(tile_size); |
| 2280 | 2158 |
| 2281 host_impl_.SetViewportSize(viewport_size); | 2159 host_impl_.SetViewportSize(viewport_size); |
| 2282 host_impl_.active_tree()->UpdateDrawProperties(); | 2160 host_impl_.active_tree()->UpdateDrawProperties(); |
| 2283 | 2161 |
| 2284 std::vector<Tile*> tiles = | 2162 std::vector<Tile*> tiles = |
| 2285 active_layer_->HighResTiling()->AllTilesForTesting(); | 2163 active_layer_->HighResTiling()->AllTilesForTesting(); |
| 2286 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 2164 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2354 contents_scale = 0.5f; | 2232 contents_scale = 0.5f; |
| 2355 | 2233 |
| 2356 SetContentsScaleOnBothLayers(contents_scale, | 2234 SetContentsScaleOnBothLayers(contents_scale, |
| 2357 device_scale, | 2235 device_scale, |
| 2358 page_scale, | 2236 page_scale, |
| 2359 maximum_animation_scale, | 2237 maximum_animation_scale, |
| 2360 animating_transform); | 2238 animating_transform); |
| 2361 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2239 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 2362 } | 2240 } |
| 2363 | 2241 |
| 2242 TEST_F(PictureLayerImplTest, VerifySharedQuadState) { | |
|
danakj
2014/05/21 15:01:00
rename to SharedQuadStateContainsMaxTilingScale
| |
| 2243 MockQuadCuller quad_culler; | |
| 2244 | |
| 2245 gfx::Size tile_size(400, 400); | |
| 2246 gfx::Size layer_bounds(1000, 2000); | |
| 2247 | |
| 2248 scoped_refptr<FakePicturePileImpl> pending_pile = | |
| 2249 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 2250 scoped_refptr<FakePicturePileImpl> active_pile = | |
| 2251 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 2252 | |
| 2253 SetupTrees(pending_pile, active_pile); | |
| 2254 | |
| 2255 SetupDrawPropertiesAndUpdateTilePriorities( | |
| 2256 pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); | |
| 2257 | |
| 2258 active_layer_->SetContentBounds(layer_bounds); | |
| 2259 active_layer_->draw_properties().visible_content_rect = | |
| 2260 gfx::Rect(layer_bounds); | |
| 2261 | |
| 2262 float max_contents_scale = active_layer_->MaximumTilingContentScale(); | |
| 2263 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); | |
| 2264 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | |
| 2265 SK_MScalar1 / max_contents_scale); | |
| 2266 | |
| 2267 AppendQuadsData data; | |
| 2268 active_layer_->AppendQuads(&quad_culler, &data); | |
| 2269 | |
| 2270 EXPECT_EQ(1u, quad_culler.shared_quad_state_list().size()); | |
| 2271 EXPECT_EQ( | |
|
danakj
2014/05/21 15:01:00
Add a comment to each of these EXPECT_EQ saying wh
| |
| 2272 scaled_draw_transform, | |
|
danakj
2014/05/21 15:01:00
use .ToString() for each of these so we get a nice
| |
| 2273 quad_culler.shared_quad_state_list()[0]->content_to_target_transform); | |
| 2274 EXPECT_EQ(gfx::Size(2500u, 5000u).ToString(), | |
| 2275 quad_culler.shared_quad_state_list()[0]->content_bounds.ToString()); | |
| 2276 EXPECT_EQ( | |
| 2277 gfx::Rect(0u, 0u, 2500u, 5000u).ToString(), | |
| 2278 quad_culler.shared_quad_state_list()[0]->visible_content_rect.ToString()); | |
| 2279 } | |
| 2280 | |
| 2364 } // namespace | 2281 } // namespace |
| 2365 } // namespace cc | 2282 } // namespace cc |
| OLD | NEW |