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

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

Issue 196343005: cc: Replace recorded region with direct map lookup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 <utility> 7 #include <utility>
8 8
9 #include "cc/layers/append_quads_data.h" 9 #include "cc/layers/append_quads_data.h"
10 #include "cc/layers/picture_layer.h" 10 #include "cc/layers/picture_layer.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 const PictureLayerTiling* tiling = tilings->tiling_at(i); 475 const PictureLayerTiling* tiling = tilings->tiling_at(i);
476 476
477 for (PictureLayerTiling::CoverageIterator 477 for (PictureLayerTiling::CoverageIterator
478 iter(tiling, 478 iter(tiling,
479 tiling->contents_scale(), 479 tiling->contents_scale(),
480 tiling->ContentRect()); 480 tiling->ContentRect());
481 iter; 481 iter;
482 ++iter) { 482 ++iter) {
483 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); 483 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty());
484 // Ensure there is a recording for this tile. 484 // Ensure there is a recording for this tile.
485 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( 485 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect(
vmpstr 2014/03/12 23:57:35 I think this variable is now unused and can be rem
enne (OOO) 2014/03/13 01:35:43 Done.
486 iter.full_tile_geometry_rect(), 1.f / tiling->contents_scale()); 486 iter.full_tile_geometry_rect(), 1.f / tiling->contents_scale());
487 layer_rect.Intersect(gfx::Rect(layer_bounds)); 487 layer_rect.Intersect(gfx::Rect(layer_bounds));
488 488
489 bool in_pending = pending_pile->recorded_region().Contains(layer_rect); 489 bool in_pending = pending_pile->CanRaster(tiling->contents_scale(),
490 bool in_active = active_pile->recorded_region().Contains(layer_rect); 490 iter.full_tile_geometry_rect());
491 bool in_active = active_pile->CanRaster(tiling->contents_scale(),
492 iter.full_tile_geometry_rect());
491 493
492 if (in_pending && !in_active) 494 if (in_pending && !in_active)
493 EXPECT_EQ(pending_pile, iter->picture_pile()); 495 EXPECT_EQ(pending_pile, iter->picture_pile());
494 else if (in_active) 496 else if (in_active)
495 EXPECT_EQ(active_pile, iter->picture_pile()); 497 EXPECT_EQ(active_pile, iter->picture_pile());
496 else 498 else
497 EXPECT_FALSE(*iter); 499 EXPECT_FALSE(*iter);
498 } 500 }
499 } 501 }
500 } 502 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 } 622 }
621 623
622 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { 624 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) {
623 // This test makes sure that if a layer can have tilings, then a commit makes 625 // This test makes sure that if a layer can have tilings, then a commit makes
624 // it not able to have tilings (empty size), and then a future commit that 626 // it not able to have tilings (empty size), and then a future commit that
625 // makes it valid again should be able to create tilings. 627 // makes it valid again should be able to create tilings.
626 gfx::Size tile_size(400, 400); 628 gfx::Size tile_size(400, 400);
627 gfx::Size layer_bounds(1300, 1900); 629 gfx::Size layer_bounds(1300, 1900);
628 630
629 scoped_refptr<FakePicturePileImpl> empty_pile = 631 scoped_refptr<FakePicturePileImpl> empty_pile =
630 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 0)); 632 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
631 scoped_refptr<FakePicturePileImpl> valid_pile = 633 scoped_refptr<FakePicturePileImpl> valid_pile =
632 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 634 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
633 635
634 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 636 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
635 EXPECT_LT(low_res_factor, 1.f); 637 EXPECT_LT(low_res_factor, 1.f);
636 638
637 float high_res_scale = 1.3f; 639 float high_res_scale = 1.3f;
638 float low_res_scale = high_res_scale * low_res_factor; 640 float low_res_scale = high_res_scale * low_res_factor;
639 float device_scale = 1.7f; 641 float device_scale = 1.7f;
640 float page_scale = 3.2f; 642 float page_scale = 3.2f;
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 pending_layer_->MarkVisibleResourcesAsRequired(); 1309 pending_layer_->MarkVisibleResourcesAsRequired();
1308 AssertNoTilesRequired(pending_layer_->HighResTiling()); 1310 AssertNoTilesRequired(pending_layer_->HighResTiling());
1309 AssertNoTilesRequired(pending_layer_->LowResTiling()); 1311 AssertNoTilesRequired(pending_layer_->LowResTiling());
1310 } 1312 }
1311 1313
1312 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 1314 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
1313 gfx::Size layer_bounds(400, 400); 1315 gfx::Size layer_bounds(400, 400);
1314 gfx::Size tile_size(100, 100); 1316 gfx::Size tile_size(100, 100);
1315 scoped_refptr<FakePicturePileImpl> pending_pile = 1317 scoped_refptr<FakePicturePileImpl> pending_pile =
1316 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1318 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1317 // An arbitrary bogus outside the layer recording. Enough for the layer to 1319 // This pile will create tilings, but has no recordings so will
1318 // think it can create tiles, but not in bounds so all tiles are null. 1320 // not create any tiles.
1319 Region active_recorded_region;
1320 active_recorded_region.Union(gfx::Rect(1000, 1000, 1, 1));
1321 scoped_refptr<FakePicturePileImpl> active_pile = 1321 scoped_refptr<FakePicturePileImpl> active_pile =
1322 FakePicturePileImpl::CreatePileWithRecordedRegion( 1322 FakePicturePileImpl::CreateEmptyPileThatThinksItHasTiles(tile_size,
1323 tile_size, layer_bounds, active_recorded_region); 1323 layer_bounds);
1324 SetupTrees(pending_pile, active_pile); 1324 SetupTrees(pending_pile, active_pile);
1325 pending_layer_->set_fixed_tile_size(tile_size); 1325 pending_layer_->set_fixed_tile_size(tile_size);
1326 active_layer_->set_fixed_tile_size(tile_size); 1326 active_layer_->set_fixed_tile_size(tile_size);
1327 1327
1328 CreateHighLowResAndSetAllTilesVisible(); 1328 CreateHighLowResAndSetAllTilesVisible();
1329 1329
1330 // Active layer has tilings, but no tiles due to missing recordings. 1330 // Active layer has tilings, but no tiles due to missing recordings.
1331 EXPECT_TRUE(active_layer_->CanHaveTilings()); 1331 EXPECT_TRUE(active_layer_->CanHaveTilings());
1332 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); 1332 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u);
1333 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 1333 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 TestContextProvider::Create(), NULL)); 1547 TestContextProvider::Create(), NULL));
1548 1548
1549 // These will crash PictureLayerImpl if this is not true. 1549 // These will crash PictureLayerImpl if this is not true.
1550 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); 1550 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties());
1551 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); 1551 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties());
1552 host_impl_.active_tree()->UpdateDrawProperties(); 1552 host_impl_.active_tree()->UpdateDrawProperties();
1553 } 1553 }
1554 1554
1555 } // namespace 1555 } // namespace
1556 } // namespace cc 1556 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698