Commit db2e29cd authored by vmpstr@chromium.org's avatar vmpstr@chromium.org

cc: Make sure mask and replica layers get DidBecomeActive signal.

Since we create and rasterize mask and replica layer tiles as well,
we need to ensure that they get the DidBecomeActive signal in order
to ensure the tile priorities of the contained tiles are correct.
(DidBecomeActive switches active and pending priorities and clears
the pending priority). Without this, there are cases where the pending
priority can remain high without any mechanism clearing it.

BUG=400560
R=enne

Review URL: https://codereview.chromium.org/441863002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287693 0039d316-1c4b-4281-b951-d872f2087c98
parent 9a9a6695
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
namespace cc { namespace cc {
FakePictureLayerImpl::FakePictureLayerImpl( FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl,
LayerTreeImpl* tree_impl, int id,
int id, scoped_refptr<PicturePileImpl> pile)
scoped_refptr<PicturePileImpl> pile)
: PictureLayerImpl(tree_impl, id), : PictureLayerImpl(tree_impl, id),
append_quads_count_(0) { append_quads_count_(0),
did_become_active_call_count_(0) {
pile_ = pile; pile_ = pile;
SetBounds(pile_->tiling_size()); SetBounds(pile_->tiling_size());
SetContentBounds(pile_->tiling_size()); SetContentBounds(pile_->tiling_size());
...@@ -25,14 +25,19 @@ FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, ...@@ -25,14 +25,19 @@ FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl,
int id, int id,
scoped_refptr<PicturePileImpl> pile, scoped_refptr<PicturePileImpl> pile,
const gfx::Size& layer_bounds) const gfx::Size& layer_bounds)
: PictureLayerImpl(tree_impl, id), append_quads_count_(0) { : PictureLayerImpl(tree_impl, id),
append_quads_count_(0),
did_become_active_call_count_(0) {
pile_ = pile; pile_ = pile;
SetBounds(layer_bounds); SetBounds(layer_bounds);
SetContentBounds(layer_bounds); SetContentBounds(layer_bounds);
} }
FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id) FakePictureLayerImpl::FakePictureLayerImpl(LayerTreeImpl* tree_impl, int id)
: PictureLayerImpl(tree_impl, id), append_quads_count_(0) {} : PictureLayerImpl(tree_impl, id),
append_quads_count_(0),
did_become_active_call_count_(0) {
}
scoped_ptr<LayerImpl> FakePictureLayerImpl::CreateLayerImpl( scoped_ptr<LayerImpl> FakePictureLayerImpl::CreateLayerImpl(
LayerTreeImpl* tree_impl) { LayerTreeImpl* tree_impl) {
...@@ -153,4 +158,9 @@ void FakePictureLayerImpl::CreateDefaultTilingsAndTiles() { ...@@ -153,4 +158,9 @@ void FakePictureLayerImpl::CreateDefaultTilingsAndTiles() {
} }
} }
void FakePictureLayerImpl::DidBecomeActive() {
PictureLayerImpl::DidBecomeActive();
++did_become_active_call_count_;
}
} // namespace cc } // namespace cc
...@@ -41,6 +41,11 @@ class FakePictureLayerImpl : public PictureLayerImpl { ...@@ -41,6 +41,11 @@ class FakePictureLayerImpl : public PictureLayerImpl {
virtual gfx::Size CalculateTileSize( virtual gfx::Size CalculateTileSize(
const gfx::Size& content_bounds) const OVERRIDE; const gfx::Size& content_bounds) const OVERRIDE;
virtual void DidBecomeActive() OVERRIDE;
size_t did_become_active_call_count() {
return did_become_active_call_count_;
}
using PictureLayerImpl::AddTiling; using PictureLayerImpl::AddTiling;
using PictureLayerImpl::CleanUpTilingsOnActiveLayer; using PictureLayerImpl::CleanUpTilingsOnActiveLayer;
using PictureLayerImpl::CanHaveTilings; using PictureLayerImpl::CanHaveTilings;
...@@ -110,6 +115,7 @@ class FakePictureLayerImpl : public PictureLayerImpl { ...@@ -110,6 +115,7 @@ class FakePictureLayerImpl : public PictureLayerImpl {
gfx::Size fixed_tile_size_; gfx::Size fixed_tile_size_;
size_t append_quads_count_; size_t append_quads_count_;
size_t did_become_active_call_count_;
}; };
} // namespace cc } // namespace cc
......
...@@ -6764,5 +6764,56 @@ TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { ...@@ -6764,5 +6764,56 @@ TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) {
EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending); EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending);
} }
TEST_F(LayerTreeHostImplTest, DidBecomeActive) {
host_impl_->CreatePendingTree();
host_impl_->ActivateSyncTree();
host_impl_->CreatePendingTree();
LayerTreeImpl* pending_tree = host_impl_->pending_tree();
scoped_ptr<FakePictureLayerImpl> pending_layer =
FakePictureLayerImpl::Create(pending_tree, 10);
pending_layer->DoPostCommitInitializationIfNeeded();
FakePictureLayerImpl* raw_pending_layer = pending_layer.get();
pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>());
ASSERT_EQ(raw_pending_layer, pending_tree->root_layer());
EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count());
pending_tree->DidBecomeActive();
EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count());
scoped_ptr<FakePictureLayerImpl> mask_layer =
FakePictureLayerImpl::Create(pending_tree, 11);
mask_layer->DoPostCommitInitializationIfNeeded();
FakePictureLayerImpl* raw_mask_layer = mask_layer.get();
raw_pending_layer->SetMaskLayer(mask_layer.PassAs<LayerImpl>());
ASSERT_EQ(raw_mask_layer, raw_pending_layer->mask_layer());
EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count());
EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count());
pending_tree->DidBecomeActive();
EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count());
EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count());
scoped_ptr<FakePictureLayerImpl> replica_layer =
FakePictureLayerImpl::Create(pending_tree, 12);
scoped_ptr<FakePictureLayerImpl> replica_mask_layer =
FakePictureLayerImpl::Create(pending_tree, 13);
replica_mask_layer->DoPostCommitInitializationIfNeeded();
FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get();
replica_layer->SetMaskLayer(replica_mask_layer.PassAs<LayerImpl>());
raw_pending_layer->SetReplicaLayer(replica_layer.PassAs<LayerImpl>());
ASSERT_EQ(raw_replica_mask_layer,
raw_pending_layer->replica_layer()->mask_layer());
EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count());
EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count());
EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count());
pending_tree->DidBecomeActive();
EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count());
EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count());
EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count());
}
} // namespace } // namespace
} // namespace cc } // namespace cc
...@@ -579,6 +579,11 @@ void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { ...@@ -579,6 +579,11 @@ void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) {
static void DidBecomeActiveRecursive(LayerImpl* layer) { static void DidBecomeActiveRecursive(LayerImpl* layer) {
layer->DidBecomeActive(); layer->DidBecomeActive();
if (layer->mask_layer())
layer->mask_layer()->DidBecomeActive();
if (layer->replica_layer() && layer->replica_layer()->mask_layer())
layer->replica_layer()->mask_layer()->DidBecomeActive();
for (size_t i = 0; i < layer->children().size(); ++i) for (size_t i = 0; i < layer->children().size(); ++i)
DidBecomeActiveRecursive(layer->children()[i]); DidBecomeActiveRecursive(layer->children()[i]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment