| 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/picture_layer_impl.h" | 5 #include "cc/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include "cc/layer_tree_impl.h" | 7 #include "cc/layer_tree_impl.h" |
| 8 #include "cc/picture_layer.h" | 8 #include "cc/picture_layer.h" |
| 9 #include "cc/test/fake_content_layer_client.h" | 9 #include "cc/test/fake_content_layer_client.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 | 143 |
| 144 std::vector<SkRect> rects_; | 144 std::vector<SkRect> rects_; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 class PictureLayerImplTest : public testing::Test { | 147 class PictureLayerImplTest : public testing::Test { |
| 148 public: | 148 public: |
| 149 PictureLayerImplTest() | 149 PictureLayerImplTest() |
| 150 : host_impl_(ImplSidePaintingSettings(), &proxy_), | 150 : host_impl_(ImplSidePaintingSettings(), &proxy_), |
| 151 id_(7) { | 151 id_(7) { |
| 152 host_impl_.initializeRenderer(createFakeOutputSurface()); | 152 host_impl_.InitializeRenderer(createFakeOutputSurface()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 virtual ~PictureLayerImplTest() { | 155 virtual ~PictureLayerImplTest() { |
| 156 } | 156 } |
| 157 | 157 |
| 158 void SetupTrees( | 158 void SetupTrees( |
| 159 scoped_refptr<PicturePileImpl> pending_pile, | 159 scoped_refptr<PicturePileImpl> pending_pile, |
| 160 scoped_refptr<PicturePileImpl> active_pile) { | 160 scoped_refptr<PicturePileImpl> active_pile) { |
| 161 SetupPendingTree(active_pile); | 161 SetupPendingTree(active_pile); |
| 162 host_impl_.activatePendingTree(); | 162 host_impl_.ActivatePendingTree(); |
| 163 | 163 |
| 164 active_layer_ = static_cast<TestablePictureLayerImpl*>( | 164 active_layer_ = static_cast<TestablePictureLayerImpl*>( |
| 165 host_impl_.activeTree()->LayerById(id_)); | 165 host_impl_.active_tree()->LayerById(id_)); |
| 166 | 166 |
| 167 SetupPendingTree(pending_pile); | 167 SetupPendingTree(pending_pile); |
| 168 pending_layer_ = static_cast<TestablePictureLayerImpl*>( | 168 pending_layer_ = static_cast<TestablePictureLayerImpl*>( |
| 169 host_impl_.pendingTree()->LayerById(id_)); | 169 host_impl_.pending_tree()->LayerById(id_)); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { | 172 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { |
| 173 active_layer_->AddTiling(2.3f); | 173 active_layer_->AddTiling(2.3f); |
| 174 active_layer_->AddTiling(1.0f); | 174 active_layer_->AddTiling(1.0f); |
| 175 active_layer_->AddTiling(0.5f); | 175 active_layer_->AddTiling(0.5f); |
| 176 pending_layer_->invalidation() = invalidation; | 176 pending_layer_->invalidation() = invalidation; |
| 177 pending_layer_->SyncFromActiveLayer(); | 177 pending_layer_->SyncFromActiveLayer(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void SetupPendingTree( | 180 void SetupPendingTree( |
| 181 scoped_refptr<PicturePileImpl> pile) { | 181 scoped_refptr<PicturePileImpl> pile) { |
| 182 host_impl_.createPendingTree(); | 182 host_impl_.CreatePendingTree(); |
| 183 LayerTreeImpl* pending_tree = host_impl_.pendingTree(); | 183 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 184 // Clear recycled tree. | 184 // Clear recycled tree. |
| 185 pending_tree->DetachLayerTree(); | 185 pending_tree->DetachLayerTree(); |
| 186 | 186 |
| 187 scoped_ptr<TestablePictureLayerImpl> pending_layer = | 187 scoped_ptr<TestablePictureLayerImpl> pending_layer = |
| 188 TestablePictureLayerImpl::Create(pending_tree, id_, pile); | 188 TestablePictureLayerImpl::Create(pending_tree, id_, pile); |
| 189 pending_layer->SetDrawsContent(true); | 189 pending_layer->SetDrawsContent(true); |
| 190 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); | 190 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
| 191 } | 191 } |
| 192 | 192 |
| 193 static void VerifyAllTilesExistAndHavePile( | 193 static void VerifyAllTilesExistAndHavePile( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 222 settings.defaultTileSize.width() * 7 / 2, | 222 settings.defaultTileSize.width() * 7 / 2, |
| 223 settings.defaultTileSize.height() * 7 / 2); | 223 settings.defaultTileSize.height() * 7 / 2); |
| 224 | 224 |
| 225 scoped_refptr<TestablePicturePileImpl> pending_pile = | 225 scoped_refptr<TestablePicturePileImpl> pending_pile = |
| 226 TestablePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 226 TestablePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 227 scoped_refptr<TestablePicturePileImpl> active_pile = | 227 scoped_refptr<TestablePicturePileImpl> active_pile = |
| 228 TestablePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 228 TestablePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 229 | 229 |
| 230 SetupTrees(pending_pile, active_pile); | 230 SetupTrees(pending_pile, active_pile); |
| 231 | 231 |
| 232 host_impl_.activeTree()->SetPageScaleFactorAndLimits(1.f, 1.f, 1.f); | 232 host_impl_.active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 1.f); |
| 233 float result_scale_x, result_scale_y; | 233 float result_scale_x, result_scale_y; |
| 234 gfx::Size result_bounds; | 234 gfx::Size result_bounds; |
| 235 active_layer_->CalculateContentsScale( | 235 active_layer_->CalculateContentsScale( |
| 236 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 236 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
| 237 | 237 |
| 238 // Add 1x1 rects at the centers of each tile, then re-record pile contents | 238 // Add 1x1 rects at the centers of each tile, then re-record pile contents |
| 239 std::vector<Tile*> tiles = | 239 std::vector<Tile*> tiles = |
| 240 active_layer_->tilings().tiling_at(0)->AllTilesForTesting(); | 240 active_layer_->tilings().tiling_at(0)->AllTilesForTesting(); |
| 241 EXPECT_EQ(16, tiles.size()); | 241 EXPECT_EQ(16, tiles.size()); |
| 242 std::vector<SkRect> rects; | 242 std::vector<SkRect> rects; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 FakeImplProxy proxy_; | 277 FakeImplProxy proxy_; |
| 278 FakeLayerTreeHostImpl host_impl_; | 278 FakeLayerTreeHostImpl host_impl_; |
| 279 int id_; | 279 int id_; |
| 280 TestablePictureLayerImpl* pending_layer_; | 280 TestablePictureLayerImpl* pending_layer_; |
| 281 TestablePictureLayerImpl* active_layer_; | 281 TestablePictureLayerImpl* active_layer_; |
| 282 | 282 |
| 283 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); | 283 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); |
| 284 }; | 284 }; |
| 285 | 285 |
| 286 TEST_F(PictureLayerImplTest, tileGridAlignment) { | 286 TEST_F(PictureLayerImplTest, tileGridAlignment) { |
| 287 host_impl_.setDeviceScaleFactor(1.f); | 287 host_impl_.SetDeviceScaleFactor(1.f); |
| 288 TestTileGridAlignmentCommon(); | 288 TestTileGridAlignmentCommon(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 TEST_F(PictureLayerImplTest, tileGridAlignmentHiDPI) { | 291 TEST_F(PictureLayerImplTest, tileGridAlignmentHiDPI) { |
| 292 host_impl_.setDeviceScaleFactor(2.f); | 292 host_impl_.SetDeviceScaleFactor(2.f); |
| 293 TestTileGridAlignmentCommon(); | 293 TestTileGridAlignmentCommon(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 TEST_F(PictureLayerImplTest, cloneNoInvalidation) { | 296 TEST_F(PictureLayerImplTest, cloneNoInvalidation) { |
| 297 gfx::Size tile_size(100, 100); | 297 gfx::Size tile_size(100, 100); |
| 298 gfx::Size layer_bounds(400, 400); | 298 gfx::Size layer_bounds(400, 400); |
| 299 | 299 |
| 300 scoped_refptr<TestablePicturePileImpl> pending_pile = | 300 scoped_refptr<TestablePicturePileImpl> pending_pile = |
| 301 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 301 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 302 scoped_refptr<TestablePicturePileImpl> active_pile = | 302 scoped_refptr<TestablePicturePileImpl> active_pile = |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 TestablePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 482 TestablePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 483 scoped_refptr<TestablePicturePileImpl> active_pile = | 483 scoped_refptr<TestablePicturePileImpl> active_pile = |
| 484 TestablePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 484 TestablePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
| 485 | 485 |
| 486 float result_scale_x, result_scale_y; | 486 float result_scale_x, result_scale_y; |
| 487 gfx::Size result_bounds; | 487 gfx::Size result_bounds; |
| 488 | 488 |
| 489 SetupTrees(pending_pile, active_pile); | 489 SetupTrees(pending_pile, active_pile); |
| 490 | 490 |
| 491 // These are included in the scale given to the layer. | 491 // These are included in the scale given to the layer. |
| 492 host_impl_.setDeviceScaleFactor(1.f); | 492 host_impl_.SetDeviceScaleFactor(1.f); |
| 493 host_impl_.pendingTree()->SetPageScaleFactorAndLimits(1.f, 1.f, 1.f); | 493 host_impl_.pending_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 1.f); |
| 494 | 494 |
| 495 pending_layer_->CalculateContentsScale( | 495 pending_layer_->CalculateContentsScale( |
| 496 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); | 496 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
| 497 | 497 |
| 498 EXPECT_EQ(0u, pending_layer_->tilings().num_tilings()); | 498 EXPECT_EQ(0u, pending_layer_->tilings().num_tilings()); |
| 499 } | 499 } |
| 500 | 500 |
| 501 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { | 501 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
| 502 gfx::Size tile_size(400, 400); | 502 gfx::Size tile_size(400, 400); |
| 503 gfx::Size layer_bounds(1300, 1900); | 503 gfx::Size layer_bounds(1300, 1900); |
| 504 | 504 |
| 505 scoped_refptr<TestablePicturePileImpl> pending_pile = | 505 scoped_refptr<TestablePicturePileImpl> pending_pile = |
| 506 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 506 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 507 scoped_refptr<TestablePicturePileImpl> active_pile = | 507 scoped_refptr<TestablePicturePileImpl> active_pile = |
| 508 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 508 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 509 | 509 |
| 510 float result_scale_x, result_scale_y; | 510 float result_scale_x, result_scale_y; |
| 511 gfx::Size result_bounds; | 511 gfx::Size result_bounds; |
| 512 | 512 |
| 513 SetupTrees(pending_pile, active_pile); | 513 SetupTrees(pending_pile, active_pile); |
| 514 EXPECT_EQ(0u, pending_layer_->tilings().num_tilings()); | 514 EXPECT_EQ(0u, pending_layer_->tilings().num_tilings()); |
| 515 | 515 |
| 516 float low_res_factor = host_impl_.Settings().lowResContentsScaleFactor; | 516 float low_res_factor = host_impl_.settings().lowResContentsScaleFactor; |
| 517 EXPECT_LT(low_res_factor, 1.f); | 517 EXPECT_LT(low_res_factor, 1.f); |
| 518 | 518 |
| 519 // These are included in the scale given to the layer. | 519 // These are included in the scale given to the layer. |
| 520 host_impl_.setDeviceScaleFactor(1.7f); | 520 host_impl_.SetDeviceScaleFactor(1.7f); |
| 521 host_impl_.pendingTree()->SetPageScaleFactorAndLimits(3.2f, 3.2f, 3.2f); | 521 host_impl_.pending_tree()->SetPageScaleFactorAndLimits(3.2f, 3.2f, 3.2f); |
| 522 | 522 |
| 523 pending_layer_->CalculateContentsScale( | 523 pending_layer_->CalculateContentsScale( |
| 524 1.3f, false, &result_scale_x, &result_scale_y, &result_bounds); | 524 1.3f, false, &result_scale_x, &result_scale_y, &result_bounds); |
| 525 ASSERT_EQ(2u, pending_layer_->tilings().num_tilings()); | 525 ASSERT_EQ(2u, pending_layer_->tilings().num_tilings()); |
| 526 EXPECT_FLOAT_EQ( | 526 EXPECT_FLOAT_EQ( |
| 527 1.3f, | 527 1.3f, |
| 528 pending_layer_->tilings().tiling_at(0)->contents_scale()); | 528 pending_layer_->tilings().tiling_at(0)->contents_scale()); |
| 529 EXPECT_FLOAT_EQ( | 529 EXPECT_FLOAT_EQ( |
| 530 1.3f * low_res_factor, | 530 1.3f * low_res_factor, |
| 531 pending_layer_->tilings().tiling_at(1)->contents_scale()); | 531 pending_layer_->tilings().tiling_at(1)->contents_scale()); |
| 532 | 532 |
| 533 // If we change the layer's CSS scale factor, then we should not get new | 533 // If we change the layer's CSS scale factor, then we should not get new |
| 534 // tilings. | 534 // tilings. |
| 535 pending_layer_->CalculateContentsScale( | 535 pending_layer_->CalculateContentsScale( |
| 536 1.8f, false, &result_scale_x, &result_scale_y, &result_bounds); | 536 1.8f, false, &result_scale_x, &result_scale_y, &result_bounds); |
| 537 ASSERT_EQ(2u, pending_layer_->tilings().num_tilings()); | 537 ASSERT_EQ(2u, pending_layer_->tilings().num_tilings()); |
| 538 EXPECT_FLOAT_EQ( | 538 EXPECT_FLOAT_EQ( |
| 539 1.3f, | 539 1.3f, |
| 540 pending_layer_->tilings().tiling_at(0)->contents_scale()); | 540 pending_layer_->tilings().tiling_at(0)->contents_scale()); |
| 541 EXPECT_FLOAT_EQ( | 541 EXPECT_FLOAT_EQ( |
| 542 1.3f * low_res_factor, | 542 1.3f * low_res_factor, |
| 543 pending_layer_->tilings().tiling_at(1)->contents_scale()); | 543 pending_layer_->tilings().tiling_at(1)->contents_scale()); |
| 544 | 544 |
| 545 // If we change the page scale factor, then we should get new tilings. | 545 // If we change the page scale factor, then we should get new tilings. |
| 546 host_impl_.pendingTree()->SetPageScaleFactorAndLimits(2.2f, 2.2f, 2.2f); | 546 host_impl_.pending_tree()->SetPageScaleFactorAndLimits(2.2f, 2.2f, 2.2f); |
| 547 | 547 |
| 548 pending_layer_->CalculateContentsScale( | 548 pending_layer_->CalculateContentsScale( |
| 549 1.8f, false, &result_scale_x, &result_scale_y, &result_bounds); | 549 1.8f, false, &result_scale_x, &result_scale_y, &result_bounds); |
| 550 ASSERT_EQ(4u, pending_layer_->tilings().num_tilings()); | 550 ASSERT_EQ(4u, pending_layer_->tilings().num_tilings()); |
| 551 EXPECT_FLOAT_EQ( | 551 EXPECT_FLOAT_EQ( |
| 552 1.8f, | 552 1.8f, |
| 553 pending_layer_->tilings().tiling_at(0)->contents_scale()); | 553 pending_layer_->tilings().tiling_at(0)->contents_scale()); |
| 554 EXPECT_FLOAT_EQ( | 554 EXPECT_FLOAT_EQ( |
| 555 1.8f * low_res_factor, | 555 1.8f * low_res_factor, |
| 556 pending_layer_->tilings().tiling_at(2)->contents_scale()); | 556 pending_layer_->tilings().tiling_at(2)->contents_scale()); |
| 557 | 557 |
| 558 // If we change the device scale factor, then we should get new tilings. | 558 // If we change the device scale factor, then we should get new tilings. |
| 559 host_impl_.setDeviceScaleFactor(1.4f); | 559 host_impl_.SetDeviceScaleFactor(1.4f); |
| 560 | 560 |
| 561 pending_layer_->CalculateContentsScale( | 561 pending_layer_->CalculateContentsScale( |
| 562 1.9f, false, &result_scale_x, &result_scale_y, &result_bounds); | 562 1.9f, false, &result_scale_x, &result_scale_y, &result_bounds); |
| 563 ASSERT_EQ(6u, pending_layer_->tilings().num_tilings()); | 563 ASSERT_EQ(6u, pending_layer_->tilings().num_tilings()); |
| 564 EXPECT_FLOAT_EQ( | 564 EXPECT_FLOAT_EQ( |
| 565 1.9f, | 565 1.9f, |
| 566 pending_layer_->tilings().tiling_at(0)->contents_scale()); | 566 pending_layer_->tilings().tiling_at(0)->contents_scale()); |
| 567 EXPECT_FLOAT_EQ( | 567 EXPECT_FLOAT_EQ( |
| 568 1.9f * low_res_factor, | 568 1.9f * low_res_factor, |
| 569 pending_layer_->tilings().tiling_at(3)->contents_scale()); | 569 pending_layer_->tilings().tiling_at(3)->contents_scale()); |
| 570 | 570 |
| 571 // If we change the device scale factor, but end up at the same total scale | 571 // If we change the device scale factor, but end up at the same total scale |
| 572 // factor somehow, then we don't get new tilings. | 572 // factor somehow, then we don't get new tilings. |
| 573 host_impl_.setDeviceScaleFactor(2.2f); | 573 host_impl_.SetDeviceScaleFactor(2.2f); |
| 574 host_impl_.pendingTree()->SetPageScaleFactorAndLimits(1.4f, 1.4f, 1.4f); | 574 host_impl_.pending_tree()->SetPageScaleFactorAndLimits(1.4f, 1.4f, 1.4f); |
| 575 | 575 |
| 576 pending_layer_->CalculateContentsScale( | 576 pending_layer_->CalculateContentsScale( |
| 577 1.9f, false, &result_scale_x, &result_scale_y, &result_bounds); | 577 1.9f, false, &result_scale_x, &result_scale_y, &result_bounds); |
| 578 ASSERT_EQ(6u, pending_layer_->tilings().num_tilings()); | 578 ASSERT_EQ(6u, pending_layer_->tilings().num_tilings()); |
| 579 EXPECT_FLOAT_EQ( | 579 EXPECT_FLOAT_EQ( |
| 580 1.9f, | 580 1.9f, |
| 581 pending_layer_->tilings().tiling_at(0)->contents_scale()); | 581 pending_layer_->tilings().tiling_at(0)->contents_scale()); |
| 582 EXPECT_FLOAT_EQ( | 582 EXPECT_FLOAT_EQ( |
| 583 1.9f * low_res_factor, | 583 1.9f * low_res_factor, |
| 584 pending_layer_->tilings().tiling_at(3)->contents_scale()); | 584 pending_layer_->tilings().tiling_at(3)->contents_scale()); |
| 585 } | 585 } |
| 586 | 586 |
| 587 TEST_F(PictureLayerImplTest, CleanUpTilings) { | 587 TEST_F(PictureLayerImplTest, CleanUpTilings) { |
| 588 gfx::Size tile_size(400, 400); | 588 gfx::Size tile_size(400, 400); |
| 589 gfx::Size layer_bounds(1300, 1900); | 589 gfx::Size layer_bounds(1300, 1900); |
| 590 | 590 |
| 591 scoped_refptr<TestablePicturePileImpl> pending_pile = | 591 scoped_refptr<TestablePicturePileImpl> pending_pile = |
| 592 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 592 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 593 scoped_refptr<TestablePicturePileImpl> active_pile = | 593 scoped_refptr<TestablePicturePileImpl> active_pile = |
| 594 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 594 TestablePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 595 | 595 |
| 596 float result_scale_x, result_scale_y; | 596 float result_scale_x, result_scale_y; |
| 597 gfx::Size result_bounds; | 597 gfx::Size result_bounds; |
| 598 std::vector<PictureLayerTiling*> used_tilings; | 598 std::vector<PictureLayerTiling*> used_tilings; |
| 599 | 599 |
| 600 SetupTrees(pending_pile, active_pile); | 600 SetupTrees(pending_pile, active_pile); |
| 601 EXPECT_EQ(0u, pending_layer_->tilings().num_tilings()); | 601 EXPECT_EQ(0u, pending_layer_->tilings().num_tilings()); |
| 602 | 602 |
| 603 float low_res_factor = host_impl_.Settings().lowResContentsScaleFactor; | 603 float low_res_factor = host_impl_.settings().lowResContentsScaleFactor; |
| 604 EXPECT_LT(low_res_factor, 1.f); | 604 EXPECT_LT(low_res_factor, 1.f); |
| 605 | 605 |
| 606 // These are included in the scale given to the layer. | 606 // These are included in the scale given to the layer. |
| 607 host_impl_.setDeviceScaleFactor(1.7f); | 607 host_impl_.SetDeviceScaleFactor(1.7f); |
| 608 host_impl_.pendingTree()->SetPageScaleFactorAndLimits(3.2f, 3.2f, 3.2f); | 608 host_impl_.pending_tree()->SetPageScaleFactorAndLimits(3.2f, 3.2f, 3.2f); |
| 609 host_impl_.activeTree()->SetPageScaleFactorAndLimits(3.2f, 3.2f, 3.2f); | 609 host_impl_.active_tree()->SetPageScaleFactorAndLimits(3.2f, 3.2f, 3.2f); |
| 610 | 610 |
| 611 SetContentsScaleOnBothLayers(1.f, false); | 611 SetContentsScaleOnBothLayers(1.f, false); |
| 612 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); | 612 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); |
| 613 | 613 |
| 614 // We only have ideal tilings, so they aren't removed. | 614 // We only have ideal tilings, so they aren't removed. |
| 615 used_tilings.clear(); | 615 used_tilings.clear(); |
| 616 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 616 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 617 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); | 617 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); |
| 618 | 618 |
| 619 // Changing the ideal but not creating new tilings. | 619 // Changing the ideal but not creating new tilings. |
| 620 SetContentsScaleOnBothLayers(1.5f, false); | 620 SetContentsScaleOnBothLayers(1.5f, false); |
| 621 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); | 621 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); |
| 622 | 622 |
| 623 // The tilings are still our target scale, so they aren't removed. | 623 // The tilings are still our target scale, so they aren't removed. |
| 624 used_tilings.clear(); | 624 used_tilings.clear(); |
| 625 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 625 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 626 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); | 626 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); |
| 627 | 627 |
| 628 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 628 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
| 629 host_impl_.pendingTree()->SetPageScaleFactorAndLimits(1.2f, 1.2f, 1.2f); | 629 host_impl_.pending_tree()->SetPageScaleFactorAndLimits(1.2f, 1.2f, 1.2f); |
| 630 host_impl_.activeTree()->SetPageScaleFactorAndLimits(1.2f, 1.2f, 1.2f); | 630 host_impl_.active_tree()->SetPageScaleFactorAndLimits(1.2f, 1.2f, 1.2f); |
| 631 SetContentsScaleOnBothLayers(1.2f, false); | 631 SetContentsScaleOnBothLayers(1.2f, false); |
| 632 ASSERT_EQ(4u, active_layer_->tilings().num_tilings()); | 632 ASSERT_EQ(4u, active_layer_->tilings().num_tilings()); |
| 633 EXPECT_FLOAT_EQ( | 633 EXPECT_FLOAT_EQ( |
| 634 1.f, | 634 1.f, |
| 635 active_layer_->tilings().tiling_at(1)->contents_scale()); | 635 active_layer_->tilings().tiling_at(1)->contents_scale()); |
| 636 EXPECT_FLOAT_EQ( | 636 EXPECT_FLOAT_EQ( |
| 637 1.f * low_res_factor, | 637 1.f * low_res_factor, |
| 638 active_layer_->tilings().tiling_at(3)->contents_scale()); | 638 active_layer_->tilings().tiling_at(3)->contents_scale()); |
| 639 | 639 |
| 640 // Mark the non-ideal tilings as used. They won't be removed. | 640 // Mark the non-ideal tilings as used. They won't be removed. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 693 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 694 ASSERT_EQ(3u, active_layer_->tilings().num_tilings()); | 694 ASSERT_EQ(3u, active_layer_->tilings().num_tilings()); |
| 695 used_tilings.clear(); | 695 used_tilings.clear(); |
| 696 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 696 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 697 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); | 697 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); |
| 698 | 698 |
| 699 } | 699 } |
| 700 | 700 |
| 701 } // namespace | 701 } // namespace |
| 702 } // namespace cc | 702 } // namespace cc |
| OLD | NEW |