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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 protected: | 184 protected: |
185 FakePictureLayerTilingClient client_; | 185 FakePictureLayerTilingClient client_; |
186 scoped_ptr<TestablePictureLayerTiling> tiling_; | 186 scoped_ptr<TestablePictureLayerTiling> tiling_; |
187 | 187 |
188 private: | 188 private: |
189 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); | 189 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); |
190 }; | 190 }; |
191 | 191 |
192 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { | 192 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { |
193 // Verifies that a resize deletes tiles that used to be on the edge. | 193 // Verifies that a resize with invalidation for newly exposed pixels will |
| 194 // deletes tiles that intersect that invalidation. |
194 gfx::Size tile_size(100, 100); | 195 gfx::Size tile_size(100, 100); |
195 gfx::Size original_layer_size(10, 10); | 196 gfx::Size original_layer_size(10, 10); |
196 Initialize(tile_size, 1.f, original_layer_size); | 197 Initialize(tile_size, 1.f, original_layer_size); |
197 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 198 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
198 | 199 |
199 // Tiling only has one tile, since its total size is less than one. | 200 // Tiling only has one tile, since its total size is less than one. |
200 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 201 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
201 | 202 |
202 // Stop creating tiles so that any invalidations are left as holes. | 203 // Stop creating tiles so that any invalidations are left as holes. |
203 client_.set_allow_create_tile(false); | 204 client_.set_allow_create_tile(false); |
204 | 205 |
205 tiling_->SetLayerBounds(gfx::Size(200, 200)); | 206 Region invalidation = |
| 207 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 208 tiling_->UpdateTilesToCurrentPile(invalidation, gfx::Size(200, 200)); |
206 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 209 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
207 } | 210 } |
208 | 211 |
| 212 TEST_F(PictureLayerTilingIteratorTest, ResizeOverBorderPixelsDeletesTiles) { |
| 213 // Verifies that a resize with invalidation for newly exposed pixels will |
| 214 // deletes tiles that intersect that invalidation. |
| 215 gfx::Size tile_size(100, 100); |
| 216 gfx::Size original_layer_size(99, 99); |
| 217 Initialize(tile_size, 1.f, original_layer_size); |
| 218 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
| 219 |
| 220 // Tiling only has one tile, since its total size is less than one. |
| 221 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 222 |
| 223 // Stop creating tiles so that any invalidations are left as holes. |
| 224 client_.set_allow_create_tile(false); |
| 225 |
| 226 Region invalidation = |
| 227 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
| 228 tiling_->UpdateTilesToCurrentPile(invalidation, gfx::Size(200, 200)); |
| 229 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
| 230 |
| 231 // The original tile was the same size after resize, but it would include new |
| 232 // border pixels. |
| 233 EXPECT_EQ(gfx::Rect(original_layer_size), |
| 234 tiling_->TilingDataForTesting().TileBounds(0, 0)); |
| 235 } |
| 236 |
209 TEST_F(PictureLayerTilingIteratorTest, LiveTilesExactlyCoverLiveTileRect) { | 237 TEST_F(PictureLayerTilingIteratorTest, LiveTilesExactlyCoverLiveTileRect) { |
210 Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801)); | 238 Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801)); |
211 SetLiveRectAndVerifyTiles(gfx::Rect(100, 100)); | 239 SetLiveRectAndVerifyTiles(gfx::Rect(100, 100)); |
212 SetLiveRectAndVerifyTiles(gfx::Rect(101, 99)); | 240 SetLiveRectAndVerifyTiles(gfx::Rect(101, 99)); |
213 SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); | 241 SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); |
214 SetLiveRectAndVerifyTiles(gfx::Rect(1, 801)); | 242 SetLiveRectAndVerifyTiles(gfx::Rect(1, 801)); |
215 SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); | 243 SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); |
216 SetLiveRectAndVerifyTiles(gfx::Rect(201, 800)); | 244 SetLiveRectAndVerifyTiles(gfx::Rect(201, 800)); |
217 } | 245 } |
218 | 246 |
(...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1840 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1813 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1841 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1814 | 1842 |
1815 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); | 1843 priority = tiling->TileAt(1, 0)->priority(ACTIVE_TREE); |
1816 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); | 1844 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); |
1817 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 1845 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
1818 } | 1846 } |
1819 | 1847 |
1820 } // namespace | 1848 } // namespace |
1821 } // namespace cc | 1849 } // namespace cc |
OLD | NEW |