OLD | NEW |
---|---|
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 3186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3197 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3197 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
3198 | 3198 |
3199 // Unshared tiles are occluded on the active tree iff they lie beneath | 3199 // Unshared tiles are occluded on the active tree iff they lie beneath |
3200 // the occluding layer. | 3200 // the occluding layer. |
3201 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), | 3201 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), |
3202 scaled_content_rect.x() >= occluding_layer_position.x()); | 3202 scaled_content_rect.x() >= occluding_layer_position.x()); |
3203 } | 3203 } |
3204 } | 3204 } |
3205 } | 3205 } |
3206 } | 3206 } |
3207 | |
3208 TEST_F(OcclusionTrackingPictureLayerImplTest, | |
3209 OccludedTilesConsideredDuringEviction) { | |
3210 gfx::Size tile_size(102, 102); | |
3211 gfx::Size layer_bounds(1000, 1000); | |
3212 gfx::Size viewport_size(500, 500); | |
3213 gfx::Point occluding_layer_position(310, 0); | |
3214 | |
3215 scoped_refptr<FakePicturePileImpl> pending_pile = | |
3216 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
3217 SetupPendingTree(pending_pile); | |
3218 pending_layer_->set_fixed_tile_size(tile_size); | |
3219 | |
3220 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
3221 | |
3222 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | |
3223 | |
3224 std::vector<PictureLayerTiling*> tilings; | |
3225 tilings.push_back(pending_layer_->AddTiling(low_res_factor)); | |
3226 tilings.push_back(pending_layer_->AddTiling(0.3f)); | |
3227 tilings.push_back(pending_layer_->AddTiling(0.7f)); | |
3228 tilings.push_back(pending_layer_->AddTiling(1.0f)); | |
3229 tilings.push_back(pending_layer_->AddTiling(2.0f)); | |
3230 | |
3231 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | |
3232 LayerImpl* layer1 = pending_layer_->children()[0]; | |
3233 layer1->SetBounds(layer_bounds); | |
3234 layer1->SetContentBounds(layer_bounds); | |
3235 layer1->SetDrawsContent(true); | |
3236 | |
3237 // No occlusion. | |
3238 layer1->SetContentsOpaque(false); | |
3239 | |
3240 host_impl_.SetViewportSize(viewport_size); | |
3241 host_impl_.pending_tree()->UpdateDrawProperties(); | |
3242 | |
3243 std::vector<Tile*> all_tiles; | |
3244 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | |
3245 tilings.begin(); | |
3246 tiling_iterator != tilings.end(); | |
3247 ++tiling_iterator) { | |
3248 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | |
3249 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); | |
3250 } | |
3251 | |
3252 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | |
3253 | |
3254 int occluded_tile_count = 0; | |
3255 Tile* last_tile = NULL; | |
3256 for (PictureLayerImpl::LayerEvictionTileIterator it = | |
3257 PictureLayerImpl::LayerEvictionTileIterator( | |
3258 pending_layer_, NEW_CONTENT_TAKES_PRIORITY); | |
danakj
2014/07/09 17:38:40
what about the SAME_PRIORITY_FOR_BOTH_TREES case?
jbedley
2014/07/11 00:19:38
I added all 6 cases to the test (pending or active
| |
3259 it; | |
3260 ++it) { | |
3261 Tile* tile = *it; | |
3262 if (!last_tile) | |
3263 last_tile = tile; | |
3264 | |
3265 EXPECT_TRUE(tile); | |
3266 | |
3267 if (tile->is_occluded(PENDING_TREE)) { | |
3268 occluded_tile_count++; | |
3269 // Occluded tiles should be evicted first within each tiling. | |
3270 if (!last_tile->is_occluded(PENDING_TREE)) | |
3271 EXPECT_NE(tile->contents_scale(), last_tile->contents_scale()); | |
3272 } | |
3273 | |
3274 last_tile = tile; | |
3275 } | |
3276 EXPECT_EQ(occluded_tile_count, 0); | |
3277 | |
3278 // Partial occlusion. | |
3279 layer1->SetContentsOpaque(true); | |
3280 layer1->SetPosition(occluding_layer_position); | |
3281 | |
3282 host_impl_.pending_tree()->UpdateDrawProperties(); | |
3283 | |
3284 occluded_tile_count = 0; | |
3285 last_tile = NULL; | |
3286 for (PictureLayerImpl::LayerEvictionTileIterator it = | |
3287 PictureLayerImpl::LayerEvictionTileIterator( | |
3288 pending_layer_, NEW_CONTENT_TAKES_PRIORITY); | |
3289 it; | |
3290 ++it) { | |
3291 Tile* tile = *it; | |
3292 if (!last_tile) | |
3293 last_tile = tile; | |
3294 | |
3295 EXPECT_TRUE(tile); | |
3296 | |
3297 if (tile->is_occluded(PENDING_TREE)) { | |
danakj
2014/07/09 17:38:40
Hm, this verifies that we don't evict an occluded
jbedley
2014/07/11 00:19:38
Done.
| |
3298 occluded_tile_count++; | |
3299 if (!last_tile->is_occluded(PENDING_TREE)) | |
3300 EXPECT_NE(tile->contents_scale(), last_tile->contents_scale()); | |
3301 } | |
3302 | |
3303 last_tile = tile; | |
3304 } | |
3305 EXPECT_EQ(occluded_tile_count, 43); | |
3306 | |
3307 // Back to no occlusion. | |
3308 layer1->SetContentsOpaque(false); | |
3309 | |
3310 host_impl_.pending_tree()->UpdateDrawProperties(); | |
3311 | |
3312 occluded_tile_count = 0; | |
3313 last_tile = NULL; | |
3314 for (PictureLayerImpl::LayerEvictionTileIterator it = | |
3315 PictureLayerImpl::LayerEvictionTileIterator( | |
3316 pending_layer_, NEW_CONTENT_TAKES_PRIORITY); | |
3317 it; | |
3318 ++it) { | |
3319 Tile* tile = *it; | |
3320 if (!last_tile) | |
3321 last_tile = tile; | |
3322 | |
3323 EXPECT_TRUE(tile); | |
3324 | |
3325 if (tile->is_occluded(PENDING_TREE)) { | |
3326 occluded_tile_count++; | |
3327 if (!last_tile->is_occluded(PENDING_TREE)) | |
3328 EXPECT_NE(tile->contents_scale(), last_tile->contents_scale()); | |
3329 } | |
3330 | |
3331 last_tile = tile; | |
3332 } | |
3333 EXPECT_EQ(occluded_tile_count, 0); | |
3334 } | |
3207 } // namespace | 3335 } // namespace |
3208 } // namespace cc | 3336 } // namespace cc |
OLD | NEW |