| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 class LowResTilingsSettings : public PictureLayerImplTestSettings { | 87 class LowResTilingsSettings : public PictureLayerImplTestSettings { |
| 88 public: | 88 public: |
| 89 LowResTilingsSettings() { create_low_res_tiling = true; } | 89 LowResTilingsSettings() { create_low_res_tiling = true; } |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 class PictureLayerImplTest : public testing::Test { | 92 class PictureLayerImplTest : public testing::Test { |
| 93 public: | 93 public: |
| 94 PictureLayerImplTest() | 94 PictureLayerImplTest() |
| 95 : proxy_(base::ThreadTaskRunnerHandle::Get()), | 95 : proxy_(base::ThreadTaskRunnerHandle::Get()), |
| 96 output_surface_(FakeOutputSurface::Create3d()), | |
| 97 host_impl_(LowResTilingsSettings(), | 96 host_impl_(LowResTilingsSettings(), |
| 98 &proxy_, | 97 &proxy_, |
| 99 &shared_bitmap_manager_, | 98 &shared_bitmap_manager_, |
| 100 &task_graph_runner_), | 99 &task_graph_runner_), |
| 101 root_id_(6), | 100 root_id_(6), |
| 102 id_(7), | 101 id_(7), |
| 103 pending_layer_(nullptr), | 102 pending_layer_(nullptr), |
| 104 old_pending_layer_(nullptr), | 103 old_pending_layer_(nullptr), |
| 105 active_layer_(nullptr) { | 104 active_layer_(nullptr) { |
| 106 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); | 105 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); |
| 107 } | 106 } |
| 108 | 107 |
| 109 explicit PictureLayerImplTest(const LayerTreeSettings& settings) | 108 explicit PictureLayerImplTest(const LayerTreeSettings& settings) |
| 110 : proxy_(base::ThreadTaskRunnerHandle::Get()), | 109 : proxy_(base::ThreadTaskRunnerHandle::Get()), |
| 111 output_surface_(FakeOutputSurface::Create3d()), | |
| 112 host_impl_(settings, | 110 host_impl_(settings, |
| 113 &proxy_, | 111 &proxy_, |
| 114 &shared_bitmap_manager_, | 112 &shared_bitmap_manager_, |
| 115 &task_graph_runner_), | 113 &task_graph_runner_), |
| 116 root_id_(6), | 114 root_id_(6), |
| 117 id_(7) { | 115 id_(7) { |
| 118 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); | 116 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); |
| 119 } | 117 } |
| 120 | 118 |
| 121 ~PictureLayerImplTest() override {} | 119 ~PictureLayerImplTest() override {} |
| 122 | 120 |
| 123 void SetUp() override { InitializeRenderer(); } | 121 void SetUp() override { InitializeRenderer(); } |
| 124 | 122 |
| 125 virtual void InitializeRenderer() { | 123 virtual void InitializeRenderer() { |
| 126 host_impl_.InitializeRenderer(output_surface_.get()); | 124 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); |
| 127 } | 125 } |
| 128 | 126 |
| 129 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 127 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 130 gfx::Size tile_size(100, 100); | 128 gfx::Size tile_size(100, 100); |
| 131 | 129 |
| 132 scoped_refptr<FakePicturePileImpl> pending_pile = | 130 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 133 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 131 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 134 scoped_refptr<FakePicturePileImpl> active_pile = | 132 scoped_refptr<FakePicturePileImpl> active_pile = |
| 135 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 133 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 136 | 134 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 EXPECT_FALSE(tiles[i]->required_for_activation()) << "i: " << i; | 352 EXPECT_FALSE(tiles[i]->required_for_activation()) << "i: " << i; |
| 355 EXPECT_GT(tiles.size(), 0u); | 353 EXPECT_GT(tiles.size(), 0u); |
| 356 } | 354 } |
| 357 | 355 |
| 358 protected: | 356 protected: |
| 359 void TestQuadsForSolidColor(bool test_for_solid); | 357 void TestQuadsForSolidColor(bool test_for_solid); |
| 360 | 358 |
| 361 FakeImplProxy proxy_; | 359 FakeImplProxy proxy_; |
| 362 TestSharedBitmapManager shared_bitmap_manager_; | 360 TestSharedBitmapManager shared_bitmap_manager_; |
| 363 TestTaskGraphRunner task_graph_runner_; | 361 TestTaskGraphRunner task_graph_runner_; |
| 364 scoped_ptr<OutputSurface> output_surface_; | |
| 365 FakeLayerTreeHostImpl host_impl_; | 362 FakeLayerTreeHostImpl host_impl_; |
| 366 int root_id_; | 363 int root_id_; |
| 367 int id_; | 364 int id_; |
| 368 FakePictureLayerImpl* pending_layer_; | 365 FakePictureLayerImpl* pending_layer_; |
| 369 FakePictureLayerImpl* old_pending_layer_; | 366 FakePictureLayerImpl* old_pending_layer_; |
| 370 FakePictureLayerImpl* active_layer_; | 367 FakePictureLayerImpl* active_layer_; |
| 371 LayerSettings layer_settings_; | 368 LayerSettings layer_settings_; |
| 372 | 369 |
| 373 private: | 370 private: |
| 374 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); | 371 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); |
| (...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1620 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
| 1624 tile->content_rect().size().ToString()); | 1621 tile->content_rect().size().ToString()); |
| 1625 | 1622 |
| 1626 ResetTilingsAndRasterScales(); | 1623 ResetTilingsAndRasterScales(); |
| 1627 | 1624 |
| 1628 // Change the max texture size on the output surface context. | 1625 // Change the max texture size on the output surface context. |
| 1629 scoped_ptr<TestWebGraphicsContext3D> context = | 1626 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1630 TestWebGraphicsContext3D::Create(); | 1627 TestWebGraphicsContext3D::Create(); |
| 1631 context->set_max_texture_size(140); | 1628 context->set_max_texture_size(140); |
| 1632 host_impl_.DidLoseOutputSurface(); | 1629 host_impl_.DidLoseOutputSurface(); |
| 1633 scoped_ptr<OutputSurface> new_output_surface = | 1630 host_impl_.InitializeRenderer( |
| 1634 FakeOutputSurface::Create3d(context.Pass()); | 1631 FakeOutputSurface::Create3d(context.Pass()).Pass()); |
| 1635 host_impl_.InitializeRenderer(new_output_surface.get()); | |
| 1636 output_surface_ = new_output_surface.Pass(); | |
| 1637 | 1632 |
| 1638 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, | 1633 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1639 false); | 1634 false); |
| 1640 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 1635 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 1641 | 1636 |
| 1642 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1637 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1643 | 1638 |
| 1644 // Verify the tiles are not larger than the context's max texture size. | 1639 // Verify the tiles are not larger than the context's max texture size. |
| 1645 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1640 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
| 1646 EXPECT_GE(140, tile->content_rect().width()); | 1641 EXPECT_GE(140, tile->content_rect().width()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1670 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0); | 1665 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0); |
| 1671 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1666 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
| 1672 | 1667 |
| 1673 ResetTilingsAndRasterScales(); | 1668 ResetTilingsAndRasterScales(); |
| 1674 | 1669 |
| 1675 // Change the max texture size on the output surface context. | 1670 // Change the max texture size on the output surface context. |
| 1676 scoped_ptr<TestWebGraphicsContext3D> context = | 1671 scoped_ptr<TestWebGraphicsContext3D> context = |
| 1677 TestWebGraphicsContext3D::Create(); | 1672 TestWebGraphicsContext3D::Create(); |
| 1678 context->set_max_texture_size(140); | 1673 context->set_max_texture_size(140); |
| 1679 host_impl_.DidLoseOutputSurface(); | 1674 host_impl_.DidLoseOutputSurface(); |
| 1680 scoped_ptr<OutputSurface> new_output_surface = | 1675 host_impl_.InitializeRenderer( |
| 1681 FakeOutputSurface::Create3d(context.Pass()); | 1676 FakeOutputSurface::Create3d(context.Pass()).Pass()); |
| 1682 host_impl_.InitializeRenderer(new_output_surface.get()); | |
| 1683 output_surface_ = new_output_surface.Pass(); | |
| 1684 | 1677 |
| 1685 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, | 1678 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, |
| 1686 false); | 1679 false); |
| 1687 ASSERT_LE(1u, active_layer_->tilings()->num_tilings()); | 1680 ASSERT_LE(1u, active_layer_->tilings()->num_tilings()); |
| 1688 | 1681 |
| 1689 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1682 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 1690 | 1683 |
| 1691 // There should be more than one tile since the max texture size won't cover | 1684 // There should be more than one tile since the max texture size won't cover |
| 1692 // the layer. | 1685 // the layer. |
| 1693 high_res_tiling = active_layer_->tilings()->tiling_at(0); | 1686 high_res_tiling = active_layer_->tilings()->tiling_at(0); |
| (...skipping 2231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3925 ->quad_layer_bounds.ToString()); | 3918 ->quad_layer_bounds.ToString()); |
| 3926 // The visible_layer_rect should be scaled by the | 3919 // The visible_layer_rect should be scaled by the |
| 3927 // MaximumTilingContentsScale on the layer. | 3920 // MaximumTilingContentsScale on the layer. |
| 3928 EXPECT_EQ(gfx::Rect(0u, 0u, 2500u, 5000u).ToString(), | 3921 EXPECT_EQ(gfx::Rect(0u, 0u, 2500u, 5000u).ToString(), |
| 3929 render_pass->shared_quad_state_list.front() | 3922 render_pass->shared_quad_state_list.front() |
| 3930 ->visible_quad_layer_rect.ToString()); | 3923 ->visible_quad_layer_rect.ToString()); |
| 3931 } | 3924 } |
| 3932 | 3925 |
| 3933 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { | 3926 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { |
| 3934 public: | 3927 public: |
| 3935 PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() { | 3928 PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} |
| 3936 output_surface_ = FakeOutputSurface::CreateDelegating3d(); | |
| 3937 } | |
| 3938 | 3929 |
| 3939 void InitializeRenderer() override { | 3930 void InitializeRenderer() override { |
| 3940 host_impl_.InitializeRenderer(output_surface_.get()); | 3931 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDelegating3d()); |
| 3941 } | 3932 } |
| 3942 }; | 3933 }; |
| 3943 | 3934 |
| 3944 TEST_F(PictureLayerImplTestWithDelegatingRenderer, | 3935 TEST_F(PictureLayerImplTestWithDelegatingRenderer, |
| 3945 DelegatingRendererWithTileOOM) { | 3936 DelegatingRendererWithTileOOM) { |
| 3946 // This test is added for crbug.com/402321, where quad should be produced when | 3937 // This test is added for crbug.com/402321, where quad should be produced when |
| 3947 // raster on demand is not allowed and tile is OOM. | 3938 // raster on demand is not allowed and tile is OOM. |
| 3948 gfx::Size tile_size = host_impl_.settings().default_tile_size; | 3939 gfx::Size tile_size = host_impl_.settings().default_tile_size; |
| 3949 gfx::Size layer_bounds(1000, 1000); | 3940 gfx::Size layer_bounds(1000, 1000); |
| 3950 | 3941 |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5172 // New low res tiling. | 5163 // New low res tiling. |
| 5173 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 5164 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
| 5174 | 5165 |
| 5175 // This tiling will be high res now, it won't contain low res content since it | 5166 // This tiling will be high res now, it won't contain low res content since it |
| 5176 // was all destroyed. | 5167 // was all destroyed. |
| 5177 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 5168 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
| 5178 } | 5169 } |
| 5179 | 5170 |
| 5180 } // namespace | 5171 } // namespace |
| 5181 } // namespace cc | 5172 } // namespace cc |
| OLD | NEW |