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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 float contents_scale, | 57 float contents_scale, |
58 const gfx::Size& layer_bounds, | 58 const gfx::Size& layer_bounds, |
59 PictureLayerTilingClient* client) { | 59 PictureLayerTilingClient* client) { |
60 return make_scoped_ptr(new TestablePictureLayerTiling( | 60 return make_scoped_ptr(new TestablePictureLayerTiling( |
61 contents_scale, | 61 contents_scale, |
62 layer_bounds, | 62 layer_bounds, |
63 client)); | 63 client)); |
64 } | 64 } |
65 | 65 |
66 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 66 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 67 bool eviction_tiles_cache_valid() const { |
| 68 return eviction_tiles_cache_valid_; |
| 69 } |
67 | 70 |
68 using PictureLayerTiling::ComputeSkewport; | 71 using PictureLayerTiling::ComputeSkewport; |
| 72 using PictureLayerTiling::RemoveTileAt; |
69 | 73 |
70 protected: | 74 protected: |
71 TestablePictureLayerTiling(float contents_scale, | 75 TestablePictureLayerTiling(float contents_scale, |
72 const gfx::Size& layer_bounds, | 76 const gfx::Size& layer_bounds, |
73 PictureLayerTilingClient* client) | 77 PictureLayerTilingClient* client) |
74 : PictureLayerTiling(contents_scale, layer_bounds, client) { } | 78 : PictureLayerTiling(contents_scale, layer_bounds, client) { } |
75 }; | 79 }; |
76 | 80 |
77 class PictureLayerTilingIteratorTest : public testing::Test { | 81 class PictureLayerTilingIteratorTest : public testing::Test { |
78 public: | 82 public: |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 } | 1341 } |
1338 | 1342 |
1339 it = PictureLayerTiling::TilingEvictionTileIterator( | 1343 it = PictureLayerTiling::TilingEvictionTileIterator( |
1340 tiling.get(), | 1344 tiling.get(), |
1341 SMOOTHNESS_TAKES_PRIORITY, | 1345 SMOOTHNESS_TAKES_PRIORITY, |
1342 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION); | 1346 PictureLayerTiling::NOW_AND_REQUIRED_FOR_ACTIVATION); |
1343 EXPECT_FALSE(it); | 1347 EXPECT_FALSE(it); |
1344 | 1348 |
1345 EXPECT_GT(all_tiles_set.size(), 0u); | 1349 EXPECT_GT(all_tiles_set.size(), 0u); |
1346 EXPECT_EQ(all_tiles_set, eviction_tiles); | 1350 EXPECT_EQ(all_tiles_set, eviction_tiles); |
| 1351 |
| 1352 EXPECT_TRUE(tiling->eviction_tiles_cache_valid()); |
| 1353 tiling->RemoveTileAt(0, 0, nullptr); |
| 1354 EXPECT_FALSE(tiling->eviction_tiles_cache_valid()); |
1347 } | 1355 } |
1348 | 1356 |
1349 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { | 1357 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { |
1350 gfx::Size layer_bounds(1099, 801); | 1358 gfx::Size layer_bounds(1099, 801); |
1351 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1359 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
1352 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1360 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
1353 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1361 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
1354 | 1362 |
1355 client_.set_tree(ACTIVE_TREE); | 1363 client_.set_tree(ACTIVE_TREE); |
1356 tiling_->ComputeTilePriorityRects( | 1364 tiling_->ComputeTilePriorityRects( |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); | 2172 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); |
2165 | 2173 |
2166 // Reset the active tiling. The recycle tiles should be released too. | 2174 // Reset the active tiling. The recycle tiles should be released too. |
2167 active_tiling->Reset(); | 2175 active_tiling->Reset(); |
2168 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 2176 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
2169 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2177 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
2170 } | 2178 } |
2171 | 2179 |
2172 } // namespace | 2180 } // namespace |
2173 } // namespace cc | 2181 } // namespace cc |
OLD | NEW |