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 3093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3104 | 3104 |
3105 root->AddChild(layer_with_mask.PassAs<LayerImpl>()); | 3105 root->AddChild(layer_with_mask.PassAs<LayerImpl>()); |
3106 | 3106 |
3107 host_impl_.pending_tree()->SetRootLayer(root.Pass()); | 3107 host_impl_.pending_tree()->SetRootLayer(root.Pass()); |
3108 | 3108 |
3109 EXPECT_FALSE(pending_mask_content->tilings()); | 3109 EXPECT_FALSE(pending_mask_content->tilings()); |
3110 host_impl_.pending_tree()->UpdateDrawProperties(); | 3110 host_impl_.pending_tree()->UpdateDrawProperties(); |
3111 EXPECT_NE(0u, pending_mask_content->num_tilings()); | 3111 EXPECT_NE(0u, pending_mask_content->num_tilings()); |
3112 } | 3112 } |
3113 | 3113 |
| 3114 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { |
| 3115 public: |
| 3116 PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} |
| 3117 |
| 3118 virtual void InitializeRenderer() OVERRIDE { |
| 3119 host_impl_.InitializeRenderer( |
| 3120 FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>()); |
| 3121 } |
| 3122 }; |
| 3123 |
| 3124 TEST_F(PictureLayerImplTestWithDelegatingRenderer, |
| 3125 DelegatingRendererWithTileOOM) { |
| 3126 // This test is added for crbug.com/402321, where quad should be produced when |
| 3127 // raster on demand is not allowed and tile is OOM. |
| 3128 gfx::Size tile_size = host_impl_.settings().default_tile_size; |
| 3129 gfx::Size layer_bounds(1000, 1000); |
| 3130 |
| 3131 // Create tiles. |
| 3132 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3133 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3134 SetupPendingTree(pending_pile); |
| 3135 pending_layer_->SetBounds(layer_bounds); |
| 3136 host_impl_.SetViewportSize(layer_bounds); |
| 3137 ActivateTree(); |
| 3138 host_impl_.active_tree()->UpdateDrawProperties(); |
| 3139 std::vector<Tile*> tiles = |
| 3140 active_layer_->HighResTiling()->AllTilesForTesting(); |
| 3141 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 3142 |
| 3143 // Force tiles after max_tiles to be OOM. TileManager uses |
| 3144 // GlobalStateThatImpactsTilesPriority from LayerTreeHostImpl, and we cannot |
| 3145 // directly set state to host_impl_, so we set policy that would change the |
| 3146 // state. We also need to update tree priority separately. |
| 3147 GlobalStateThatImpactsTilePriority state; |
| 3148 size_t max_tiles = 1; |
| 3149 size_t memory_limit = max_tiles * 4 * tile_size.width() * tile_size.height(); |
| 3150 size_t resource_limit = max_tiles; |
| 3151 ManagedMemoryPolicy policy(memory_limit, |
| 3152 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
| 3153 resource_limit); |
| 3154 host_impl_.SetMemoryPolicy(policy); |
| 3155 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 3156 host_impl_.ManageTiles(); |
| 3157 |
| 3158 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 3159 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 3160 AppendQuadsData data; |
| 3161 active_layer_->WillDraw(DRAW_MODE_HARDWARE, NULL); |
| 3162 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
| 3163 active_layer_->DidDraw(NULL); |
| 3164 |
| 3165 // Even when OOM, quads should be produced, and should be different material |
| 3166 // from quads with resource. |
| 3167 EXPECT_LT(max_tiles, render_pass->quad_list.size()); |
| 3168 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT, |
| 3169 render_pass->quad_list.front()->material); |
| 3170 EXPECT_EQ(DrawQuad::Material::SOLID_COLOR, |
| 3171 render_pass->quad_list.back()->material); |
| 3172 } |
| 3173 |
3114 class OcclusionTrackingSettings : public ImplSidePaintingSettings { | 3174 class OcclusionTrackingSettings : public ImplSidePaintingSettings { |
3115 public: | 3175 public: |
3116 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } | 3176 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } |
3117 }; | 3177 }; |
3118 | 3178 |
3119 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3179 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
3120 public: | 3180 public: |
3121 OcclusionTrackingPictureLayerImplTest() | 3181 OcclusionTrackingPictureLayerImplTest() |
3122 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3182 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
3123 | 3183 |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3720 | 3780 |
3721 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3781 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
3722 | 3782 |
3723 VerifyEvictionConsidersOcclusion(pending_layer_, | 3783 VerifyEvictionConsidersOcclusion(pending_layer_, |
3724 total_expected_occluded_tile_count); | 3784 total_expected_occluded_tile_count); |
3725 VerifyEvictionConsidersOcclusion(active_layer_, | 3785 VerifyEvictionConsidersOcclusion(active_layer_, |
3726 total_expected_occluded_tile_count); | 3786 total_expected_occluded_tile_count); |
3727 } | 3787 } |
3728 } // namespace | 3788 } // namespace |
3729 } // namespace cc | 3789 } // namespace cc |
OLD | NEW |