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 3083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3094 | 3094 |
3095 root->AddChild(layer_with_mask.PassAs<LayerImpl>()); | 3095 root->AddChild(layer_with_mask.PassAs<LayerImpl>()); |
3096 | 3096 |
3097 host_impl_.pending_tree()->SetRootLayer(root.Pass()); | 3097 host_impl_.pending_tree()->SetRootLayer(root.Pass()); |
3098 | 3098 |
3099 EXPECT_FALSE(pending_mask_content->tilings()); | 3099 EXPECT_FALSE(pending_mask_content->tilings()); |
3100 host_impl_.pending_tree()->UpdateDrawProperties(); | 3100 host_impl_.pending_tree()->UpdateDrawProperties(); |
3101 EXPECT_NE(0u, pending_mask_content->num_tilings()); | 3101 EXPECT_NE(0u, pending_mask_content->num_tilings()); |
3102 } | 3102 } |
3103 | 3103 |
3104 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { | |
3105 public: | |
3106 PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} | |
3107 | |
3108 virtual void InitializeRenderer() OVERRIDE { | |
3109 host_impl_.InitializeRenderer( | |
3110 FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>()); | |
3111 } | |
3112 }; | |
3113 | |
3114 TEST_F(PictureLayerImplTestWithDelegatingRenderer, | |
3115 DelegatingRendererWithTileOOM) { | |
3116 // This test is added for crbug.com/402321, where quad should be produced when | |
3117 // raster on demand is not allowed and tile is OOM. | |
3118 MockOcclusionTracker<LayerImpl> occlusion_tracker; | |
danakj
2014/08/13 21:48:25
can you make this down closer to where it's used
| |
3119 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | |
3120 | |
3121 gfx::Size tile_size = host_impl_.settings().default_tile_size; | |
3122 gfx::Size layer_bounds(1000, 1000); | |
3123 | |
3124 // Create tiles. | |
3125 scoped_refptr<FakePicturePileImpl> pending_pile = | |
3126 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
3127 SetupPendingTree(pending_pile); | |
3128 pending_layer_->SetBounds(layer_bounds); | |
3129 host_impl_.SetViewportSize(layer_bounds); | |
3130 ActivateTree(); | |
3131 host_impl_.active_tree()->UpdateDrawProperties(); | |
3132 std::vector<Tile*> tiles = | |
3133 active_layer_->HighResTiling()->AllTilesForTesting(); | |
3134 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | |
3135 | |
3136 // Force tiles after max_tiles to be OOM. TileManager uses | |
3137 // GlobalStateThatImpactsTilesPriority from LayerTreeHostImpl, and we cannot | |
3138 // directly set state to host_impl_, so we try set policy that would change | |
danakj
2014/08/13 21:48:25
s/try//
| |
3139 // the state. We also need to update tree priority separately. | |
3140 GlobalStateThatImpactsTilePriority state; | |
3141 size_t max_tiles = 1; | |
3142 size_t memory_limit = max_tiles * 4 * tile_size.width() * tile_size.height(); | |
3143 size_t resource_limit = max_tiles; | |
3144 ManagedMemoryPolicy policy(memory_limit, | |
3145 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | |
3146 resource_limit); | |
3147 host_impl_.SetMemoryPolicy(policy); | |
3148 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | |
3149 host_impl_.ManageTiles(); | |
3150 | |
3151 gfx::Rect occluded; | |
3152 occlusion_tracker.set_occluded_target_rect(occluded); | |
danakj
2014/08/13 21:48:25
do you need?
| |
3153 AppendQuadsData data; | |
3154 active_layer_->WillDraw(DRAW_MODE_HARDWARE, NULL); | |
3155 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); | |
3156 active_layer_->DidDraw(NULL); | |
3157 | |
3158 // Even when OOM, quads should be produced, and should be different material | |
3159 // from quads with resource. | |
3160 EXPECT_LT(max_tiles, render_pass->quad_list.size()); | |
3161 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT, | |
3162 render_pass->quad_list.front()->material); | |
3163 EXPECT_EQ(DrawQuad::Material::SOLID_COLOR, | |
3164 render_pass->quad_list.back()->material); | |
3165 } | |
3166 | |
3104 class OcclusionTrackingSettings : public ImplSidePaintingSettings { | 3167 class OcclusionTrackingSettings : public ImplSidePaintingSettings { |
3105 public: | 3168 public: |
3106 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } | 3169 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } |
3107 }; | 3170 }; |
3108 | 3171 |
3109 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3172 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
3110 public: | 3173 public: |
3111 OcclusionTrackingPictureLayerImplTest() | 3174 OcclusionTrackingPictureLayerImplTest() |
3112 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3175 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
3113 | 3176 |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3704 | 3767 |
3705 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3768 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
3706 | 3769 |
3707 VerifyEvictionConsidersOcclusion(pending_layer_, | 3770 VerifyEvictionConsidersOcclusion(pending_layer_, |
3708 total_expected_occluded_tile_count); | 3771 total_expected_occluded_tile_count); |
3709 VerifyEvictionConsidersOcclusion(active_layer_, | 3772 VerifyEvictionConsidersOcclusion(active_layer_, |
3710 total_expected_occluded_tile_count); | 3773 total_expected_occluded_tile_count); |
3711 } | 3774 } |
3712 } // namespace | 3775 } // namespace |
3713 } // namespace cc | 3776 } // namespace cc |
OLD | NEW |