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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 contents_scale, | 157 contents_scale, |
158 device_scale_factor, | 158 device_scale_factor, |
159 page_scale_factor, | 159 page_scale_factor, |
160 animating_transform, | 160 animating_transform, |
161 &result_scale_x, | 161 &result_scale_x, |
162 &result_scale_y, | 162 &result_scale_y, |
163 &result_bounds); | 163 &result_bounds); |
164 } | 164 } |
165 | 165 |
166 void ResetTilingsAndRasterScales() { | 166 void ResetTilingsAndRasterScales() { |
167 pending_layer_->DidLoseOutputSurface(); | 167 pending_layer_->ReleaseResources(); |
168 active_layer_->DidLoseOutputSurface(); | 168 active_layer_->ReleaseResources(); |
169 } | 169 } |
170 | 170 |
171 void AssertAllTilesRequired(PictureLayerTiling* tiling) { | 171 void AssertAllTilesRequired(PictureLayerTiling* tiling) { |
172 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 172 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
173 for (size_t i = 0; i < tiles.size(); ++i) | 173 for (size_t i = 0; i < tiles.size(); ++i) |
174 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; | 174 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; |
175 EXPECT_GT(tiles.size(), 0u); | 175 EXPECT_GT(tiles.size(), 0u); |
176 } | 176 } |
177 | 177 |
178 void AssertNoTilesRequired(PictureLayerTiling* tiling) { | 178 void AssertNoTilesRequired(PictureLayerTiling* tiling) { |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 | 985 |
986 // Mask layers dont create low res since they always fit on one tile. | 986 // Mask layers dont create low res since they always fit on one tile. |
987 pending_layer_->SetIsMask(true); | 987 pending_layer_->SetIsMask(true); |
988 active_layer_->SetIsMask(true); | 988 active_layer_->SetIsMask(true); |
989 SetContentsScaleOnBothLayers( | 989 SetContentsScaleOnBothLayers( |
990 contents_scale, device_scale, page_scale, animating_transform); | 990 contents_scale, device_scale, page_scale, animating_transform); |
991 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 991 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
992 EXPECT_BOTH_EQ(num_tilings(), 1u); | 992 EXPECT_BOTH_EQ(num_tilings(), 1u); |
993 } | 993 } |
994 | 994 |
995 TEST_F(PictureLayerImplTest, DidLoseOutputSurface) { | 995 TEST_F(PictureLayerImplTest, ReleaseResources) { |
996 gfx::Size tile_size(400, 400); | 996 gfx::Size tile_size(400, 400); |
997 gfx::Size layer_bounds(1300, 1900); | 997 gfx::Size layer_bounds(1300, 1900); |
998 | 998 |
999 scoped_refptr<FakePicturePileImpl> pending_pile = | 999 scoped_refptr<FakePicturePileImpl> pending_pile = |
1000 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1000 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1001 scoped_refptr<FakePicturePileImpl> active_pile = | 1001 scoped_refptr<FakePicturePileImpl> active_pile = |
1002 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1002 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1003 | 1003 |
1004 float result_scale_x, result_scale_y; | 1004 float result_scale_x, result_scale_y; |
1005 gfx::Size result_bounds; | 1005 gfx::Size result_bounds; |
1006 | 1006 |
1007 SetupTrees(pending_pile, active_pile); | 1007 SetupTrees(pending_pile, active_pile); |
1008 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1008 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1009 | 1009 |
1010 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale | 1010 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
1011 2.7f, // device scale | 1011 2.7f, // device scale |
1012 3.2f, // page cale | 1012 3.2f, // page cale |
1013 false, | 1013 false, |
1014 &result_scale_x, | 1014 &result_scale_x, |
1015 &result_scale_y, | 1015 &result_scale_y, |
1016 &result_bounds); | 1016 &result_bounds); |
1017 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1017 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1018 | 1018 |
1019 // All tilings should be removed when losing output surface. | 1019 // All tilings should be removed when losing output surface. |
1020 active_layer_->DidLoseOutputSurface(); | 1020 active_layer_->ReleaseResources(); |
1021 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 1021 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
1022 pending_layer_->DidLoseOutputSurface(); | 1022 pending_layer_->ReleaseResources(); |
1023 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1023 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1024 | 1024 |
1025 // This should create new tilings. | 1025 // This should create new tilings. |
1026 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale | 1026 pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
1027 2.7f, // device scale | 1027 2.7f, // device scale |
1028 3.2f, // page cale | 1028 3.2f, // page cale |
1029 false, | 1029 false, |
1030 &result_scale_x, | 1030 &result_scale_x, |
1031 &result_scale_y, | 1031 &result_scale_y, |
1032 &result_bounds); | 1032 &result_bounds); |
(...skipping 23 matching lines...) Expand all Loading... |
1056 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1056 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1057 | 1057 |
1058 // The default value. | 1058 // The default value. |
1059 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1059 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
1060 host_impl_.settings().default_tile_size.ToString()); | 1060 host_impl_.settings().default_tile_size.ToString()); |
1061 | 1061 |
1062 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1062 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
1063 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1063 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
1064 tile->content_rect().size().ToString()); | 1064 tile->content_rect().size().ToString()); |
1065 | 1065 |
1066 pending_layer_->DidLoseOutputSurface(); | 1066 pending_layer_->ReleaseResources(); |
1067 | 1067 |
1068 // Change the max texture size on the output surface context. | 1068 // Change the max texture size on the output surface context. |
1069 scoped_ptr<TestWebGraphicsContext3D> context = | 1069 scoped_ptr<TestWebGraphicsContext3D> context = |
1070 TestWebGraphicsContext3D::Create(); | 1070 TestWebGraphicsContext3D::Create(); |
1071 context->set_max_texture_size(140); | 1071 context->set_max_texture_size(140); |
1072 host_impl_.DidLoseOutputSurface(); | 1072 host_impl_.DidLoseOutputSurface(); |
1073 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1073 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
1074 context.Pass()).PassAs<OutputSurface>()); | 1074 context.Pass()).PassAs<OutputSurface>()); |
1075 | 1075 |
1076 pending_layer_->CalculateContentsScale( | 1076 pending_layer_->CalculateContentsScale( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1108 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1109 | 1109 |
1110 // The default value. The layer is smaller than this. | 1110 // The default value. The layer is smaller than this. |
1111 EXPECT_EQ(gfx::Size(512, 512).ToString(), | 1111 EXPECT_EQ(gfx::Size(512, 512).ToString(), |
1112 host_impl_.settings().max_untiled_layer_size.ToString()); | 1112 host_impl_.settings().max_untiled_layer_size.ToString()); |
1113 | 1113 |
1114 // There should be a single tile since the layer is small. | 1114 // There should be a single tile since the layer is small. |
1115 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1115 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
1116 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1116 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
1117 | 1117 |
1118 pending_layer_->DidLoseOutputSurface(); | 1118 pending_layer_->ReleaseResources(); |
1119 | 1119 |
1120 // Change the max texture size on the output surface context. | 1120 // Change the max texture size on the output surface context. |
1121 scoped_ptr<TestWebGraphicsContext3D> context = | 1121 scoped_ptr<TestWebGraphicsContext3D> context = |
1122 TestWebGraphicsContext3D::Create(); | 1122 TestWebGraphicsContext3D::Create(); |
1123 context->set_max_texture_size(140); | 1123 context->set_max_texture_size(140); |
1124 host_impl_.DidLoseOutputSurface(); | 1124 host_impl_.DidLoseOutputSurface(); |
1125 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( | 1125 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
1126 context.Pass()).PassAs<OutputSurface>()); | 1126 context.Pass()).PassAs<OutputSurface>()); |
1127 | 1127 |
1128 pending_layer_->CalculateContentsScale( | 1128 pending_layer_->CalculateContentsScale( |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 | 1387 |
1388 TEST_F(PictureLayerImplTest, SyncTilingAfterReleaseResource) { | 1388 TEST_F(PictureLayerImplTest, SyncTilingAfterReleaseResource) { |
1389 SetupDefaultTrees(gfx::Size(10, 10)); | 1389 SetupDefaultTrees(gfx::Size(10, 10)); |
1390 host_impl_.active_tree()->UpdateDrawProperties(); | 1390 host_impl_.active_tree()->UpdateDrawProperties(); |
1391 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); | 1391 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); |
1392 | 1392 |
1393 // Contrived unit test of a real crash. A layer is transparent during a | 1393 // Contrived unit test of a real crash. A layer is transparent during a |
1394 // context loss, and later becomes opaque, causing active layer SyncTiling to | 1394 // context loss, and later becomes opaque, causing active layer SyncTiling to |
1395 // be called. | 1395 // be called. |
1396 const float tile_scale = 2.f; | 1396 const float tile_scale = 2.f; |
1397 active_layer_->DidLoseOutputSurface(); | 1397 active_layer_->ReleaseResources(); |
1398 EXPECT_FALSE(active_layer_->tilings()->TilingAtScale(tile_scale)); | 1398 EXPECT_FALSE(active_layer_->tilings()->TilingAtScale(tile_scale)); |
1399 pending_layer_->AddTiling(2.f); | 1399 pending_layer_->AddTiling(2.f); |
1400 EXPECT_TRUE(active_layer_->tilings()->TilingAtScale(tile_scale)); | 1400 EXPECT_TRUE(active_layer_->tilings()->TilingAtScale(tile_scale)); |
1401 } | 1401 } |
1402 | 1402 |
1403 TEST_F(PictureLayerImplTest, TileSizeForGpuRasterization) { | 1403 TEST_F(PictureLayerImplTest, TileSizeForGpuRasterization) { |
1404 gfx::Size default_tile_size_gpu( | 1404 gfx::Size default_tile_size_gpu( |
1405 host_impl_.settings().default_tile_size_gpu_rasterization); | 1405 host_impl_.settings().default_tile_size_gpu_rasterization); |
1406 gfx::Size layer_bounds(default_tile_size_gpu.width() + 1, | 1406 gfx::Size layer_bounds(default_tile_size_gpu.width() + 1, |
1407 default_tile_size_gpu.height() + 1); | 1407 default_tile_size_gpu.height() + 1); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 TestContextProvider::Create(), NULL)); | 1552 TestContextProvider::Create(), NULL)); |
1553 | 1553 |
1554 // These will crash PictureLayerImpl if this is not true. | 1554 // These will crash PictureLayerImpl if this is not true. |
1555 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); | 1555 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); |
1556 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); | 1556 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); |
1557 host_impl_.active_tree()->UpdateDrawProperties(); | 1557 host_impl_.active_tree()->UpdateDrawProperties(); |
1558 } | 1558 } |
1559 | 1559 |
1560 } // namespace | 1560 } // namespace |
1561 } // namespace cc | 1561 } // namespace cc |
OLD | NEW |