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