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 |