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

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

Issue 868803002: cc: Change the activation/ready for draw check from layer to queue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment format Created 5 years, 11 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
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 3234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 3245
3246 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { 3246 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) {
3247 gfx::Size tile_size(100, 100); 3247 gfx::Size tile_size(100, 100);
3248 gfx::Size layer_bounds(1000, 1000); 3248 gfx::Size layer_bounds(1000, 1000);
3249 3249
3250 // Make sure some tiles are not shared. 3250 // Make sure some tiles are not shared.
3251 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); 3251 gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
3252 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); 3252 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
3253 3253
3254 // All pending layer tiles required are not ready. 3254 // All pending layer tiles required are not ready.
3255 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 3255 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3256 3256
3257 // Initialize all low-res tiles. 3257 // Initialize all low-res tiles.
3258 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); 3258 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
3259 3259
3260 // Low-res tiles should not be enough. 3260 // Low-res tiles should not be enough.
3261 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 3261 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3262 3262
3263 // Initialize remaining tiles. 3263 // Initialize remaining tiles.
3264 pending_layer_->SetAllTilesReady(); 3264 pending_layer_->SetAllTilesReady();
3265 3265
3266 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 3266 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
3267 } 3267 }
3268 3268
3269 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { 3269 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) {
3270 gfx::Size tile_size(100, 100); 3270 gfx::Size tile_size(100, 100);
3271 gfx::Size layer_bounds(1000, 1000); 3271 gfx::Size layer_bounds(1000, 1000);
3272 3272
3273 // Make sure some tiles are not shared. 3273 // Make sure some tiles are not shared.
3274 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); 3274 gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
3275 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); 3275 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
3276 3276
3277 // All pending layer tiles required are not ready. 3277 // All pending layer tiles required are not ready.
3278 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 3278 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3279 3279
3280 // Initialize all high-res tiles. 3280 // Initialize all high-res tiles.
3281 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 3281 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
3282 3282
3283 // High-res tiles should be enough, since they cover everything visible. 3283 // High-res tiles should be enough, since they cover everything visible.
3284 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 3284 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
3285 } 3285 }
3286 3286
3287 TEST_F(PictureLayerImplTest, 3287 TEST_F(PictureLayerImplTest,
3288 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { 3288 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) {
3289 gfx::Size tile_size(100, 100); 3289 gfx::Size tile_size(100, 100);
3290 gfx::Size layer_bounds(1000, 1000); 3290 gfx::Size layer_bounds(1000, 1000);
3291 3291
3292 // Make sure some tiles are not shared. 3292 // Make sure some tiles are not shared.
3293 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); 3293 gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
3294 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); 3294 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
3295 3295
3296 // Initialize all high-res tiles in the active layer. 3296 // Initialize all high-res tiles in the active layer.
3297 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); 3297 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
3298 // And all the low-res tiles in the pending layer. 3298 // And all the low-res tiles in the pending layer.
3299 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); 3299 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
3300 3300
3301 // The unshared high-res tiles are not ready, so we cannot activate. 3301 // The unshared high-res tiles are not ready, so we cannot activate.
3302 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 3302 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3303 3303
3304 // When the unshared pending high-res tiles are ready, we can activate. 3304 // When the unshared pending high-res tiles are ready, we can activate.
3305 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 3305 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
3306 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 3306 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
3307 } 3307 }
3308 3308
3309 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { 3309 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) {
3310 gfx::Size tile_size(100, 100); 3310 gfx::Size tile_size(100, 100);
3311 gfx::Size layer_bounds(1000, 1000); 3311 gfx::Size layer_bounds(1000, 1000);
3312 3312
3313 // Make sure some tiles are not shared. 3313 // Make sure some tiles are not shared.
3314 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); 3314 gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
3315 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); 3315 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
3316 3316
3317 // Initialize all high-res tiles in the active layer. 3317 // Initialize all high-res tiles in the active layer.
3318 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); 3318 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
3319 3319
3320 // The unshared high-res tiles are not ready, so we cannot activate. 3320 // The unshared high-res tiles are not ready, so we cannot activate.
3321 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 3321 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3322 3322
3323 // When the unshared pending high-res tiles are ready, we can activate. 3323 // When the unshared pending high-res tiles are ready, we can activate.
3324 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 3324 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
3325 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 3325 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
3326 } 3326 }
3327 3327
3328 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { 3328 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) {
3329 gfx::Size tile_size(400, 400); 3329 gfx::Size tile_size(400, 400);
3330 gfx::Size layer_bounds(1300, 1900); 3330 gfx::Size layer_bounds(1300, 1900);
3331 3331
3332 scoped_refptr<FakePicturePileImpl> pending_pile = 3332 scoped_refptr<FakePicturePileImpl> pending_pile =
3333 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3333 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3334 scoped_refptr<FakePicturePileImpl> active_pile = 3334 scoped_refptr<FakePicturePileImpl> active_pile =
3335 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3335 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
4722 4722
4723 host_impl_.SetRequiresHighResToDraw(); 4723 host_impl_.SetRequiresHighResToDraw();
4724 4724
4725 // Update tiles. 4725 // Update tiles.
4726 pending_layer_->draw_properties().visible_content_rect = viewport; 4726 pending_layer_->draw_properties().visible_content_rect = viewport;
4727 pending_layer_->draw_properties().screen_space_transform = transform; 4727 pending_layer_->draw_properties().screen_space_transform = transform;
4728 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); 4728 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
4729 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 4729 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
4730 4730
4731 // Ensure we can't activate. 4731 // Ensure we can't activate.
4732 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 4732 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
4733 4733
4734 // Now in the same frame, move the viewport (this can happen during 4734 // Now in the same frame, move the viewport (this can happen during
4735 // animation). 4735 // animation).
4736 viewport = gfx::Rect(0, 2000, 100, 100); 4736 viewport = gfx::Rect(0, 2000, 100, 100);
4737 4737
4738 // Update tiles. 4738 // Update tiles.
4739 pending_layer_->draw_properties().visible_content_rect = viewport; 4739 pending_layer_->draw_properties().visible_content_rect = viewport;
4740 pending_layer_->draw_properties().screen_space_transform = transform; 4740 pending_layer_->draw_properties().screen_space_transform = transform;
4741 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); 4741 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
4742 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); 4742 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting();
4743 4743
4744 // Make sure all viewport tiles (viewport from the tiling) are ready to draw. 4744 // Make sure all viewport tiles (viewport from the tiling) are ready to draw.
4745 std::vector<Tile*> tiles; 4745 std::vector<Tile*> tiles;
4746 for (PictureLayerTiling::CoverageIterator iter( 4746 for (PictureLayerTiling::CoverageIterator iter(
4747 pending_layer_->HighResTiling(), 4747 pending_layer_->HighResTiling(),
4748 1.f, 4748 1.f,
4749 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting()); 4749 pending_layer_->HighResTiling()->GetCurrentVisibleRectForTesting());
4750 iter; 4750 iter;
4751 ++iter) { 4751 ++iter) {
4752 if (*iter) 4752 if (*iter)
4753 tiles.push_back(*iter); 4753 tiles.push_back(*iter);
4754 } 4754 }
4755 4755
4756 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 4756 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
4757 4757
4758 // Ensure we can activate. 4758 // Ensure we can activate.
4759 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); 4759 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
4760 } 4760 }
4761 4761
4762 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { 4762 TEST_F(PictureLayerImplTest, CloneMissingRecordings) {
4763 gfx::Size tile_size(100, 100); 4763 gfx::Size tile_size(100, 100);
4764 gfx::Size layer_bounds(400, 400); 4764 gfx::Size layer_bounds(400, 400);
4765 4765
4766 scoped_refptr<FakePicturePileImpl> filled_pile = 4766 scoped_refptr<FakePicturePileImpl> filled_pile =
4767 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4767 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4768 scoped_refptr<FakePicturePileImpl> partial_pile = 4768 scoped_refptr<FakePicturePileImpl> partial_pile =
4769 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 4769 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
4879 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4879 result = layer->CalculateTileSize(gfx::Size(447, 400));
4880 EXPECT_EQ(result.width(), 448); 4880 EXPECT_EQ(result.width(), 448);
4881 EXPECT_EQ(result.height(), 448); 4881 EXPECT_EQ(result.height(), 448);
4882 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4882 result = layer->CalculateTileSize(gfx::Size(500, 499));
4883 EXPECT_EQ(result.width(), 512); 4883 EXPECT_EQ(result.width(), 512);
4884 EXPECT_EQ(result.height(), 500 + 2); 4884 EXPECT_EQ(result.height(), 500 + 2);
4885 } 4885 }
4886 4886
4887 } // namespace 4887 } // namespace
4888 } // namespace cc 4888 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698