| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 layer->draw_properties().page_scale_factor = page_scale_factor; | 250 layer->draw_properties().page_scale_factor = page_scale_factor; |
| 251 layer->draw_properties().maximum_animation_contents_scale = | 251 layer->draw_properties().maximum_animation_contents_scale = |
| 252 maximum_animation_contents_scale; | 252 maximum_animation_contents_scale; |
| 253 layer->draw_properties().starting_animation_contents_scale = | 253 layer->draw_properties().starting_animation_contents_scale = |
| 254 starting_animation_contents_scale; | 254 starting_animation_contents_scale; |
| 255 layer->draw_properties().screen_space_transform_is_animating = | 255 layer->draw_properties().screen_space_transform_is_animating = |
| 256 animating_transform_to_screen; | 256 animating_transform_to_screen; |
| 257 bool resourceless_software_draw = false; | 257 bool resourceless_software_draw = false; |
| 258 layer->UpdateTiles(resourceless_software_draw); | 258 layer->UpdateTiles(resourceless_software_draw); |
| 259 } | 259 } |
| 260 static void VerifyAllTilesExistAndHavePile( | 260 static void VerifyAllPrioritizedTilesExistAndHavePile( |
| 261 const PictureLayerTiling* tiling, | 261 const PictureLayerTiling* tiling, |
| 262 PicturePileImpl* pile) { | 262 PicturePileImpl* pile) { |
| 263 auto prioritized_tiles = |
| 264 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 263 for (PictureLayerTiling::CoverageIterator iter( | 265 for (PictureLayerTiling::CoverageIterator iter( |
| 264 tiling, | 266 tiling, |
| 265 tiling->contents_scale(), | 267 tiling->contents_scale(), |
| 266 gfx::Rect(tiling->tiling_size())); | 268 gfx::Rect(tiling->tiling_size())); |
| 267 iter; | 269 iter; |
| 268 ++iter) { | 270 ++iter) { |
| 269 EXPECT_TRUE(*iter); | 271 EXPECT_TRUE(*iter); |
| 270 EXPECT_EQ(pile, iter->raster_source()); | 272 EXPECT_EQ(pile, prioritized_tiles[*iter].raster_source()); |
| 271 } | 273 } |
| 272 } | 274 } |
| 273 | 275 |
| 274 void SetContentsScaleOnBothLayers(float contents_scale, | 276 void SetContentsScaleOnBothLayers(float contents_scale, |
| 275 float device_scale_factor, | 277 float device_scale_factor, |
| 276 float page_scale_factor, | 278 float page_scale_factor, |
| 277 float maximum_animation_contents_scale, | 279 float maximum_animation_contents_scale, |
| 278 float starting_animation_contents_scale, | 280 float starting_animation_contents_scale, |
| 279 bool animating_transform) { | 281 bool animating_transform) { |
| 280 SetupDrawPropertiesAndUpdateTiles( | 282 SetupDrawPropertiesAndUpdateTiles( |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 EXPECT_EQ(2u, pending_layer_->num_tilings()); | 691 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
| 690 EXPECT_EQ(3u, active_layer_->num_tilings()); | 692 EXPECT_EQ(3u, active_layer_->num_tilings()); |
| 691 | 693 |
| 692 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 694 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
| 693 EXPECT_GT(tilings->num_tilings(), 0u); | 695 EXPECT_GT(tilings->num_tilings(), 0u); |
| 694 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 696 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
| 695 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 697 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 696 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( | 698 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( |
| 697 layer_invalidation, | 699 layer_invalidation, |
| 698 tiling->contents_scale()); | 700 tiling->contents_scale()); |
| 701 auto prioritized_tiles = |
| 702 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 699 for (PictureLayerTiling::CoverageIterator iter( | 703 for (PictureLayerTiling::CoverageIterator iter( |
| 700 tiling, | 704 tiling, |
| 701 tiling->contents_scale(), | 705 tiling->contents_scale(), |
| 702 gfx::Rect(tiling->tiling_size())); | 706 gfx::Rect(tiling->tiling_size())); |
| 703 iter; | 707 iter; |
| 704 ++iter) { | 708 ++iter) { |
| 705 // We don't always have a tile, but when we do it's because it was | 709 // We don't always have a tile, but when we do it's because it was |
| 706 // invalidated and it has the latest raster source. | 710 // invalidated and it has the latest raster source. |
| 707 if (*iter) { | 711 if (*iter) { |
| 708 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 712 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 709 EXPECT_EQ(pending_pile.get(), iter->raster_source()); | 713 EXPECT_EQ(pending_pile.get(), prioritized_tiles[*iter].raster_source()); |
| 710 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation)); | 714 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation)); |
| 711 } else { | 715 } else { |
| 712 // We don't create tiles in non-invalidated regions. | 716 // We don't create tiles in non-invalidated regions. |
| 713 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation)); | 717 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation)); |
| 714 } | 718 } |
| 715 } | 719 } |
| 716 } | 720 } |
| 717 | 721 |
| 718 tilings = active_layer_->tilings(); | 722 tilings = active_layer_->tilings(); |
| 719 EXPECT_GT(tilings->num_tilings(), 0u); | 723 EXPECT_GT(tilings->num_tilings(), 0u); |
| 720 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 724 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
| 721 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 725 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
| 722 gfx::Rect content_invalidation = | 726 gfx::Rect content_invalidation = |
| 723 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); | 727 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); |
| 728 auto prioritized_tiles = |
| 729 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 724 for (PictureLayerTiling::CoverageIterator iter( | 730 for (PictureLayerTiling::CoverageIterator iter( |
| 725 tiling, | 731 tiling, |
| 726 tiling->contents_scale(), | 732 tiling->contents_scale(), |
| 727 gfx::Rect(tiling->tiling_size())); | 733 gfx::Rect(tiling->tiling_size())); |
| 728 iter; | 734 iter; |
| 729 ++iter) { | 735 ++iter) { |
| 730 EXPECT_TRUE(*iter); | 736 EXPECT_TRUE(*iter); |
| 731 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 737 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
| 732 // Pile will be updated upon activation. | 738 // Pile will be updated upon activation. |
| 733 EXPECT_EQ(active_pile.get(), iter->raster_source()); | 739 EXPECT_EQ(active_pile.get(), prioritized_tiles[*iter].raster_source()); |
| 734 } | 740 } |
| 735 } | 741 } |
| 736 } | 742 } |
| 737 | 743 |
| 738 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { | 744 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { |
| 739 gfx::Size tile_size(90, 80); | 745 gfx::Size tile_size(90, 80); |
| 740 gfx::Size layer_bounds(300, 500); | 746 gfx::Size layer_bounds(300, 500); |
| 741 | 747 |
| 742 scoped_refptr<FakePicturePileImpl> pending_pile = | 748 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 743 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 749 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 744 scoped_refptr<FakePicturePileImpl> active_pile = | 750 scoped_refptr<FakePicturePileImpl> active_pile = |
| 745 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 751 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 746 | 752 |
| 747 SetupTreesWithInvalidation(pending_pile, active_pile, | 753 SetupTreesWithInvalidation(pending_pile, active_pile, |
| 748 gfx::Rect(layer_bounds)); | 754 gfx::Rect(layer_bounds)); |
| 749 | 755 |
| 750 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), | 756 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), |
| 751 active_layer_->tilings()->num_tilings()); | 757 active_layer_->tilings()->num_tilings()); |
| 752 | 758 |
| 753 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 759 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
| 754 EXPECT_GT(tilings->num_tilings(), 0u); | 760 EXPECT_GT(tilings->num_tilings(), 0u); |
| 755 for (size_t i = 0; i < tilings->num_tilings(); ++i) | 761 for (size_t i = 0; i < tilings->num_tilings(); ++i) |
| 756 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); | 762 VerifyAllPrioritizedTilesExistAndHavePile(tilings->tiling_at(i), |
| 763 pending_pile.get()); |
| 757 } | 764 } |
| 758 | 765 |
| 759 TEST_F(PictureLayerImplTest, UpdateTilesCreatesTilings) { | 766 TEST_F(PictureLayerImplTest, UpdateTilesCreatesTilings) { |
| 760 gfx::Size tile_size(400, 400); | 767 gfx::Size tile_size(400, 400); |
| 761 gfx::Size layer_bounds(1300, 1900); | 768 gfx::Size layer_bounds(1300, 1900); |
| 762 | 769 |
| 763 scoped_refptr<FakePicturePileImpl> pending_pile = | 770 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 764 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 771 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 765 scoped_refptr<FakePicturePileImpl> active_pile = | 772 scoped_refptr<FakePicturePileImpl> active_pile = |
| 766 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 773 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 4217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4984 host_impl_.SetDeviceScaleFactor(1.f); | 4991 host_impl_.SetDeviceScaleFactor(1.f); |
| 4985 | 4992 |
| 4986 scoped_refptr<FakePicturePileImpl> pending_pile = | 4993 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 4987 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4994 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4988 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 4995 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 4989 | 4996 |
| 4990 EXPECT_TRUE(pending_layer_->RasterSourceUsesLCDText()); | 4997 EXPECT_TRUE(pending_layer_->RasterSourceUsesLCDText()); |
| 4991 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles()); | 4998 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles()); |
| 4992 std::vector<Tile*> tiles = | 4999 std::vector<Tile*> tiles = |
| 4993 pending_layer_->HighResTiling()->AllTilesForTesting(); | 5000 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 5001 auto prioritized_tiles = pending_layer_->HighResTiling() |
| 5002 ->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 5003 |
| 4994 for (Tile* tile : tiles) | 5004 for (Tile* tile : tiles) |
| 4995 EXPECT_EQ(pending_layer_->raster_source(), tile->raster_source()); | 5005 EXPECT_EQ(pending_layer_->raster_source(), |
| 5006 prioritized_tiles[tile].raster_source()); |
| 4996 | 5007 |
| 4997 pending_layer_->draw_properties().can_use_lcd_text = false; | 5008 pending_layer_->draw_properties().can_use_lcd_text = false; |
| 4998 pending_layer_->UpdateCanUseLCDTextAfterCommit(); | 5009 pending_layer_->UpdateCanUseLCDTextAfterCommit(); |
| 4999 | 5010 |
| 5000 EXPECT_FALSE(pending_layer_->RasterSourceUsesLCDText()); | 5011 EXPECT_FALSE(pending_layer_->RasterSourceUsesLCDText()); |
| 5001 EXPECT_NE(pending_pile.get(), pending_layer_->raster_source()); | 5012 EXPECT_NE(pending_pile.get(), pending_layer_->raster_source()); |
| 5002 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles()); | 5013 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles()); |
| 5003 tiles = pending_layer_->HighResTiling()->AllTilesForTesting(); | 5014 tiles = pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 5015 prioritized_tiles = pending_layer_->HighResTiling() |
| 5016 ->UpdateAndGetAllPrioritizedTilesForTesting(); |
| 5004 for (Tile* tile : tiles) | 5017 for (Tile* tile : tiles) |
| 5005 EXPECT_EQ(pending_layer_->raster_source(), tile->raster_source()); | 5018 EXPECT_EQ(pending_layer_->raster_source(), |
| 5019 prioritized_tiles[tile].raster_source()); |
| 5006 } | 5020 } |
| 5007 | 5021 |
| 5008 class TileSizeSettings : public GpuRasterizationEnabledSettings { | 5022 class TileSizeSettings : public GpuRasterizationEnabledSettings { |
| 5009 public: | 5023 public: |
| 5010 TileSizeSettings() { | 5024 TileSizeSettings() { |
| 5011 default_tile_size = gfx::Size(100, 100); | 5025 default_tile_size = gfx::Size(100, 100); |
| 5012 max_untiled_layer_size = gfx::Size(200, 200); | 5026 max_untiled_layer_size = gfx::Size(200, 200); |
| 5013 } | 5027 } |
| 5014 }; | 5028 }; |
| 5015 | 5029 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5074 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 5088 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 5075 EXPECT_EQ(result.width(), 448); | 5089 EXPECT_EQ(result.width(), 448); |
| 5076 EXPECT_EQ(result.height(), 448); | 5090 EXPECT_EQ(result.height(), 448); |
| 5077 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 5091 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 5078 EXPECT_EQ(result.width(), 512); | 5092 EXPECT_EQ(result.width(), 512); |
| 5079 EXPECT_EQ(result.height(), 500 + 2); | 5093 EXPECT_EQ(result.height(), 500 + 2); |
| 5080 } | 5094 } |
| 5081 | 5095 |
| 5082 } // namespace | 5096 } // namespace |
| 5083 } // namespace cc | 5097 } // namespace cc |
| OLD | NEW |