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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 487 |
488 EXPECT_FALSE(visible_rect_for_tile_priority == | 488 EXPECT_FALSE(visible_rect_for_tile_priority == |
489 active_layer_->visible_rect_for_tile_priority()); | 489 active_layer_->visible_rect_for_tile_priority()); |
490 EXPECT_FALSE(viewport_rect_for_tile_priority == | 490 EXPECT_FALSE(viewport_rect_for_tile_priority == |
491 active_layer_->viewport_rect_for_tile_priority()); | 491 active_layer_->viewport_rect_for_tile_priority()); |
492 EXPECT_FALSE(screen_space_transform_for_tile_priority == | 492 EXPECT_FALSE(screen_space_transform_for_tile_priority == |
493 active_layer_->screen_space_transform_for_tile_priority()); | 493 active_layer_->screen_space_transform_for_tile_priority()); |
494 } | 494 } |
495 | 495 |
496 TEST_F(PictureLayerImplTest, InvalidViewportAfterReleaseResources) { | 496 TEST_F(PictureLayerImplTest, InvalidViewportAfterReleaseResources) { |
497 base::TimeTicks time_ticks; | |
498 time_ticks += base::TimeDelta::FromMilliseconds(1); | |
499 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | |
500 | |
501 gfx::Size tile_size(100, 100); | 497 gfx::Size tile_size(100, 100); |
502 gfx::Size layer_bounds(400, 400); | 498 gfx::Size layer_bounds(400, 400); |
503 | 499 |
504 scoped_refptr<FakePicturePileImpl> pending_pile = | 500 scoped_refptr<FakePicturePileImpl> pending_pile = |
505 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 501 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
506 scoped_refptr<FakePicturePileImpl> active_pile = | 502 scoped_refptr<FakePicturePileImpl> active_pile = |
507 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 503 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
508 | 504 |
509 SetupTrees(pending_pile, active_pile); | 505 SetupTrees(pending_pile, active_pile); |
510 | 506 |
(...skipping 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2757 | 2753 |
2758 EXPECT_FALSE(visible_rect_for_tile_priority == | 2754 EXPECT_FALSE(visible_rect_for_tile_priority == |
2759 active_layer_->visible_rect_for_tile_priority()); | 2755 active_layer_->visible_rect_for_tile_priority()); |
2760 EXPECT_FALSE(viewport_rect_for_tile_priority == | 2756 EXPECT_FALSE(viewport_rect_for_tile_priority == |
2761 active_layer_->viewport_rect_for_tile_priority()); | 2757 active_layer_->viewport_rect_for_tile_priority()); |
2762 EXPECT_FALSE(screen_space_transform_for_tile_priority == | 2758 EXPECT_FALSE(screen_space_transform_for_tile_priority == |
2763 active_layer_->screen_space_transform_for_tile_priority()); | 2759 active_layer_->screen_space_transform_for_tile_priority()); |
2764 } | 2760 } |
2765 | 2761 |
2766 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportAfterReleaseResources) { | 2762 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportAfterReleaseResources) { |
2767 base::TimeTicks time_ticks; | |
2768 time_ticks += base::TimeDelta::FromMilliseconds(1); | |
2769 host_impl_.SetCurrentFrameTimeTicks(time_ticks); | |
2770 | |
2771 gfx::Size tile_size(100, 100); | 2763 gfx::Size tile_size(100, 100); |
2772 gfx::Size layer_bounds(400, 400); | 2764 gfx::Size layer_bounds(400, 400); |
2773 | 2765 |
2774 scoped_refptr<FakePicturePileImpl> pending_pile = | 2766 scoped_refptr<FakePicturePileImpl> pending_pile = |
2775 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2767 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2776 scoped_refptr<FakePicturePileImpl> active_pile = | 2768 scoped_refptr<FakePicturePileImpl> active_pile = |
2777 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2769 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2778 | 2770 |
2779 SetupTrees(pending_pile, active_pile); | 2771 SetupTrees(pending_pile, active_pile); |
2780 | 2772 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3161 } | 3153 } |
3162 } | 3154 } |
3163 last_tile = tile; | 3155 last_tile = tile; |
3164 } | 3156 } |
3165 EXPECT_EQ(expected_occluded_tile_count[priority_count], | 3157 EXPECT_EQ(expected_occluded_tile_count[priority_count], |
3166 occluded_tile_count); | 3158 occluded_tile_count); |
3167 } | 3159 } |
3168 } | 3160 } |
3169 }; | 3161 }; |
3170 | 3162 |
3171 #if defined(OS_WIN) | |
3172 #define MAYBE_OccludedTilesSkippedDuringRasterization \ | |
3173 DISABLED_OccludedTilesSkippedDuringRasterization | |
3174 #else | |
3175 #define MAYBE_OccludedTilesSkippedDuringRasterization \ | |
3176 OccludedTilesSkippedDuringRasterization | |
3177 #endif | |
3178 TEST_F(OcclusionTrackingPictureLayerImplTest, | 3163 TEST_F(OcclusionTrackingPictureLayerImplTest, |
3179 MAYBE_OccludedTilesSkippedDuringRasterization) { | 3164 OccludedTilesSkippedDuringRasterization) { |
| 3165 base::TimeTicks time_ticks; |
| 3166 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 3167 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
| 3168 |
3180 gfx::Size tile_size(102, 102); | 3169 gfx::Size tile_size(102, 102); |
3181 gfx::Size layer_bounds(1000, 1000); | 3170 gfx::Size layer_bounds(1000, 1000); |
3182 gfx::Size viewport_size(500, 500); | 3171 gfx::Size viewport_size(500, 500); |
3183 gfx::Point occluding_layer_position(310, 0); | 3172 gfx::Point occluding_layer_position(310, 0); |
3184 | 3173 |
3185 scoped_refptr<FakePicturePileImpl> pending_pile = | 3174 scoped_refptr<FakePicturePileImpl> pending_pile = |
3186 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3175 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3187 SetupPendingTree(pending_pile); | 3176 SetupPendingTree(pending_pile); |
3188 pending_layer_->set_fixed_tile_size(tile_size); | 3177 pending_layer_->set_fixed_tile_size(tile_size); |
3189 | 3178 |
(...skipping 22 matching lines...) Expand all Loading... |
3212 | 3201 |
3213 // Partial occlusion. | 3202 // Partial occlusion. |
3214 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 3203 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
3215 LayerImpl* layer1 = pending_layer_->children()[0]; | 3204 LayerImpl* layer1 = pending_layer_->children()[0]; |
3216 layer1->SetBounds(layer_bounds); | 3205 layer1->SetBounds(layer_bounds); |
3217 layer1->SetContentBounds(layer_bounds); | 3206 layer1->SetContentBounds(layer_bounds); |
3218 layer1->SetDrawsContent(true); | 3207 layer1->SetDrawsContent(true); |
3219 layer1->SetContentsOpaque(true); | 3208 layer1->SetContentsOpaque(true); |
3220 layer1->SetPosition(occluding_layer_position); | 3209 layer1->SetPosition(occluding_layer_position); |
3221 | 3210 |
| 3211 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3212 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
3222 host_impl_.pending_tree()->UpdateDrawProperties(); | 3213 host_impl_.pending_tree()->UpdateDrawProperties(); |
3223 | 3214 |
3224 unoccluded_tile_count = 0; | 3215 unoccluded_tile_count = 0; |
3225 for (PictureLayerImpl::LayerRasterTileIterator it = | 3216 for (PictureLayerImpl::LayerRasterTileIterator it = |
3226 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 3217 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
3227 it; | 3218 it; |
3228 ++it) { | 3219 ++it) { |
3229 Tile* tile = *it; | 3220 Tile* tile = *it; |
3230 | 3221 |
3231 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3222 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
3232 | 3223 |
3233 bool tile_is_visible = | 3224 bool tile_is_visible = |
3234 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3225 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
3235 if (tile_is_visible) | 3226 if (tile_is_visible) |
3236 unoccluded_tile_count++; | 3227 unoccluded_tile_count++; |
3237 } | 3228 } |
3238 EXPECT_EQ(unoccluded_tile_count, 20 + 2); | 3229 EXPECT_EQ(unoccluded_tile_count, 20 + 2); |
3239 | 3230 |
3240 // Full occlusion. | 3231 // Full occlusion. |
3241 layer1->SetPosition(gfx::Point(0, 0)); | 3232 layer1->SetPosition(gfx::Point(0, 0)); |
3242 | 3233 |
| 3234 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3235 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
3243 host_impl_.pending_tree()->UpdateDrawProperties(); | 3236 host_impl_.pending_tree()->UpdateDrawProperties(); |
3244 | 3237 |
3245 unoccluded_tile_count = 0; | 3238 unoccluded_tile_count = 0; |
3246 for (PictureLayerImpl::LayerRasterTileIterator it = | 3239 for (PictureLayerImpl::LayerRasterTileIterator it = |
3247 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 3240 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
3248 it; | 3241 it; |
3249 ++it) { | 3242 ++it) { |
3250 Tile* tile = *it; | 3243 Tile* tile = *it; |
3251 | 3244 |
3252 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); | 3245 EXPECT_FALSE(tile->is_occluded(PENDING_TREE)); |
3253 | 3246 |
3254 bool tile_is_visible = | 3247 bool tile_is_visible = |
3255 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); | 3248 tile->content_rect().Intersects(pending_layer_->visible_content_rect()); |
3256 if (tile_is_visible) | 3249 if (tile_is_visible) |
3257 unoccluded_tile_count++; | 3250 unoccluded_tile_count++; |
3258 } | 3251 } |
3259 EXPECT_EQ(unoccluded_tile_count, 0); | 3252 EXPECT_EQ(unoccluded_tile_count, 0); |
3260 } | 3253 } |
3261 | 3254 |
3262 #if defined(OS_WIN) | |
3263 #define MAYBE_OccludedTilesNotMarkedAsRequired \ | |
3264 DISABLED_OccludedTilesNotMarkedAsRequired | |
3265 #else | |
3266 #define MAYBE_OccludedTilesNotMarkedAsRequired OccludedTilesNotMarkedAsRequired | |
3267 #endif | |
3268 TEST_F(OcclusionTrackingPictureLayerImplTest, | 3255 TEST_F(OcclusionTrackingPictureLayerImplTest, |
3269 MAYBE_OccludedTilesNotMarkedAsRequired) { | 3256 OccludedTilesNotMarkedAsRequired) { |
| 3257 base::TimeTicks time_ticks; |
| 3258 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 3259 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
| 3260 |
3270 gfx::Size tile_size(102, 102); | 3261 gfx::Size tile_size(102, 102); |
3271 gfx::Size layer_bounds(1000, 1000); | 3262 gfx::Size layer_bounds(1000, 1000); |
3272 gfx::Size viewport_size(500, 500); | 3263 gfx::Size viewport_size(500, 500); |
3273 gfx::Point occluding_layer_position(310, 0); | 3264 gfx::Point occluding_layer_position(310, 0); |
3274 | 3265 |
3275 scoped_refptr<FakePicturePileImpl> pending_pile = | 3266 scoped_refptr<FakePicturePileImpl> pending_pile = |
3276 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3267 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3277 SetupPendingTree(pending_pile); | 3268 SetupPendingTree(pending_pile); |
3278 pending_layer_->set_fixed_tile_size(tile_size); | 3269 pending_layer_->set_fixed_tile_size(tile_size); |
3279 | 3270 |
(...skipping 27 matching lines...) Expand all Loading... |
3307 | 3298 |
3308 // Partial occlusion. | 3299 // Partial occlusion. |
3309 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 3300 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
3310 LayerImpl* layer1 = pending_layer_->children()[0]; | 3301 LayerImpl* layer1 = pending_layer_->children()[0]; |
3311 layer1->SetBounds(layer_bounds); | 3302 layer1->SetBounds(layer_bounds); |
3312 layer1->SetContentBounds(layer_bounds); | 3303 layer1->SetContentBounds(layer_bounds); |
3313 layer1->SetDrawsContent(true); | 3304 layer1->SetDrawsContent(true); |
3314 layer1->SetContentsOpaque(true); | 3305 layer1->SetContentsOpaque(true); |
3315 layer1->SetPosition(occluding_layer_position); | 3306 layer1->SetPosition(occluding_layer_position); |
3316 | 3307 |
| 3308 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3309 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
3317 host_impl_.pending_tree()->UpdateDrawProperties(); | 3310 host_impl_.pending_tree()->UpdateDrawProperties(); |
3318 | 3311 |
3319 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 3312 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
3320 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 3313 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
3321 | 3314 |
3322 occluded_tile_count = 0; | 3315 occluded_tile_count = 0; |
3323 for (PictureLayerTiling::CoverageIterator iter( | 3316 for (PictureLayerTiling::CoverageIterator iter( |
3324 tiling, | 3317 tiling, |
3325 pending_layer_->contents_scale_x(), | 3318 pending_layer_->contents_scale_x(), |
3326 gfx::Rect(layer_bounds)); | 3319 gfx::Rect(layer_bounds)); |
(...skipping 16 matching lines...) Expand all Loading... |
3343 EXPECT_EQ(occluded_tile_count, 2); | 3336 EXPECT_EQ(occluded_tile_count, 2); |
3344 break; | 3337 break; |
3345 default: | 3338 default: |
3346 NOTREACHED(); | 3339 NOTREACHED(); |
3347 } | 3340 } |
3348 } | 3341 } |
3349 | 3342 |
3350 // Full occlusion. | 3343 // Full occlusion. |
3351 layer1->SetPosition(gfx::PointF(0, 0)); | 3344 layer1->SetPosition(gfx::PointF(0, 0)); |
3352 | 3345 |
| 3346 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3347 host_impl_.SetCurrentFrameTimeTicks(time_ticks); |
3353 host_impl_.pending_tree()->UpdateDrawProperties(); | 3348 host_impl_.pending_tree()->UpdateDrawProperties(); |
3354 | 3349 |
3355 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 3350 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
3356 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 3351 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
3357 | 3352 |
3358 occluded_tile_count = 0; | 3353 occluded_tile_count = 0; |
3359 for (PictureLayerTiling::CoverageIterator iter( | 3354 for (PictureLayerTiling::CoverageIterator iter( |
3360 tiling, | 3355 tiling, |
3361 pending_layer_->contents_scale_x(), | 3356 pending_layer_->contents_scale_x(), |
3362 gfx::Rect(layer_bounds)); | 3357 gfx::Rect(layer_bounds)); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3709 | 3704 |
3710 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3705 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
3711 | 3706 |
3712 VerifyEvictionConsidersOcclusion(pending_layer_, | 3707 VerifyEvictionConsidersOcclusion(pending_layer_, |
3713 total_expected_occluded_tile_count); | 3708 total_expected_occluded_tile_count); |
3714 VerifyEvictionConsidersOcclusion(active_layer_, | 3709 VerifyEvictionConsidersOcclusion(active_layer_, |
3715 total_expected_occluded_tile_count); | 3710 total_expected_occluded_tile_count); |
3716 } | 3711 } |
3717 } // namespace | 3712 } // namespace |
3718 } // namespace cc | 3713 } // namespace cc |
OLD | NEW |