diff options
author | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-11 19:50:57 +0000 |
---|---|---|
committer | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-11 19:50:57 +0000 |
commit | 56fffddd38f4ee14d432d0829e17edd118767d9e (patch) | |
tree | 36e671eef451b4c6adcddf6071ecf8bf122350bd /cc/trees/layer_tree_host_common.cc | |
parent | 3a13eeb48780dc76e7be6aa8e90b26c201103247 (diff) | |
download | chromium_src-56fffddd38f4ee14d432d0829e17edd118767d9e.zip chromium_src-56fffddd38f4ee14d432d0829e17edd118767d9e.tar.gz chromium_src-56fffddd38f4ee14d432d0829e17edd118767d9e.tar.bz2 |
Split preserve3d into: "should-flatten" and "is-3d-sorted"
Preserve3d has implications for both sorting and flattening of
transforms. This is a bummer. Sometimes we want to allow a transform to
remain unflattened, but we don't want that to affect 3d sorting. With
this CL, we will have the ability to do that.
Note: this is essentially this cl
https://codereview.chromium.org/100393005/
..minus the generalizations to sorting that were being attempted in that
patch.
Note, this CL is gated on https://codereview.chromium.org/98373011/
R=enne@chromium.org
BUG=338980
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=249974
Review URL: https://codereview.chromium.org/147833003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250474 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees/layer_tree_host_common.cc')
-rw-r--r-- | cc/trees/layer_tree_host_common.cc | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 54674ef..b0b3b73 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -328,21 +328,16 @@ template <typename LayerType> static inline bool IsRootLayer(LayerType* layer) { template <typename LayerType> static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { - // According to current W3C spec on CSS transforms, a layer is part of an - // established 3d rendering context if its parent has transform-style of - // preserves-3d. - return layer->parent() && layer->parent()->preserves_3d(); + return layer->is_3d_sorted() && layer->parent() && + layer->parent()->is_3d_sorted(); } template <typename LayerType> static bool IsRootLayerOfNewRenderingContext(LayerType* layer) { - // According to current W3C spec on CSS transforms (Section 6.1), a layer is - // the beginning of 3d rendering context if its parent does not have - // transform-style: preserve-3d, but this layer itself does. if (layer->parent()) - return !layer->parent()->preserves_3d() && layer->preserves_3d(); + return !layer->parent()->is_3d_sorted() && layer->is_3d_sorted(); - return layer->preserves_3d(); + return layer->is_3d_sorted(); } template <typename LayerType> @@ -574,9 +569,10 @@ static bool SubtreeShouldRenderToSeparateSurface( int num_descendants_that_draw_content = layer->draw_properties().num_descendants_that_draw_content; - // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), but - // it is treated as a 3D object by its parent (i.e. parent does preserve-3d). - if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() && + // If the layer flattens its subtree, but it is treated as a 3D object by its + // parent (i.e. parent participates in a 3D rendering context). + if (LayerIsInExisting3DRenderingContext(layer) && + layer->should_flatten_transform() && num_descendants_that_draw_content > 0) { TRACE_EVENT_INSTANT0( "cc", @@ -622,7 +618,7 @@ static bool SubtreeShouldRenderToSeparateSurface( num_descendants_that_draw_content > 0 && (layer->DrawsContent() || num_descendants_that_draw_content > 1); - if (layer->opacity() != 1.f && !layer->preserves_3d() && + if (layer->opacity() != 1.f && layer->should_flatten_transform() && at_least_two_layers_in_subtree_draw_content) { TRACE_EVENT_INSTANT0( "cc", @@ -1577,7 +1573,7 @@ static void CalculateDrawPropertiesInternal( // layer's "screen space" and local content space. layer_draw_properties.screen_space_transform = data_from_ancestor.full_hierarchy_matrix; - if (!layer->preserves_3d()) + if (layer->should_flatten_transform()) layer_draw_properties.screen_space_transform.FlattenTo2d(); layer_draw_properties.screen_space_transform.PreconcatTransform (layer_draw_properties.target_space_transform); @@ -1883,7 +1879,7 @@ static void CalculateDrawPropertiesInternal( } // Flatten to 2D if the layer doesn't preserve 3D. - if (!layer->preserves_3d()) + if (layer->should_flatten_transform()) data_for_children.parent_matrix.FlattenTo2d(); // Apply the sublayer transform at the anchor point of the layer. @@ -2113,8 +2109,8 @@ static void CalculateDrawPropertiesInternal( // drawn from back to front. If the preserves-3d property is also set on the // parent then skip the sorting as the parent will sort all the descendants // anyway. - if (globals.layer_sorter && descendants.size() && layer->preserves_3d() && - (!layer->parent() || !layer->parent()->preserves_3d())) { + if (globals.layer_sorter && descendants.size() && layer->is_3d_sorted() && + !LayerIsInExisting3DRenderingContext(layer)) { SortLayers(descendants.begin() + sorting_start_index, descendants.end(), globals.layer_sorter); |