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

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: re-adding a previously removed check of the transforms between a layer and its child 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/layer_impl.h ('K') | « cc/layer_impl.h ('k') | cc/texture_layer.h » ('j') | 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..af489b0c70b6fce775e24923afb4928b1da7de90 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) && !axisAlignedWithRespectToParent && !layer->drawProperties().can_clip_self)
return true;
// If the layer has some translucency and does not have a preserves-3d transform style.
@@ -429,21 +429,45 @@ static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList
layerToRemove->clearRenderSurface();
}
+inline bool isPositiveScaleOrTranslation(const gfx::Transform& xform)
shawnsingh 2012/12/14 23:59:11 Re: James' comment; I think a good place for this,
danakj 2012/12/15 00:02:17 nit: call the variable "transform"? we don't do th
+{
+ if (!xform.IsScaleOrTranslation())
+ return false;
+
+ // Grab our scale and make sure it's positive.
+ double x_scale = xform.matrix().getDouble(0, 0);
+ double y_scale = xform.matrix().getDouble(1, 1);
danakj 2012/12/15 00:02:17 What about z_scale?
+ if (x_scale <= 0.0 || y_scale <= 0.0)
+ 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 canClipSelf = true;
+ bool sublayerXformPreventsClip = !isPositiveScaleOrTranslation(layer->sublayerTransform());
danakj 2012/12/15 00:02:17 nit: "sublayerTransform..."
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;
+
+ if (childLayer->drawsContent() && !childLayer->CanClipSelf() ||
jamesr 2012/12/14 22:51:16 multiple invocations of && and || merit some group
+ !childLayer->drawProperties().can_clip_self ||
+ sublayerXformPreventsClip ||
+ !isPositiveScaleOrTranslation(childLayer->transform()))
+ canClipSelf = false;
jamesr 2012/12/14 22:51:16 i would probably use braces around this block sinc
shawnsingh 2012/12/14 23:59:11 looking at this if-statement, there is a triple-me
}
layer->drawProperties().num_descendants_that_draw_content = numDescendantsThatDrawContent;
+ layer->drawProperties().can_clip_self = canClipSelf;
}
// Recursively walks the layer tree starting at the given node and computes all the
« cc/layer_impl.h ('K') | « cc/layer_impl.h ('k') | cc/texture_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698