diff options
author | clholgat@chromium.org <clholgat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-18 03:24:34 +0000 |
---|---|---|
committer | clholgat@chromium.org <clholgat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-18 03:24:34 +0000 |
commit | ad0250b469ec6afbd7cdceab302ec2142ea90ebb (patch) | |
tree | 2488c1a4764074adf78e326f2af1d4e5df897d95 /cc/trees | |
parent | b8c7eed238ffa4a47f90df3a077f4ee1daf23569 (diff) | |
download | chromium_src-ad0250b469ec6afbd7cdceab302ec2142ea90ebb.zip chromium_src-ad0250b469ec6afbd7cdceab302ec2142ea90ebb.tar.gz chromium_src-ad0250b469ec6afbd7cdceab302ec2142ea90ebb.tar.bz2 |
Pluming for needs_push_properties for the impl tree.
This change ensures that pending tree is only synced
with the active tree if something has changed on the
pending tree.
Notable performance improvements to BrowserCompositorInvalidateLayerTreePerfTest
Before:
*RESULT layer_tree_host_frame_time: dense_layer_tree= 768.87890625 us
After:
*RESULT layer_tree_host_frame_time: dense_layer_tree= 655.21044921875 us
(run on a Galaxy Nexus running Android 4.3)
BUG=259511
Review URL: https://codereview.chromium.org/25896002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245734 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees')
-rw-r--r-- | cc/trees/damage_tracker_unittest.cc | 38 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 48 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 243 | ||||
-rw-r--r-- | cc/trees/tree_synchronizer.cc | 15 | ||||
-rw-r--r-- | cc/trees/tree_synchronizer.h | 3 |
5 files changed, 288 insertions, 59 deletions
diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc index 7fb8720..31d2b46 100644 --- a/cc/trees/damage_tracker_unittest.cc +++ b/cc/trees/damage_tracker_unittest.cc @@ -231,7 +231,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { // CASE 1: Setting the update rect should cause the corresponding damage to // the surface. ClearDamageForAllSurfaces(root.get()); - child->set_update_rect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); + child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); EmulateDrawingOneFrame(root.get()); // Damage position on the surface should be: position of update_rect (10, 11) @@ -243,7 +243,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { // CASE 2: The same update rect twice in a row still produces the same // damage. ClearDamageForAllSurfaces(root.get()); - child->set_update_rect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); + child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); EmulateDrawingOneFrame(root.get()); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); @@ -252,7 +252,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForUpdateRects) { // CASE 3: Setting a different update rect should cause damage on the new // update region, but no additional exposed old region. ClearDamageForAllSurfaces(root.get()); - child->set_update_rect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); + child->SetUpdateRect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); EmulateDrawingOneFrame(root.get()); // Damage position on the surface should be: position of update_rect (20, 25) @@ -269,7 +269,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForPropertyChanges) { // CASE 1: The layer's property changed flag takes priority over update rect. // ClearDamageForAllSurfaces(root.get()); - child->set_update_rect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); + child->SetUpdateRect(gfx::RectF(10.f, 11.f, 12.f, 13.f)); child->SetOpacity(0.5f); EmulateDrawingOneFrame(root.get()); @@ -417,7 +417,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { // Setting the update rect should cause the corresponding damage to the // surface, blurred based on the size of the blur filter. ClearDamageForAllSurfaces(root.get()); - child->set_update_rect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); + child->SetUpdateRect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); EmulateDrawingOneFrame(root.get()); // Damage position on the surface should be: position of update_rect (1, 2) @@ -461,7 +461,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { // CASE 1: Setting the update rect should damage the whole surface (for now) ClearDamageForAllSurfaces(root.get()); - child->set_update_rect(gfx::RectF(0.f, 0.f, 1.f, 1.f)); + child->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 1.f)); EmulateDrawingOneFrame(root.get()); root_damage_rect = @@ -494,7 +494,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { // the surface, blurred based on the size of the child's background // blur filter. ClearDamageForAllSurfaces(root.get()); - root->set_update_rect(gfx::RectF(297.f, 297.f, 2.f, 2.f)); + root->SetUpdateRect(gfx::RectF(297.f, 297.f, 2.f, 2.f)); EmulateDrawingOneFrame(root.get()); gfx::RectF root_damage_rect = @@ -516,7 +516,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { // blur filter. Since the damage extends to the right/bottom outside // of the blurred layer, only the left/top should end up expanded. ClearDamageForAllSurfaces(root.get()); - root->set_update_rect(gfx::RectF(297.f, 297.f, 30.f, 30.f)); + root->SetUpdateRect(gfx::RectF(297.f, 297.f, 30.f, 30.f)); EmulateDrawingOneFrame(root.get()); root_damage_rect = @@ -536,7 +536,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { // CASE 3: Setting this update rect outside the blurred content_bounds of the // blurred child1 will not cause it to be expanded. ClearDamageForAllSurfaces(root.get()); - root->set_update_rect(gfx::RectF(30.f, 30.f, 2.f, 2.f)); + root->SetUpdateRect(gfx::RectF(30.f, 30.f, 2.f, 2.f)); EmulateDrawingOneFrame(root.get()); root_damage_rect = @@ -552,7 +552,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { // outside the original content_bounds of the blurred child1 will // cause it to be expanded. ClearDamageForAllSurfaces(root.get()); - root->set_update_rect(gfx::RectF(99.f, 99.f, 1.f, 1.f)); + root->SetUpdateRect(gfx::RectF(99.f, 99.f, 1.f, 1.f)); EmulateDrawingOneFrame(root.get()); root_damage_rect = @@ -572,7 +572,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { // CASE 5: Setting the update rect on child2, which is above child1, will // not get blurred by child1, so it does not need to get expanded. ClearDamageForAllSurfaces(root.get()); - child2->set_update_rect(gfx::RectF(0.f, 0.f, 1.f, 1.f)); + child2->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 1.f)); EmulateDrawingOneFrame(root.get()); root_damage_rect = @@ -588,7 +588,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { // that any pixels needed for the blur are redrawn in the current // frame. ClearDamageForAllSurfaces(root.get()); - child1->set_update_rect(gfx::RectF(0.f, 0.f, 1.f, 1.f)); + child1->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 1.f)); EmulateDrawingOneFrame(root.get()); root_damage_rect = @@ -712,8 +712,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForMultipleLayers) { // - child1 update rect in surface space: gfx::RectF(100.f, 100.f, 1.f, 2.f); // - child2 update rect in surface space: gfx::RectF(400.f, 380.f, 3.f, 4.f); ClearDamageForAllSurfaces(root.get()); - child1->set_update_rect(gfx::RectF(0.f, 0.f, 1.f, 2.f)); - child2->set_update_rect(gfx::RectF(0.f, 0.f, 3.f, 4.f)); + child1->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 2.f)); + child2->SetUpdateRect(gfx::RectF(0.f, 0.f, 3.f, 4.f)); EmulateDrawingOneFrame(root.get()); gfx::RectF root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); @@ -916,7 +916,7 @@ TEST_F(DamageTrackerTest, VerifyNoDamageForUpdateRectThatDoesNotDrawContent) { // In our specific tree, the update rect of child1 should not cause any // damage to any surface because it does not actually draw content. ClearDamageForAllSurfaces(root.get()); - child1->set_update_rect(gfx::RectF(0.f, 0.f, 1.f, 2.f)); + child1->SetUpdateRect(gfx::RectF(0.f, 0.f, 1.f, 2.f)); EmulateDrawingOneFrame(root.get()); child_damage_rect = child1->render_surface()->damage_tracker()->current_damage_rect(); @@ -1070,7 +1070,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { // CASE 1: the update_rect on a mask layer should damage the entire target // surface. ClearDamageForAllSurfaces(root.get()); - mask_layer->set_update_rect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); + mask_layer->SetUpdateRect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); EmulateDrawingOneFrame(root.get()); gfx::RectF child_damage_rect = child->render_surface()->damage_tracker()->current_damage_rect(); @@ -1258,7 +1258,7 @@ TEST_F(DamageTrackerTest, DamageWhenAddedExternally) { // it is included with any other partial damage. // ClearDamageForAllSurfaces(root.get()); - child->set_update_rect(gfx::RectF(10, 11, 12, 13)); + child->SetUpdateRect(gfx::RectF(10, 11, 12, 13)); root->render_surface()->damage_tracker()->AddDamageNextUpdate( gfx::RectF(15, 16, 32, 33)); EmulateDrawingOneFrame(root.get()); @@ -1312,7 +1312,7 @@ TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { LayerImpl* child = root->children()[0]; ClearDamageForAllSurfaces(root.get()); - child->set_update_rect(gfx::RectF(10.f, 11.f, 1.f, 2.f)); + child->SetUpdateRect(gfx::RectF(10.f, 11.f, 1.f, 2.f)); EmulateDrawingOneFrame(root.get()); // Sanity check damage after the first frame; this isnt the actual test yet. @@ -1322,7 +1322,7 @@ TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { // New damage, without having cleared the previous damage, should be unioned // to the previous one. - child->set_update_rect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); + child->SetUpdateRect(gfx::RectF(20.f, 25.f, 1.f, 2.f)); EmulateDrawingOneFrame(root.get()); root_damage_rect = root->render_surface()->damage_tracker()->current_damage_rect(); diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 1d30479..05fc56c 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -2849,7 +2849,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { // Opaque layer, drawn without blending. layer1->SetContentsOpaque(true); layer1->SetExpectation(false, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2858,7 +2858,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { // Layer with translucent content and painting, so drawn with blending. layer1->SetContentsOpaque(false); layer1->SetExpectation(true, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2868,7 +2868,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(0.5f); layer1->SetExpectation(true, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2878,7 +2878,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(0.5f); layer1->SetExpectation(true, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2896,11 +2896,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(1.f); layer1->SetExpectation(false, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); layer2->SetContentsOpaque(true); layer2->SetOpacity(1.f); layer2->SetExpectation(false, false); - layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2911,9 +2911,9 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { // Child layer with opaque content, drawn without blending. layer1->SetContentsOpaque(false); layer1->SetExpectation(true, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); layer2->SetExpectation(false, false); - layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2925,9 +2925,9 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { // Child layer with opaque content, drawn without blending. layer1->SetContentsOpaque(true); layer1->SetExpectation(false, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); layer2->SetExpectation(false, false); - layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2942,9 +2942,9 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(0.5f); layer1->SetExpectation(false, true); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); layer2->SetExpectation(false, false); - layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2956,11 +2956,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(1.f); layer1->SetExpectation(false, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); layer2->SetContentsOpaque(true); layer2->SetOpacity(0.5f); layer2->SetExpectation(true, false); - layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2971,11 +2971,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(1.f); layer1->SetExpectation(false, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); layer2->SetContentsOpaque(false); layer2->SetOpacity(1.f); layer2->SetExpectation(true, false); - layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -2987,11 +2987,11 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetContentsOpaque(true); layer1->SetOpacity(1.f); layer1->SetExpectation(false, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); layer2->SetContentsOpaque(true); layer2->SetOpacity(1.f); layer2->SetExpectation(false, false); - layer2->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -3004,7 +3004,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(true, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -3016,7 +3016,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(true, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -3028,7 +3028,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(true, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -3041,7 +3041,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(false, false); - layer1->set_update_rect(gfx::RectF(layer1->content_bounds())); + layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); @@ -3680,7 +3680,7 @@ TEST_F(LayerTreeHostImplTest, PartialSwap) { Mock::VerifyAndClearExpectations(&mock_context); // Damage a portion of the frame. - host_impl_->active_tree()->root_layer()->set_update_rect( + host_impl_->active_tree()->root_layer()->SetUpdateRect( gfx::Rect(0, 0, 2, 3)); // The second frame will be partially-swapped (the y coordinates are flipped). @@ -4027,7 +4027,7 @@ TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { // The second frame has damage that doesn't touch the child layer. Its quads // should still be generated. gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); - host_impl_->active_tree()->root_layer()->set_update_rect(small_damage); + host_impl_->active_tree()->root_layer()->SetUpdateRect(small_damage); DrawFrameAndTestDamage(small_damage); // The third frame should have no damage, so no quads should be generated. diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 66b0f92..650f7ca 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -3180,6 +3180,43 @@ class LayerTreeHostTestUIResource : public LayerTreeHostTest { MULTI_THREAD_TEST_F(LayerTreeHostTestUIResource); +class PushPropertiesCountingLayerImpl : public LayerImpl { + public: + static scoped_ptr<PushPropertiesCountingLayerImpl> Create( + LayerTreeImpl* tree_impl, int id) { + return make_scoped_ptr(new PushPropertiesCountingLayerImpl(tree_impl, id)); + } + + virtual ~PushPropertiesCountingLayerImpl() {} + + virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE { + LayerImpl::PushPropertiesTo(layer); + push_properties_count_++; + // Push state to the active tree because we can only access it from there. + static_cast<PushPropertiesCountingLayerImpl*>( + layer)->push_properties_count_ = push_properties_count_; + } + + virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) + OVERRIDE { + return PushPropertiesCountingLayerImpl::Create(tree_impl, id()). + PassAs<LayerImpl>(); + } + + size_t push_properties_count() const { return push_properties_count_; } + void reset_push_properties_count() { push_properties_count_ = 0; } + + private: + size_t push_properties_count_; + + PushPropertiesCountingLayerImpl(LayerTreeImpl* tree_impl, int id) + : LayerImpl(tree_impl, id), + push_properties_count_(0) { + SetAnchorPoint(gfx::PointF()); + SetBounds(gfx::Size(1, 1)); + } +}; + class PushPropertiesCountingLayer : public Layer { public: static scoped_refptr<PushPropertiesCountingLayer> Create() { @@ -3193,6 +3230,12 @@ class PushPropertiesCountingLayer : public Layer { needs_push_properties_ = true; } + virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) + OVERRIDE { + return PushPropertiesCountingLayerImpl::Create(tree_impl, id()). + PassAs<LayerImpl>(); + } + size_t push_properties_count() const { return push_properties_count_; } void reset_push_properties_count() { push_properties_count_ = 0; } @@ -3405,6 +3448,206 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest { MULTI_THREAD_TEST_F(LayerTreeHostTestLayersPushProperties); +class LayerTreeHostTestImplLayersPushProperties + : public LayerTreeHostTestLayersPushProperties { + protected: + virtual void BeginTest() OVERRIDE { + expected_push_properties_root_impl_ = 0; + expected_push_properties_child_impl_ = 0; + expected_push_properties_grandchild_impl_ = 0; + expected_push_properties_child2_impl_ = 0; + expected_push_properties_grandchild2_impl_ = 0; + LayerTreeHostTestLayersPushProperties::BeginTest(); + } + + virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { + // These commits are in response to the changes made in + // LayerTreeHostTestLayersPushProperties::DidCommitAndDrawFrame() + switch (num_commits_) { + case 0: + // Tree hasn't been setup yet don't bother to check anything. + return; + case 1: + // Root gets set up, Everyone is initialized. + ++expected_push_properties_root_impl_; + ++expected_push_properties_child_impl_; + ++expected_push_properties_grandchild_impl_; + ++expected_push_properties_child2_impl_; + ++expected_push_properties_grandchild2_impl_; + break; + case 2: + // Tree doesn't change but the one leaf that always pushes is pushed. + ++expected_push_properties_grandchild2_impl_; + break; + case 3: + // Root is swapped here. + // Clear the expected push properties the tree will be rebuilt. + expected_push_properties_root_impl_ = 0; + expected_push_properties_child_impl_ = 0; + expected_push_properties_grandchild_impl_ = 0; + expected_push_properties_child2_impl_ = 0; + expected_push_properties_grandchild2_impl_ = 0; + + // Make sure the new root is pushed. + EXPECT_EQ(1u, static_cast<PushPropertiesCountingLayerImpl*>( + host_impl->RootLayer())->push_properties_count()); + return; + case 4: + // Root is swapped back all of the layers in the tree get pushed. + ++expected_push_properties_root_impl_; + ++expected_push_properties_child_impl_; + ++expected_push_properties_grandchild_impl_; + ++expected_push_properties_child2_impl_; + ++expected_push_properties_grandchild2_impl_; + break; + case 5: + // Tree doesn't change but the one leaf that always pushes is pushed. + ++expected_push_properties_grandchild2_impl_; + break; + case 6: + // First child is removed. Structure of the tree changes here so swap + // some of the values. child_impl becomes child2_impl. + expected_push_properties_child_impl_ = + expected_push_properties_child2_impl_; + expected_push_properties_child2_impl_ = 0; + // grandchild_impl becomes grandchild2_impl. + expected_push_properties_grandchild_impl_ = + expected_push_properties_grandchild2_impl_; + expected_push_properties_grandchild2_impl_ = 0; + + // grandchild_impl is now the leaf that always pushes. It is pushed. + ++expected_push_properties_grandchild_impl_; + break; + case 7: + // The leaf that always pushes is pushed. + ++expected_push_properties_grandchild_impl_; + + // Child is added back. New layers are initialized. + ++expected_push_properties_grandchild2_impl_; + ++expected_push_properties_child2_impl_; + break; + case 8: + // Leaf is removed. + expected_push_properties_grandchild2_impl_ = 0; + + // Always pushing. + ++expected_push_properties_grandchild_impl_; + break; + case 9: + // Leaf is added back + ++expected_push_properties_grandchild2_impl_; + + // The leaf that always pushes is pushed. + ++expected_push_properties_grandchild_impl_; + break; + case 10: + // The leaf that always pushes is pushed. + ++expected_push_properties_grandchild_impl_; + break; + case 11: + // The leaf that always pushes is pushed. + ++expected_push_properties_grandchild_impl_; + break; + case 12: + // The leaf that always pushes is pushed. + ++expected_push_properties_grandchild_impl_; + + // This child position was changed. + ++expected_push_properties_child2_impl_; + break; + case 13: + // The position of this child was changed. + ++expected_push_properties_child_impl_; + + // The leaf that always pushes is pushed. + ++expected_push_properties_grandchild_impl_; + break; + case 14: + // Second child is removed from tree. Don't discard counts because + // they are added back before commit. + + // The leaf that always pushes is pushed. + ++expected_push_properties_grandchild_impl_; + + // Second child added back. + ++expected_push_properties_child2_impl_; + ++expected_push_properties_grandchild2_impl_; + + break; + case 15: + // The position of this child was changed. + ++expected_push_properties_grandchild2_impl_; + + // The leaf that always pushes is pushed. + ++expected_push_properties_grandchild_impl_; + break; + case 16: + // Second child is invalidated with SetNeedsDisplay + ++expected_push_properties_child2_impl_; + + // The leaf that always pushed is pushed. + ++expected_push_properties_grandchild_impl_; + break; + } + + PushPropertiesCountingLayerImpl* root_impl_ = NULL; + PushPropertiesCountingLayerImpl* child_impl_ = NULL; + PushPropertiesCountingLayerImpl* child2_impl_ = NULL; + PushPropertiesCountingLayerImpl* grandchild_impl_ = NULL; + PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = NULL; + + // Pull the layers that we need from the tree assuming the same structure + // as LayerTreeHostTestLayersPushProperties + root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( + host_impl->RootLayer()); + + if (root_impl_ && root_impl_->children().size() > 0) { + child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( + root_impl_->children()[0]); + + if (child_impl_ && child_impl_->children().size() > 0) + grandchild_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( + child_impl_->children()[0]); + } + + if (root_impl_ && root_impl_->children().size() > 1) { + child2_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( + root_impl_->children()[1]); + + if (child2_impl_ && child2_impl_->children().size() > 0) + leaf_always_pushing_layer_impl_ = + static_cast<PushPropertiesCountingLayerImpl*>( + child2_impl_->children()[0]); + } + + if (root_impl_) + EXPECT_EQ(expected_push_properties_root_impl_, + root_impl_->push_properties_count()); + if (child_impl_) + EXPECT_EQ(expected_push_properties_child_impl_, + child_impl_->push_properties_count()); + if (grandchild_impl_) + EXPECT_EQ(expected_push_properties_grandchild_impl_, + grandchild_impl_->push_properties_count()); + if (child2_impl_) + EXPECT_EQ(expected_push_properties_child2_impl_, + child2_impl_->push_properties_count()); + if (leaf_always_pushing_layer_impl_) + EXPECT_EQ(expected_push_properties_grandchild2_impl_, + leaf_always_pushing_layer_impl_->push_properties_count()); + } + + size_t expected_push_properties_root_impl_; + size_t expected_push_properties_child_impl_; + size_t expected_push_properties_child2_impl_; + size_t expected_push_properties_grandchild_impl_; + size_t expected_push_properties_grandchild2_impl_; +}; + +TEST_F(LayerTreeHostTestImplLayersPushProperties, DelegatingRenderer) { + RunTestWithImplSidePainting(); +} + class LayerTreeHostTestPropertyChangesDuringUpdateArePushed : public LayerTreeHostTest { protected: diff --git a/cc/trees/tree_synchronizer.cc b/cc/trees/tree_synchronizer.cc index 48a9d5b..27f9dab 100644 --- a/cc/trees/tree_synchronizer.cc +++ b/cc/trees/tree_synchronizer.cc @@ -187,17 +187,6 @@ void UpdateScrollbarLayerPointersRecursive(const RawPtrLayerImplMap* new_layers, } // static -void TreeSynchronizer::SetNumDependentsNeedPushProperties( - Layer* layer, size_t num) { - layer->num_dependents_need_push_properties_ = num; -} - -// static -void TreeSynchronizer::SetNumDependentsNeedPushProperties( - LayerImpl* layer, size_t num) { -} - -// static template <typename LayerType> void TreeSynchronizer::PushPropertiesInternal( LayerType* layer, @@ -240,8 +229,8 @@ void TreeSynchronizer::PushPropertiesInternal( // every PushProperties tree walk. Here we keep track of those layers, and // ensure that their ancestors know about them for the next PushProperties // tree walk. - SetNumDependentsNeedPushProperties( - layer, num_dependents_need_push_properties); + layer->num_dependents_need_push_properties_ = + num_dependents_need_push_properties; } bool add_self_to_parent = num_dependents_need_push_properties > 0 || diff --git a/cc/trees/tree_synchronizer.h b/cc/trees/tree_synchronizer.h index de48cee..e7b2e2b 100644 --- a/cc/trees/tree_synchronizer.h +++ b/cc/trees/tree_synchronizer.h @@ -38,9 +38,6 @@ class CC_EXPORT TreeSynchronizer { private: TreeSynchronizer(); // Not instantiable. - static void SetNumDependentsNeedPushProperties(Layer* layer, size_t num); - static void SetNumDependentsNeedPushProperties(LayerImpl* layer, size_t num); - template <typename LayerType> static void PushPropertiesInternal( LayerType* layer, |