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 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 EXPECT_FALSE(pending_layer_->LowResTiling()); | 1364 EXPECT_FALSE(pending_layer_->LowResTiling()); |
1365 EXPECT_EQ(active_layer_->num_tilings(), 2u); | 1365 EXPECT_EQ(active_layer_->num_tilings(), 2u); |
1366 EXPECT_EQ(pending_layer_->num_tilings(), 1u); | 1366 EXPECT_EQ(pending_layer_->num_tilings(), 1u); |
1367 | 1367 |
1368 // Mask layers dont create low res since they always fit on one tile. | 1368 // Mask layers dont create low res since they always fit on one tile. |
1369 scoped_ptr<FakePictureLayerImpl> mask = | 1369 scoped_ptr<FakePictureLayerImpl> mask = |
1370 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1370 FakePictureLayerImpl::CreateMaskWithRasterSource( |
1371 host_impl_.pending_tree(), 3, pending_raster_source); | 1371 host_impl_.pending_tree(), 3, pending_raster_source); |
1372 mask->SetBounds(layer_bounds); | 1372 mask->SetBounds(layer_bounds); |
1373 mask->SetDrawsContent(true); | 1373 mask->SetDrawsContent(true); |
| 1374 pending_layer_->SetMaskLayer(std::move(mask)); |
| 1375 pending_layer_->SetHasRenderSurface(true); |
| 1376 RebuildPropertyTreesOnPendingTree(); |
| 1377 host_impl_.pending_tree()->UpdateDrawProperties(false); |
1374 | 1378 |
| 1379 FakePictureLayerImpl* mask_raw = |
| 1380 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); |
1375 SetupDrawPropertiesAndUpdateTiles( | 1381 SetupDrawPropertiesAndUpdateTiles( |
1376 mask.get(), contents_scale, device_scale, page_scale, | 1382 mask_raw, contents_scale, device_scale, page_scale, |
1377 maximum_animation_scale, starting_animation_scale, animating_transform); | 1383 maximum_animation_scale, starting_animation_scale, animating_transform); |
1378 EXPECT_EQ(mask->HighResTiling()->contents_scale(), contents_scale); | 1384 EXPECT_EQ(mask_raw->HighResTiling()->contents_scale(), contents_scale); |
1379 EXPECT_EQ(mask->num_tilings(), 1u); | 1385 EXPECT_EQ(mask_raw->num_tilings(), 1u); |
1380 } | 1386 } |
1381 | 1387 |
1382 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { | 1388 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { |
1383 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 1389 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
1384 | 1390 |
1385 gfx::Size layer_bounds(1000, 1000); | 1391 gfx::Size layer_bounds(1000, 1000); |
1386 | 1392 |
1387 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source = | 1393 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source = |
1388 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | 1394 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
1389 SetupPendingTree(valid_raster_source); | 1395 SetupPendingTree(valid_raster_source); |
(...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3824 host_impl_.SetViewportSize(gfx::Size(10000, 20000)); | 3830 host_impl_.SetViewportSize(gfx::Size(10000, 20000)); |
3825 SetupDefaultTrees(layer_bounds); | 3831 SetupDefaultTrees(layer_bounds); |
3826 | 3832 |
3827 ResetTilingsAndRasterScales(); | 3833 ResetTilingsAndRasterScales(); |
3828 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, 0.f, | 3834 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, 0.f, |
3829 false); | 3835 false); |
3830 | 3836 |
3831 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); | 3837 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); |
3832 EXPECT_EQ(2.5f, max_contents_scale); | 3838 EXPECT_EQ(2.5f, max_contents_scale); |
3833 | 3839 |
3834 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); | 3840 gfx::Transform scaled_draw_transform = active_layer_->DrawTransform(); |
3835 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | 3841 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
3836 SK_MScalar1 / max_contents_scale); | 3842 SK_MScalar1 / max_contents_scale); |
3837 | 3843 |
3838 AppendQuadsData data; | 3844 AppendQuadsData data; |
3839 active_layer_->AppendQuads(render_pass.get(), &data); | 3845 active_layer_->AppendQuads(render_pass.get(), &data); |
3840 | 3846 |
3841 // SharedQuadState should have be of size 1, as we are doing AppenQuad once. | 3847 // SharedQuadState should have be of size 1, as we are doing AppenQuad once. |
3842 EXPECT_EQ(1u, render_pass->shared_quad_state_list.size()); | 3848 EXPECT_EQ(1u, render_pass->shared_quad_state_list.size()); |
3843 // The quad_to_target_transform should be scaled by the | 3849 // The quad_to_target_transform should be scaled by the |
3844 // MaximumTilingContentsScale on the layer. | 3850 // MaximumTilingContentsScale on the layer. |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5078 // New low res tiling. | 5084 // New low res tiling. |
5079 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); | 5085 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); |
5080 | 5086 |
5081 // This tiling will be high res now, it won't contain low res content since it | 5087 // This tiling will be high res now, it won't contain low res content since it |
5082 // was all destroyed. | 5088 // was all destroyed. |
5083 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); | 5089 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); |
5084 } | 5090 } |
5085 | 5091 |
5086 } // namespace | 5092 } // namespace |
5087 } // namespace cc | 5093 } // namespace cc |
OLD | NEW |