| 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" |
| 11 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
| 12 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/skia/include/core/SkDevice.h" | 14 #include "third_party/skia/include/core/SkDevice.h" |
| 15 #include "ui/gfx/rect_conversions.h" | 15 #include "ui/gfx/rect_conversions.h" |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 class TestablePictureLayerImpl : public PictureLayerImpl { | 20 class TestablePictureLayerImpl : public PictureLayerImpl { |
| 21 public: | 21 public: |
| 22 static scoped_ptr<TestablePictureLayerImpl> create( | 22 static scoped_ptr<TestablePictureLayerImpl> Create( |
| 23 LayerTreeImpl* treeImpl, | 23 LayerTreeImpl* treeImpl, |
| 24 int id, | 24 int id, |
| 25 scoped_refptr<PicturePileImpl> pile) | 25 scoped_refptr<PicturePileImpl> pile) |
| 26 { | 26 { |
| 27 return make_scoped_ptr(new TestablePictureLayerImpl(treeImpl, id, pile)); | 27 return make_scoped_ptr(new TestablePictureLayerImpl(treeImpl, id, pile)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 PictureLayerTilingSet& tilings() { return *tilings_; } | 30 PictureLayerTilingSet& tilings() { return *tilings_; } |
| 31 Region& invalidation() { return invalidation_; } | 31 Region& invalidation() { return invalidation_; } |
| 32 | 32 |
| 33 virtual gfx::Size CalculateTileSize( | 33 virtual gfx::Size CalculateTileSize( |
| 34 gfx::Size current_tile_size, | 34 gfx::Size current_tile_size, |
| 35 gfx::Size /* content_bounds */) OVERRIDE { | 35 gfx::Size /* content_bounds */) OVERRIDE { |
| 36 if (current_tile_size.IsEmpty()) | 36 if (current_tile_size.IsEmpty()) |
| 37 return gfx::Size(100, 100); | 37 return gfx::Size(100, 100); |
| 38 return current_tile_size; | 38 return current_tile_size; |
| 39 } | 39 } |
| 40 | 40 |
| 41 using PictureLayerImpl::AddTiling; | 41 using PictureLayerImpl::AddTiling; |
| 42 using PictureLayerImpl::CleanUpTilingsOnActiveLayer; | 42 using PictureLayerImpl::CleanUpTilingsOnActiveLayer; |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 TestablePictureLayerImpl( | 45 TestablePictureLayerImpl( |
| 46 LayerTreeImpl* treeImpl, | 46 LayerTreeImpl* treeImpl, |
| 47 int id, | 47 int id, |
| 48 scoped_refptr<PicturePileImpl> pile) | 48 scoped_refptr<PicturePileImpl> pile) |
| 49 : PictureLayerImpl(treeImpl, id) { | 49 : PictureLayerImpl(treeImpl, id) { |
| 50 pile_ = pile; | 50 pile_ = pile; |
| 51 setBounds(pile_->size()); | 51 SetBounds(pile_->size()); |
| 52 CreateTilingSet(); | 52 CreateTilingSet(); |
| 53 } | 53 } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 class ImplSidePaintingSettings : public LayerTreeSettings { | 56 class ImplSidePaintingSettings : public LayerTreeSettings { |
| 57 public: | 57 public: |
| 58 ImplSidePaintingSettings() { | 58 ImplSidePaintingSettings() { |
| 59 implSidePainting = true; | 59 implSidePainting = true; |
| 60 } | 60 } |
| 61 }; | 61 }; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_.pendingTree(); |
| 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( |
| 194 const PictureLayerTiling* tiling, | 194 const PictureLayerTiling* tiling, |
| 195 PicturePileImpl* pile) { | 195 PicturePileImpl* pile) { |
| 196 for (PictureLayerTiling::Iterator iter(tiling, | 196 for (PictureLayerTiling::Iterator iter(tiling, |
| 197 tiling->contents_scale(), | 197 tiling->contents_scale(), |
| 198 tiling->ContentRect(), | 198 tiling->ContentRect(), |
| 199 PictureLayerTiling::LayerDeviceAlignm
entUnknown); | 199 PictureLayerTiling::LayerDeviceAlignm
entUnknown); |
| 200 iter; ++iter) { | 200 iter; ++iter) { |
| 201 EXPECT_TRUE(*iter); | 201 EXPECT_TRUE(*iter); |
| 202 EXPECT_EQ(pile, iter->picture_pile()); | 202 EXPECT_EQ(pile, iter->picture_pile()); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 void SetContentsScaleOnBothLayers(float scale, bool animating_transform) { | 206 void SetContentsScaleOnBothLayers(float scale, bool animating_transform) { |
| 207 float result_scale_x, result_scale_y; | 207 float result_scale_x, result_scale_y; |
| 208 gfx::Size result_bounds; | 208 gfx::Size result_bounds; |
| 209 pending_layer_->calculateContentsScale( | 209 pending_layer_->CalculateContentsScale( |
| 210 scale, animating_transform, | 210 scale, animating_transform, |
| 211 &result_scale_x, &result_scale_y, &result_bounds); | 211 &result_scale_x, &result_scale_y, &result_bounds); |
| 212 active_layer_->calculateContentsScale( | 212 active_layer_->CalculateContentsScale( |
| 213 scale, animating_transform, | 213 scale, animating_transform, |
| 214 &result_scale_x, &result_scale_y, &result_bounds); | 214 &result_scale_x, &result_scale_y, &result_bounds); |
| 215 } | 215 } |
| 216 | 216 |
| 217 protected: | 217 protected: |
| 218 void TestTileGridAlignmentCommon() { | 218 void TestTileGridAlignmentCommon() { |
| 219 // Layer to span 4 raster tiles in x and in y | 219 // Layer to span 4 raster tiles in x and in y |
| 220 ImplSidePaintingSettings settings; | 220 ImplSidePaintingSettings settings; |
| 221 gfx::Size layer_size( | 221 gfx::Size layer_size( |
| 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_.activeTree()->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; |
| 243 std::vector<Tile*>::const_iterator tile_iter; | 243 std::vector<Tile*>::const_iterator tile_iter; |
| 244 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | 244 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
| 245 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); | 245 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_.pendingTree()->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_.pendingTree()->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_.pendingTree()->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_.pendingTree()->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 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 // Now move the ideal scale to 1.0. Our target stays 1.2. | 656 // Now move the ideal scale to 1.0. Our target stays 1.2. |
| 657 SetContentsScaleOnBothLayers(1.f, false); | 657 SetContentsScaleOnBothLayers(1.f, false); |
| 658 | 658 |
| 659 // All the tilings are between are target and the ideal, so they are not | 659 // All the tilings are between are target and the ideal, so they are not |
| 660 // removed. | 660 // removed. |
| 661 used_tilings.clear(); | 661 used_tilings.clear(); |
| 662 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 662 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 663 ASSERT_EQ(4u, active_layer_->tilings().num_tilings()); | 663 ASSERT_EQ(4u, active_layer_->tilings().num_tilings()); |
| 664 | 664 |
| 665 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 665 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
| 666 active_layer_->calculateContentsScale( | 666 active_layer_->CalculateContentsScale( |
| 667 1.1f, false, &result_scale_x, &result_scale_y, &result_bounds); | 667 1.1f, false, &result_scale_x, &result_scale_y, &result_bounds); |
| 668 | 668 |
| 669 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 669 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
| 670 // in the range [1.0,1.2] and are kept. | 670 // in the range [1.0,1.2] and are kept. |
| 671 used_tilings.clear(); | 671 used_tilings.clear(); |
| 672 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 672 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 673 ASSERT_EQ(4u, active_layer_->tilings().num_tilings()); | 673 ASSERT_EQ(4u, active_layer_->tilings().num_tilings()); |
| 674 | 674 |
| 675 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 675 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
| 676 // 1.2 still. | 676 // 1.2 still. |
| 677 pending_layer_->calculateContentsScale( | 677 pending_layer_->CalculateContentsScale( |
| 678 1.1f, false, &result_scale_x, &result_scale_y, &result_bounds); | 678 1.1f, false, &result_scale_x, &result_scale_y, &result_bounds); |
| 679 | 679 |
| 680 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 680 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
| 681 // target raster scale. But it is in our used tilings set, so nothing is | 681 // target raster scale. But it is in our used tilings set, so nothing is |
| 682 // deleted. | 682 // deleted. |
| 683 used_tilings.clear(); | 683 used_tilings.clear(); |
| 684 used_tilings.push_back(active_layer_->tilings().tiling_at(1)); | 684 used_tilings.push_back(active_layer_->tilings().tiling_at(1)); |
| 685 used_tilings.push_back(active_layer_->tilings().tiling_at(3)); | 685 used_tilings.push_back(active_layer_->tilings().tiling_at(3)); |
| 686 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 686 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
| 687 ASSERT_EQ(4u, active_layer_->tilings().num_tilings()); | 687 ASSERT_EQ(4u, active_layer_->tilings().num_tilings()); |
| 688 | 688 |
| 689 // If we remove it from our used tilings set, it is outside the range to keep | 689 // If we remove it from our used tilings set, it is outside the range to keep |
| 690 // so it is deleted. Try one tiling at a time. | 690 // so it is deleted. Try one tiling at a time. |
| 691 used_tilings.clear(); | 691 used_tilings.clear(); |
| 692 used_tilings.push_back(active_layer_->tilings().tiling_at(1)); | 692 used_tilings.push_back(active_layer_->tilings().tiling_at(1)); |
| 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 |