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

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

Issue 377793003: Consider occluded tiles during eviction with occluded as Tile property. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 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 | « no previous file | cc/resources/picture_layer_tiling.cc » ('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 2906 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 2917
2918 class OcclusionTrackingSettings : public ImplSidePaintingSettings { 2918 class OcclusionTrackingSettings : public ImplSidePaintingSettings {
2919 public: 2919 public:
2920 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } 2920 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; }
2921 }; 2921 };
2922 2922
2923 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { 2923 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest {
2924 public: 2924 public:
2925 OcclusionTrackingPictureLayerImplTest() 2925 OcclusionTrackingPictureLayerImplTest()
2926 : PictureLayerImplTest(OcclusionTrackingSettings()) {} 2926 : PictureLayerImplTest(OcclusionTrackingSettings()) {}
2927
2928 void VerifyEvictionConsidersOcclusion(
2929 PictureLayerImpl* layer,
2930 size_t expected_occluded_tile_count[NUM_TREE_PRIORITIES]) {
2931 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES;
2932 ++priority_count) {
2933 TreePriority tree_priority = static_cast<TreePriority>(priority_count);
2934 size_t occluded_tile_count = 0u;
2935 Tile* last_tile = NULL;
2936
2937 for (PictureLayerImpl::LayerEvictionTileIterator it =
2938 PictureLayerImpl::LayerEvictionTileIterator(layer,
2939 tree_priority);
2940 it;
2941 ++it) {
2942 Tile* tile = *it;
2943 if (!last_tile)
2944 last_tile = tile;
2945
2946 // The only way we will encounter an occluded tile after an unoccluded
2947 // tile is if the priorty bin decreased, the tile is required for
2948 // activation, or the scale changed.
2949 bool tile_is_occluded =
2950 tile->is_occluded_for_tree_priority(tree_priority);
2951 if (tile_is_occluded) {
2952 occluded_tile_count++;
2953
2954 bool last_tile_is_occluded =
2955 last_tile->is_occluded_for_tree_priority(tree_priority);
2956 if (!last_tile_is_occluded) {
2957 TilePriority::PriorityBin tile_priority_bin =
2958 tile->priority_for_tree_priority(tree_priority).priority_bin;
2959 TilePriority::PriorityBin last_tile_priority_bin =
2960 last_tile->priority_for_tree_priority(tree_priority)
2961 .priority_bin;
2962
2963 EXPECT_TRUE(
2964 (tile_priority_bin < last_tile_priority_bin) ||
2965 tile->required_for_activation() ||
2966 (tile->contents_scale() != last_tile->contents_scale()));
2967 }
2968 }
2969 last_tile = tile;
2970 }
2971 EXPECT_EQ(expected_occluded_tile_count[priority_count],
2972 occluded_tile_count);
2973 }
2974 }
2927 }; 2975 };
2928 2976
2929 #if defined(OS_WIN) 2977 #if defined(OS_WIN)
2930 #define MAYBE_OccludedTilesSkippedDuringRasterization \ 2978 #define MAYBE_OccludedTilesSkippedDuringRasterization \
2931 DISABLED_OccludedTilesSkippedDuringRasterization 2979 DISABLED_OccludedTilesSkippedDuringRasterization
2932 #else 2980 #else
2933 #define MAYBE_OccludedTilesSkippedDuringRasterization \ 2981 #define MAYBE_OccludedTilesSkippedDuringRasterization \
2934 OccludedTilesSkippedDuringRasterization 2982 OccludedTilesSkippedDuringRasterization
2935 #endif 2983 #endif
2936 TEST_F(OcclusionTrackingPictureLayerImplTest, 2984 TEST_F(OcclusionTrackingPictureLayerImplTest,
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
3312 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); 3360 EXPECT_FALSE(tile->is_occluded(PENDING_TREE));
3313 3361
3314 // Unshared tiles are occluded on the active tree iff they lie beneath 3362 // Unshared tiles are occluded on the active tree iff they lie beneath
3315 // the occluding layer. 3363 // the occluding layer.
3316 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), 3364 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE),
3317 scaled_content_rect.x() >= occluding_layer_position.x()); 3365 scaled_content_rect.x() >= occluding_layer_position.x());
3318 } 3366 }
3319 } 3367 }
3320 } 3368 }
3321 } 3369 }
3370
3371 TEST_F(OcclusionTrackingPictureLayerImplTest,
3372 OccludedTilesConsideredDuringEviction) {
3373 gfx::Size tile_size(102, 102);
3374 gfx::Size layer_bounds(1000, 1000);
3375 gfx::Size viewport_size(500, 500);
3376 gfx::Point pending_occluding_layer_position(310, 0);
3377 gfx::Point active_occluding_layer_position(0, 310);
3378 gfx::Rect invalidation_rect(230, 230, 102, 102);
3379
3380 scoped_refptr<FakePicturePileImpl> pending_pile =
3381 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3382 scoped_refptr<FakePicturePileImpl> active_pile =
3383 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3384 SetupTrees(pending_pile, active_pile);
3385
3386 pending_layer_->set_fixed_tile_size(tile_size);
3387 active_layer_->set_fixed_tile_size(tile_size);
3388
3389 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
3390
3391 std::vector<PictureLayerTiling*> tilings;
3392 tilings.push_back(pending_layer_->AddTiling(low_res_factor));
3393 tilings.push_back(pending_layer_->AddTiling(0.3f));
3394 tilings.push_back(pending_layer_->AddTiling(0.7f));
3395 tilings.push_back(pending_layer_->AddTiling(1.0f));
3396 tilings.push_back(pending_layer_->AddTiling(2.0f));
3397
3398 EXPECT_EQ(5u, pending_layer_->num_tilings());
3399 EXPECT_EQ(5u, active_layer_->num_tilings());
3400
3401 // Partially occlude the pending layer.
3402 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1));
3403 LayerImpl* pending_occluding_layer = pending_layer_->children()[0];
3404 pending_occluding_layer->SetBounds(layer_bounds);
3405 pending_occluding_layer->SetContentBounds(layer_bounds);
3406 pending_occluding_layer->SetDrawsContent(true);
3407 pending_occluding_layer->SetContentsOpaque(true);
3408 pending_occluding_layer->SetPosition(pending_occluding_layer_position);
3409
3410 // Partially occlude the active layer.
3411 active_layer_->AddChild(LayerImpl::Create(host_impl_.active_tree(), 2));
3412 LayerImpl* active_occluding_layer = active_layer_->children()[0];
3413 active_occluding_layer->SetBounds(layer_bounds);
3414 active_occluding_layer->SetContentBounds(layer_bounds);
3415 active_occluding_layer->SetDrawsContent(true);
3416 active_occluding_layer->SetContentsOpaque(true);
3417 active_occluding_layer->SetPosition(active_occluding_layer_position);
3418
3419 // Partially invalidate the pending layer. Tiles inside the invalidation rect
3420 // are not shared between trees.
3421 pending_layer_->set_invalidation(invalidation_rect);
3422
3423 host_impl_.SetViewportSize(viewport_size);
3424 host_impl_.active_tree()->UpdateDrawProperties();
3425 host_impl_.pending_tree()->UpdateDrawProperties();
3426
3427 // The expected number of occluded tiles on each of the 5 tilings for each of
3428 // the 3 tree priorities.
3429 size_t expected_occluded_tile_count_on_both[] = {9u, 1u, 1u, 1u, 1u};
3430 size_t expected_occluded_tile_count_on_active[] = {30u, 5u, 4u, 2u, 2u};
3431 size_t expected_occluded_tile_count_on_pending[] = {30u, 5u, 4u, 2u, 2u};
3432
3433 // The total expected number of occluded tiles on all tilings for each of the
3434 // 3 tree priorities.
3435 size_t total_expected_occluded_tile_count[] = {13u, 43u, 43u};
3436
3437 ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES);
3438
3439 // Verify number of occluded tiles on the pending layer for each tiling.
3440 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
3441 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3442 tiling->CreateAllTilesForTesting();
3443
3444 size_t occluded_tile_count_on_pending = 0u;
3445 size_t occluded_tile_count_on_active = 0u;
3446 size_t occluded_tile_count_on_both = 0u;
3447 for (PictureLayerTiling::CoverageIterator iter(
3448 tiling,
3449 pending_layer_->contents_scale_x(),
3450 gfx::Rect(layer_bounds));
3451 iter;
3452 ++iter) {
3453 Tile* tile = *iter;
3454
3455 if (tile->is_occluded(PENDING_TREE))
3456 occluded_tile_count_on_pending++;
3457 if (tile->is_occluded(ACTIVE_TREE))
3458 occluded_tile_count_on_active++;
3459 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE))
3460 occluded_tile_count_on_both++;
3461 }
3462 EXPECT_EQ(expected_occluded_tile_count_on_pending[i],
3463 occluded_tile_count_on_pending)
3464 << i;
3465 EXPECT_EQ(expected_occluded_tile_count_on_active[i],
3466 occluded_tile_count_on_active)
3467 << i;
3468 EXPECT_EQ(expected_occluded_tile_count_on_both[i],
3469 occluded_tile_count_on_both)
3470 << i;
3471 }
3472
3473 // Verify number of occluded tiles on the active layer for each tiling.
3474 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
3475 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
3476 tiling->CreateAllTilesForTesting();
3477
3478 size_t occluded_tile_count_on_pending = 0u;
3479 size_t occluded_tile_count_on_active = 0u;
3480 size_t occluded_tile_count_on_both = 0u;
3481 for (PictureLayerTiling::CoverageIterator iter(
3482 tiling,
3483 pending_layer_->contents_scale_x(),
3484 gfx::Rect(layer_bounds));
3485 iter;
3486 ++iter) {
3487 Tile* tile = *iter;
3488
3489 if (tile->is_occluded(PENDING_TREE))
3490 occluded_tile_count_on_pending++;
3491 if (tile->is_occluded(ACTIVE_TREE))
3492 occluded_tile_count_on_active++;
3493 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE))
3494 occluded_tile_count_on_both++;
3495 }
3496 EXPECT_EQ(expected_occluded_tile_count_on_pending[i],
3497 occluded_tile_count_on_pending)
3498 << i;
3499 EXPECT_EQ(expected_occluded_tile_count_on_active[i],
3500 occluded_tile_count_on_active)
3501 << i;
3502 EXPECT_EQ(expected_occluded_tile_count_on_both[i],
3503 occluded_tile_count_on_both)
3504 << i;
3505 }
3506
3507 std::vector<Tile*> all_tiles;
3508 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator =
3509 tilings.begin();
3510 tiling_iterator != tilings.end();
3511 ++tiling_iterator) {
3512 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting();
3513 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles));
3514 }
3515
3516 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
3517
3518 VerifyEvictionConsidersOcclusion(pending_layer_,
3519 total_expected_occluded_tile_count);
3520 VerifyEvictionConsidersOcclusion(active_layer_,
3521 total_expected_occluded_tile_count);
3522 }
3322 } // namespace 3523 } // namespace
3323 } // namespace cc 3524 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698