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

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 475233002: cc: Avoid redraw for missing tile outside visible rect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove skip_viewport_for_tile_priority_check Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/test/fake_picture_layer_impl.h » ('j') | 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 "cc/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 } else { 1450 } else {
1451 EXPECT_FALSE(tile->required_for_activation()); 1451 EXPECT_FALSE(tile->required_for_activation());
1452 num_offscreen++; 1452 num_offscreen++;
1453 } 1453 }
1454 } 1454 }
1455 1455
1456 EXPECT_GT(num_visible, 0); 1456 EXPECT_GT(num_visible, 0);
1457 EXPECT_GT(num_offscreen, 0); 1457 EXPECT_GT(num_offscreen, 0);
1458 } 1458 }
1459 1459
1460 TEST_F(PictureLayerImplTest, TileOutsideOfViewportForTilePriorityNotRequired) {
1461 base::TimeTicks time_ticks;
1462 time_ticks += base::TimeDelta::FromMilliseconds(1);
1463 host_impl_.SetCurrentBeginFrameArgs(
1464 CreateBeginFrameArgsForTesting(time_ticks));
1465
1466 gfx::Size tile_size(100, 100);
1467 gfx::Size layer_bounds(400, 400);
1468 gfx::Rect external_viewport_for_tile_priority(400, 200);
1469 gfx::Rect visible_content_rect(200, 400);
1470
1471 scoped_refptr<FakePicturePileImpl> active_pile =
1472 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1473 scoped_refptr<FakePicturePileImpl> pending_pile =
1474 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1475 SetupTrees(pending_pile, active_pile);
1476
1477 active_layer_->set_fixed_tile_size(tile_size);
1478 pending_layer_->set_fixed_tile_size(tile_size);
1479 ASSERT_TRUE(pending_layer_->CanHaveTilings());
1480 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f);
1481
1482 // Set external viewport for tile priority.
1483 gfx::Rect viewport = gfx::Rect(layer_bounds);
1484 gfx::Transform transform;
1485 gfx::Transform transform_for_tile_priority;
1486 bool resourceless_software_draw = false;
1487 host_impl_.SetExternalDrawConstraints(transform,
1488 viewport,
1489 viewport,
1490 external_viewport_for_tile_priority,
1491 transform_for_tile_priority,
1492 resourceless_software_draw);
1493 host_impl_.pending_tree()->UpdateDrawProperties();
1494
1495 // Set visible content rect that is different from
1496 // external_viewport_for_tile_priority.
1497 pending_layer_->draw_properties().visible_content_rect = visible_content_rect;
1498 time_ticks += base::TimeDelta::FromMilliseconds(200);
1499 host_impl_.SetCurrentBeginFrameArgs(
1500 CreateBeginFrameArgsForTesting(time_ticks));
1501 pending_layer_->UpdateTiles(NULL);
1502
1503 pending_layer_->MarkVisibleResourcesAsRequired();
1504
1505 // Intersect the two rects. Any tile outside should not be required for
1506 // activation.
1507 gfx::Rect viewport_for_tile_priority =
1508 pending_layer_->GetViewportForTilePriorityInContentSpace();
1509 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect());
1510
1511 int num_inside = 0;
1512 int num_outside = 0;
1513 for (PictureLayerTiling::CoverageIterator iter(
1514 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds));
1515 iter;
1516 ++iter) {
1517 if (!*iter)
1518 continue;
1519 Tile* tile = *iter;
1520 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) {
1521 num_inside++;
1522 // Mark everything in viewport for tile priority as ready to draw.
1523 ManagedTileState::TileVersion& tile_version =
1524 tile->GetTileVersionForTesting(
1525 tile->DetermineRasterModeForTree(PENDING_TREE));
1526 tile_version.SetSolidColorForTesting(SK_ColorRED);
1527 } else {
1528 num_outside++;
1529 EXPECT_FALSE(tile->required_for_activation());
1530 }
1531 }
1532
1533 EXPECT_GT(num_inside, 0);
1534 EXPECT_GT(num_outside, 0);
1535
1536 // Activate and draw active layer.
1537 host_impl_.ActivateSyncTree();
1538 host_impl_.active_tree()->UpdateDrawProperties();
1539 active_layer_->draw_properties().visible_content_rect = visible_content_rect;
1540
1541 MockOcclusionTracker<LayerImpl> occlusion_tracker;
1542 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1543 AppendQuadsData data;
1544 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL);
1545 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data);
1546 active_layer_->DidDraw(NULL);
1547
1548 // All tiles in activation rect is ready to draw.
1549 EXPECT_EQ(0u, data.num_missing_tiles);
1550 EXPECT_EQ(0u, data.num_incomplete_tiles);
1551 }
1552
1460 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { 1553 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) {
1461 gfx::Size layer_bounds(400, 400); 1554 gfx::Size layer_bounds(400, 400);
1462 gfx::Size tile_size(100, 100); 1555 gfx::Size tile_size(100, 100);
1463 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 1556 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
1464 1557
1465 // No tiles shared. 1558 // No tiles shared.
1466 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); 1559 pending_layer_->set_invalidation(gfx::Rect(layer_bounds));
1467 1560
1468 CreateHighLowResAndSetAllTilesVisible(); 1561 CreateHighLowResAndSetAllTilesVisible();
1469 1562
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3720 3813
3721 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); 3814 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
3722 3815
3723 VerifyEvictionConsidersOcclusion(pending_layer_, 3816 VerifyEvictionConsidersOcclusion(pending_layer_,
3724 total_expected_occluded_tile_count); 3817 total_expected_occluded_tile_count);
3725 VerifyEvictionConsidersOcclusion(active_layer_, 3818 VerifyEvictionConsidersOcclusion(active_layer_,
3726 total_expected_occluded_tile_count); 3819 total_expected_occluded_tile_count);
3727 } 3820 }
3728 } // namespace 3821 } // namespace
3729 } // namespace cc 3822 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/test/fake_picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698