Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "cc/base/math_util.h" | 12 #include "cc/base/math_util.h" |
| 13 #include "cc/layers/append_quads_data.h" | 13 #include "cc/layers/append_quads_data.h" |
| 14 #include "cc/layers/picture_layer.h" | 14 #include "cc/layers/picture_layer.h" |
| 15 #include "cc/quads/draw_quad.h" | 15 #include "cc/quads/draw_quad.h" |
| 16 #include "cc/test/fake_content_layer_client.h" | 16 #include "cc/test/fake_content_layer_client.h" |
| 17 #include "cc/test/fake_impl_proxy.h" | 17 #include "cc/test/fake_impl_proxy.h" |
| 18 #include "cc/test/fake_layer_tree_host_impl.h" | 18 #include "cc/test/fake_layer_tree_host_impl.h" |
| 19 #include "cc/test/fake_output_surface.h" | 19 #include "cc/test/fake_output_surface.h" |
| 20 #include "cc/test/fake_picture_layer_impl.h" | 20 #include "cc/test/fake_picture_layer_impl.h" |
| 21 #include "cc/test/fake_picture_pile_impl.h" | 21 #include "cc/test/fake_picture_pile_impl.h" |
| 22 #include "cc/test/fake_tile_manager.h" | |
| 22 #include "cc/test/geometry_test_utils.h" | 23 #include "cc/test/geometry_test_utils.h" |
| 23 #include "cc/test/impl_side_painting_settings.h" | 24 #include "cc/test/impl_side_painting_settings.h" |
| 24 #include "cc/test/layer_test_common.h" | 25 #include "cc/test/layer_test_common.h" |
| 25 #include "cc/test/test_shared_bitmap_manager.h" | 26 #include "cc/test/test_shared_bitmap_manager.h" |
| 26 #include "cc/test/test_web_graphics_context_3d.h" | 27 #include "cc/test/test_web_graphics_context_3d.h" |
| 27 #include "cc/trees/layer_tree_impl.h" | 28 #include "cc/trees/layer_tree_impl.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/gfx/rect_conversions.h" | 30 #include "ui/gfx/rect_conversions.h" |
| 30 #include "ui/gfx/size_conversions.h" | 31 #include "ui/gfx/size_conversions.h" |
| 31 | 32 |
| (...skipping 3062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3094 | 3095 |
| 3095 root->AddChild(layer_with_mask.PassAs<LayerImpl>()); | 3096 root->AddChild(layer_with_mask.PassAs<LayerImpl>()); |
| 3096 | 3097 |
| 3097 host_impl_.pending_tree()->SetRootLayer(root.Pass()); | 3098 host_impl_.pending_tree()->SetRootLayer(root.Pass()); |
| 3098 | 3099 |
| 3099 EXPECT_FALSE(pending_mask_content->tilings()); | 3100 EXPECT_FALSE(pending_mask_content->tilings()); |
| 3100 host_impl_.pending_tree()->UpdateDrawProperties(); | 3101 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 3101 EXPECT_NE(0u, pending_mask_content->num_tilings()); | 3102 EXPECT_NE(0u, pending_mask_content->num_tilings()); |
| 3102 } | 3103 } |
| 3103 | 3104 |
| 3105 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { | |
| 3106 public: | |
| 3107 PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} | |
| 3108 | |
| 3109 virtual void InitializeRenderer() OVERRIDE { | |
| 3110 host_impl_.InitializeRenderer( | |
| 3111 FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>()); | |
| 3112 } | |
| 3113 }; | |
| 3114 | |
| 3115 TEST_F(PictureLayerImplTestWithDelegatingRenderer, | |
| 3116 DelegatingRendererWithTileOOM) { | |
| 3117 // This test is added for crbug.com/402321, where quad should be produced when | |
| 3118 // raster on demand is not allowed and tile is OOM. | |
| 3119 MockOcclusionTracker<LayerImpl> occlusion_tracker; | |
| 3120 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | |
| 3121 | |
| 3122 gfx::Size tile_size(400, 400); | |
| 3123 gfx::Size layer_bounds(1000, 1000); | |
| 3124 | |
| 3125 // FakeTileManager has ability to adjust memory assigned to tiles. | |
| 3126 host_impl_.CreateFakeTileManager(); | |
|
danakj
2014/08/13 16:26:42
FakeTileManager seems like it mostly exists to pri
weiliangc
2014/08/13 17:45:15
Mostly I want to call that AssignMemoryToTiles fun
| |
| 3127 | |
| 3128 // Create tiles. | |
| 3129 scoped_refptr<FakePicturePileImpl> pending_pile = | |
| 3130 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 3131 SetupPendingTree(pending_pile); | |
| 3132 pending_layer_->SetBounds(layer_bounds); | |
| 3133 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); | |
|
danakj
2014/08/13 16:26:42
use layer_bounds instead of 1000,1000?
weiliangc
2014/08/13 17:45:15
Done.
| |
| 3134 ActivateTree(); | |
| 3135 active_layer_->set_fixed_tile_size(tile_size); | |
|
danakj
2014/08/13 16:26:42
why is this needed?
weiliangc
2014/08/13 17:45:15
So active layer takes tile size from pending tree,
| |
| 3136 host_impl_.active_tree()->UpdateDrawProperties(); | |
| 3137 std::vector<Tile*> tiles = | |
| 3138 active_layer_->HighResTiling()->AllTilesForTesting(); | |
| 3139 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | |
| 3140 | |
| 3141 // Force tiles after max_tiles to be OOM. | |
| 3142 GlobalStateThatImpactsTilePriority state; | |
| 3143 size_t max_tiles = 1; | |
| 3144 state.soft_memory_limit_in_bytes = | |
| 3145 max_tiles * 4 * tile_size.width() * tile_size.height(); | |
| 3146 state.num_resources_limit = max_tiles; | |
| 3147 | |
|
danakj
2014/08/13 16:26:42
random whitespace?
weiliangc
2014/08/13 17:45:15
Done.
| |
| 3148 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes * 2; | |
|
danakj
2014/08/13 16:26:42
why * 2?
weiliangc
2014/08/13 17:45:15
Magic number copied from tile_manager_unittest. No
| |
| 3149 state.memory_limit_policy = ALLOW_ANYTHING; | |
| 3150 state.tree_priority = SAME_PRIORITY_FOR_BOTH_TREES; | |
| 3151 host_impl_.resource_pool()->SetResourceUsageLimits( | |
| 3152 state.soft_memory_limit_in_bytes, | |
| 3153 state.soft_memory_limit_in_bytes, | |
| 3154 state.num_resources_limit); | |
| 3155 host_impl_.tile_manager()->SetGlobalStateForTesting(state); | |
| 3156 static_cast<FakeTileManager*>(host_impl_.tile_manager()) | |
| 3157 ->AssignMemoryToTiles(state); | |
|
danakj
2014/08/13 16:26:42
Would it work if you did ManageTiles() here instea
weiliangc
2014/08/13 17:45:15
ManageTiles produces invalid tiles, which won't hi
weiliangc
2014/08/13 20:01:23
Aha!
So I'm wrong, I can use ManageTiles just need
| |
| 3158 | |
| 3159 gfx::Rect occluded; | |
| 3160 occlusion_tracker.set_occluded_target_rect(occluded); | |
| 3161 AppendQuadsData data; | |
| 3162 active_layer_->WillDraw(DRAW_MODE_HARDWARE, NULL); | |
| 3163 active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); | |
| 3164 active_layer_->DidDraw(NULL); | |
| 3165 | |
| 3166 // Even when OOM, quads should be produced, and should be different material | |
| 3167 // from quads with resource. | |
| 3168 EXPECT_LT(max_tiles, render_pass->quad_list.size()); | |
| 3169 EXPECT_NE(render_pass->quad_list.back()->material, | |
|
danakj
2014/08/13 16:26:42
Can you verify explicit materials?
weiliangc
2014/08/13 17:45:15
Done.
| |
| 3170 render_pass->quad_list.front()->material); | |
| 3171 } | |
| 3172 | |
| 3104 class OcclusionTrackingSettings : public ImplSidePaintingSettings { | 3173 class OcclusionTrackingSettings : public ImplSidePaintingSettings { |
| 3105 public: | 3174 public: |
| 3106 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } | 3175 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } |
| 3107 }; | 3176 }; |
| 3108 | 3177 |
| 3109 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { | 3178 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { |
| 3110 public: | 3179 public: |
| 3111 OcclusionTrackingPictureLayerImplTest() | 3180 OcclusionTrackingPictureLayerImplTest() |
| 3112 : PictureLayerImplTest(OcclusionTrackingSettings()) {} | 3181 : PictureLayerImplTest(OcclusionTrackingSettings()) {} |
| 3113 | 3182 |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3704 | 3773 |
| 3705 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 3774 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 3706 | 3775 |
| 3707 VerifyEvictionConsidersOcclusion(pending_layer_, | 3776 VerifyEvictionConsidersOcclusion(pending_layer_, |
| 3708 total_expected_occluded_tile_count); | 3777 total_expected_occluded_tile_count); |
| 3709 VerifyEvictionConsidersOcclusion(active_layer_, | 3778 VerifyEvictionConsidersOcclusion(active_layer_, |
| 3710 total_expected_occluded_tile_count); | 3779 total_expected_occluded_tile_count); |
| 3711 } | 3780 } |
| 3712 } // namespace | 3781 } // namespace |
| 3713 } // namespace cc | 3782 } // namespace cc |
| OLD | NEW |