Commit 20384bfc authored by ajuma's avatar ajuma Committed by Commit bot

cc: Make animated opacity trigger render surface creation

This makes layers with animated opacity get treated as though they
have non-1 opacity when determining whether they need a render surface,
since an animation can cause opacity to change from 1 to non-1 without
a commit happening in between.

CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/2169143002
Cr-Commit-Position: refs/heads/master@{#407142}
parent 21bee10a
......@@ -8503,6 +8503,34 @@ TEST_F(LayerTreeHostCommonTest,
descendant_of_animation->visible_layer_rect_for_testing());
}
// Verify that having animated opacity but current opacity 1 still creates
// a render surface.
TEST_F(LayerTreeHostCommonTest, AnimatedOpacityCreatesRenderSurface) {
LayerImpl* root = root_layer_for_testing();
LayerImpl* child = AddChild<LayerImpl>(root);
LayerImpl* grandchild = AddChild<LayerImpl>(child);
child->SetDrawsContent(true);
grandchild->SetDrawsContent(true);
gfx::Transform identity_transform;
SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(),
gfx::PointF(), gfx::Size(50, 50), true, false);
SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(),
gfx::PointF(), gfx::Size(50, 50), true, false);
SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(),
gfx::PointF(), gfx::Size(50, 50), true, false);
SetElementIdsForTesting();
AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline_impl(),
10.0, 1.f, 0.2f, false);
ExecuteCalculateDrawProperties(root);
EXPECT_EQ(1.f, child->Opacity());
EXPECT_TRUE(root->has_render_surface());
EXPECT_TRUE(child->has_render_surface());
EXPECT_FALSE(grandchild->has_render_surface());
}
// Verify that having an animated filter (but no current filter, as these
// are mutually exclusive) correctly creates a render surface.
TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) {
......
......@@ -882,7 +882,9 @@ bool ShouldCreateRenderSurface(LayerType* layer,
num_descendants_that_draw_content > 0 &&
(layer->DrawsContent() || num_descendants_that_draw_content > 1);
if (EffectiveOpacity(layer) != 1.f && ShouldFlattenTransform(layer) &&
bool may_have_transparency = EffectiveOpacity(layer) != 1.f ||
HasPotentiallyRunningOpacityAnimation(layer);
if (may_have_transparency && ShouldFlattenTransform(layer) &&
at_least_two_layers_in_subtree_draw_content) {
TRACE_EVENT_INSTANT0(
"cc", "PropertyTreeBuilder::ShouldCreateRenderSurface opacity",
......
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