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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 explicit PictureLayerImplTest(const LayerTreeSettings& settings) | 81 explicit PictureLayerImplTest(const LayerTreeSettings& settings) |
82 : proxy_(base::MessageLoopProxy::current()), | 82 : proxy_(base::MessageLoopProxy::current()), |
83 host_impl_(settings, &proxy_, &shared_bitmap_manager_), | 83 host_impl_(settings, &proxy_, &shared_bitmap_manager_), |
84 root_id_(6), | 84 root_id_(6), |
85 id_(7) { | 85 id_(7) { |
86 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); | 86 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); |
87 } | 87 } |
88 | 88 |
89 virtual ~PictureLayerImplTest() { | 89 ~PictureLayerImplTest() override {} |
90 } | |
91 | 90 |
92 void SetUp() override { InitializeRenderer(); } | 91 void SetUp() override { InitializeRenderer(); } |
93 | 92 |
94 virtual void InitializeRenderer() { | 93 virtual void InitializeRenderer() { |
95 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 94 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); |
96 } | 95 } |
97 | 96 |
98 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 97 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
99 gfx::Size tile_size(100, 100); | 98 gfx::Size tile_size(100, 100); |
100 | 99 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); | 201 pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); |
203 if (!tile_size.IsEmpty()) | 202 if (!tile_size.IsEmpty()) |
204 pending_layer->set_fixed_tile_size(tile_size); | 203 pending_layer->set_fixed_tile_size(tile_size); |
205 pending_layer->SetDrawsContent(true); | 204 pending_layer->SetDrawsContent(true); |
206 } else { | 205 } else { |
207 pending_layer.reset(static_cast<FakePictureLayerImpl*>( | 206 pending_layer.reset(static_cast<FakePictureLayerImpl*>( |
208 pending_root->RemoveChild(pending_root->children()[0]).release())); | 207 pending_root->RemoveChild(pending_root->children()[0]).release())); |
209 if (!tile_size.IsEmpty()) | 208 if (!tile_size.IsEmpty()) |
210 pending_layer->set_fixed_tile_size(tile_size); | 209 pending_layer->set_fixed_tile_size(tile_size); |
211 } | 210 } |
| 211 pending_root->SetHasRenderSurface(true); |
212 // The bounds() just mirror the pile size. | 212 // The bounds() just mirror the pile size. |
213 pending_layer->SetBounds(raster_source->GetSize()); | 213 pending_layer->SetBounds(raster_source->GetSize()); |
214 pending_layer->SetContentBounds(raster_source->GetSize()); | 214 pending_layer->SetContentBounds(raster_source->GetSize()); |
215 pending_layer->SetRasterSourceOnPending(raster_source, invalidation); | 215 pending_layer->SetRasterSourceOnPending(raster_source, invalidation); |
216 | 216 |
217 pending_root->AddChild(pending_layer.Pass()); | 217 pending_root->AddChild(pending_layer.Pass()); |
218 pending_tree->SetRootLayer(pending_root.Pass()); | 218 pending_tree->SetRootLayer(pending_root.Pass()); |
219 | 219 |
220 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 220 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
221 host_impl_.pending_tree()->LayerById(id_)); | 221 host_impl_.pending_tree()->LayerById(id_)); |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1202 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1203 SetupPendingTree(valid_pile); | 1203 SetupPendingTree(valid_pile); |
1204 | 1204 |
1205 scoped_ptr<FakePictureLayerImpl> mask_ptr = | 1205 scoped_ptr<FakePictureLayerImpl> mask_ptr = |
1206 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1206 FakePictureLayerImpl::CreateMaskWithRasterSource( |
1207 host_impl_.pending_tree(), 3, valid_pile); | 1207 host_impl_.pending_tree(), 3, valid_pile); |
1208 mask_ptr->SetBounds(layer_bounds); | 1208 mask_ptr->SetBounds(layer_bounds); |
1209 mask_ptr->SetContentBounds(layer_bounds); | 1209 mask_ptr->SetContentBounds(layer_bounds); |
1210 mask_ptr->SetDrawsContent(true); | 1210 mask_ptr->SetDrawsContent(true); |
1211 pending_layer_->SetMaskLayer(mask_ptr.Pass()); | 1211 pending_layer_->SetMaskLayer(mask_ptr.Pass()); |
| 1212 pending_layer_->SetHasRenderSurface(true); |
1212 | 1213 |
1213 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1214 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1214 host_impl_.SetCurrentBeginFrameArgs( | 1215 host_impl_.SetCurrentBeginFrameArgs( |
1215 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1216 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1216 host_impl_.pending_tree()->UpdateDrawProperties(); | 1217 host_impl_.pending_tree()->UpdateDrawProperties(); |
1217 | 1218 |
1218 FakePictureLayerImpl* pending_mask = | 1219 FakePictureLayerImpl* pending_mask = |
1219 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); | 1220 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); |
1220 | 1221 |
1221 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); | 1222 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1336 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1336 SetupPendingTree(valid_pile); | 1337 SetupPendingTree(valid_pile); |
1337 | 1338 |
1338 scoped_ptr<FakePictureLayerImpl> mask_ptr = | 1339 scoped_ptr<FakePictureLayerImpl> mask_ptr = |
1339 FakePictureLayerImpl::CreateMaskWithRasterSource( | 1340 FakePictureLayerImpl::CreateMaskWithRasterSource( |
1340 host_impl_.pending_tree(), 3, valid_pile); | 1341 host_impl_.pending_tree(), 3, valid_pile); |
1341 mask_ptr->SetBounds(layer_bounds); | 1342 mask_ptr->SetBounds(layer_bounds); |
1342 mask_ptr->SetContentBounds(layer_bounds); | 1343 mask_ptr->SetContentBounds(layer_bounds); |
1343 mask_ptr->SetDrawsContent(true); | 1344 mask_ptr->SetDrawsContent(true); |
1344 pending_layer_->SetMaskLayer(mask_ptr.Pass()); | 1345 pending_layer_->SetMaskLayer(mask_ptr.Pass()); |
| 1346 pending_layer_->SetHasRenderSurface(true); |
1345 | 1347 |
1346 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1348 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1347 host_impl_.SetCurrentBeginFrameArgs( | 1349 host_impl_.SetCurrentBeginFrameArgs( |
1348 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1350 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1349 host_impl_.pending_tree()->UpdateDrawProperties(); | 1351 host_impl_.pending_tree()->UpdateDrawProperties(); |
1350 | 1352 |
1351 FakePictureLayerImpl* pending_mask = | 1353 FakePictureLayerImpl* pending_mask = |
1352 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); | 1354 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); |
1353 | 1355 |
1354 // Masks are scaled, and do not have a low res tiling. | 1356 // Masks are scaled, and do not have a low res tiling. |
(...skipping 3375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4730 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4732 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4731 EXPECT_EQ(result.width(), 448); | 4733 EXPECT_EQ(result.width(), 448); |
4732 EXPECT_EQ(result.height(), 448); | 4734 EXPECT_EQ(result.height(), 448); |
4733 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4735 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4734 EXPECT_EQ(result.width(), 512); | 4736 EXPECT_EQ(result.width(), 512); |
4735 EXPECT_EQ(result.height(), 500 + 2); | 4737 EXPECT_EQ(result.height(), 500 + 2); |
4736 } | 4738 } |
4737 | 4739 |
4738 } // namespace | 4740 } // namespace |
4739 } // namespace cc | 4741 } // namespace cc |
OLD | NEW |