Commit 2cde7b51 authored by jaydasika's avatar jaydasika Committed by Commit bot

cc : Fix axis alignment tracking bug in property tree building

We track if the transform is 2d axis aligned since the last render target
during property tree building but it is not updated when we create an
effect node but not a render surface. This CL fixes that.
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2885953002
Cr-Commit-Position: refs/heads/master@{#472252}
parent 2679a47b
......@@ -1317,6 +1317,30 @@ TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) {
}
}
TEST_F(LayerTreeHostCommonTest, RenderSurfaceForNonAxisAlignedClipping) {
LayerImpl* root = root_layer_for_testing();
LayerImpl* rotated_and_transparent = AddChildToRoot<LayerImpl>();
LayerImpl* clips_subtree = AddChild<LayerImpl>(rotated_and_transparent);
LayerImpl* draws_content = AddChild<LayerImpl>(clips_subtree);
root->SetBounds(gfx::Size(10, 10));
rotated_and_transparent->SetBounds(gfx::Size(10, 10));
rotated_and_transparent->test_properties()->opacity = 0.5f;
gfx::Transform rotate;
rotate.Rotate(2);
rotated_and_transparent->test_properties()->transform = rotate;
clips_subtree->SetBounds(gfx::Size(10, 10));
clips_subtree->SetMasksToBounds(true);
draws_content->SetBounds(gfx::Size(10, 10));
draws_content->SetDrawsContent(true);
ExecuteCalculateDrawProperties(root);
EffectTree& effect_tree =
root->layer_tree_impl()->property_trees()->effect_tree;
EffectNode* node = effect_tree.Node(clips_subtree->effect_tree_index());
EXPECT_TRUE(node->has_render_surface);
}
TEST_F(LayerTreeHostCommonTest,
RenderSurfaceListForRenderSurfaceWithClippedLayer) {
LayerImpl* root = root_layer_for_testing();
......
......@@ -55,7 +55,7 @@ struct DataForRecursion {
bool scroll_tree_parent_created_by_uninheritable_criteria;
const gfx::Transform* device_transform;
gfx::Transform compound_transform_since_render_target;
bool axis_align_since_render_target;
bool animation_axis_aligned_since_render_target;
SkColor safe_opaque_background_color;
};
......@@ -727,10 +727,9 @@ static inline bool PropertyChanged(LayerImpl* layer) {
template <typename LayerType>
bool ShouldCreateRenderSurface(LayerType* layer,
gfx::Transform current_transform,
bool axis_aligned) {
bool animation_axis_aligned) {
const bool preserves_2d_axis_alignment =
(current_transform * Transform(layer)).Preserves2dAxisAlignment() &&
axis_aligned && AnimationsPreserveAxisAlignment(layer);
current_transform.Preserves2dAxisAlignment() && animation_axis_aligned;
const bool is_root = !Parent(layer);
if (is_root)
return true;
......@@ -885,11 +884,13 @@ bool AddEffectNodeIfNeeded(
HasPotentiallyRunningFilterAnimation(layer);
const bool has_proxied_opacity =
!!(layer->mutable_properties() & MutableProperty::kOpacity);
const bool should_create_render_surface = ShouldCreateRenderSurface(
layer, data_from_ancestor.compound_transform_since_render_target,
data_from_ancestor.axis_align_since_render_target);
data_for_children->axis_align_since_render_target &=
data_for_children->animation_axis_aligned_since_render_target &=
AnimationsPreserveAxisAlignment(layer);
data_for_children->compound_transform_since_render_target *= Transform(layer);
const bool should_create_render_surface = ShouldCreateRenderSurface(
layer, data_for_children->compound_transform_since_render_target,
data_for_children->animation_axis_aligned_since_render_target);
bool requires_node = is_root || has_transparency ||
has_potential_opacity_animation || has_proxied_opacity ||
......@@ -900,8 +901,6 @@ bool AddEffectNodeIfNeeded(
if (!requires_node) {
layer->SetEffectTreeIndex(parent_id);
data_for_children->effect_tree_parent = parent_id;
data_for_children->compound_transform_since_render_target *=
Transform(layer);
return false;
}
......@@ -981,7 +980,7 @@ bool AddEffectNodeIfNeeded(
if (should_create_render_surface) {
data_for_children->compound_transform_since_render_target =
gfx::Transform();
data_for_children->axis_align_since_render_target = true;
data_for_children->animation_axis_aligned_since_render_target = true;
}
return should_create_render_surface;
}
......@@ -1272,7 +1271,7 @@ void BuildPropertyTreesTopLevelInternal(
data_for_recursion.property_trees->clear();
data_for_recursion.compound_transform_since_render_target = gfx::Transform();
data_for_recursion.axis_align_since_render_target = true;
data_for_recursion.animation_axis_aligned_since_render_target = true;
data_for_recursion.property_trees->transform_tree.set_device_scale_factor(
device_scale_factor);
data_for_recursion.safe_opaque_background_color = color;
......
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