Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: cc/resources/picture_layer_tiling_unittest.cc

Issue 793693003: Tile Compression (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 // Tiling only has one tile, since its total size is less than one. 203 // Tiling only has one tile, since its total size is less than one.
204 EXPECT_TRUE(tiling_->TileAt(0, 0)); 204 EXPECT_TRUE(tiling_->TileAt(0, 0));
205 205
206 // Stop creating tiles so that any invalidations are left as holes. 206 // Stop creating tiles so that any invalidations are left as holes.
207 client_.set_allow_create_tile(false); 207 client_.set_allow_create_tile(false);
208 208
209 Region invalidation = 209 Region invalidation =
210 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); 210 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size));
211 tiling_->UpdateTilesToCurrentRasterSource(client_.raster_source(), 211 tiling_->UpdateTilesToCurrentRasterSource(client_.raster_source(),
212 invalidation, gfx::Size(200, 200)); 212 invalidation, gfx::Size(200, 200),
213 base::TimeTicks());
213 EXPECT_FALSE(tiling_->TileAt(0, 0)); 214 EXPECT_FALSE(tiling_->TileAt(0, 0));
214 } 215 }
215 216
216 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { 217 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) {
217 // The tiling has three rows and columns. 218 // The tiling has three rows and columns.
218 Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 250)); 219 Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 250));
219 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); 220 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x());
220 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); 221 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y());
221 222
222 // The live tiles rect is at the very edge of the right-most and 223 // The live tiles rect is at the very edge of the right-most and
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 EXPECT_TRUE(tiling_->TileAt(1, 3)); 259 EXPECT_TRUE(tiling_->TileAt(1, 3));
259 EXPECT_TRUE(tiling_->TileAt(0, 3)); 260 EXPECT_TRUE(tiling_->TileAt(0, 3));
260 261
261 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); 262 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x();
262 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); 263 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y();
263 264
264 // Shrink the tiling so that the last tile row/column is entirely in the 265 // 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. 266 // border pixels of the interior tiles. That row/column is removed.
266 Region invalidation; 267 Region invalidation;
267 tiling_->UpdateTilesToCurrentRasterSource( 268 tiling_->UpdateTilesToCurrentRasterSource(
268 client_.raster_source(), invalidation, gfx::Size(right + 1, bottom + 1)); 269 client_.raster_source(), invalidation, gfx::Size(right + 1, bottom + 1),
270 base::TimeTicks());
269 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); 271 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x());
270 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); 272 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y());
271 273
272 // The live tiles rect was clamped to the pile size. 274 // The live tiles rect was clamped to the pile size.
273 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); 275 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect());
274 276
275 // Since the row/column is gone, the tiles should be gone too. 277 // Since the row/column is gone, the tiles should be gone too.
276 EXPECT_FALSE(tiling_->TileAt(2, 0)); 278 EXPECT_FALSE(tiling_->TileAt(2, 0));
277 EXPECT_FALSE(tiling_->TileAt(2, 1)); 279 EXPECT_FALSE(tiling_->TileAt(2, 1));
278 EXPECT_FALSE(tiling_->TileAt(2, 2)); 280 EXPECT_FALSE(tiling_->TileAt(2, 2));
279 EXPECT_FALSE(tiling_->TileAt(2, 3)); 281 EXPECT_FALSE(tiling_->TileAt(2, 3));
280 EXPECT_FALSE(tiling_->TileAt(1, 3)); 282 EXPECT_FALSE(tiling_->TileAt(1, 3));
281 EXPECT_FALSE(tiling_->TileAt(0, 3)); 283 EXPECT_FALSE(tiling_->TileAt(0, 3));
282 284
283 // Growing outside the current right/bottom tiles border pixels should create 285 // Growing outside the current right/bottom tiles border pixels should create
284 // the tiles again, even though the live rect has not changed size. 286 // the tiles again, even though the live rect has not changed size.
285 tiling_->UpdateTilesToCurrentRasterSource( 287 tiling_->UpdateTilesToCurrentRasterSource(
286 client_.raster_source(), invalidation, gfx::Size(right + 2, bottom + 2)); 288 client_.raster_source(), invalidation, gfx::Size(right + 2, bottom + 2),
289 base::TimeTicks());
287 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); 290 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x());
288 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); 291 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y());
289 292
290 // Not changed. 293 // Not changed.
291 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); 294 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect());
292 295
293 // The last row/column tiles are inside the live tiles rect. 296 // The last row/column tiles are inside the live tiles rect.
294 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( 297 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects(
295 tiling_->TilingDataForTesting().TileBounds(2, 0))); 298 tiling_->TilingDataForTesting().TileBounds(2, 0)));
296 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( 299 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects(
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 416
414 // Tiling only has one tile, since its total size is less than one. 417 // Tiling only has one tile, since its total size is less than one.
415 EXPECT_TRUE(tiling_->TileAt(0, 0)); 418 EXPECT_TRUE(tiling_->TileAt(0, 0));
416 419
417 // Stop creating tiles so that any invalidations are left as holes. 420 // Stop creating tiles so that any invalidations are left as holes.
418 client_.set_allow_create_tile(false); 421 client_.set_allow_create_tile(false);
419 422
420 Region invalidation = 423 Region invalidation =
421 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); 424 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size));
422 tiling_->UpdateTilesToCurrentRasterSource(client_.raster_source(), 425 tiling_->UpdateTilesToCurrentRasterSource(client_.raster_source(),
423 invalidation, gfx::Size(200, 200)); 426 invalidation, gfx::Size(200, 200),
427 base::TimeTicks());
424 EXPECT_FALSE(tiling_->TileAt(0, 0)); 428 EXPECT_FALSE(tiling_->TileAt(0, 0));
425 429
426 // The original tile was the same size after resize, but it would include new 430 // The original tile was the same size after resize, but it would include new
427 // border pixels. 431 // border pixels.
428 EXPECT_EQ(gfx::Rect(original_layer_size), 432 EXPECT_EQ(gfx::Rect(original_layer_size),
429 tiling_->TilingDataForTesting().TileBounds(0, 0)); 433 tiling_->TilingDataForTesting().TileBounds(0, 0));
430 } 434 }
431 435
432 TEST_F(PictureLayerTilingIteratorTest, LiveTilesExactlyCoverLiveTileRect) { 436 TEST_F(PictureLayerTilingIteratorTest, LiveTilesExactlyCoverLiveTileRect) {
433 Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801)); 437 Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801));
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 1.0); // current frame time 1367 1.0); // current frame time
1364 1368
1365 // The active tiling has tiles now. 1369 // The active tiling has tiles now.
1366 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), 1370 VerifyTiles(active_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds),
1367 base::Bind(&TileExists, true)); 1371 base::Bind(&TileExists, true));
1368 1372
1369 // Add the same tilings to the pending set. 1373 // Add the same tilings to the pending set.
1370 auto pending_set = PictureLayerTilingSet::Create(&client_); 1374 auto pending_set = PictureLayerTilingSet::Create(&client_);
1371 Region invalidation; 1375 Region invalidation;
1372 pending_set->SyncTilings(*active_set, layer_bounds, invalidation, 0.f, 1376 pending_set->SyncTilings(*active_set, layer_bounds, invalidation, 0.f,
1373 client_.raster_source()); 1377 client_.raster_source(), base::TimeTicks());
1374 1378
1375 // The pending tiling starts with no tiles. 1379 // The pending tiling starts with no tiles.
1376 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds), 1380 VerifyTiles(pending_set->tiling_at(0), 1.f, gfx::Rect(layer_bounds),
1377 base::Bind(&TileExists, false)); 1381 base::Bind(&TileExists, false));
1378 1382
1379 // ComputeTilePriorityRects on the pending tiling at the same frame time. The 1383 // ComputeTilePriorityRects on the pending tiling at the same frame time. The
1380 // pending tiling should get tiles. 1384 // pending tiling should get tiles.
1381 UpdateAllTilePriorities(pending_set.get(), 1385 UpdateAllTilePriorities(pending_set.get(),
1382 gfx::Rect(layer_bounds), // visible content rect 1386 gfx::Rect(layer_bounds), // visible content rect
1383 1.f, // current contents scale 1387 1.f, // current contents scale
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 invalidation, gfx::Size(250, 150)); 2059 invalidation, gfx::Size(250, 150));
2056 2060
2057 // Tile size in the tiling should be resized to 250x200. 2061 // Tile size in the tiling should be resized to 250x200.
2058 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); 2062 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width());
2059 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); 2063 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height());
2060 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); 2064 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size());
2061 } 2065 }
2062 2066
2063 } // namespace 2067 } // namespace
2064 } // namespace cc 2068 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling_set_unittest.cc ('k') | cc/resources/prioritized_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698