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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 class TestablePictureLayerTiling : public PictureLayerTiling { | 49 class TestablePictureLayerTiling : public PictureLayerTiling { |
50 public: | 50 public: |
51 using PictureLayerTiling::SetLiveTilesRect; | 51 using PictureLayerTiling::SetLiveTilesRect; |
52 using PictureLayerTiling::TileAt; | 52 using PictureLayerTiling::TileAt; |
53 | 53 |
54 static scoped_ptr<TestablePictureLayerTiling> Create( | 54 static scoped_ptr<TestablePictureLayerTiling> Create( |
55 float contents_scale, | 55 float contents_scale, |
56 const gfx::Size& layer_bounds, | 56 const gfx::Size& layer_bounds, |
57 PictureLayerTilingClient* client) { | 57 PictureLayerTilingClient* client, |
| 58 const LayerTreeSettings& settings) { |
58 return make_scoped_ptr(new TestablePictureLayerTiling( | 59 return make_scoped_ptr(new TestablePictureLayerTiling( |
59 contents_scale, | 60 contents_scale, layer_bounds, client, |
60 layer_bounds, | 61 settings.max_tiles_for_interest_area, |
61 client)); | 62 settings.skewport_target_time_in_seconds, |
| 63 settings.skewport_extrapolation_limit_in_content_pixels)); |
62 } | 64 } |
63 | 65 |
64 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 66 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
65 bool eviction_tiles_cache_valid() const { | |
66 return eviction_tiles_cache_valid_; | |
67 } | |
68 | 67 |
69 using PictureLayerTiling::ComputeSkewport; | 68 using PictureLayerTiling::ComputeSkewport; |
70 using PictureLayerTiling::RemoveTileAt; | 69 using PictureLayerTiling::RemoveTileAt; |
71 | 70 |
72 protected: | 71 protected: |
73 TestablePictureLayerTiling(float contents_scale, | 72 TestablePictureLayerTiling(float contents_scale, |
74 const gfx::Size& layer_bounds, | 73 const gfx::Size& layer_bounds, |
75 PictureLayerTilingClient* client) | 74 PictureLayerTilingClient* client, |
76 : PictureLayerTiling(contents_scale, layer_bounds, client) { } | 75 size_t max_tiles_for_interest_area, |
| 76 float skewport_target_time, |
| 77 int skewport_extrapolation_limit) |
| 78 : PictureLayerTiling(contents_scale, |
| 79 layer_bounds, |
| 80 client, |
| 81 max_tiles_for_interest_area, |
| 82 skewport_target_time, |
| 83 skewport_extrapolation_limit) {} |
77 }; | 84 }; |
78 | 85 |
79 class PictureLayerTilingIteratorTest : public testing::Test { | 86 class PictureLayerTilingIteratorTest : public testing::Test { |
80 public: | 87 public: |
81 PictureLayerTilingIteratorTest() {} | 88 PictureLayerTilingIteratorTest() {} |
82 virtual ~PictureLayerTilingIteratorTest() {} | 89 virtual ~PictureLayerTilingIteratorTest() {} |
83 | 90 |
84 void Initialize(const gfx::Size& tile_size, | 91 void Initialize(const gfx::Size& tile_size, |
85 float contents_scale, | 92 float contents_scale, |
86 const gfx::Size& layer_bounds) { | 93 const gfx::Size& layer_bounds) { |
87 client_.SetTileSize(tile_size); | 94 client_.SetTileSize(tile_size); |
88 client_.set_tree(PENDING_TREE); | 95 client_.set_tree(PENDING_TREE); |
89 tiling_ = TestablePictureLayerTiling::Create(contents_scale, | 96 tiling_ = TestablePictureLayerTiling::Create(contents_scale, layer_bounds, |
90 layer_bounds, | 97 &client_, LayerTreeSettings()); |
91 &client_); | |
92 } | 98 } |
93 | 99 |
94 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { | 100 void SetLiveRectAndVerifyTiles(const gfx::Rect& live_tiles_rect) { |
95 tiling_->SetLiveTilesRect(live_tiles_rect); | 101 tiling_->SetLiveTilesRect(live_tiles_rect); |
96 | 102 |
97 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); | 103 std::vector<Tile*> tiles = tiling_->AllTilesForTesting(); |
98 for (std::vector<Tile*>::iterator iter = tiles.begin(); | 104 for (std::vector<Tile*>::iterator iter = tiles.begin(); |
99 iter != tiles.end(); | 105 iter != tiles.end(); |
100 ++iter) { | 106 ++iter) { |
101 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); | 107 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 179 |
174 void VerifyTilesCoverNonContainedRect(float rect_scale, | 180 void VerifyTilesCoverNonContainedRect(float rect_scale, |
175 const gfx::Rect& dest_rect) { | 181 const gfx::Rect& dest_rect) { |
176 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; | 182 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; |
177 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( | 183 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( |
178 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); | 184 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); |
179 clamped_rect.Intersect(dest_rect); | 185 clamped_rect.Intersect(dest_rect); |
180 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); | 186 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); |
181 } | 187 } |
182 | 188 |
183 void set_max_tiles_for_interest_area(size_t area) { | |
184 client_.set_max_tiles_for_interest_area(area); | |
185 } | |
186 | |
187 protected: | 189 protected: |
188 FakePictureLayerTilingClient client_; | 190 FakePictureLayerTilingClient client_; |
189 scoped_ptr<TestablePictureLayerTiling> tiling_; | 191 scoped_ptr<TestablePictureLayerTiling> tiling_; |
190 | 192 |
191 private: | 193 private: |
192 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); | 194 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); |
193 }; | 195 }; |
194 | 196 |
195 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { | 197 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { |
196 // Verifies that a resize with invalidation for newly exposed pixels will | 198 // Verifies that a resize with invalidation for newly exposed pixels will |
197 // deletes tiles that intersect that invalidation. | 199 // deletes tiles that intersect that invalidation. |
198 gfx::Size tile_size(100, 100); | 200 gfx::Size tile_size(100, 100); |
199 gfx::Size original_layer_size(10, 10); | 201 gfx::Size original_layer_size(10, 10); |
200 Initialize(tile_size, 1.f, original_layer_size); | 202 Initialize(tile_size, 1.f, original_layer_size); |
201 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 203 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
202 | 204 |
203 // Tiling only has one tile, since its total size is less than one. | 205 // Tiling only has one tile, since its total size is less than one. |
204 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 206 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
205 | 207 |
206 // Stop creating tiles so that any invalidations are left as holes. | 208 // Stop creating tiles so that any invalidations are left as holes. |
207 client_.set_allow_create_tile(false); | 209 client_.set_allow_create_tile(false); |
208 | 210 |
209 Region invalidation = | 211 Region invalidation = |
210 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 212 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
211 tiling_->UpdateTilesToCurrentRasterSource(client_.raster_source(), | 213 tiling_->Resize(gfx::Size(200, 200)); |
212 invalidation, gfx::Size(200, 200)); | 214 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 215 tiling_->Invalidate(invalidation); |
213 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 216 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
214 } | 217 } |
215 | 218 |
216 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { | 219 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { |
217 // The tiling has three rows and columns. | 220 // The tiling has three rows and columns. |
218 Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 250)); | 221 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 250)); |
219 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 222 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
220 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); | 223 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
221 | 224 |
222 // The live tiles rect is at the very edge of the right-most and | 225 // The live tiles rect is at the very edge of the right-most and |
223 // bottom-most tiles. Their border pixels would still be inside the live | 226 // bottom-most tiles. Their border pixels would still be inside the live |
224 // tiles rect, but the tiles should not exist just for that. | 227 // tiles rect, but the tiles should not exist just for that. |
225 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); | 228 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); |
226 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 2).y(); | 229 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 2).y(); |
227 | 230 |
228 SetLiveRectAndVerifyTiles(gfx::Rect(right, bottom)); | 231 SetLiveRectAndVerifyTiles(gfx::Rect(right, bottom)); |
229 EXPECT_FALSE(tiling_->TileAt(2, 0)); | 232 EXPECT_FALSE(tiling_->TileAt(2, 0)); |
230 EXPECT_FALSE(tiling_->TileAt(2, 1)); | 233 EXPECT_FALSE(tiling_->TileAt(2, 1)); |
231 EXPECT_FALSE(tiling_->TileAt(2, 2)); | 234 EXPECT_FALSE(tiling_->TileAt(2, 2)); |
232 EXPECT_FALSE(tiling_->TileAt(1, 2)); | 235 EXPECT_FALSE(tiling_->TileAt(1, 2)); |
233 EXPECT_FALSE(tiling_->TileAt(0, 2)); | 236 EXPECT_FALSE(tiling_->TileAt(0, 2)); |
234 | 237 |
235 // Verify CreateMissingTilesInLiveTilesRect respects this. | 238 // Verify CreateMissingTilesInLiveTilesRect respects this. |
236 tiling_->CreateMissingTilesInLiveTilesRect(); | 239 tiling_->CreateMissingTilesInLiveTilesRect(); |
237 EXPECT_FALSE(tiling_->TileAt(2, 0)); | 240 EXPECT_FALSE(tiling_->TileAt(2, 0)); |
238 EXPECT_FALSE(tiling_->TileAt(2, 1)); | 241 EXPECT_FALSE(tiling_->TileAt(2, 1)); |
239 EXPECT_FALSE(tiling_->TileAt(2, 2)); | 242 EXPECT_FALSE(tiling_->TileAt(2, 2)); |
240 EXPECT_FALSE(tiling_->TileAt(1, 2)); | 243 EXPECT_FALSE(tiling_->TileAt(1, 2)); |
241 EXPECT_FALSE(tiling_->TileAt(0, 2)); | 244 EXPECT_FALSE(tiling_->TileAt(0, 2)); |
242 } | 245 } |
243 | 246 |
244 TEST_F(PictureLayerTilingIteratorTest, ResizeTilingOverTileBorders) { | 247 TEST_F(PictureLayerTilingIteratorTest, ResizeTilingOverTileBorders) { |
245 // The tiling has four rows and three columns. | 248 // The tiling has four rows and three columns. |
246 Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 350)); | 249 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 350)); |
247 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 250 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
248 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); | 251 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); |
249 | 252 |
250 // The live tiles rect covers the whole tiling. | 253 // The live tiles rect covers the whole tiling. |
251 SetLiveRectAndVerifyTiles(gfx::Rect(250, 350)); | 254 SetLiveRectAndVerifyTiles(gfx::Rect(250, 350)); |
252 | 255 |
253 // Tiles in the bottom row and right column exist. | 256 // Tiles in the bottom row and right column exist. |
254 EXPECT_TRUE(tiling_->TileAt(2, 0)); | 257 EXPECT_TRUE(tiling_->TileAt(2, 0)); |
255 EXPECT_TRUE(tiling_->TileAt(2, 1)); | 258 EXPECT_TRUE(tiling_->TileAt(2, 1)); |
256 EXPECT_TRUE(tiling_->TileAt(2, 2)); | 259 EXPECT_TRUE(tiling_->TileAt(2, 2)); |
257 EXPECT_TRUE(tiling_->TileAt(2, 3)); | 260 EXPECT_TRUE(tiling_->TileAt(2, 3)); |
258 EXPECT_TRUE(tiling_->TileAt(1, 3)); | 261 EXPECT_TRUE(tiling_->TileAt(1, 3)); |
259 EXPECT_TRUE(tiling_->TileAt(0, 3)); | 262 EXPECT_TRUE(tiling_->TileAt(0, 3)); |
260 | 263 |
261 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); | 264 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); |
262 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); | 265 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); |
263 | 266 |
264 // Shrink the tiling so that the last tile row/column is entirely in the | 267 // Shrink the tiling so that the last tile row/column is entirely in the |
265 // border pixels of the interior tiles. That row/column is removed. | 268 // border pixels of the interior tiles. That row/column is removed. |
266 Region invalidation; | 269 tiling_->Resize(gfx::Size(right + 1, bottom + 1)); |
267 tiling_->UpdateTilesToCurrentRasterSource( | |
268 client_.raster_source(), invalidation, gfx::Size(right + 1, bottom + 1)); | |
269 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); | 270 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); |
270 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); | 271 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); |
271 | 272 |
272 // The live tiles rect was clamped to the pile size. | 273 // The live tiles rect was clamped to the pile size. |
273 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 274 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
274 | 275 |
275 // Since the row/column is gone, the tiles should be gone too. | 276 // Since the row/column is gone, the tiles should be gone too. |
276 EXPECT_FALSE(tiling_->TileAt(2, 0)); | 277 EXPECT_FALSE(tiling_->TileAt(2, 0)); |
277 EXPECT_FALSE(tiling_->TileAt(2, 1)); | 278 EXPECT_FALSE(tiling_->TileAt(2, 1)); |
278 EXPECT_FALSE(tiling_->TileAt(2, 2)); | 279 EXPECT_FALSE(tiling_->TileAt(2, 2)); |
279 EXPECT_FALSE(tiling_->TileAt(2, 3)); | 280 EXPECT_FALSE(tiling_->TileAt(2, 3)); |
280 EXPECT_FALSE(tiling_->TileAt(1, 3)); | 281 EXPECT_FALSE(tiling_->TileAt(1, 3)); |
281 EXPECT_FALSE(tiling_->TileAt(0, 3)); | 282 EXPECT_FALSE(tiling_->TileAt(0, 3)); |
282 | 283 |
283 // Growing outside the current right/bottom tiles border pixels should create | 284 // Growing outside the current right/bottom tiles border pixels should create |
284 // the tiles again, even though the live rect has not changed size. | 285 // the tiles again, even though the live rect has not changed size. |
285 tiling_->UpdateTilesToCurrentRasterSource( | 286 tiling_->Resize(gfx::Size(right + 2, bottom + 2)); |
286 client_.raster_source(), invalidation, gfx::Size(right + 2, bottom + 2)); | |
287 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 287 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
288 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); | 288 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); |
289 | 289 |
290 // Not changed. | 290 // Not changed. |
291 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); | 291 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); |
292 | 292 |
293 // The last row/column tiles are inside the live tiles rect. | 293 // The last row/column tiles are inside the live tiles rect. |
294 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( | 294 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( |
295 tiling_->TilingDataForTesting().TileBounds(2, 0))); | 295 tiling_->TilingDataForTesting().TileBounds(2, 0))); |
296 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( | 296 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( |
297 tiling_->TilingDataForTesting().TileBounds(0, 3))); | 297 tiling_->TilingDataForTesting().TileBounds(0, 3))); |
298 | 298 |
299 EXPECT_TRUE(tiling_->TileAt(2, 0)); | 299 EXPECT_TRUE(tiling_->TileAt(2, 0)); |
300 EXPECT_TRUE(tiling_->TileAt(2, 1)); | 300 EXPECT_TRUE(tiling_->TileAt(2, 1)); |
301 EXPECT_TRUE(tiling_->TileAt(2, 2)); | 301 EXPECT_TRUE(tiling_->TileAt(2, 2)); |
302 EXPECT_TRUE(tiling_->TileAt(2, 3)); | 302 EXPECT_TRUE(tiling_->TileAt(2, 3)); |
303 EXPECT_TRUE(tiling_->TileAt(1, 3)); | 303 EXPECT_TRUE(tiling_->TileAt(1, 3)); |
304 EXPECT_TRUE(tiling_->TileAt(0, 3)); | 304 EXPECT_TRUE(tiling_->TileAt(0, 3)); |
305 } | 305 } |
306 | 306 |
307 TEST_F(PictureLayerTilingIteratorTest, ResizeLiveTileRectOverTileBorders) { | 307 TEST_F(PictureLayerTilingIteratorTest, ResizeLiveTileRectOverTileBorders) { |
308 // The tiling has three rows and columns. | 308 // The tiling has three rows and columns. |
309 Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 350)); | 309 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 350)); |
310 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 310 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
311 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); | 311 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); |
312 | 312 |
313 // The live tiles rect covers the whole tiling. | 313 // The live tiles rect covers the whole tiling. |
314 SetLiveRectAndVerifyTiles(gfx::Rect(250, 350)); | 314 SetLiveRectAndVerifyTiles(gfx::Rect(250, 350)); |
315 | 315 |
316 // Tiles in the bottom row and right column exist. | 316 // Tiles in the bottom row and right column exist. |
317 EXPECT_TRUE(tiling_->TileAt(2, 0)); | 317 EXPECT_TRUE(tiling_->TileAt(2, 0)); |
318 EXPECT_TRUE(tiling_->TileAt(2, 1)); | 318 EXPECT_TRUE(tiling_->TileAt(2, 1)); |
319 EXPECT_TRUE(tiling_->TileAt(2, 2)); | 319 EXPECT_TRUE(tiling_->TileAt(2, 2)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 EXPECT_TRUE(tiling_->TileAt(0, 3)); | 364 EXPECT_TRUE(tiling_->TileAt(0, 3)); |
365 EXPECT_TRUE(tiling_->TileAt(0, 2)); | 365 EXPECT_TRUE(tiling_->TileAt(0, 2)); |
366 EXPECT_TRUE(tiling_->TileAt(0, 1)); | 366 EXPECT_TRUE(tiling_->TileAt(0, 1)); |
367 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 367 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
368 EXPECT_TRUE(tiling_->TileAt(1, 0)); | 368 EXPECT_TRUE(tiling_->TileAt(1, 0)); |
369 EXPECT_TRUE(tiling_->TileAt(2, 0)); | 369 EXPECT_TRUE(tiling_->TileAt(2, 0)); |
370 } | 370 } |
371 | 371 |
372 TEST_F(PictureLayerTilingIteratorTest, ResizeLiveTileRectOverSameTiles) { | 372 TEST_F(PictureLayerTilingIteratorTest, ResizeLiveTileRectOverSameTiles) { |
373 // The tiling has four rows and three columns. | 373 // The tiling has four rows and three columns. |
374 Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 350)); | 374 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(250, 350)); |
375 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); | 375 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); |
376 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); | 376 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); |
377 | 377 |
378 // The live tiles rect covers the whole tiling. | 378 // The live tiles rect covers the whole tiling. |
379 SetLiveRectAndVerifyTiles(gfx::Rect(250, 350)); | 379 SetLiveRectAndVerifyTiles(gfx::Rect(250, 350)); |
380 | 380 |
381 // All tiles exist. | 381 // All tiles exist. |
382 for (int i = 0; i < 3; ++i) { | 382 for (int i = 0; i < 3; ++i) { |
383 for (int j = 0; j < 4; ++j) | 383 for (int j = 0; j < 4; ++j) |
384 EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; | 384 EXPECT_TRUE(tiling_->TileAt(i, j)) << i << "," << j; |
(...skipping 27 matching lines...) Expand all Loading... |
412 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); | 412 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); |
413 | 413 |
414 // Tiling only has one tile, since its total size is less than one. | 414 // Tiling only has one tile, since its total size is less than one. |
415 EXPECT_TRUE(tiling_->TileAt(0, 0)); | 415 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
416 | 416 |
417 // Stop creating tiles so that any invalidations are left as holes. | 417 // Stop creating tiles so that any invalidations are left as holes. |
418 client_.set_allow_create_tile(false); | 418 client_.set_allow_create_tile(false); |
419 | 419 |
420 Region invalidation = | 420 Region invalidation = |
421 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); | 421 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); |
422 tiling_->UpdateTilesToCurrentRasterSource(client_.raster_source(), | 422 tiling_->Resize(gfx::Size(200, 200)); |
423 invalidation, gfx::Size(200, 200)); | 423 EXPECT_TRUE(tiling_->TileAt(0, 0)); |
| 424 tiling_->Invalidate(invalidation); |
424 EXPECT_FALSE(tiling_->TileAt(0, 0)); | 425 EXPECT_FALSE(tiling_->TileAt(0, 0)); |
425 | 426 |
426 // The original tile was the same size after resize, but it would include new | 427 // The original tile was the same size after resize, but it would include new |
427 // border pixels. | 428 // border pixels. |
428 EXPECT_EQ(gfx::Rect(original_layer_size), | 429 EXPECT_EQ(gfx::Rect(original_layer_size), |
429 tiling_->TilingDataForTesting().TileBounds(0, 0)); | 430 tiling_->TilingDataForTesting().TileBounds(0, 0)); |
430 } | 431 } |
431 | 432 |
432 TEST_F(PictureLayerTilingIteratorTest, LiveTilesExactlyCoverLiveTileRect) { | 433 TEST_F(PictureLayerTilingIteratorTest, LiveTilesExactlyCoverLiveTileRect) { |
433 Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801)); | 434 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(1099, 801)); |
434 SetLiveRectAndVerifyTiles(gfx::Rect(100, 100)); | 435 SetLiveRectAndVerifyTiles(gfx::Rect(100, 100)); |
435 SetLiveRectAndVerifyTiles(gfx::Rect(101, 99)); | 436 SetLiveRectAndVerifyTiles(gfx::Rect(101, 99)); |
436 SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); | 437 SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); |
437 SetLiveRectAndVerifyTiles(gfx::Rect(1, 801)); | 438 SetLiveRectAndVerifyTiles(gfx::Rect(1, 801)); |
438 SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); | 439 SetLiveRectAndVerifyTiles(gfx::Rect(1099, 1)); |
439 SetLiveRectAndVerifyTiles(gfx::Rect(201, 800)); | 440 SetLiveRectAndVerifyTiles(gfx::Rect(201, 800)); |
440 } | 441 } |
441 | 442 |
442 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsNoScale) { | 443 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsNoScale) { |
443 Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801)); | 444 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(1099, 801)); |
444 VerifyTilesExactlyCoverRect(1, gfx::Rect()); | 445 VerifyTilesExactlyCoverRect(1, gfx::Rect()); |
445 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1099, 801)); | 446 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1099, 801)); |
446 VerifyTilesExactlyCoverRect(1, gfx::Rect(52, 83, 789, 412)); | 447 VerifyTilesExactlyCoverRect(1, gfx::Rect(52, 83, 789, 412)); |
447 | 448 |
448 // With borders, a size of 3x3 = 1 pixel of content. | 449 // With borders, a size of 3x3 = 1 pixel of content. |
449 Initialize(gfx::Size(3, 3), 1, gfx::Size(10, 10)); | 450 Initialize(gfx::Size(3, 3), 1.f, gfx::Size(10, 10)); |
450 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1, 1)); | 451 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1, 1)); |
451 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 2, 2)); | 452 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 2, 2)); |
452 VerifyTilesExactlyCoverRect(1, gfx::Rect(1, 1, 2, 2)); | 453 VerifyTilesExactlyCoverRect(1, gfx::Rect(1, 1, 2, 2)); |
453 VerifyTilesExactlyCoverRect(1, gfx::Rect(3, 2, 5, 2)); | 454 VerifyTilesExactlyCoverRect(1, gfx::Rect(3, 2, 5, 2)); |
454 } | 455 } |
455 | 456 |
456 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsTilingScale) { | 457 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsTilingScale) { |
457 Initialize(gfx::Size(200, 100), 2.0f, gfx::Size(1005, 2010)); | 458 Initialize(gfx::Size(200, 100), 2.0f, gfx::Size(1005, 2010)); |
458 VerifyTilesExactlyCoverRect(1, gfx::Rect()); | 459 VerifyTilesExactlyCoverRect(1, gfx::Rect()); |
459 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); | 460 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000)); | 526 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000)); |
526 | 527 |
527 // Partially covering content, but too large | 528 // Partially covering content, but too large |
528 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); | 529 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); |
529 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); | 530 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); |
530 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); | 531 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); |
531 } | 532 } |
532 | 533 |
533 TEST(PictureLayerTilingTest, SkewportLimits) { | 534 TEST(PictureLayerTilingTest, SkewportLimits) { |
534 FakePictureLayerTilingClient client; | 535 FakePictureLayerTilingClient client; |
535 client.set_skewport_extrapolation_limit_in_content_pixels(75); | |
536 client.set_tree(ACTIVE_TREE); | 536 client.set_tree(ACTIVE_TREE); |
537 scoped_ptr<TestablePictureLayerTiling> tiling; | 537 scoped_ptr<TestablePictureLayerTiling> tiling; |
538 | 538 |
539 gfx::Rect viewport(0, 0, 100, 100); | 539 gfx::Rect viewport(0, 0, 100, 100); |
540 gfx::Size layer_bounds(200, 200); | 540 gfx::Size layer_bounds(200, 200); |
541 | 541 |
542 client.SetTileSize(gfx::Size(100, 100)); | 542 client.SetTileSize(gfx::Size(100, 100)); |
543 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 543 LayerTreeSettings settings; |
| 544 settings.max_tiles_for_interest_area = 10000; |
| 545 settings.skewport_extrapolation_limit_in_content_pixels = 75; |
| 546 tiling = |
| 547 TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, settings); |
544 | 548 |
545 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 549 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
546 | 550 |
547 // Move viewport down 50 pixels in 0.5 seconds. | 551 // Move viewport down 50 pixels in 0.5 seconds. |
548 gfx::Rect down_skewport = | 552 gfx::Rect down_skewport = |
549 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 553 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
550 | 554 |
551 EXPECT_EQ(0, down_skewport.x()); | 555 EXPECT_EQ(0, down_skewport.x()); |
552 EXPECT_EQ(50, down_skewport.y()); | 556 EXPECT_EQ(50, down_skewport.y()); |
553 EXPECT_EQ(100, down_skewport.width()); | 557 EXPECT_EQ(100, down_skewport.width()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 603 |
600 TEST(PictureLayerTilingTest, ComputeSkewport) { | 604 TEST(PictureLayerTilingTest, ComputeSkewport) { |
601 FakePictureLayerTilingClient client; | 605 FakePictureLayerTilingClient client; |
602 scoped_ptr<TestablePictureLayerTiling> tiling; | 606 scoped_ptr<TestablePictureLayerTiling> tiling; |
603 | 607 |
604 gfx::Rect viewport(0, 0, 100, 100); | 608 gfx::Rect viewport(0, 0, 100, 100); |
605 gfx::Size layer_bounds(200, 200); | 609 gfx::Size layer_bounds(200, 200); |
606 | 610 |
607 client.SetTileSize(gfx::Size(100, 100)); | 611 client.SetTileSize(gfx::Size(100, 100)); |
608 client.set_tree(ACTIVE_TREE); | 612 client.set_tree(ACTIVE_TREE); |
609 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 613 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, |
| 614 LayerTreeSettings()); |
610 | 615 |
611 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 616 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
612 | 617 |
613 // Move viewport down 50 pixels in 0.5 seconds. | 618 // Move viewport down 50 pixels in 0.5 seconds. |
614 gfx::Rect down_skewport = | 619 gfx::Rect down_skewport = |
615 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); | 620 tiling->ComputeSkewport(1.5, gfx::Rect(0, 50, 100, 100)); |
616 | 621 |
617 EXPECT_EQ(0, down_skewport.x()); | 622 EXPECT_EQ(0, down_skewport.x()); |
618 EXPECT_EQ(50, down_skewport.y()); | 623 EXPECT_EQ(50, down_skewport.y()); |
619 EXPECT_EQ(100, down_skewport.width()); | 624 EXPECT_EQ(100, down_skewport.width()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 | 663 |
659 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { | 664 TEST(PictureLayerTilingTest, ViewportDistanceWithScale) { |
660 FakePictureLayerTilingClient client; | 665 FakePictureLayerTilingClient client; |
661 scoped_ptr<TestablePictureLayerTiling> tiling; | 666 scoped_ptr<TestablePictureLayerTiling> tiling; |
662 | 667 |
663 gfx::Rect viewport(0, 0, 100, 100); | 668 gfx::Rect viewport(0, 0, 100, 100); |
664 gfx::Size layer_bounds(1500, 1500); | 669 gfx::Size layer_bounds(1500, 1500); |
665 | 670 |
666 client.SetTileSize(gfx::Size(10, 10)); | 671 client.SetTileSize(gfx::Size(10, 10)); |
667 client.set_tree(ACTIVE_TREE); | 672 client.set_tree(ACTIVE_TREE); |
| 673 LayerTreeSettings settings; |
| 674 settings.max_tiles_for_interest_area = 10000; |
668 | 675 |
669 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. | 676 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. |
670 // The reason is that each tile has a one pixel border, so tile at (1, 2) | 677 // The reason is that each tile has a one pixel border, so tile at (1, 2) |
671 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at | 678 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at |
672 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the | 679 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the |
673 // tiling. | 680 // tiling. |
674 tiling = TestablePictureLayerTiling::Create(0.25f, layer_bounds, &client); | 681 tiling = TestablePictureLayerTiling::Create(0.25f, layer_bounds, &client, |
| 682 settings); |
675 gfx::Rect viewport_in_content_space = | 683 gfx::Rect viewport_in_content_space = |
676 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); | 684 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); |
677 | 685 |
678 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); | 686 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); |
679 tiling->UpdateAllTilePrioritiesForTesting(); | 687 tiling->UpdateAllTilePrioritiesForTesting(); |
680 | 688 |
681 gfx::Rect soon_rect = viewport; | 689 gfx::Rect soon_rect = viewport; |
682 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 690 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
683 gfx::Rect soon_rect_in_content_space = | 691 gfx::Rect soon_rect_in_content_space = |
684 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); | 692 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 826 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
819 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); | 827 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); |
820 | 828 |
821 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 829 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
822 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); | 830 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); |
823 | 831 |
824 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 832 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
825 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); | 833 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); |
826 | 834 |
827 // Test additional scales. | 835 // Test additional scales. |
828 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client); | 836 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client, |
| 837 LayerTreeSettings()); |
829 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); | 838 tiling->ComputeTilePriorityRects(viewport, 1.0f, 4.0, Occlusion()); |
830 tiling->UpdateAllTilePrioritiesForTesting(); | 839 tiling->UpdateAllTilePrioritiesForTesting(); |
831 | 840 |
832 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); | 841 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); |
833 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); | 842 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); |
834 | 843 |
835 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); | 844 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); |
836 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); | 845 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); |
837 | 846 |
838 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); | 847 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 scoped_ptr<TestablePictureLayerTiling> tiling; | 1087 scoped_ptr<TestablePictureLayerTiling> tiling; |
1079 | 1088 |
1080 gfx::Rect viewport(50, 50, 100, 100); | 1089 gfx::Rect viewport(50, 50, 100, 100); |
1081 gfx::Size layer_bounds(800, 800); | 1090 gfx::Size layer_bounds(800, 800); |
1082 | 1091 |
1083 gfx::Rect soon_rect = viewport; | 1092 gfx::Rect soon_rect = viewport; |
1084 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1093 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
1085 | 1094 |
1086 client.SetTileSize(gfx::Size(30, 30)); | 1095 client.SetTileSize(gfx::Size(30, 30)); |
1087 client.set_tree(ACTIVE_TREE); | 1096 client.set_tree(ACTIVE_TREE); |
| 1097 LayerTreeSettings settings; |
| 1098 settings.max_tiles_for_interest_area = 10000; |
1088 | 1099 |
1089 tiling = TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client); | 1100 tiling = |
| 1101 TestablePictureLayerTiling::Create(1.0f, layer_bounds, &client, settings); |
1090 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1102 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
1091 tiling->UpdateAllTilePrioritiesForTesting(); | 1103 tiling->UpdateAllTilePrioritiesForTesting(); |
1092 | 1104 |
1093 PictureLayerTiling::TilingRasterTileIterator empty_iterator; | 1105 PictureLayerTiling::TilingRasterTileIterator empty_iterator; |
1094 EXPECT_FALSE(empty_iterator); | 1106 EXPECT_FALSE(empty_iterator); |
1095 | 1107 |
1096 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1108 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
1097 | 1109 |
1098 // Sanity check. | 1110 // Sanity check. |
1099 EXPECT_EQ(841u, all_tiles.size()); | 1111 EXPECT_EQ(841u, all_tiles.size()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 TEST(PictureLayerTilingTest, TilingRasterTileIteratorMovingViewport) { | 1195 TEST(PictureLayerTilingTest, TilingRasterTileIteratorMovingViewport) { |
1184 FakePictureLayerTilingClient client; | 1196 FakePictureLayerTilingClient client; |
1185 scoped_ptr<TestablePictureLayerTiling> tiling; | 1197 scoped_ptr<TestablePictureLayerTiling> tiling; |
1186 | 1198 |
1187 gfx::Rect viewport(50, 0, 100, 100); | 1199 gfx::Rect viewport(50, 0, 100, 100); |
1188 gfx::Rect moved_viewport(50, 0, 100, 500); | 1200 gfx::Rect moved_viewport(50, 0, 100, 500); |
1189 gfx::Size layer_bounds(1000, 1000); | 1201 gfx::Size layer_bounds(1000, 1000); |
1190 | 1202 |
1191 client.SetTileSize(gfx::Size(30, 30)); | 1203 client.SetTileSize(gfx::Size(30, 30)); |
1192 client.set_tree(ACTIVE_TREE); | 1204 client.set_tree(ACTIVE_TREE); |
| 1205 LayerTreeSettings settings; |
| 1206 settings.max_tiles_for_interest_area = 10000; |
1193 | 1207 |
1194 tiling = TestablePictureLayerTiling::Create(1.f, layer_bounds, &client); | 1208 tiling = |
| 1209 TestablePictureLayerTiling::Create(1.f, layer_bounds, &client, settings); |
1195 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); | 1210 tiling->ComputeTilePriorityRects(viewport, 1.0f, 1.0, Occlusion()); |
1196 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); | 1211 tiling->ComputeTilePriorityRects(moved_viewport, 1.0f, 2.0, Occlusion()); |
1197 tiling->UpdateAllTilePrioritiesForTesting(); | 1212 tiling->UpdateAllTilePrioritiesForTesting(); |
1198 | 1213 |
1199 gfx::Rect soon_rect = moved_viewport; | 1214 gfx::Rect soon_rect = moved_viewport; |
1200 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1215 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); |
1201 | 1216 |
1202 // There are 3 bins in TilePriority. | 1217 // There are 3 bins in TilePriority. |
1203 bool have_tiles[3] = {}; | 1218 bool have_tiles[3] = {}; |
1204 Tile* last_tile = NULL; | 1219 Tile* last_tile = NULL; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 bool intersects = rect.Intersects(geometry_rect); | 1334 bool intersects = rect.Intersects(geometry_rect); |
1320 bool expected_exists = intersect_exists ? intersects : !intersects; | 1335 bool expected_exists = intersect_exists ? intersects : !intersects; |
1321 EXPECT_EQ(expected_exists, tile != NULL) | 1336 EXPECT_EQ(expected_exists, tile != NULL) |
1322 << "Rects intersecting " << rect.ToString() << " should exist. " | 1337 << "Rects intersecting " << rect.ToString() << " should exist. " |
1323 << "Current tile rect is " << geometry_rect.ToString(); | 1338 << "Current tile rect is " << geometry_rect.ToString(); |
1324 } | 1339 } |
1325 | 1340 |
1326 TEST_F(PictureLayerTilingIteratorTest, | 1341 TEST_F(PictureLayerTilingIteratorTest, |
1327 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { | 1342 TilesExistLargeViewportAndLayerWithSmallVisibleArea) { |
1328 gfx::Size layer_bounds(10000, 10000); | 1343 gfx::Size layer_bounds(10000, 10000); |
1329 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 1344 client_.SetTileSize(gfx::Size(100, 100)); |
| 1345 client_.set_tree(PENDING_TREE); |
| 1346 LayerTreeSettings settings; |
| 1347 settings.max_tiles_for_interest_area = 1; |
| 1348 |
| 1349 tiling_ = |
| 1350 TestablePictureLayerTiling::Create(1.f, layer_bounds, &client_, settings); |
1330 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); | 1351 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds)); |
1331 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); | 1352 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false)); |
1332 | 1353 |
1333 gfx::Rect visible_rect(8000, 8000, 50, 50); | 1354 gfx::Rect visible_rect(8000, 8000, 50, 50); |
1334 | 1355 |
1335 client_.set_tree(ACTIVE_TREE); | 1356 client_.set_tree(ACTIVE_TREE); |
1336 set_max_tiles_for_interest_area(1); | |
1337 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect | 1357 tiling_->ComputeTilePriorityRects(visible_rect, // visible content rect |
1338 1.f, // current contents scale | 1358 1.f, // current contents scale |
1339 1.0, // current frame time | 1359 1.0, // current frame time |
1340 Occlusion()); | 1360 Occlusion()); |
1341 VerifyTiles(1.f, | 1361 VerifyTiles(1.f, |
1342 gfx::Rect(layer_bounds), | 1362 gfx::Rect(layer_bounds), |
1343 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); | 1363 base::Bind(&TilesIntersectingRectExist, visible_rect, true)); |
1344 } | 1364 } |
1345 | 1365 |
1346 TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { | 1366 TEST_F(PictureLayerTilingIteratorTest, AddTilingsToMatchScale) { |
1347 gfx::Size layer_bounds(1099, 801); | 1367 gfx::Size layer_bounds(1099, 801); |
1348 gfx::Size tile_size(100, 100); | 1368 gfx::Size tile_size(100, 100); |
1349 | 1369 |
1350 client_.SetTileSize(tile_size); | 1370 client_.SetTileSize(tile_size); |
1351 client_.set_tree(PENDING_TREE); | 1371 client_.set_tree(PENDING_TREE); |
1352 | 1372 |
1353 auto active_set = PictureLayerTilingSet::Create(&client_); | 1373 LayerTreeSettings defaults; |
| 1374 auto active_set = PictureLayerTilingSet::Create( |
| 1375 &client_, 10000, defaults.skewport_target_time_in_seconds, |
| 1376 defaults.skewport_extrapolation_limit_in_content_pixels); |
1354 | 1377 |
1355 active_set->AddTiling(1.f, layer_bounds); | 1378 active_set->AddTiling(1.f, layer_bounds); |
1356 | 1379 |
1357 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | 1380 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), |
1358 base::Bind(&TileExists, false)); | 1381 base::Bind(&TileExists, false)); |
1359 | 1382 |
1360 UpdateAllTilePriorities(active_set.get(), | 1383 UpdateAllTilePriorities(active_set.get(), |
1361 gfx::Rect(layer_bounds), // visible content rect | 1384 gfx::Rect(layer_bounds), // visible content rect |
1362 1.f, // current contents scale | 1385 1.f, // current contents scale |
1363 1.0); // current frame time | 1386 1.0); // current frame time |
1364 | 1387 |
1365 // The active tiling has tiles now. | 1388 // The active tiling has tiles now. |
1366 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | 1389 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), |
1367 base::Bind(&TileExists, true)); | 1390 base::Bind(&TileExists, true)); |
1368 | 1391 |
1369 // Add the same tilings to the pending set. | 1392 // Add the same tilings to the pending set. |
1370 auto pending_set = PictureLayerTilingSet::Create(&client_); | 1393 auto pending_set = PictureLayerTilingSet::Create( |
| 1394 &client_, 10000, defaults.skewport_target_time_in_seconds, |
| 1395 defaults.skewport_extrapolation_limit_in_content_pixels); |
1371 Region invalidation; | 1396 Region invalidation; |
1372 pending_set->SyncTilings(*active_set, layer_bounds, invalidation, 0.f, | 1397 pending_set->SyncTilingsForTesting(*active_set, layer_bounds, invalidation, |
1373 client_.raster_source()); | 1398 0.f, client_.raster_source()); |
1374 | 1399 |
1375 // The pending tiling starts with no tiles. | 1400 // The pending tiling starts with no tiles. |
1376 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), | 1401 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), |
1377 base::Bind(&TileExists, false)); | 1402 base::Bind(&TileExists, false)); |
1378 | 1403 |
1379 // ComputeTilePriorityRects on the pending tiling at the same frame time. The | 1404 // ComputeTilePriorityRects on the pending tiling at the same frame time. The |
1380 // pending tiling should get tiles. | 1405 // pending tiling should get tiles. |
1381 UpdateAllTilePriorities(pending_set.get(), | 1406 UpdateAllTilePriorities(pending_set.get(), |
1382 gfx::Rect(layer_bounds), // visible content rect | 1407 gfx::Rect(layer_bounds), // visible content rect |
1383 1.f, // current contents scale | 1408 1.f, // current contents scale |
(...skipping 16 matching lines...) Expand all Loading... |
1400 float current_layer_contents_scale = 1.f; | 1425 float current_layer_contents_scale = 1.f; |
1401 gfx::Transform current_screen_transform; | 1426 gfx::Transform current_screen_transform; |
1402 double current_frame_time_in_seconds = 1.0; | 1427 double current_frame_time_in_seconds = 1.0; |
1403 | 1428 |
1404 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1429 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1405 current_screen_transform, device_viewport); | 1430 current_screen_transform, device_viewport); |
1406 | 1431 |
1407 client.SetTileSize(gfx::Size(100, 100)); | 1432 client.SetTileSize(gfx::Size(100, 100)); |
1408 client.set_tree(ACTIVE_TREE); | 1433 client.set_tree(ACTIVE_TREE); |
1409 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1434 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
1410 current_layer_bounds, | 1435 current_layer_bounds, &client, |
1411 &client); | 1436 LayerTreeSettings()); |
1412 | 1437 |
1413 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1438 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1414 current_layer_contents_scale, | 1439 current_layer_contents_scale, |
1415 current_frame_time_in_seconds, Occlusion()); | 1440 current_frame_time_in_seconds, Occlusion()); |
1416 tiling->UpdateAllTilePrioritiesForTesting(); | 1441 tiling->UpdateAllTilePrioritiesForTesting(); |
1417 | 1442 |
1418 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1443 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1419 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1444 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1420 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1445 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1421 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1446 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 | 1479 |
1455 current_screen_transform.Translate(850, 0); | 1480 current_screen_transform.Translate(850, 0); |
1456 last_screen_transform = current_screen_transform; | 1481 last_screen_transform = current_screen_transform; |
1457 | 1482 |
1458 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1483 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1459 current_screen_transform, device_viewport); | 1484 current_screen_transform, device_viewport); |
1460 | 1485 |
1461 client.SetTileSize(gfx::Size(100, 100)); | 1486 client.SetTileSize(gfx::Size(100, 100)); |
1462 client.set_tree(ACTIVE_TREE); | 1487 client.set_tree(ACTIVE_TREE); |
1463 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1488 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
1464 current_layer_bounds, | 1489 current_layer_bounds, &client, |
1465 &client); | 1490 LayerTreeSettings()); |
1466 | 1491 |
1467 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1492 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1468 current_layer_contents_scale, | 1493 current_layer_contents_scale, |
1469 current_frame_time_in_seconds, Occlusion()); | 1494 current_frame_time_in_seconds, Occlusion()); |
1470 tiling->UpdateAllTilePrioritiesForTesting(); | 1495 tiling->UpdateAllTilePrioritiesForTesting(); |
1471 | 1496 |
1472 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1497 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1473 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1498 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1474 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1499 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1475 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1500 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 | 1543 |
1519 current_screen_transform.Translate(705, 505); | 1544 current_screen_transform.Translate(705, 505); |
1520 last_screen_transform = current_screen_transform; | 1545 last_screen_transform = current_screen_transform; |
1521 | 1546 |
1522 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1547 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1523 current_screen_transform, device_viewport); | 1548 current_screen_transform, device_viewport); |
1524 | 1549 |
1525 client.SetTileSize(gfx::Size(100, 100)); | 1550 client.SetTileSize(gfx::Size(100, 100)); |
1526 client.set_tree(ACTIVE_TREE); | 1551 client.set_tree(ACTIVE_TREE); |
1527 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1552 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
1528 current_layer_bounds, | 1553 current_layer_bounds, &client, |
1529 &client); | 1554 LayerTreeSettings()); |
1530 | 1555 |
1531 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1556 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1532 current_layer_contents_scale, | 1557 current_layer_contents_scale, |
1533 current_frame_time_in_seconds, Occlusion()); | 1558 current_frame_time_in_seconds, Occlusion()); |
1534 tiling->UpdateAllTilePrioritiesForTesting(); | 1559 tiling->UpdateAllTilePrioritiesForTesting(); |
1535 | 1560 |
1536 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1561 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1537 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1562 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1538 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1563 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1539 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1564 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 current_screen_transform.Translate(600, 750); | 1601 current_screen_transform.Translate(600, 750); |
1577 current_screen_transform.RotateAboutZAxis(45); | 1602 current_screen_transform.RotateAboutZAxis(45); |
1578 last_screen_transform = current_screen_transform; | 1603 last_screen_transform = current_screen_transform; |
1579 | 1604 |
1580 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1605 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1581 current_screen_transform, device_viewport); | 1606 current_screen_transform, device_viewport); |
1582 | 1607 |
1583 client.SetTileSize(gfx::Size(100, 100)); | 1608 client.SetTileSize(gfx::Size(100, 100)); |
1584 client.set_tree(ACTIVE_TREE); | 1609 client.set_tree(ACTIVE_TREE); |
1585 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1610 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
1586 current_layer_bounds, | 1611 current_layer_bounds, &client, |
1587 &client); | 1612 LayerTreeSettings()); |
1588 | 1613 |
1589 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1614 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1590 current_layer_contents_scale, | 1615 current_layer_contents_scale, |
1591 current_frame_time_in_seconds, Occlusion()); | 1616 current_frame_time_in_seconds, Occlusion()); |
1592 tiling->UpdateAllTilePrioritiesForTesting(); | 1617 tiling->UpdateAllTilePrioritiesForTesting(); |
1593 | 1618 |
1594 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1619 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1595 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1620 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1596 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1621 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1597 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1622 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), | 1683 gfx::QuadF(gfx::RectF(0, 0, 200, 200)), |
1659 &clipped); | 1684 &clipped); |
1660 ASSERT_FALSE(clipped); | 1685 ASSERT_FALSE(clipped); |
1661 | 1686 |
1662 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1687 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1663 current_screen_transform, device_viewport); | 1688 current_screen_transform, device_viewport); |
1664 | 1689 |
1665 client.SetTileSize(gfx::Size(100, 100)); | 1690 client.SetTileSize(gfx::Size(100, 100)); |
1666 client.set_tree(ACTIVE_TREE); | 1691 client.set_tree(ACTIVE_TREE); |
1667 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1692 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
1668 current_layer_bounds, | 1693 current_layer_bounds, &client, |
1669 &client); | 1694 LayerTreeSettings()); |
1670 | 1695 |
1671 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1696 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1672 current_layer_contents_scale, | 1697 current_layer_contents_scale, |
1673 current_frame_time_in_seconds, Occlusion()); | 1698 current_frame_time_in_seconds, Occlusion()); |
1674 tiling->UpdateAllTilePrioritiesForTesting(); | 1699 tiling->UpdateAllTilePrioritiesForTesting(); |
1675 | 1700 |
1676 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1701 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1677 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1702 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1678 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1703 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1679 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1704 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), | 1775 gfx::QuadF(gfx::RectF(100, 0, 100, 200)), |
1751 &clipped); | 1776 &clipped); |
1752 ASSERT_FALSE(clipped); | 1777 ASSERT_FALSE(clipped); |
1753 | 1778 |
1754 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1779 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1755 current_screen_transform, device_viewport); | 1780 current_screen_transform, device_viewport); |
1756 | 1781 |
1757 client.SetTileSize(gfx::Size(100, 100)); | 1782 client.SetTileSize(gfx::Size(100, 100)); |
1758 client.set_tree(ACTIVE_TREE); | 1783 client.set_tree(ACTIVE_TREE); |
1759 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1784 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
1760 current_layer_bounds, | 1785 current_layer_bounds, &client, |
1761 &client); | 1786 LayerTreeSettings()); |
1762 | 1787 |
1763 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1788 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1764 current_layer_contents_scale, | 1789 current_layer_contents_scale, |
1765 current_frame_time_in_seconds, Occlusion()); | 1790 current_frame_time_in_seconds, Occlusion()); |
1766 tiling->UpdateAllTilePrioritiesForTesting(); | 1791 tiling->UpdateAllTilePrioritiesForTesting(); |
1767 | 1792 |
1768 ASSERT_TRUE(tiling->TileAt(0, 0)); | 1793 ASSERT_TRUE(tiling->TileAt(0, 0)); |
1769 ASSERT_TRUE(tiling->TileAt(0, 1)); | 1794 ASSERT_TRUE(tiling->TileAt(0, 1)); |
1770 ASSERT_TRUE(tiling->TileAt(1, 0)); | 1795 ASSERT_TRUE(tiling->TileAt(1, 0)); |
1771 ASSERT_TRUE(tiling->TileAt(1, 1)); | 1796 ASSERT_TRUE(tiling->TileAt(1, 1)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 | 1836 |
1812 // Offscreen layer is coming closer to viewport at 1000 pixels per second. | 1837 // Offscreen layer is coming closer to viewport at 1000 pixels per second. |
1813 current_screen_transform.Translate(1800, 0); | 1838 current_screen_transform.Translate(1800, 0); |
1814 last_screen_transform.Translate(2800, 0); | 1839 last_screen_transform.Translate(2800, 0); |
1815 | 1840 |
1816 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1841 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1817 current_screen_transform, device_viewport); | 1842 current_screen_transform, device_viewport); |
1818 | 1843 |
1819 client.SetTileSize(gfx::Size(100, 100)); | 1844 client.SetTileSize(gfx::Size(100, 100)); |
1820 client.set_tree(ACTIVE_TREE); | 1845 client.set_tree(ACTIVE_TREE); |
| 1846 LayerTreeSettings settings; |
| 1847 settings.max_tiles_for_interest_area = 10000; |
1821 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1848 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
1822 current_layer_bounds, | 1849 current_layer_bounds, &client, |
1823 &client); | 1850 settings); |
1824 | 1851 |
1825 // previous ("last") frame | 1852 // previous ("last") frame |
1826 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1853 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1827 last_layer_contents_scale, | 1854 last_layer_contents_scale, |
1828 last_frame_time_in_seconds, Occlusion()); | 1855 last_frame_time_in_seconds, Occlusion()); |
1829 | 1856 |
1830 // current frame | 1857 // current frame |
1831 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1858 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1832 current_layer_contents_scale, | 1859 current_layer_contents_scale, |
1833 current_frame_time_in_seconds, Occlusion()); | 1860 current_frame_time_in_seconds, Occlusion()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 current_screen_transform.RotateAboutZAxis(45); | 1914 current_screen_transform.RotateAboutZAxis(45); |
1888 | 1915 |
1889 last_screen_transform.Translate(400, 550); | 1916 last_screen_transform.Translate(400, 550); |
1890 | 1917 |
1891 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( | 1918 gfx::Rect viewport_in_layer_space = ViewportInLayerSpace( |
1892 current_screen_transform, device_viewport); | 1919 current_screen_transform, device_viewport); |
1893 | 1920 |
1894 client.SetTileSize(gfx::Size(100, 100)); | 1921 client.SetTileSize(gfx::Size(100, 100)); |
1895 client.set_tree(ACTIVE_TREE); | 1922 client.set_tree(ACTIVE_TREE); |
1896 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1923 tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
1897 current_layer_bounds, | 1924 current_layer_bounds, &client, |
1898 &client); | 1925 LayerTreeSettings()); |
1899 | 1926 |
1900 // previous ("last") frame | 1927 // previous ("last") frame |
1901 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1928 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1902 last_layer_contents_scale, | 1929 last_layer_contents_scale, |
1903 last_frame_time_in_seconds, Occlusion()); | 1930 last_frame_time_in_seconds, Occlusion()); |
1904 | 1931 |
1905 // current frame | 1932 // current frame |
1906 tiling->ComputeTilePriorityRects(viewport_in_layer_space, | 1933 tiling->ComputeTilePriorityRects(viewport_in_layer_space, |
1907 current_layer_contents_scale, | 1934 current_layer_contents_scale, |
1908 current_frame_time_in_seconds, Occlusion()); | 1935 current_frame_time_in_seconds, Occlusion()); |
(...skipping 26 matching lines...) Expand all Loading... |
1935 // - Viewport moves back and a new active tiling tile is created. | 1962 // - Viewport moves back and a new active tiling tile is created. |
1936 // Result: | 1963 // Result: |
1937 // - Recycle tiling does _not_ have the tile in the same location (thus it | 1964 // - Recycle tiling does _not_ have the tile in the same location (thus it |
1938 // will be shared next time a pending tiling is created). | 1965 // will be shared next time a pending tiling is created). |
1939 | 1966 |
1940 FakePictureLayerTilingClient active_client; | 1967 FakePictureLayerTilingClient active_client; |
1941 scoped_ptr<TestablePictureLayerTiling> active_tiling; | 1968 scoped_ptr<TestablePictureLayerTiling> active_tiling; |
1942 | 1969 |
1943 active_client.SetTileSize(gfx::Size(100, 100)); | 1970 active_client.SetTileSize(gfx::Size(100, 100)); |
1944 active_client.set_tree(ACTIVE_TREE); | 1971 active_client.set_tree(ACTIVE_TREE); |
1945 active_client.set_max_tiles_for_interest_area(10); | 1972 LayerTreeSettings settings; |
| 1973 settings.max_tiles_for_interest_area = 10; |
1946 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1974 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale |
1947 gfx::Size(10000, 10000), | 1975 gfx::Size(10000, 10000), |
1948 &active_client); | 1976 &active_client, settings); |
1949 // Create all tiles on this tiling. | 1977 // Create all tiles on this tiling. |
1950 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 1978 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
1951 Occlusion()); | 1979 Occlusion()); |
1952 | 1980 |
1953 FakePictureLayerTilingClient recycle_client; | 1981 FakePictureLayerTilingClient recycle_client; |
1954 recycle_client.SetTileSize(gfx::Size(100, 100)); | 1982 recycle_client.SetTileSize(gfx::Size(100, 100)); |
1955 recycle_client.set_tree(PENDING_TREE); | 1983 recycle_client.set_tree(PENDING_TREE); |
1956 recycle_client.set_twin_tiling(active_tiling.get()); | 1984 recycle_client.set_twin_tiling(active_tiling.get()); |
1957 recycle_client.set_max_tiles_for_interest_area(10); | |
1958 | 1985 |
1959 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 1986 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; |
1960 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 1987 recycle_tiling = TestablePictureLayerTiling::Create( |
1961 gfx::Size(10000, 10000), | 1988 1.0f, // contents_scale |
1962 &recycle_client); | 1989 gfx::Size(10000, 10000), &recycle_client, settings); |
1963 | 1990 |
1964 // Create all tiles on the second tiling. All tiles should be shared. | 1991 // Create all tiles on the second tiling. All tiles should be shared. |
1965 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 1992 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
1966 1.0f, Occlusion()); | 1993 1.0f, Occlusion()); |
1967 | 1994 |
1968 // Set the second tiling as recycled. | 1995 // Set the second tiling as recycled. |
1969 active_client.set_twin_tiling(NULL); | 1996 active_client.set_twin_tiling(NULL); |
1970 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 1997 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
1971 recycle_client.set_twin_tiling(NULL); | 1998 recycle_client.set_twin_tiling(NULL); |
1972 | 1999 |
1973 // Verify that tiles exist and are shared. | 2000 // Verify that tiles exist and are shared. |
1974 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2001 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
1975 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); | 2002 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
1976 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); | 2003 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); |
1977 | 2004 |
1978 // Move the viewport far away from the (0, 0) tile. | 2005 // Move the viewport far away from the (0, 0) tile. |
1979 active_tiling->ComputeTilePriorityRects(gfx::Rect(9000, 9000, 100, 100), 1.0f, | 2006 active_tiling->ComputeTilePriorityRects(gfx::Rect(9000, 9000, 100, 100), 1.0f, |
1980 2.0, Occlusion()); | 2007 2.0, Occlusion()); |
1981 // Ensure the tile was deleted on both tilings. | 2008 // Ensure the tile was deleted on both tilings. |
1982 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 2009 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
1983 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2010 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
1984 | 2011 |
1985 // Move the viewport back to (0, 0) tile. | 2012 // Move the viewport back to (0, 0) tile. |
1986 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 3.0, | 2013 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 3.0, |
1987 Occlusion()); | 2014 Occlusion()); |
1988 | 2015 |
1989 // Ensure that we now have a tile here, but the recycle tiling does not. | 2016 // Ensure that we now have a tile here on both tilings again. |
1990 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2017 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
1991 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2018 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
1992 } | 2019 } |
1993 | 2020 |
1994 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { | 2021 TEST(PictureLayerTilingTest, RecycledTilesClearedOnReset) { |
1995 FakePictureLayerTilingClient active_client; | 2022 FakePictureLayerTilingClient active_client; |
1996 scoped_ptr<TestablePictureLayerTiling> active_tiling; | 2023 scoped_ptr<TestablePictureLayerTiling> active_tiling; |
1997 | 2024 |
1998 active_client.SetTileSize(gfx::Size(100, 100)); | 2025 active_client.SetTileSize(gfx::Size(100, 100)); |
1999 active_client.set_tree(ACTIVE_TREE); | 2026 active_client.set_tree(ACTIVE_TREE); |
2000 active_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2027 active_tiling = TestablePictureLayerTiling::Create( |
2001 gfx::Size(100, 100), | 2028 1.0f, // contents_scale |
2002 &active_client); | 2029 gfx::Size(100, 100), &active_client, LayerTreeSettings()); |
2003 // Create all tiles on this tiling. | 2030 // Create all tiles on this tiling. |
2004 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, | 2031 active_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, 1.0f, |
2005 Occlusion()); | 2032 Occlusion()); |
2006 | 2033 |
2007 FakePictureLayerTilingClient recycle_client; | 2034 FakePictureLayerTilingClient recycle_client; |
2008 recycle_client.SetTileSize(gfx::Size(100, 100)); | 2035 recycle_client.SetTileSize(gfx::Size(100, 100)); |
2009 recycle_client.set_tree(PENDING_TREE); | 2036 recycle_client.set_tree(PENDING_TREE); |
2010 recycle_client.set_twin_tiling(active_tiling.get()); | 2037 recycle_client.set_twin_tiling(active_tiling.get()); |
2011 recycle_client.set_max_tiles_for_interest_area(10); | |
2012 | 2038 |
| 2039 LayerTreeSettings settings; |
| 2040 settings.max_tiles_for_interest_area = 10; |
2013 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; | 2041 scoped_ptr<TestablePictureLayerTiling> recycle_tiling; |
2014 recycle_tiling = TestablePictureLayerTiling::Create(1.0f, // contents_scale | 2042 recycle_tiling = TestablePictureLayerTiling::Create( |
2015 gfx::Size(100, 100), | 2043 1.0f, // contents_scale |
2016 &recycle_client); | 2044 gfx::Size(100, 100), &recycle_client, settings); |
2017 | 2045 |
2018 // Create all tiles on the recycle tiling. All tiles should be shared. | 2046 // Create all tiles on the recycle tiling. All tiles should be shared. |
2019 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, | 2047 recycle_tiling->ComputeTilePriorityRects(gfx::Rect(0, 0, 100, 100), 1.0f, |
2020 1.0f, Occlusion()); | 2048 1.0f, Occlusion()); |
2021 | 2049 |
2022 // Set the second tiling as recycled. | 2050 // Set the second tiling as recycled. |
2023 active_client.set_twin_tiling(NULL); | 2051 active_client.set_twin_tiling(NULL); |
2024 active_client.set_recycled_twin_tiling(recycle_tiling.get()); | 2052 active_client.set_recycled_twin_tiling(recycle_tiling.get()); |
2025 recycle_client.set_twin_tiling(NULL); | 2053 recycle_client.set_twin_tiling(NULL); |
2026 | 2054 |
2027 // Verify that tiles exist and are shared. | 2055 // Verify that tiles exist and are shared. |
2028 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2056 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
2029 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); | 2057 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); |
2030 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); | 2058 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); |
2031 | 2059 |
2032 // Reset the active tiling. The recycle tiles should be released too. | 2060 // Reset the active tiling. The recycle tiles should be released too. |
2033 active_tiling->Reset(); | 2061 active_tiling->Reset(); |
2034 EXPECT_FALSE(active_tiling->TileAt(0, 0)); | 2062 EXPECT_FALSE(active_tiling->TileAt(0, 0)); |
2035 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); | 2063 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); |
2036 } | 2064 } |
2037 | 2065 |
2038 TEST_F(PictureLayerTilingIteratorTest, ResizeTilesAndUpdateToCurrent) { | 2066 TEST_F(PictureLayerTilingIteratorTest, ResizeTilesAndUpdateToCurrent) { |
2039 // The tiling has four rows and three columns. | 2067 // The tiling has four rows and three columns. |
2040 Initialize(gfx::Size(150, 100), 1, gfx::Size(250, 150)); | 2068 Initialize(gfx::Size(150, 100), 1.f, gfx::Size(250, 150)); |
2041 tiling_->CreateAllTilesForTesting(); | 2069 tiling_->CreateAllTilesForTesting(); |
2042 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); | 2070 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); |
2043 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 2071 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
2044 EXPECT_EQ(4u, tiling_->AllRefTilesForTesting().size()); | 2072 EXPECT_EQ(4u, tiling_->AllRefTilesForTesting().size()); |
2045 | 2073 |
2046 client_.SetTileSize(gfx::Size(250, 200)); | 2074 client_.SetTileSize(gfx::Size(250, 200)); |
2047 client_.set_tree(PENDING_TREE); | 2075 client_.set_tree(PENDING_TREE); |
2048 | 2076 |
2049 // Tile size in the tiling should still be 150x100. | 2077 // Tile size in the tiling should still be 150x100. |
2050 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); | 2078 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width()); |
2051 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); | 2079 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height()); |
2052 | 2080 |
2053 Region invalidation; | 2081 tiling_->Resize(gfx::Size(250, 150)); |
2054 tiling_->UpdateTilesToCurrentRasterSource(client_.raster_source(), | |
2055 invalidation, gfx::Size(250, 150)); | |
2056 | 2082 |
2057 // Tile size in the tiling should be resized to 250x200. | 2083 // Tile size in the tiling should be resized to 250x200. |
2058 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 2084 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
2059 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 2085 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
2060 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 2086 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
2061 } | 2087 } |
2062 | 2088 |
2063 } // namespace | 2089 } // namespace |
2064 } // namespace cc | 2090 } // namespace cc |
OLD | NEW |