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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
11 #include <set> | 11 #include <set> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "cc/base/math_util.h" | 17 #include "cc/base/math_util.h" |
18 #include "cc/layers/append_quads_data.h" | 18 #include "cc/layers/append_quads_data.h" |
19 #include "cc/layers/picture_layer.h" | 19 #include "cc/layers/picture_layer.h" |
20 #include "cc/output/buffer_to_texture_target_map.h" | 20 #include "cc/output/buffer_to_texture_target_map.h" |
21 #include "cc/quads/draw_quad.h" | 21 #include "cc/quads/draw_quad.h" |
22 #include "cc/quads/tile_draw_quad.h" | 22 #include "cc/quads/tile_draw_quad.h" |
23 #include "cc/test/begin_frame_args_test.h" | 23 #include "cc/test/begin_frame_args_test.h" |
| 24 #include "cc/test/fake_compositor_frame_sink.h" |
24 #include "cc/test/fake_content_layer_client.h" | 25 #include "cc/test/fake_content_layer_client.h" |
25 #include "cc/test/fake_impl_task_runner_provider.h" | 26 #include "cc/test/fake_impl_task_runner_provider.h" |
26 #include "cc/test/fake_layer_tree_host.h" | 27 #include "cc/test/fake_layer_tree_host.h" |
27 #include "cc/test/fake_layer_tree_host_client.h" | 28 #include "cc/test/fake_layer_tree_host_client.h" |
28 #include "cc/test/fake_layer_tree_host_impl.h" | 29 #include "cc/test/fake_layer_tree_host_impl.h" |
29 #include "cc/test/fake_output_surface.h" | |
30 #include "cc/test/fake_picture_layer_impl.h" | 30 #include "cc/test/fake_picture_layer_impl.h" |
31 #include "cc/test/fake_raster_source.h" | 31 #include "cc/test/fake_raster_source.h" |
32 #include "cc/test/fake_recording_source.h" | 32 #include "cc/test/fake_recording_source.h" |
33 #include "cc/test/geometry_test_utils.h" | 33 #include "cc/test/geometry_test_utils.h" |
34 #include "cc/test/gpu_rasterization_enabled_settings.h" | 34 #include "cc/test/gpu_rasterization_enabled_settings.h" |
35 #include "cc/test/layer_test_common.h" | 35 #include "cc/test/layer_test_common.h" |
36 #include "cc/test/test_layer_tree_host_base.h" | 36 #include "cc/test/test_layer_tree_host_base.h" |
37 #include "cc/test/test_shared_bitmap_manager.h" | 37 #include "cc/test/test_shared_bitmap_manager.h" |
38 #include "cc/test/test_task_graph_runner.h" | 38 #include "cc/test/test_task_graph_runner.h" |
39 #include "cc/test/test_web_graphics_context_3d.h" | 39 #include "cc/test/test_web_graphics_context_3d.h" |
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 pending_layer()->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1447 pending_layer()->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
1448 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1448 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
1449 tile->content_rect().size().ToString()); | 1449 tile->content_rect().size().ToString()); |
1450 | 1450 |
1451 ResetTilingsAndRasterScales(); | 1451 ResetTilingsAndRasterScales(); |
1452 | 1452 |
1453 // Change the max texture size on the output surface context. | 1453 // Change the max texture size on the output surface context. |
1454 std::unique_ptr<TestWebGraphicsContext3D> context = | 1454 std::unique_ptr<TestWebGraphicsContext3D> context = |
1455 TestWebGraphicsContext3D::Create(); | 1455 TestWebGraphicsContext3D::Create(); |
1456 context->set_max_texture_size(140); | 1456 context->set_max_texture_size(140); |
1457 ResetOutputSurface(FakeOutputSurface::CreateDelegating3d(std::move(context))); | 1457 ResetCompositorFrameSink( |
| 1458 FakeCompositorFrameSink::Create3d(std::move(context))); |
1458 | 1459 |
1459 SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, | 1460 SetupDrawPropertiesAndUpdateTiles(pending_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, |
1460 false); | 1461 false); |
1461 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | 1462 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
1462 | 1463 |
1463 pending_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1464 pending_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1464 | 1465 |
1465 // Verify the tiles are not larger than the context's max texture size. | 1466 // Verify the tiles are not larger than the context's max texture size. |
1466 tile = pending_layer()->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1467 tile = pending_layer()->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
1467 EXPECT_GE(140, tile->content_rect().width()); | 1468 EXPECT_GE(140, tile->content_rect().width()); |
(...skipping 14 matching lines...) Expand all Loading... |
1482 // There should be a single tile since the layer is small. | 1483 // There should be a single tile since the layer is small. |
1483 PictureLayerTiling* high_res_tiling = active_layer()->tilings()->tiling_at(0); | 1484 PictureLayerTiling* high_res_tiling = active_layer()->tilings()->tiling_at(0); |
1484 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1485 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
1485 | 1486 |
1486 ResetTilingsAndRasterScales(); | 1487 ResetTilingsAndRasterScales(); |
1487 | 1488 |
1488 // Change the max texture size on the output surface context. | 1489 // Change the max texture size on the output surface context. |
1489 std::unique_ptr<TestWebGraphicsContext3D> context = | 1490 std::unique_ptr<TestWebGraphicsContext3D> context = |
1490 TestWebGraphicsContext3D::Create(); | 1491 TestWebGraphicsContext3D::Create(); |
1491 context->set_max_texture_size(140); | 1492 context->set_max_texture_size(140); |
1492 ResetOutputSurface(FakeOutputSurface::CreateDelegating3d(std::move(context))); | 1493 ResetCompositorFrameSink( |
| 1494 FakeCompositorFrameSink::Create3d(std::move(context))); |
1493 | 1495 |
1494 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, | 1496 SetupDrawPropertiesAndUpdateTiles(active_layer(), 1.f, 1.f, 1.f, 1.f, 0.f, |
1495 false); | 1497 false); |
1496 ASSERT_LE(1u, active_layer()->tilings()->num_tilings()); | 1498 ASSERT_LE(1u, active_layer()->tilings()->num_tilings()); |
1497 | 1499 |
1498 active_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1500 active_layer()->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1499 | 1501 |
1500 // There should be more than one tile since the max texture size won't cover | 1502 // There should be more than one tile since the max texture size won't cover |
1501 // the layer. | 1503 // the layer. |
1502 high_res_tiling = active_layer()->tilings()->tiling_at(0); | 1504 high_res_tiling = active_layer()->tilings()->tiling_at(0); |
(...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3577 ->quad_layer_bounds.ToString()); | 3579 ->quad_layer_bounds.ToString()); |
3578 // The visible_layer_rect should be scaled by the | 3580 // The visible_layer_rect should be scaled by the |
3579 // MaximumTilingContentsScale on the layer. | 3581 // MaximumTilingContentsScale on the layer. |
3580 EXPECT_EQ(gfx::Rect(0u, 0u, 2500u, 5000u).ToString(), | 3582 EXPECT_EQ(gfx::Rect(0u, 0u, 2500u, 5000u).ToString(), |
3581 render_pass->shared_quad_state_list.front() | 3583 render_pass->shared_quad_state_list.front() |
3582 ->visible_quad_layer_rect.ToString()); | 3584 ->visible_quad_layer_rect.ToString()); |
3583 } | 3585 } |
3584 | 3586 |
3585 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { | 3587 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { |
3586 public: | 3588 public: |
3587 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 3589 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { |
3588 return FakeOutputSurface::CreateDelegating3d(); | 3590 return FakeCompositorFrameSink::Create3d(); |
3589 } | 3591 } |
3590 }; | 3592 }; |
3591 | 3593 |
3592 TEST_F(PictureLayerImplTestWithDelegatingRenderer, | 3594 TEST_F(PictureLayerImplTestWithDelegatingRenderer, |
3593 DelegatingRendererWithTileOOM) { | 3595 DelegatingRendererWithTileOOM) { |
3594 // This test is added for crbug.com/402321, where quad should be produced when | 3596 // This test is added for crbug.com/402321, where quad should be produced when |
3595 // raster on demand is not allowed and tile is OOM. | 3597 // raster on demand is not allowed and tile is OOM. |
3596 gfx::Size layer_bounds(1000, 1000); | 3598 gfx::Size layer_bounds(1000, 1000); |
3597 | 3599 |
3598 // Create tiles. | 3600 // Create tiles. |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4960 EXPECT_FLOAT_EQ(expected_contents_scale, | 4962 EXPECT_FLOAT_EQ(expected_contents_scale, |
4961 pending_layer_ptr->picture_layer_tiling_set() | 4963 pending_layer_ptr->picture_layer_tiling_set() |
4962 ->FindTilingWithResolution(HIGH_RESOLUTION) | 4964 ->FindTilingWithResolution(HIGH_RESOLUTION) |
4963 ->contents_scale()) | 4965 ->contents_scale()) |
4964 << "ideal_contents_scale: " << ideal_contents_scale; | 4966 << "ideal_contents_scale: " << ideal_contents_scale; |
4965 } | 4967 } |
4966 } | 4968 } |
4967 | 4969 |
4968 } // namespace | 4970 } // namespace |
4969 } // namespace cc | 4971 } // namespace cc |
OLD | NEW |