| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 static void VerifyAllTilesExistAndHavePile( | 170 static void VerifyAllTilesExistAndHavePile( |
| 171 const PictureLayerTiling* tiling, | 171 const PictureLayerTiling* tiling, |
| 172 PicturePileImpl* pile) { | 172 PicturePileImpl* pile) { |
| 173 for (PictureLayerTiling::CoverageIterator iter( | 173 for (PictureLayerTiling::CoverageIterator iter( |
| 174 tiling, | 174 tiling, |
| 175 tiling->contents_scale(), | 175 tiling->contents_scale(), |
| 176 gfx::Rect(tiling->tiling_size())); | 176 gfx::Rect(tiling->tiling_size())); |
| 177 iter; | 177 iter; |
| 178 ++iter) { | 178 ++iter) { |
| 179 EXPECT_TRUE(*iter); | 179 EXPECT_TRUE(*iter); |
| 180 EXPECT_EQ(pile, iter->picture_pile()); | 180 EXPECT_EQ(pile, iter->raster_source()); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 void SetContentsScaleOnBothLayers(float contents_scale, | 184 void SetContentsScaleOnBothLayers(float contents_scale, |
| 185 float device_scale_factor, | 185 float device_scale_factor, |
| 186 float page_scale_factor, | 186 float page_scale_factor, |
| 187 float maximum_animation_contents_scale, | 187 float maximum_animation_contents_scale, |
| 188 bool animating_transform) { | 188 bool animating_transform) { |
| 189 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 189 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
| 190 contents_scale, | 190 contents_scale, |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 tiling->contents_scale()); | 522 tiling->contents_scale()); |
| 523 for (PictureLayerTiling::CoverageIterator iter( | 523 for (PictureLayerTiling::CoverageIterator iter( |
| 524 tiling, | 524 tiling, |
| 525 tiling->contents_scale(), | 525 tiling->contents_scale(), |
| 526 gfx::Rect(tiling->tiling_size())); | 526 gfx::Rect(tiling->tiling_size())); |
| 527 iter; | 527 iter; |
| 528 ++iter) { | 528 ++iter) { |
| 529 EXPECT_TRUE(*iter); | 529 EXPECT_TRUE(*iter); |
| 530 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 530 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 531 if (iter.geometry_rect().Intersects(content_invalidation)) | 531 if (iter.geometry_rect().Intersects(content_invalidation)) |
| 532 EXPECT_EQ(pending_pile.get(), iter->picture_pile()); | 532 EXPECT_EQ(pending_pile.get(), iter->raster_source()); |
| 533 else | 533 else |
| 534 EXPECT_EQ(active_pile.get(), iter->picture_pile()); | 534 EXPECT_EQ(active_pile.get(), iter->raster_source()); |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 | 538 |
| 539 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { | 539 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { |
| 540 gfx::Size tile_size(90, 80); | 540 gfx::Size tile_size(90, 80); |
| 541 gfx::Size layer_bounds(300, 500); | 541 gfx::Size layer_bounds(300, 500); |
| 542 | 542 |
| 543 scoped_refptr<FakePicturePileImpl> pending_pile = | 543 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 544 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 544 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 ++iter) { | 591 ++iter) { |
| 592 EXPECT_TRUE(*iter); | 592 EXPECT_TRUE(*iter); |
| 593 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 593 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 594 std::vector<Tile*> active_tiles = | 594 std::vector<Tile*> active_tiles = |
| 595 active_layer_->tilings()->tiling_at(i)->AllTilesForTesting(); | 595 active_layer_->tilings()->tiling_at(i)->AllTilesForTesting(); |
| 596 std::vector<Tile*> pending_tiles = tiling->AllTilesForTesting(); | 596 std::vector<Tile*> pending_tiles = tiling->AllTilesForTesting(); |
| 597 if (iter.geometry_rect().right() >= active_content_bounds.width() || | 597 if (iter.geometry_rect().right() >= active_content_bounds.width() || |
| 598 iter.geometry_rect().bottom() >= active_content_bounds.height() || | 598 iter.geometry_rect().bottom() >= active_content_bounds.height() || |
| 599 active_tiles[0]->content_rect().size() != | 599 active_tiles[0]->content_rect().size() != |
| 600 pending_tiles[0]->content_rect().size()) { | 600 pending_tiles[0]->content_rect().size()) { |
| 601 EXPECT_EQ(pending_pile.get(), iter->picture_pile()); | 601 EXPECT_EQ(pending_pile.get(), iter->raster_source()); |
| 602 } else { | 602 } else { |
| 603 EXPECT_EQ(active_pile.get(), iter->picture_pile()); | 603 EXPECT_EQ(active_pile.get(), iter->raster_source()); |
| 604 } | 604 } |
| 605 } | 605 } |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 | 608 |
| 609 TEST_F(PictureLayerImplTest, AddTilesFromNewRecording) { | 609 TEST_F(PictureLayerImplTest, AddTilesFromNewRecording) { |
| 610 gfx::Size tile_size(400, 400); | 610 gfx::Size tile_size(400, 400); |
| 611 gfx::Size layer_bounds(1300, 1900); | 611 gfx::Size layer_bounds(1300, 1900); |
| 612 | 612 |
| 613 scoped_refptr<FakePicturePileImpl> pending_pile = | 613 scoped_refptr<FakePicturePileImpl> pending_pile = |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 iter; | 646 iter; |
| 647 ++iter) { | 647 ++iter) { |
| 648 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); | 648 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); |
| 649 // Ensure there is a recording for this tile. | 649 // Ensure there is a recording for this tile. |
| 650 bool in_pending = pending_pile->CanRaster(tiling->contents_scale(), | 650 bool in_pending = pending_pile->CanRaster(tiling->contents_scale(), |
| 651 iter.full_tile_geometry_rect()); | 651 iter.full_tile_geometry_rect()); |
| 652 bool in_active = active_pile->CanRaster(tiling->contents_scale(), | 652 bool in_active = active_pile->CanRaster(tiling->contents_scale(), |
| 653 iter.full_tile_geometry_rect()); | 653 iter.full_tile_geometry_rect()); |
| 654 | 654 |
| 655 if (in_pending && !in_active) | 655 if (in_pending && !in_active) |
| 656 EXPECT_EQ(pending_pile.get(), iter->picture_pile()); | 656 EXPECT_EQ(pending_pile.get(), iter->raster_source()); |
| 657 else if (in_active) | 657 else if (in_active) |
| 658 EXPECT_EQ(active_pile.get(), iter->picture_pile()); | 658 EXPECT_EQ(active_pile.get(), iter->raster_source()); |
| 659 else | 659 else |
| 660 EXPECT_FALSE(*iter); | 660 EXPECT_FALSE(*iter); |
| 661 } | 661 } |
| 662 } | 662 } |
| 663 } | 663 } |
| 664 | 664 |
| 665 TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { | 665 TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { |
| 666 gfx::Size tile_size(400, 400); | 666 gfx::Size tile_size(400, 400); |
| 667 gfx::Size layer_bounds(1300, 1900); | 667 gfx::Size layer_bounds(1300, 1900); |
| 668 | 668 |
| (...skipping 3978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4647 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4647 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4648 EXPECT_EQ(result.width(), 448); | 4648 EXPECT_EQ(result.width(), 448); |
| 4649 EXPECT_EQ(result.height(), 448); | 4649 EXPECT_EQ(result.height(), 448); |
| 4650 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4650 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4651 EXPECT_EQ(result.width(), 512); | 4651 EXPECT_EQ(result.width(), 512); |
| 4652 EXPECT_EQ(result.height(), 500 + 2); | 4652 EXPECT_EQ(result.height(), 500 + 2); |
| 4653 } | 4653 } |
| 4654 | 4654 |
| 4655 } // namespace | 4655 } // namespace |
| 4656 } // namespace cc | 4656 } // namespace cc |
| OLD | NEW |