Chromium Code Reviews| Index: cc/layers/picture_layer_impl_unittest.cc |
| diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc |
| index 5eae6a6c52ae72d544d5985f29221da8d7b4562d..a6e5947d420df5eaf13511fb151cec709a957562 100644 |
| --- a/cc/layers/picture_layer_impl_unittest.cc |
| +++ b/cc/layers/picture_layer_impl_unittest.cc |
| @@ -19,6 +19,7 @@ |
| #include "cc/test/fake_output_surface.h" |
| #include "cc/test/fake_picture_layer_impl.h" |
| #include "cc/test/fake_picture_pile_impl.h" |
| +#include "cc/test/fake_tile_manager.h" |
| #include "cc/test/geometry_test_utils.h" |
| #include "cc/test/impl_side_painting_settings.h" |
| #include "cc/test/layer_test_common.h" |
| @@ -3101,6 +3102,74 @@ TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) { |
| EXPECT_NE(0u, pending_mask_content->num_tilings()); |
| } |
| +class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { |
| + public: |
| + PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} |
| + |
| + virtual void InitializeRenderer() OVERRIDE { |
| + host_impl_.InitializeRenderer( |
| + FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>()); |
| + } |
| +}; |
| + |
| +TEST_F(PictureLayerImplTestWithDelegatingRenderer, |
| + DelegatingRendererWithTileOOM) { |
| + // This test is added for crbug.com/402321, where quad should be produced when |
| + // raster on demand is not allowed and tile is OOM. |
| + MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| + scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| + |
| + gfx::Size tile_size(400, 400); |
| + gfx::Size layer_bounds(1000, 1000); |
| + |
| + // FakeTileManager has ability to adjust memory assigned to tiles. |
| + 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
|
| + |
| + // Create tiles. |
| + scoped_refptr<FakePicturePileImpl> pending_pile = |
| + FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| + SetupPendingTree(pending_pile); |
| + pending_layer_->SetBounds(layer_bounds); |
| + 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.
|
| + ActivateTree(); |
| + 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,
|
| + host_impl_.active_tree()->UpdateDrawProperties(); |
| + std::vector<Tile*> tiles = |
| + active_layer_->HighResTiling()->AllTilesForTesting(); |
| + host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| + |
| + // Force tiles after max_tiles to be OOM. |
| + GlobalStateThatImpactsTilePriority state; |
| + size_t max_tiles = 1; |
| + state.soft_memory_limit_in_bytes = |
| + max_tiles * 4 * tile_size.width() * tile_size.height(); |
| + state.num_resources_limit = max_tiles; |
| + |
|
danakj
2014/08/13 16:26:42
random whitespace?
weiliangc
2014/08/13 17:45:15
Done.
|
| + 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
|
| + state.memory_limit_policy = ALLOW_ANYTHING; |
| + state.tree_priority = SAME_PRIORITY_FOR_BOTH_TREES; |
| + host_impl_.resource_pool()->SetResourceUsageLimits( |
| + state.soft_memory_limit_in_bytes, |
| + state.soft_memory_limit_in_bytes, |
| + state.num_resources_limit); |
| + host_impl_.tile_manager()->SetGlobalStateForTesting(state); |
| + static_cast<FakeTileManager*>(host_impl_.tile_manager()) |
| + ->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
|
| + |
| + gfx::Rect occluded; |
| + occlusion_tracker.set_occluded_target_rect(occluded); |
| + AppendQuadsData data; |
| + active_layer_->WillDraw(DRAW_MODE_HARDWARE, NULL); |
| + active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
| + active_layer_->DidDraw(NULL); |
| + |
| + // Even when OOM, quads should be produced, and should be different material |
| + // from quads with resource. |
| + EXPECT_LT(max_tiles, render_pass->quad_list.size()); |
| + 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.
|
| + render_pass->quad_list.front()->material); |
| +} |
| + |
| class OcclusionTrackingSettings : public ImplSidePaintingSettings { |
| public: |
| OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } |