diff options
author | jaydasika <jaydasika@chromium.org> | 2016-01-28 18:26:00 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-29 02:26:49 +0000 |
commit | 2489a446981f61142c2e2679b4b39435d8b8958b (patch) | |
tree | 133407bf70b9b8547541d1d15e068ef7d455a73e | |
parent | ff937edd31103810aef4a934f932d49c60b05cfc (diff) | |
download | chromium_src-2489a446981f61142c2e2679b4b39435d8b8958b.zip chromium_src-2489a446981f61142c2e2679b4b39435d8b8958b.tar.gz chromium_src-2489a446981f61142c2e2679b4b39435d8b8958b.tar.bz2 |
cc :: Fix sublayer scale bug when we have scroll parents
The current visible rect computation logic with property trees assumes that
whenever a layer's target is different from its clip node's target, it is
because the layer has a clip parent. But, this case is possible even when the
layer has a scroll parent. When we have scroll parent, we need to apply scales
differently because clip parent is an ancestor but scroll parent is not.
BUG=576959
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1643053002
Cr-Commit-Position: refs/heads/master@{#372257}
-rw-r--r-- | cc/trees/draw_property_utils.cc | 49 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 19 |
2 files changed, 52 insertions, 16 deletions
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc index de3505c..cb0a6e5 100644 --- a/cc/trees/draw_property_utils.cc +++ b/cc/trees/draw_property_utils.cc @@ -85,18 +85,32 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list, // necessarily have the same target (the root). if (clip_node->data.target_id != target_node->id && non_root_surfaces_enabled) { - // In this case, layer has a clip parent (or shares the target with an - // ancestor layer that has clip parent) and the clip parent's target is - // different from the layer's target. As the layer's target has - // unclippped descendants, it is unclippped. + // In this case, layer has a clip parent or scroll parent (or shares the + // target with an ancestor layer that has clip parent) and the clip + // parent's target is different from the layer's target. As the layer's + // target has unclippped descendants, it is unclippped. if (!clip_node->data.layers_are_clipped) { layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds)); layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); continue; } gfx::Transform clip_to_target; - success = transform_tree.ComputeTransform( - clip_node->data.target_id, target_node->id, &clip_to_target); + if (clip_node->data.target_id > target_node->id) { + // In this case, layer has a scroll parent. We need to keep the scale + // at the layer's target but remove the scale at the scroll parent's + // target. + success = transform_tree.ComputeTransformWithDestinationSublayerScale( + clip_node->data.target_id, target_node->id, &clip_to_target); + const TransformNode* source_node = + transform_tree.Node(clip_node->data.target_id); + if (source_node->data.sublayer_scale.x() != 0.f && + source_node->data.sublayer_scale.y() != 0.f) + clip_to_target.Scale(1.0f / source_node->data.sublayer_scale.x(), + 1.0f / source_node->data.sublayer_scale.y()); + } else { + success = transform_tree.ComputeTransform( + clip_node->data.target_id, target_node->id, &clip_to_target); + } if (!success) { // An animated singular transform may become non-singular during the // animation, so we still need to compute a visible rect. In this @@ -105,19 +119,28 @@ void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list, layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); continue; } - DCHECK_LT(clip_node->data.target_id, target_node->id); // We use the clip node's clip_in_target_space (and not // combined_clip_in_target_space) here because we want to clip // with respect to clip parent's local clip and not its combined clip as // the combined clip has even the clip parent's target's clip baked into // it and as our target is different, we don't want to use it in our // visible rect computation. - combined_clip_rect_in_target_space = - gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( - clip_to_target, clip_node->data.clip_in_target_space)); - clip_rect_in_target_space = - gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( - clip_to_target, clip_node->data.clip_in_target_space)); + if (clip_node->data.target_id < target_node->id) { + combined_clip_rect_in_target_space = + gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( + clip_to_target, clip_node->data.clip_in_target_space)); + clip_rect_in_target_space = + gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( + clip_to_target, clip_node->data.clip_in_target_space)); + } else { + combined_clip_rect_in_target_space = + gfx::ToEnclosingRect(MathUtil::MapClippedRect( + clip_to_target, clip_node->data.clip_in_target_space)); + clip_rect_in_target_space = + gfx::ToEnclosingRect(MathUtil::MapClippedRect( + clip_to_target, clip_node->data.clip_in_target_space)); + } + } else { clip_rect_in_target_space = gfx::ToEnclosingRect(clip_node->data.clip_in_target_space); diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index d5ba0ce..27342ce 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -6587,10 +6587,23 @@ TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) { gfx::Size(50, 50), true, false, true); SetLayerPropertiesForTesting(scroll_parent, identity_transform, gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), - true, false, true); + true, false, false); + scroll_parent_target->SetMasksToBounds(true); - ExecuteCalculateDrawProperties(root); - EXPECT_EQ(scroll_child->DrawTransform(), identity_transform); + float device_scale_factor = 1.5f; + LayerImplList render_surface_layer_list_impl; + root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); + LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( + root, root->bounds(), identity_transform, &render_surface_layer_list_impl, + root->layer_tree_impl()->current_render_surface_list_id()); + inputs.device_scale_factor = device_scale_factor; + LayerTreeHostCommon::CalculateDrawProperties(&inputs); + + EXPECT_EQ(scroll_child->visible_layer_rect(), gfx::Rect(10, 10, 40, 40)); + EXPECT_EQ(scroll_child->clip_rect(), gfx::Rect(15, 15, 75, 75)); + gfx::Transform scale; + scale.Scale(1.5f, 1.5f); + EXPECT_EQ(scroll_child->DrawTransform(), scale); } TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) { |