| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/tiles/picture_layer_tiling.h" | 5 #include "cc/tiles/picture_layer_tiling.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return base::WrapUnique(new TestablePictureLayerTiling( | 54 return base::WrapUnique(new TestablePictureLayerTiling( |
| 55 tree, contents_scale, raster_source, client, | 55 tree, contents_scale, raster_source, client, |
| 56 settings.tiling_interest_area_padding, | 56 settings.tiling_interest_area_padding, |
| 57 settings.skewport_target_time_in_seconds, | 57 settings.skewport_target_time_in_seconds, |
| 58 settings.skewport_extrapolation_limit_in_screen_pixels, | 58 settings.skewport_extrapolation_limit_in_screen_pixels, |
| 59 312.f, /* min_preraster_distance */ | 59 312.f, /* min_preraster_distance */ |
| 60 settings.max_preraster_distance_in_screen_pixels)); | 60 settings.max_preraster_distance_in_screen_pixels)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 63 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 64 PriorityRectType visible_rect_type() const { |
| 65 return PriorityRectType::VISIBLE_RECT; |
| 66 } |
| 64 | 67 |
| 65 using PictureLayerTiling::RemoveTileAt; | 68 using PictureLayerTiling::RemoveTileAt; |
| 66 using PictureLayerTiling::RemoveTilesInRegion; | 69 using PictureLayerTiling::RemoveTilesInRegion; |
| 70 using PictureLayerTiling::ComputePriorityRectTypeForTile; |
| 67 | 71 |
| 68 protected: | 72 protected: |
| 69 TestablePictureLayerTiling(WhichTree tree, | 73 TestablePictureLayerTiling(WhichTree tree, |
| 70 float contents_scale, | 74 float contents_scale, |
| 71 scoped_refptr<RasterSource> raster_source, | 75 scoped_refptr<RasterSource> raster_source, |
| 72 PictureLayerTilingClient* client, | 76 PictureLayerTilingClient* client, |
| 73 size_t tiling_interest_area_padding, | 77 size_t tiling_interest_area_padding, |
| 74 float skewport_target_time, | 78 float skewport_target_time, |
| 75 int skewport_extrapolation_limit, | 79 int skewport_extrapolation_limit, |
| 76 float min_preraster_distance, | 80 float min_preraster_distance, |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 | 952 |
| 949 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 953 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
| 950 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 954 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
| 951 | 955 |
| 952 // Reset the active tiling. The recycle tiles should be released too. | 956 // Reset the active tiling. The recycle tiles should be released too. |
| 953 active_tiling->Reset(); | 957 active_tiling->Reset(); |
| 954 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 958 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
| 955 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 959 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
| 956 } | 960 } |
| 957 | 961 |
| 962 TEST(PictureLayerTilingTest, EdgeCaseTileNowAndRequired) { |
| 963 FakePictureLayerTilingClient pending_client; |
| 964 pending_client.SetTileSize(gfx::Size(100, 100)); |
| 965 |
| 966 scoped_refptr<FakeRasterSource> raster_source = |
| 967 FakeRasterSource::CreateFilled(gfx::Size(500, 500)); |
| 968 std::unique_ptr<TestablePictureLayerTiling> pending_tiling = |
| 969 TestablePictureLayerTiling::Create(PENDING_TREE, 1.0f, raster_source, |
| 970 &pending_client, LayerTreeSettings()); |
| 971 pending_tiling->set_resolution(HIGH_RESOLUTION); |
| 972 pending_tiling->set_can_require_tiles_for_activation(true); |
| 973 |
| 974 // The tile at (1, 0) should be touching the visible rect, but not |
| 975 // intersecting it. |
| 976 gfx::Rect visible_rect = gfx::Rect(0, 0, 99, 99); |
| 977 gfx::Rect eventually_rect = gfx::Rect(0, 0, 500, 500); |
| 978 pending_tiling->ComputeTilePriorityRects(visible_rect, visible_rect, |
| 979 visible_rect, eventually_rect, 1.f, |
| 980 Occlusion()); |
| 981 |
| 982 Tile* tile = pending_tiling->TileAt(1, 0); |
| 983 EXPECT_NE(pending_tiling->visible_rect_type(), |
| 984 pending_tiling->ComputePriorityRectTypeForTile(tile)); |
| 985 EXPECT_FALSE(pending_tiling->IsTileRequiredForActivation(tile)); |
| 986 EXPECT_TRUE(tile->content_rect().Intersects(visible_rect)); |
| 987 EXPECT_FALSE(pending_tiling->tiling_data() |
| 988 ->TileBounds(tile->tiling_i_index(), tile->tiling_j_index()) |
| 989 .Intersects(visible_rect)); |
| 990 |
| 991 // Now the tile at (1, 0) should be intersecting the visible rect. |
| 992 visible_rect = gfx::Rect(0, 0, 100, 100); |
| 993 pending_tiling->ComputeTilePriorityRects(visible_rect, visible_rect, |
| 994 visible_rect, eventually_rect, 1.f, |
| 995 Occlusion()); |
| 996 EXPECT_EQ(pending_tiling->visible_rect_type(), |
| 997 pending_tiling->ComputePriorityRectTypeForTile(tile)); |
| 998 EXPECT_TRUE(pending_tiling->IsTileRequiredForActivation(tile)); |
| 999 EXPECT_TRUE(tile->content_rect().Intersects(visible_rect)); |
| 1000 EXPECT_TRUE(pending_tiling->tiling_data() |
| 1001 ->TileBounds(tile->tiling_i_index(), tile->tiling_j_index()) |
| 1002 .Intersects(visible_rect)); |
| 1003 } |
| 1004 |
| 958 TEST_F(PictureLayerTilingIteratorTest, ResizeTilesAndUpdateToCurrent) { | 1005 TEST_F(PictureLayerTilingIteratorTest, ResizeTilesAndUpdateToCurrent) { |
| 959 // The tiling has four rows and three columns. | 1006 // The tiling has four rows and three columns. |
| 960 Initialize(gfx::Size(150, 100), 1.f, gfx::Size(250, 150)); | 1007 Initialize(gfx::Size(150, 100), 1.f, gfx::Size(250, 150)); |
| 961 tiling_->CreateAllTilesForTesting(); | 1008 tiling_->CreateAllTilesForTesting(); |
| 962 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); | 1009 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 963 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 1010 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 964 EXPECT_EQ(4u, tiling_->AllTilesForTesting().size()); | 1011 EXPECT_EQ(4u, tiling_->AllTilesForTesting().size()); |
| 965 | 1012 |
| 966 client_.SetTileSize(gfx::Size(250, 200)); | 1013 client_.SetTileSize(gfx::Size(250, 200)); |
| 967 | 1014 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 | 1131 |
| 1085 active_tiling->TakeTilesAndPropertiesFrom(tiling_.get(), | 1132 active_tiling->TakeTilesAndPropertiesFrom(tiling_.get(), |
| 1086 Region(gfx::Rect(bounds))); | 1133 Region(gfx::Rect(bounds))); |
| 1087 for (const auto* tile : tiles) { | 1134 for (const auto* tile : tiles) { |
| 1088 EXPECT_EQ(tile->tiling(), active_tiling.get()); | 1135 EXPECT_EQ(tile->tiling(), active_tiling.get()); |
| 1089 } | 1136 } |
| 1090 } | 1137 } |
| 1091 | 1138 |
| 1092 } // namespace | 1139 } // namespace |
| 1093 } // namespace cc | 1140 } // namespace cc |
| OLD | NEW |