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/picture_layer.h" | 9 #include "cc/layers/picture_layer.h" |
10 #include "cc/test/fake_content_layer_client.h" | 10 #include "cc/test/fake_content_layer_client.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 static scoped_ptr<TestablePictureLayerImpl> Create( | 25 static scoped_ptr<TestablePictureLayerImpl> Create( |
26 LayerTreeImpl* tree_impl, | 26 LayerTreeImpl* tree_impl, |
27 int id, | 27 int id, |
28 scoped_refptr<PicturePileImpl> pile) { | 28 scoped_refptr<PicturePileImpl> pile) { |
29 return make_scoped_ptr(new TestablePictureLayerImpl(tree_impl, id, pile)); | 29 return make_scoped_ptr(new TestablePictureLayerImpl(tree_impl, id, pile)); |
30 } | 30 } |
31 | 31 |
32 PictureLayerTilingSet& tilings() { return *tilings_; } | 32 PictureLayerTilingSet& tilings() { return *tilings_; } |
33 Region& invalidation() { return invalidation_; } | 33 Region& invalidation() { return invalidation_; } |
34 | 34 |
35 virtual gfx::Size CalculateTileSize( | |
36 gfx::Size current_tile_size, | |
37 gfx::Size content_bounds) OVERRIDE { | |
38 if (current_tile_size.IsEmpty()) | |
39 return gfx::Size(100, 100); | |
40 return current_tile_size; | |
41 } | |
42 | |
43 using PictureLayerImpl::AddTiling; | 35 using PictureLayerImpl::AddTiling; |
44 using PictureLayerImpl::CleanUpTilingsOnActiveLayer; | 36 using PictureLayerImpl::CleanUpTilingsOnActiveLayer; |
45 | 37 |
46 private: | 38 private: |
47 TestablePictureLayerImpl( | 39 TestablePictureLayerImpl( |
48 LayerTreeImpl* tree_impl, | 40 LayerTreeImpl* tree_impl, |
49 int id, | 41 int id, |
50 scoped_refptr<PicturePileImpl> pile) | 42 scoped_refptr<PicturePileImpl> pile) |
51 : PictureLayerImpl(tree_impl, id) { | 43 : PictureLayerImpl(tree_impl, id) { |
52 pile_ = pile; | 44 pile_ = pile; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 154 |
163 SetupPendingTree(pending_pile); | 155 SetupPendingTree(pending_pile); |
164 pending_layer_ = static_cast<TestablePictureLayerImpl*>( | 156 pending_layer_ = static_cast<TestablePictureLayerImpl*>( |
165 host_impl_.pending_tree()->LayerById(id_)); | 157 host_impl_.pending_tree()->LayerById(id_)); |
166 } | 158 } |
167 | 159 |
168 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { | 160 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { |
169 active_layer_->AddTiling(2.3f); | 161 active_layer_->AddTiling(2.3f); |
170 active_layer_->AddTiling(1.0f); | 162 active_layer_->AddTiling(1.0f); |
171 active_layer_->AddTiling(0.5f); | 163 active_layer_->AddTiling(0.5f); |
| 164 for (size_t i = 0; i < active_layer_->tilings().num_tilings(); ++i) |
| 165 active_layer_->tilings().tiling_at(i)->AllTilesForTesting(); |
172 pending_layer_->invalidation() = invalidation; | 166 pending_layer_->invalidation() = invalidation; |
173 pending_layer_->SyncFromActiveLayer(); | 167 pending_layer_->SyncFromActiveLayer(); |
| 168 for (size_t i = 0; i < pending_layer_->tilings().num_tilings(); ++i) |
| 169 pending_layer_->tilings().tiling_at(i)->AllTilesForTesting(); |
174 } | 170 } |
175 | 171 |
176 void SetupPendingTree( | 172 void SetupPendingTree( |
177 scoped_refptr<PicturePileImpl> pile) { | 173 scoped_refptr<PicturePileImpl> pile) { |
178 host_impl_.CreatePendingTree(); | 174 host_impl_.CreatePendingTree(); |
179 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 175 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
180 // Clear recycled tree. | 176 // Clear recycled tree. |
181 pending_tree->DetachLayerTree(); | 177 pending_tree->DetachLayerTree(); |
182 | 178 |
183 scoped_ptr<TestablePictureLayerImpl> pending_layer = | 179 scoped_ptr<TestablePictureLayerImpl> pending_layer = |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 tiling->contents_scale())); | 391 tiling->contents_scale())); |
396 for (PictureLayerTiling::Iterator | 392 for (PictureLayerTiling::Iterator |
397 iter(tiling, | 393 iter(tiling, |
398 tiling->contents_scale(), | 394 tiling->contents_scale(), |
399 tiling->ContentRect()); | 395 tiling->ContentRect()); |
400 iter; | 396 iter; |
401 ++iter) { | 397 ++iter) { |
402 EXPECT_TRUE(*iter); | 398 EXPECT_TRUE(*iter); |
403 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 399 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
404 if (iter.geometry_rect().right() >= active_content_bounds.width() || | 400 if (iter.geometry_rect().right() >= active_content_bounds.width() || |
405 iter.geometry_rect().bottom() >= active_content_bounds.height()) { | 401 iter.geometry_rect().bottom() >= active_content_bounds.height() || |
| 402 tiling->tile_bounds() != |
| 403 active_layer_->tilings().tiling_at(i)->tile_bounds()) { |
406 EXPECT_EQ(pending_pile, iter->picture_pile()); | 404 EXPECT_EQ(pending_pile, iter->picture_pile()); |
407 } else { | 405 } else { |
408 EXPECT_EQ(active_pile, iter->picture_pile()); | 406 EXPECT_EQ(active_pile, iter->picture_pile()); |
409 } | 407 } |
410 } | 408 } |
411 } | 409 } |
412 } | 410 } |
413 | 411 |
414 TEST_F(PictureLayerImplTest, AddTilesFromNewRecording) { | 412 TEST_F(PictureLayerImplTest, AddTilesFromNewRecording) { |
415 gfx::Size tile_size(400, 400); | 413 gfx::Size tile_size(400, 400); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 used_tilings.push_back(active_layer_->tilings().tiling_at(1)); | 685 used_tilings.push_back(active_layer_->tilings().tiling_at(1)); |
688 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 686 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
689 ASSERT_EQ(3u, active_layer_->tilings().num_tilings()); | 687 ASSERT_EQ(3u, active_layer_->tilings().num_tilings()); |
690 used_tilings.clear(); | 688 used_tilings.clear(); |
691 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 689 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
692 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); | 690 ASSERT_EQ(2u, active_layer_->tilings().num_tilings()); |
693 } | 691 } |
694 | 692 |
695 } // namespace | 693 } // namespace |
696 } // namespace cc | 694 } // namespace cc |
OLD | NEW |