Title: [107921] trunk/Source/WebCore
- Revision
- 107921
- Author
- shawnsi...@chromium.org
- Date
- 2012-02-16 04:15:50 -0800 (Thu, 16 Feb 2012)
Log Message
[chromium] Refactor CCLayerTreeHostCommon: create helper function for complex boolean condition
https://bugs.webkit.org/show_bug.cgi?id=78539
Reviewed by James Robinson.
This change should introduce no change in behavior, and its
expected behavior is already covered by existing tests.
In calculateDrawTransformsAndVisibility, there is a complex
boolean condition that indicates whether we should create a
RenderSurface or not. This patch pulls out that boolean logic,
and wraps it in a helper function for much better readability.
* platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
(WebCore::layerShouldBeSkipped):
(WebCore):
(WebCore::subtreeShouldRenderToSeparateSurface):
(WebCore::calculateDrawTransformsAndVisibilityInternal):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (107920 => 107921)
--- trunk/Source/WebCore/ChangeLog 2012-02-16 12:11:33 UTC (rev 107920)
+++ trunk/Source/WebCore/ChangeLog 2012-02-16 12:15:50 UTC (rev 107921)
@@ -1,3 +1,24 @@
+2012-02-16 Shawn Singh <shawnsi...@chromium.org>
+
+ [chromium] Refactor CCLayerTreeHostCommon: create helper function for complex boolean condition
+ https://bugs.webkit.org/show_bug.cgi?id=78539
+
+ Reviewed by James Robinson.
+
+ This change should introduce no change in behavior, and its
+ expected behavior is already covered by existing tests.
+
+ In calculateDrawTransformsAndVisibility, there is a complex
+ boolean condition that indicates whether we should create a
+ RenderSurface or not. This patch pulls out that boolean logic,
+ and wraps it in a helper function for much better readability.
+
+ * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
+ (WebCore::layerShouldBeSkipped):
+ (WebCore):
+ (WebCore::subtreeShouldRenderToSeparateSurface):
+ (WebCore::calculateDrawTransformsAndVisibilityInternal):
+
2012-02-16 Andrey Kosyakov <ca...@chromium.org>
Web Inspector: [refactoring] move timeline overview sidebar creation to TimelineOverviewPane
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp (107920 => 107921)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp 2012-02-16 12:11:33 UTC (rev 107920)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp 2012-02-16 12:15:50 UTC (rev 107921)
@@ -72,7 +72,7 @@
}
template<typename LayerType>
-bool layerShouldBeSkipped(LayerType* layer)
+static bool layerShouldBeSkipped(LayerType* layer)
{
// Layers can be skipped if any of these conditions are met.
// - does not draw content.
@@ -104,6 +104,49 @@
return false;
}
+template<typename LayerType>
+static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlignedWithRespectToParent)
+{
+ // FIXME: If we decide to create a render surface here while this layer does
+ // preserve-3d, then we may be sorting incorrectly because we will not be
+ // sorting the individual layers of this subtree with other layers outside of
+ // this subtree.
+
+ // Cache this value, because otherwise it walks the entire subtree several times.
+ bool descendantDrawsContent = layer->descendantDrawsContent();
+
+ //
+ // A layer and its descendants should render onto a new RenderSurface if any of these rules hold:
+ //
+
+ // If the layer uses a mask.
+ if (layer->maskLayer())
+ return true;
+
+ // If the layer has a reflection.
+ if (layer->replicaLayer())
+ return true;
+
+ // If the layer uses a CSS filter.
+ if (layer->filters().size() > 0)
+ return true;
+
+ // 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 (layer->parent() && layer->parent()->preserves3D() && !layer->preserves3D() && descendantDrawsContent)
+ return true;
+
+ // If the layer clips its descendants but it is not axis-aligned with respect to its parent.
+ if (layer->masksToBounds() && !axisAlignedWithRespectToParent && descendantDrawsContent)
+ return true;
+
+ // If the layer has opacity != 1 and does not have a preserves-3d transform style.
+ if (layer->opacity() != 1 && !layer->preserves3D() && descendantDrawsContent)
+ return true;
+
+ return false;
+}
+
// Recursively walks the layer tree starting at the given node and computes all the
// necessary transformations, clipRects, render surfaces, etc.
template<typename LayerType, typename RenderSurfaceType, typename LayerSorter>
@@ -229,23 +272,7 @@
// FIXME: This seems like the wrong place to set this
layer->setUsesLayerClipping(false);
- // The layer and its descendants render on a new RenderSurface if any of
- // these conditions hold:
- // 1. The layer clips its descendants and its transform is not a simple translation.
- // 2. If the layer has opacity != 1 and does not have a preserves-3d transform style.
- // 3. The layer uses a mask
- // 4. The layer has a replica (used for reflections)
- // 5. The layer doesn't preserve-3d but is the child of a layer which does.
- // If a layer preserves-3d then we don't create a RenderSurface for it to avoid flattening
- // out its children. The opacity value of the children layers is multiplied by the opacity
- // of their parent.
- bool useSurfaceForClipping = layer->masksToBounds() && !isScaleOrTranslation(combinedTransform);
- bool useSurfaceForOpacity = layer->opacity() != 1 && !layer->preserves3D();
- bool useSurfaceForMasking = layer->maskLayer();
- bool useSurfaceForReflection = layer->replicaLayer();
- bool useSurfaceForFlatDescendants = layer->parent() && layer->parent()->preserves3D() && !layer->preserves3D() && layer->descendantDrawsContent();
- bool useSurfaceForFilters = layer->filters().size() > 0;
- if (useSurfaceForMasking || useSurfaceForReflection || useSurfaceForFlatDescendants || useSurfaceForFilters || ((useSurfaceForClipping || useSurfaceForOpacity) && layer->descendantDrawsContent())) {
+ if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combinedTransform))) {
if (!layer->renderSurface())
layer->createRenderSurface();
@@ -259,6 +286,7 @@
transformedLayerRect = IntRect(0, 0, bounds.width(), bounds.height());
+ // The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity.
renderSurface->setDrawOpacity(drawOpacity);
layer->setDrawOpacity(1);
@@ -382,7 +410,7 @@
}
}
- if (layer->masksToBounds() || useSurfaceForMasking) {
+ if (layer->masksToBounds() || layer->maskLayer()) {
IntRect drawableContentRect = layer->drawableContentRect();
drawableContentRect.intersect(transformedLayerRect);
layer->setDrawableContentRect(drawableContentRect);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes