diff options
author | ajuma <ajuma@chromium.org> | 2015-11-09 14:24:46 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-09 22:25:32 +0000 |
commit | aa0d38670f55033607bc4d2513f877db516a4b1c (patch) | |
tree | 0c15d8fbe66414d97258a8ebb8730afea58b1f4d /cc/trees | |
parent | 153f9f5aa796294694df4fdbb5ed3653cce3905a (diff) | |
download | chromium_src-aa0d38670f55033607bc4d2513f877db516a4b1c.zip chromium_src-aa0d38670f55033607bc4d2513f877db516a4b1c.tar.gz chromium_src-aa0d38670f55033607bc4d2513f877db516a4b1c.tar.bz2 |
cc: Fix computation of layer backfacing-ness when using property trees
When using property trees, layers whose transform is tested for
backfacing-ness might not have up-to-date draw properties (e.g.,
such layers might not draw content). This means that instead of
using the layer's draw_transform() draw property, we need to
call DrawTransformFromPropertyTrees.
BUG=553580
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1422453007
Cr-Commit-Position: refs/heads/master@{#358683}
Diffstat (limited to 'cc/trees')
-rw-r--r-- | cc/trees/layer_tree_host_common.cc | 26 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 42 |
2 files changed, 62 insertions, 6 deletions
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 649f6c2..345182c 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -445,14 +445,22 @@ static bool IsRootLayerOfNewRenderingContext(LayerImpl* layer) { return layer->Is3dSorted(); } -static bool IsLayerBackFaceVisible(LayerImpl* layer) { +static bool IsLayerBackFaceVisible(LayerImpl* layer, + bool use_property_trees, + const TransformTree& transform_tree) { // The current W3C spec on CSS transforms says that backface visibility should // be determined differently depending on whether the layer is in a "3d // rendering context" or not. For Chromium code, we can determine whether we // are in a 3d rendering context by checking if the parent preserves 3d. - if (LayerIsInExisting3DRenderingContext(layer)) - return layer->draw_transform().IsBackFaceVisible(); + if (LayerIsInExisting3DRenderingContext(layer)) { + if (use_property_trees) { + return DrawTransformFromPropertyTrees(layer, transform_tree) + .IsBackFaceVisible(); + } else { + return layer->draw_transform().IsBackFaceVisible(); + } + } // In this case, either the layer establishes a new 3d rendering context, or // is not in a 3d rendering context at all. @@ -519,7 +527,10 @@ static gfx::Rect CalculateVisibleLayerRect( layer_rect_in_target_space, layer->draw_transform()); } -static bool LayerShouldBeSkipped(LayerImpl* layer, bool layer_is_drawn) { +static bool LayerShouldBeSkipped(LayerImpl* layer, + bool layer_is_drawn, + bool use_property_trees, + const TransformTree& transform_tree) { // Layers can be skipped if any of these conditions are met. // - is not drawn due to it or one of its ancestors being hidden (or having // no copy requests). @@ -553,7 +564,8 @@ static bool LayerShouldBeSkipped(LayerImpl* layer, bool layer_is_drawn) { // The layer should not be drawn if (1) it is not double-sided and (2) the // back of the layer is known to be facing the screen. if (!backface_test_layer->double_sided() && - IsLayerBackFaceVisible(backface_test_layer)) + IsLayerBackFaceVisible(backface_test_layer, use_property_trees, + transform_tree)) return true; return false; @@ -2542,7 +2554,9 @@ void CalculateRenderSurfaceLayerListInternal( size_t descendants_size = descendants->size(); - bool layer_should_be_skipped = LayerShouldBeSkipped(layer, layer_is_drawn); + bool layer_should_be_skipped = + LayerShouldBeSkipped(layer, layer_is_drawn, use_property_trees, + property_trees->transform_tree); if (!layer_should_be_skipped) { MarkLayerWithRenderSurfaceLayerListId(layer, current_render_surface_layer_list_id); diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index e42460d..5e862ef 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -6067,6 +6067,48 @@ TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { .size()); } +TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) { + LayerImpl* root = root_layer(); + LayerImpl* child = AddChild<LayerImpl>(root); + LayerImpl* grand_child = AddChild<LayerImpl>(child); + grand_child->SetDrawsContent(true); + + child->SetDoubleSided(false); + grand_child->SetUseParentBackfaceVisibility(true); + + gfx::Transform identity_transform; + SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), false, true, + true); + SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), + gfx::PointF(), gfx::Size(30, 30), false, true, + false); + SetLayerPropertiesForTesting(grand_child, identity_transform, gfx::Point3F(), + gfx::PointF(), gfx::Size(20, 20), false, true, + false); + + ExecuteCalculateDrawProperties(root); + + EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); + EXPECT_EQ(grand_child, render_surface_layer_list_impl() + ->at(0) + ->render_surface() + ->layer_list()[0]); + gfx::Transform rotation_transform = identity_transform; + rotation_transform.RotateAboutXAxis(180.0); + + child->SetTransform(rotation_transform); + child->layer_tree_impl()->property_trees()->needs_rebuild = true; + + ExecuteCalculateDrawProperties(root); + EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); + EXPECT_EQ(0u, render_surface_layer_list_impl() + ->at(0) + ->render_surface() + ->layer_list() + .size()); +} + TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) { // Checks that the simple case (being clipped by a scroll parent that would // have been processed before you anyhow) results in the right clips. |