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

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: add tests 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
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 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 } else { 1443 } else {
1444 EXPECT_FALSE(tile->required_for_activation()); 1444 EXPECT_FALSE(tile->required_for_activation());
1445 num_offscreen++; 1445 num_offscreen++;
1446 } 1446 }
1447 } 1447 }
1448 1448
1449 EXPECT_GT(num_visible, 0); 1449 EXPECT_GT(num_visible, 0);
1450 EXPECT_GT(num_offscreen, 0); 1450 EXPECT_GT(num_offscreen, 0);
1451 } 1451 }
1452 1452
1453 TEST_F(PictureLayerImplTest, TileOutsideOfActivationRectNotRequired) {
1454 base::TimeTicks time_ticks;
1455 time_ticks += base::TimeDelta::FromMilliseconds(1);
1456 host_impl_.SetCurrentFrameTimeTicks(time_ticks);
1457
1458 gfx::Size tile_size(100, 100);
1459 gfx::Size layer_bounds(400, 400);
1460 gfx::Rect external_activation_rect(400, 200);
1461 gfx::Rect visible_content_rect(200, 400);
1462
1463 scoped_refptr<FakePicturePileImpl> active_pile =
1464 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1465 scoped_refptr<FakePicturePileImpl> pending_pile =
1466 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1467 SetupTrees(pending_pile, active_pile);
1468
1469 active_layer_->set_fixed_tile_size(tile_size);
1470 pending_layer_->set_fixed_tile_size(tile_size);
1471 ASSERT_TRUE(pending_layer_->CanHaveTilings());
1472 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f);
1473
1474 // Set external activation rect.
1475 gfx::Rect viewport = gfx::Rect(layer_bounds);
1476 gfx::Transform transform;
1477 gfx::Rect viewport_rect_for_tile_priority = external_activation_rect;
1478 gfx::Transform transform_for_tile_priority;
1479 bool resourceless_software_draw = false;
1480 host_impl_.SetExternalDrawConstraints(transform,
1481 viewport,
1482 viewport,
1483 viewport_rect_for_tile_priority,
1484 transform_for_tile_priority,
1485 resourceless_software_draw);
1486 host_impl_.pending_tree()->UpdateDrawProperties();
1487
1488 // Set visible content rect that is different from activation rect.
1489 pending_layer_->draw_properties().visible_content_rect = visible_content_rect;
1490 time_ticks += base::TimeDelta::FromMilliseconds(200);
1491 host_impl_.SetCurrentFrameTimeTicks(time_ticks);
1492 pending_layer_->UpdateTiles(NULL);
1493
1494 pending_layer_->MarkVisibleResourcesAsRequired();
1495
1496 // Intersect the two rects. Any tile outside should not be required for
1497 // activation.
1498 gfx::Rect activation_rect = pending_layer_->GetActivationRectInContentSpace();
1499 activation_rect.Intersect(pending_layer_->visible_content_rect());
1500
1501 int num_inside = 0;
1502 int num_outside = 0;
1503 for (PictureLayerTiling::CoverageIterator iter(
1504 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds));
1505 iter;
1506 ++iter) {
1507 if (!*iter)
1508 continue;
1509 Tile* tile = *iter;
1510 if (activation_rect.Intersects(iter.geometry_rect())) {
1511 num_inside++;
1512 // Mark everything in activation rect as ready to draw.
1513 ManagedTileState::TileVersion& tile_version =
1514 tile->GetTileVersionForTesting(
1515 tile->DetermineRasterModeForTree(PENDING_TREE));
1516 tile_version.SetSolidColorForTesting(SK_ColorRED);
hush (inactive) 2014/08/18 20:48:16 are you going to test if the color of these tiles
boliu 2014/08/18 21:32:57 I think checking the quads are red isn't really th
1517 } else {
1518 num_outside++;
1519 EXPECT_FALSE(tile->required_for_activation());
1520 }
1521 }
1522
1523 EXPECT_GT(num_inside, 0);
1524 EXPECT_GT(num_outside, 0);
1525
1526 // Activate and draw active layer.
1527 host_impl_.ActivateSyncTree();
1528 host_impl_.active_tree()->UpdateDrawProperties();
1529 active_layer_->draw_properties().visible_content_rect = visible_content_rect;
1530
1531 MockOcclusionTracker<LayerImpl> occlusion_tracker;
1532 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1533 AppendQuadsData data;
1534 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL);
1535 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data);
1536 active_layer_->DidDraw(NULL);
1537
1538 // All tiles in activation rect is ready to draw.
1539 EXPECT_EQ(0u, data.num_missing_tiles_inside_activation_rect);
1540 // There are tiles outside of activation rect but inside draw rect missing.
1541 EXPECT_LT(0u, data.num_missing_tiles);
1542 }
1543
1453 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { 1544 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) {
1454 gfx::Size layer_bounds(400, 400); 1545 gfx::Size layer_bounds(400, 400);
1455 gfx::Size tile_size(100, 100); 1546 gfx::Size tile_size(100, 100);
1456 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); 1547 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size);
1457 1548
1458 // No tiles shared. 1549 // No tiles shared.
1459 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); 1550 pending_layer_->set_invalidation(gfx::Rect(layer_bounds));
1460 1551
1461 CreateHighLowResAndSetAllTilesVisible(); 1552 CreateHighLowResAndSetAllTilesVisible();
1462 1553
(...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 3795
3705 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); 3796 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
3706 3797
3707 VerifyEvictionConsidersOcclusion(pending_layer_, 3798 VerifyEvictionConsidersOcclusion(pending_layer_,
3708 total_expected_occluded_tile_count); 3799 total_expected_occluded_tile_count);
3709 VerifyEvictionConsidersOcclusion(active_layer_, 3800 VerifyEvictionConsidersOcclusion(active_layer_,
3710 total_expected_occluded_tile_count); 3801 total_expected_occluded_tile_count);
3711 } 3802 }
3712 } // namespace 3803 } // namespace
3713 } // namespace cc 3804 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698