Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: cc/layer_tree_host_common.cc

Issue 11567034: Changes subtreeShouldRenderToSeparateSurface logic to account for explicit clipping (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« cc/draw_properties.h ('K') | « cc/draw_properties.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_tree_host_common.cc
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index 0a204ceb6914df96a5bdede2b6c8c9ee7e1c6915..81b9aa68b7efbc275f3ef0b78e18c9dca7aa9587 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -274,7 +274,7 @@ static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlig
return true;
// If the layer clips its descendants but it is not axis-aligned with respect to its parent.
- if (layerClipsSubtree(layer) && !axisAlignedWithRespectToParent && numDescendantsThatDrawContent > 0)
+ if (layerClipsSubtree(layer) && !layer->drawProperties().all_children_can_clip)
return true;
// If the layer has some translucency and does not have a preserves-3d transform style.
@@ -429,21 +429,46 @@ static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList
layerToRemove->clearRenderSurface();
}
+inline bool isPositiveScaleOrTranslation(const gfx::Transform& xform)
+{
+ if (!xform.IsScaleOrTranslation())
+ return false;
+
+ // Grab our scale and make sure it's positive.
+ float x_scale = xform.matrix().getDouble(0,0);
jamesr 2012/12/14 04:31:19 do we have to do a double->float conversion here?
whunt 2012/12/14 18:17:01 There's no reason to do the conversion. I'm just
+ float y_scale = xform.matrix().getDouble(1,1);
+ if (x_scale <= 0.0f || y_scale <= 0.0f)
+ return false;
+
+ return true;
+}
+
// Recursively walks the layer tree to compute any information that is needed
// before doing the main recursion.
template<typename LayerType>
static void preCalculateMetaInformation(LayerType* layer)
{
int numDescendantsThatDrawContent = 0;
+ bool allChildrenCanClip = true;
+
+ bool sublayerPreventsClip = !isPositiveScaleOrTranslation(layer->sublayerTransform());
jamesr 2012/12/14 04:31:19 I'm not sure that this is sufficient. If the tran
shawnsingh 2012/12/14 07:34:44 +1 james comment; we do need the additional condit
Ian Vollick 2012/12/14 12:02:16 Sorry for the drive-by, but I wanted to mention th
whunt 2012/12/14 18:17:01 I'm aware this isn't sufficient. I'm working on f
whunt 2012/12/14 18:17:01 The clipper wont work on rotations by 90 degrees s
for (size_t i = 0; i < layer->children().size(); ++i) {
LayerType* childLayer = layer->children()[i];
preCalculateMetaInformation<LayerType>(childLayer);
- numDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0;
- numDescendantsThatDrawContent += childLayer->drawProperties().num_descendants_that_draw_content;
+
+ int numChildDescendantsThatDrawContent = 0;
+ numChildDescendantsThatDrawContent += childLayer->drawsContent() ? 1 : 0;
shawnsingh 2012/12/14 07:34:44 I'm not sure about this rename, how about we omit
whunt 2012/12/14 18:17:01 I need the intermediate value. I didn't change yo
+ numChildDescendantsThatDrawContent += childLayer->drawProperties().num_descendants_that_draw_content;
+ numDescendantsThatDrawContent += numChildDescendantsThatDrawContent;
+
+ if (!childLayer->drawProperties().all_children_can_clip ||
+ numChildDescendantsThatDrawContent > 0 && (sublayerPreventsClip || !isPositiveScaleOrTranslation(childLayer->transform())))
+ allChildrenCanClip = false;
}
layer->drawProperties().num_descendants_that_draw_content = numDescendantsThatDrawContent;
+ layer->drawProperties().all_children_can_clip = allChildrenCanClip;
}
// Recursively walks the layer tree starting at the given node and computes all the
« cc/draw_properties.h ('K') | « cc/draw_properties.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698