Commit 92f2f6d9 authored by enne's avatar enne Committed by Commit bot

cc: Fix animated filter render surface check

The render surface calculation wasn't taking into account animated
filters.  These are animations which will eventually set a filter, but
the filters on the layer are empty at render surface calculation time.

This is just a missed case in render surface calculation, as it used
to be handled naturally on the compositor thread after the filter got
added.

R=vollick@chromium.org
BUG=461180

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

Cr-Commit-Position: refs/heads/master@{#318138}
parent ea77cec7
...@@ -591,6 +591,13 @@ static bool SubtreeShouldRenderToSeparateSurface( ...@@ -591,6 +591,13 @@ static bool SubtreeShouldRenderToSeparateSurface(
return true; return true;
} }
// If the layer will use a CSS filter. In this case, the animation
// will start and add a filter to this layer, so it needs a surface.
if (layer->FilterIsAnimating()) {
DCHECK(!is_root);
return true;
}
int num_descendants_that_draw_content = int num_descendants_that_draw_content =
layer->NumDescendantsThatDrawContent(); layer->NumDescendantsThatDrawContent();
...@@ -1198,20 +1205,22 @@ struct PreCalculateMetaInformationRecursiveData { ...@@ -1198,20 +1205,22 @@ struct PreCalculateMetaInformationRecursiveData {
} }
}; };
static bool ValidateRenderSurface(LayerImpl* layer) { static void ValidateRenderSurface(LayerImpl* layer) {
// This test verifies that there are no cases where a LayerImpl needs // This test verifies that there are no cases where a LayerImpl needs
// a render surface, but doesn't have one. // a render surface, but doesn't have one.
if (layer->render_surface()) if (layer->render_surface())
return true; return;
return layer->filters().IsEmpty() && layer->background_filters().IsEmpty() && DCHECK(layer->filters().IsEmpty()) << "layer: " << layer->id();
!layer->mask_layer() && !layer->replica_layer() && DCHECK(layer->background_filters().IsEmpty()) << "layer: " << layer->id();
!IsRootLayer(layer) && !layer->is_root_for_isolated_group() && DCHECK(!layer->mask_layer()) << "layer: " << layer->id();
!layer->HasCopyRequest(); DCHECK(!layer->replica_layer()) << "layer: " << layer->id();
DCHECK(!IsRootLayer(layer)) << "layer: " << layer->id();
DCHECK(!layer->is_root_for_isolated_group()) << "layer: " << layer->id();
DCHECK(!layer->HasCopyRequest()) << "layer: " << layer->id();
} }
static bool ValidateRenderSurface(Layer* layer) { static void ValidateRenderSurface(Layer* layer) {
return true;
} }
// Recursively walks the layer tree to compute any information that is needed // Recursively walks the layer tree to compute any information that is needed
...@@ -1220,7 +1229,7 @@ template <typename LayerType> ...@@ -1220,7 +1229,7 @@ template <typename LayerType>
static void PreCalculateMetaInformation( static void PreCalculateMetaInformation(
LayerType* layer, LayerType* layer,
PreCalculateMetaInformationRecursiveData* recursive_data) { PreCalculateMetaInformationRecursiveData* recursive_data) {
DCHECK(ValidateRenderSurface(layer)); ValidateRenderSurface(layer);
layer->draw_properties().sorted_for_recursion = false; layer->draw_properties().sorted_for_recursion = false;
layer->draw_properties().has_child_with_a_scroll_parent = false; layer->draw_properties().has_child_with_a_scroll_parent = false;
......
...@@ -8775,5 +8775,42 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { ...@@ -8775,5 +8775,42 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) {
EXPECT_FALSE(animated->visible_rect_from_property_trees().IsEmpty()); EXPECT_FALSE(animated->visible_rect_from_property_trees().IsEmpty());
} }
// Verify that having an animated filter (but no current filter, as these
// are mutually exclusive) correctly creates a render surface.
TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) {
scoped_refptr<Layer> root = Layer::Create();
scoped_refptr<Layer> child = Layer::Create();
scoped_refptr<Layer> grandchild = Layer::Create();
root->AddChild(child);
child->AddChild(grandchild);
gfx::Transform identity_transform;
SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
gfx::PointF(), gfx::Size(50, 50), true, false);
SetLayerPropertiesForTesting(child.get(), identity_transform, gfx::Point3F(),
gfx::PointF(), gfx::Size(50, 50), true, false);
SetLayerPropertiesForTesting(grandchild.get(), identity_transform,
gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50),
true, false);
scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost());
host->SetRootLayer(root);
AddAnimatedFilterToLayer(child.get(), 10.0, 0.1f, 0.2f);
ExecuteCalculateDrawProperties(root.get());
EXPECT_TRUE(root->render_surface());
EXPECT_TRUE(child->render_surface());
EXPECT_FALSE(grandchild->render_surface());
EXPECT_TRUE(root->filters().IsEmpty());
EXPECT_TRUE(child->filters().IsEmpty());
EXPECT_TRUE(grandchild->filters().IsEmpty());
EXPECT_FALSE(root->FilterIsAnimating());
EXPECT_TRUE(child->FilterIsAnimating());
EXPECT_FALSE(grandchild->FilterIsAnimating());
}
} // namespace } // namespace
} // namespace cc } // namespace cc
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