Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 void SetupTrees( | 51 void SetupTrees( |
| 52 scoped_refptr<PicturePileImpl> pending_pile, | 52 scoped_refptr<PicturePileImpl> pending_pile, |
| 53 scoped_refptr<PicturePileImpl> active_pile) { | 53 scoped_refptr<PicturePileImpl> active_pile) { |
| 54 SetupPendingTree(active_pile); | 54 SetupPendingTree(active_pile); |
| 55 host_impl_.ActivatePendingTree(); | 55 host_impl_.ActivatePendingTree(); |
| 56 | 56 |
| 57 active_layer_ = static_cast<FakePictureLayerImpl*>( | 57 active_layer_ = static_cast<FakePictureLayerImpl*>( |
| 58 host_impl_.active_tree()->LayerById(id_)); | 58 host_impl_.active_tree()->LayerById(id_)); |
| 59 | 59 |
| 60 SetupPendingTree(pending_pile); | 60 SetupPendingTree(pending_pile); |
| 61 pending_layer_ = static_cast<FakePictureLayerImpl*>( | |
| 62 host_impl_.pending_tree()->LayerById(id_)); | |
| 63 pending_layer_->UpdateTwinLayer(); | 61 pending_layer_->UpdateTwinLayer(); |
| 64 } | 62 } |
| 65 | 63 |
| 66 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { | 64 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { |
| 67 active_layer_->AddTiling(2.3f); | 65 active_layer_->AddTiling(2.3f); |
| 68 active_layer_->AddTiling(1.0f); | 66 active_layer_->AddTiling(1.0f); |
| 69 active_layer_->AddTiling(0.5f); | 67 active_layer_->AddTiling(0.5f); |
| 70 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i) | 68 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i) |
| 71 active_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); | 69 active_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); |
| 72 pending_layer_->set_invalidation(invalidation); | 70 pending_layer_->set_invalidation(invalidation); |
| 73 pending_layer_->SyncFromActiveLayer(); | 71 pending_layer_->SyncFromActiveLayer(); |
| 74 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i) | 72 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i) |
| 75 pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); | 73 pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); |
| 76 } | 74 } |
| 77 | 75 |
| 78 void SetupPendingTree( | 76 void SetupPendingTree( |
| 79 scoped_refptr<PicturePileImpl> pile) { | 77 scoped_refptr<PicturePileImpl> pile) { |
| 80 host_impl_.CreatePendingTree(); | 78 host_impl_.CreatePendingTree(); |
| 81 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 79 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 82 // Clear recycled tree. | 80 // Clear recycled tree. |
| 83 pending_tree->DetachLayerTree(); | 81 pending_tree->DetachLayerTree(); |
| 84 | 82 |
| 85 scoped_ptr<FakePictureLayerImpl> pending_layer = | 83 scoped_ptr<FakePictureLayerImpl> pending_layer = |
| 86 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); | 84 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); |
| 87 pending_layer->SetDrawsContent(true); | 85 pending_layer->SetDrawsContent(true); |
| 88 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); | 86 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
| 87 | |
| 88 pending_layer_ = static_cast<FakePictureLayerImpl*>( | |
| 89 host_impl_.pending_tree()->LayerById(id_)); | |
| 89 } | 90 } |
| 90 | 91 |
| 91 static void VerifyAllTilesExistAndHavePile( | 92 static void VerifyAllTilesExistAndHavePile( |
| 92 const PictureLayerTiling* tiling, | 93 const PictureLayerTiling* tiling, |
| 93 PicturePileImpl* pile) { | 94 PicturePileImpl* pile) { |
| 94 for (PictureLayerTiling::CoverageIterator | 95 for (PictureLayerTiling::CoverageIterator |
| 95 iter(tiling, tiling->contents_scale(), tiling->ContentRect()); | 96 iter(tiling, tiling->contents_scale(), tiling->ContentRect()); |
| 96 iter; | 97 iter; |
| 97 ++iter) { | 98 ++iter) { |
| 98 EXPECT_TRUE(*iter); | 99 EXPECT_TRUE(*iter); |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 799 AddDefaultTilingsWithInvalidation(invalidation); | 800 AddDefaultTilingsWithInvalidation(invalidation); |
| 800 | 801 |
| 801 AppendQuadsData data; | 802 AppendQuadsData data; |
| 802 data.allow_tile_draw_quads = false; | 803 data.allow_tile_draw_quads = false; |
| 803 active_layer_->AppendQuads(&quad_culler, &data); | 804 active_layer_->AppendQuads(&quad_culler, &data); |
| 804 | 805 |
| 805 ASSERT_EQ(1U, quad_culler.quad_list().size()); | 806 ASSERT_EQ(1U, quad_culler.quad_list().size()); |
| 806 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, quad_culler.quad_list()[0]->material); | 807 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, quad_culler.quad_list()[0]->material); |
| 807 } | 808 } |
| 808 | 809 |
| 810 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { | |
| 811 gfx::Size tile_size(100, 100); | |
| 812 gfx::Size layer_bounds(1000, 1000); | |
| 813 | |
| 814 scoped_refptr<FakePicturePileImpl> pending_pile = | |
| 815 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | |
| 816 // Layers with entirely empty piles can't get tilings. | |
| 817 pending_pile->AddRecordingAt(0, 0); | |
|
danakj
2013/05/29 00:11:47
From holiday: do you need to add recording? Or cou
enne (OOO)
2013/05/29 00:14:29
Yes. CanHaveTilings() is false if the pile's reco
danakj
2013/05/29 10:39:34
I see. I guess its just nonobvious that there are
| |
| 818 | |
| 819 SetupPendingTree(pending_pile); | |
| 820 | |
| 821 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
| 822 pending_layer_->AddTiling(1.0f); | |
| 823 pending_layer_->AddTiling(2.0f); | |
| 824 | |
| 825 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | |
|
danakj
2013/05/29 00:11:47
Can you verify that the tilings were not added? Nu
enne (OOO)
2013/05/29 00:14:29
The tilings are supposed to be there, it's that th
danakj
2013/05/29 10:39:34
Oh sorry, right.
| |
| 826 // on a layer with no recordings. | |
| 827 host_impl_.pending_tree()->UpdateDrawProperties(); | |
| 828 } | |
| 829 | |
| 809 } // namespace | 830 } // namespace |
| 810 } // namespace cc | 831 } // namespace cc |
| OLD | NEW |