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

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

Issue 1059403002: cc: Make the invalidation frequency buffer bigger. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: todo Created 5 years, 8 months 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
« no previous file with comments | « cc/resources/picture_pile.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <map> 5 #include <map>
6 #include <utility> 6 #include <utility>
7 7
8 #include "cc/resources/picture_pile.h" 8 #include "cc/resources/picture_pile.h"
9 #include "cc/test/fake_content_layer_client.h" 9 #include "cc/test/fake_content_layer_client.h"
10 #include "cc/test/fake_picture_pile.h" 10 #include "cc/test/fake_picture_pile.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()) 280 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting())
281 << "i " << i << " j " << j; 281 << "i " << i << " j " << j;
282 } 282 }
283 } 283 }
284 284
285 // Update once more with a small viewport. 285 // Update once more with a small viewport.
286 Region invalidation(tiling_rect()); 286 Region invalidation(tiling_rect());
287 UpdateAndExpandInvalidation(&invalidation, tiling_size(), viewport); 287 UpdateAndExpandInvalidation(&invalidation, tiling_size(), viewport);
288 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); 288 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString());
289 289
290 bool had_tiles_with_no_pictures = false;
290 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { 291 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) {
291 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { 292 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) {
292 FakePicturePile::PictureInfo& picture_info = 293 FakePicturePile::PictureInfo& picture_info =
293 pile_.picture_map() 294 pile_.picture_map()
294 .find(FakePicturePile::PictureMapKey(i, j)) 295 .find(FakePicturePile::PictureMapKey(i, j))
295 ->second; 296 ->second;
296 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()); 297 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting());
297 298
298 // If the y far enough away we expect to find no picture (no re-recording 299 // If the y far enough away we expect to find no picture (no re-recording
299 // happened). For close y, the picture should change. 300 // happened). For close y, the picture should change.
300 if (j >= 2) 301 if (j >= 3) {
301 EXPECT_FALSE(picture_info.GetPicture()) << "i " << i << " j " << j; 302 EXPECT_FALSE(picture_info.GetPicture()) << "i " << i << " j " << j;
302 else 303 had_tiles_with_no_pictures = true;
304 } else {
303 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; 305 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j;
306 }
304 } 307 }
305 } 308 }
306 309
310 EXPECT_TRUE(had_tiles_with_no_pictures);
311
307 // Update a partial tile that doesn't get recorded. We should expand the 312 // Update a partial tile that doesn't get recorded. We should expand the
308 // invalidation to the entire tiles that overlap it. 313 // invalidation to the entire tiles that overlap it.
309 Region small_invalidation = 314 Region small_invalidation =
310 gfx::Rect(pile_.tiling().TileBounds(3, 4).x(), 315 gfx::Rect(pile_.tiling().TileBounds(3, 4).x(),
311 pile_.tiling().TileBounds(3, 4).y() + 10, 316 pile_.tiling().TileBounds(3, 4).y() + 10,
312 1, 317 1,
313 1); 318 1);
314 UpdateAndExpandInvalidation(&small_invalidation, tiling_size(), viewport); 319 UpdateAndExpandInvalidation(&small_invalidation, tiling_size(), viewport);
315 EXPECT_TRUE(small_invalidation.Contains(gfx::UnionRects( 320 EXPECT_TRUE(small_invalidation.Contains(gfx::UnionRects(
316 pile_.tiling().TileBounds(2, 4), pile_.tiling().TileBounds(3, 4)))) 321 pile_.tiling().TileBounds(2, 4), pile_.tiling().TileBounds(3, 4))))
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 358
354 TEST_F(PicturePileTest, FrequentInvalidationCanRaster) { 359 TEST_F(PicturePileTest, FrequentInvalidationCanRaster) {
355 // This test makes sure that if part of the page is frequently invalidated 360 // This test makes sure that if part of the page is frequently invalidated
356 // and doesn't get re-recorded, then CanRaster is not true for any 361 // and doesn't get re-recorded, then CanRaster is not true for any
357 // tiles touching it, but is true for adjacent tiles, even if it 362 // tiles touching it, but is true for adjacent tiles, even if it
358 // overlaps on borders (edge case). 363 // overlaps on borders (edge case).
359 gfx::Size new_tiling_size = 364 gfx::Size new_tiling_size =
360 gfx::ToCeiledSize(gfx::ScaleSize(tiling_size(), 4.f)); 365 gfx::ToCeiledSize(gfx::ScaleSize(tiling_size(), 4.f));
361 SetTilingSize(new_tiling_size); 366 SetTilingSize(new_tiling_size);
362 367
363 gfx::Rect tile01_borders = pile_.tiling().TileBoundsWithBorder(0, 1);
364 gfx::Rect tile02_borders = pile_.tiling().TileBoundsWithBorder(0, 2); 368 gfx::Rect tile02_borders = pile_.tiling().TileBoundsWithBorder(0, 2);
365 gfx::Rect tile01_noborders = pile_.tiling().TileBounds(0, 1); 369 gfx::Rect tile03_borders = pile_.tiling().TileBoundsWithBorder(0, 3);
366 gfx::Rect tile02_noborders = pile_.tiling().TileBounds(0, 2); 370 gfx::Rect tile02_noborders = pile_.tiling().TileBounds(0, 2);
371 gfx::Rect tile03_noborders = pile_.tiling().TileBounds(0, 3);
367 372
368 // Sanity check these two tiles are overlapping with borders, since this is 373 // Sanity check these two tiles are overlapping with borders, since this is
369 // what the test is trying to repro. 374 // what the test is trying to repro.
370 EXPECT_TRUE(tile01_borders.Intersects(tile02_borders)); 375 EXPECT_TRUE(tile02_borders.Intersects(tile03_borders));
371 EXPECT_FALSE(tile01_noborders.Intersects(tile02_noborders)); 376 EXPECT_FALSE(tile02_noborders.Intersects(tile03_noborders));
372 UpdateWholePile(); 377 UpdateWholePile();
373 EXPECT_TRUE(pile_.CanRasterLayerRect(tile01_noborders));
374 EXPECT_TRUE(pile_.CanRasterSlowTileCheck(tile01_noborders));
375 EXPECT_TRUE(pile_.CanRasterLayerRect(tile02_noborders)); 378 EXPECT_TRUE(pile_.CanRasterLayerRect(tile02_noborders));
376 EXPECT_TRUE(pile_.CanRasterSlowTileCheck(tile02_noborders)); 379 EXPECT_TRUE(pile_.CanRasterSlowTileCheck(tile02_noborders));
380 EXPECT_TRUE(pile_.CanRasterLayerRect(tile03_noborders));
381 EXPECT_TRUE(pile_.CanRasterSlowTileCheck(tile03_noborders));
377 // Sanity check that an initial paint goes down the fast path of having 382 // Sanity check that an initial paint goes down the fast path of having
378 // a valid recorded viewport. 383 // a valid recorded viewport.
379 EXPECT_TRUE(!pile_.recorded_viewport().IsEmpty()); 384 EXPECT_TRUE(!pile_.recorded_viewport().IsEmpty());
380 385
381 // Update the whole layer until the invalidation frequency is high. 386 // Update the whole layer until the invalidation frequency is high.
382 for (int frame = 0; frame < 33; ++frame) { 387 for (int frame = 0; frame < 33; ++frame) {
383 UpdateWholePile(); 388 UpdateWholePile();
384 } 389 }
385 390
386 // Update once more with a small viewport. 391 // Update once more with a small viewport.
387 gfx::Rect viewport(tiling_size().width(), 1); 392 gfx::Rect viewport(tiling_size().width(), 1);
388 Region invalidation(tiling_rect()); 393 Region invalidation(tiling_rect());
389 UpdateAndExpandInvalidation(&invalidation, tiling_size(), viewport); 394 UpdateAndExpandInvalidation(&invalidation, tiling_size(), viewport);
390 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); 395 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString());
391 396
392 // Sanity check some pictures exist and others don't. 397 // Sanity check some pictures exist and others don't.
393 EXPECT_TRUE(pile_.picture_map() 398 EXPECT_TRUE(pile_.picture_map()
394 .find(FakePicturePile::PictureMapKey(0, 1)) 399 .find(FakePicturePile::PictureMapKey(0, 2))
395 ->second.GetPicture()); 400 ->second.GetPicture());
396 EXPECT_FALSE(pile_.picture_map() 401 EXPECT_FALSE(pile_.picture_map()
397 .find(FakePicturePile::PictureMapKey(0, 2)) 402 .find(FakePicturePile::PictureMapKey(0, 3))
398 ->second.GetPicture()); 403 ->second.GetPicture());
399 404
400 EXPECT_TRUE(pile_.CanRasterLayerRect(tile01_noborders)); 405 EXPECT_TRUE(pile_.CanRasterLayerRect(tile02_noborders));
401 EXPECT_TRUE(pile_.CanRasterSlowTileCheck(tile01_noborders)); 406 EXPECT_TRUE(pile_.CanRasterSlowTileCheck(tile02_noborders));
402 EXPECT_FALSE(pile_.CanRasterLayerRect(tile02_noborders)); 407 EXPECT_FALSE(pile_.CanRasterLayerRect(tile03_noborders));
403 EXPECT_FALSE(pile_.CanRasterSlowTileCheck(tile02_noborders)); 408 EXPECT_FALSE(pile_.CanRasterSlowTileCheck(tile03_noborders));
404 } 409 }
405 410
406 TEST_F(PicturePileTest, NoInvalidationValidViewport) { 411 TEST_F(PicturePileTest, NoInvalidationValidViewport) {
407 // This test validates that the recorded_viewport cache of full tiles 412 // This test validates that the recorded_viewport cache of full tiles
408 // is still valid for some use cases. If it's not, it's a performance 413 // is still valid for some use cases. If it's not, it's a performance
409 // issue because CanRaster checks will go down the slow path. 414 // issue because CanRaster checks will go down the slow path.
410 EXPECT_TRUE(!pile_.recorded_viewport().IsEmpty()); 415 EXPECT_TRUE(!pile_.recorded_viewport().IsEmpty());
411 416
412 // No invalidation, same viewport. 417 // No invalidation, same viewport.
413 Region invalidation; 418 Region invalidation;
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 EXPECT_TRUE(pile_.HasRecordings()); 1543 EXPECT_TRUE(pile_.HasRecordings());
1539 pile_.SetEmptyBounds(); 1544 pile_.SetEmptyBounds();
1540 EXPECT_FALSE(pile_.is_solid_color()); 1545 EXPECT_FALSE(pile_.is_solid_color());
1541 EXPECT_TRUE(pile_.GetSize().IsEmpty()); 1546 EXPECT_TRUE(pile_.GetSize().IsEmpty());
1542 EXPECT_TRUE(pile_.picture_map().empty()); 1547 EXPECT_TRUE(pile_.picture_map().empty());
1543 EXPECT_FALSE(pile_.HasRecordings()); 1548 EXPECT_FALSE(pile_.HasRecordings());
1544 } 1549 }
1545 1550
1546 } // namespace 1551 } // namespace
1547 } // namespace cc 1552 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698