https://bugs.webkit.org/show_bug.cgi?id=82370
Patch by Dana Jansens <danakj@chromium.org> on 2012-03-27
Reviewed by Adrienne Walker.
Source/WebCore:
On main thread, animating transforms have "unknown" values as they are changing
out of sync on the impl thread. So treat them as non-axis-aligned since they
may be, when deciding to create a render surface.
In addition, since surfaces are cheap on main thread, create one for all layers
with animating transforms and a drawing descendant, as this allows paint culling
within the layer's subtree (the animated transform won't affect drawTransforms
inside the subtree).
Also renamed the layerIsInAnimatingSubtreeFor* to animatingTransformTo*.
The old name made me pause and think what it meant and I'm the one who
created it. Hopefully this is more clear.
Unit test: CCLayerTreeHostCommonTest.verifyAnimationsForRenderSurfaceHierarchy
* platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
(WebCore::transformToParentIsKnown):
(WebCore):
(WebCore::subtreeShouldRenderToSeparateSurface):
(WebCore::calculateDrawTransformsAndVisibilityInternal):
Source/WebKit/chromium:
* tests/CCLayerTreeHostCommonTest.cpp:
(WebKitTests::TEST):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112332
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-03-27 Dana Jansens <danakj@chromium.org>
+
+ [chromium] Unknown transforms should be treated as non-axis aligned on main thread
+ https://bugs.webkit.org/show_bug.cgi?id=82370
+
+ Reviewed by Adrienne Walker.
+
+ On main thread, animating transforms have "unknown" values as they are changing
+ out of sync on the impl thread. So treat them as non-axis-aligned since they
+ may be, when deciding to create a render surface.
+
+ In addition, since surfaces are cheap on main thread, create one for all layers
+ with animating transforms and a drawing descendant, as this allows paint culling
+ within the layer's subtree (the animated transform won't affect drawTransforms
+ inside the subtree).
+
+ Also renamed the layerIsInAnimatingSubtreeFor* to animatingTransformTo*.
+ The old name made me pause and think what it meant and I'm the one who
+ created it. Hopefully this is more clear.
+
+ Unit test: CCLayerTreeHostCommonTest.verifyAnimationsForRenderSurfaceHierarchy
+
+ * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
+ (WebCore::transformToParentIsKnown):
+ (WebCore):
+ (WebCore::subtreeShouldRenderToSeparateSurface):
+ (WebCore::calculateDrawTransformsAndVisibilityInternal):
+
2012-03-27 Dirk Pranke <dpranke@chromium.org>
Re-land r112277; reverting it doesn't seem to have fixed anything.
return layer->opacity() == 1 && !layer->opacityIsAnimating();
}
+static inline bool transformToParentIsKnown(CCLayerImpl*)
+{
+ return true;
+}
+
+static inline bool transformToParentIsKnown(LayerChromium* layer)
+{
+ return !layer->transformIsAnimating();
+}
+
template<typename LayerType>
static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlignedWithRespectToParent)
{
if (layer->parent() && layer->parent()->preserves3D() && !layer->preserves3D() && descendantDrawsContent)
return true;
+ // On the main thread side, animating transforms are unknown, and may cause a RenderSurface on the impl side.
+ // Since they are cheap, we create a rendersurface for all animating transforms to cover these cases, and so
+ // that we can consider descendants as not animating relative to their target to aid culling.
+ if (!transformToParentIsKnown(layer) && 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;
TransformationMatrix combinedTransform = parentMatrix;
combinedTransform = combinedTransform.multiply(layerLocalTransform);
- bool layerIsInAnimatingSubtreeForSurface = layer->transformIsAnimating();
- bool layerIsInAnimatingSubtreeForScreen = layer->transformIsAnimating();
+ bool animatingTransformToTarget = layer->transformIsAnimating();
+ bool animatingTransformToScreen = animatingTransformToTarget;
if (layer->parent()) {
- layerIsInAnimatingSubtreeForSurface |= layer->parent()->drawTransformIsAnimating();
- layerIsInAnimatingSubtreeForScreen |= layer->parent()->screenSpaceTransformIsAnimating();
+ animatingTransformToTarget |= layer->parent()->drawTransformIsAnimating();
+ animatingTransformToScreen |= layer->parent()->screenSpaceTransformIsAnimating();
}
FloatRect layerRect(-0.5 * layer->bounds().width(), -0.5 * layer->bounds().height(), layer->bounds().width(), layer->bounds().height());
surfaceOriginTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0);
renderSurface->setOriginTransform(surfaceOriginTransform);
- renderSurface->setTargetSurfaceTransformsAreAnimating(layerIsInAnimatingSubtreeForSurface);
- renderSurface->setScreenSpaceTransformsAreAnimating(layerIsInAnimatingSubtreeForScreen);
- layerIsInAnimatingSubtreeForSurface = false;
- layer->setDrawTransformIsAnimating(layerIsInAnimatingSubtreeForSurface);
- layer->setScreenSpaceTransformIsAnimating(layerIsInAnimatingSubtreeForScreen);
+ renderSurface->setTargetSurfaceTransformsAreAnimating(animatingTransformToTarget);
+ renderSurface->setScreenSpaceTransformsAreAnimating(animatingTransformToScreen);
+ animatingTransformToTarget = false;
+ layer->setDrawTransformIsAnimating(animatingTransformToTarget);
+ layer->setScreenSpaceTransformIsAnimating(animatingTransformToScreen);
// Update the aggregate hierarchy matrix to include the transform of the newly created RenderSurface.
nextHierarchyMatrix.multiply(surfaceOriginTransform);
renderSurfaceLayerList.append(layer);
} else {
layer->setDrawTransform(combinedTransform);
- layer->setDrawTransformIsAnimating(layerIsInAnimatingSubtreeForSurface);
- layer->setScreenSpaceTransformIsAnimating(layerIsInAnimatingSubtreeForScreen);
+ layer->setDrawTransformIsAnimating(animatingTransformToTarget);
+ layer->setScreenSpaceTransformIsAnimating(animatingTransformToScreen);
transformedLayerRect = enclosingIntRect(layer->drawTransform().mapRect(layerRect));
layer->setDrawOpacity(drawOpacity);
2012-03-27 Dana Jansens <danakj@chromium.org>
+ [chromium] Unknown transforms should be treated as non-axis aligned on main thread
+ https://bugs.webkit.org/show_bug.cgi?id=82370
+
+ Reviewed by Adrienne Walker.
+
+ * tests/CCLayerTreeHostCommonTest.cpp:
+ (WebKitTests::TEST):
+
+2012-03-27 Dana Jansens <danakj@chromium.org>
+
[chromium] Rename opaqueContentsRegion() to visibleContentOpaqueRegion()
https://bugs.webkit.org/show_bug.cgi?id=81689
// In combination with descendantDrawsContent, opacity != 1 forces the layer to have a new renderSurface.
addOpacityTransitionToController(*renderSurface1->layerAnimationController(), 10, 1, 0, false);
- addOpacityTransitionToController(*renderSurface2->layerAnimationController(), 10, 1, 0, false);
- // Also put an animation on a layer without descendants.
+ // Also put an animated opacity on a layer without descendants.
addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController(), 10, 1, 0, false);
TransformationMatrix layerTransform;
TransformationMatrix sublayerTransform;
sublayerTransform.scale3d(10.0, 1.0, 1.0);
- // Put transform animations on child, renderSurface2, grandChildOfRoot, and grandChildOfRS2
- addAnimatedTransformToController(*childOfRoot->layerAnimationController(), 10, 30, 0);
- addAnimatedTransformToController(*grandChildOfRoot->layerAnimationController(), 10, 30, 0);
+ // In combination with descendantDrawsContent, an animated transform forces the layer to have a new renderSurface.
addAnimatedTransformToController(*renderSurface2->layerAnimationController(), 10, 30, 0);
+
+ // Also put transform animations on grandChildOfRoot, and grandChildOfRS2
+ addAnimatedTransformToController(*grandChildOfRoot->layerAnimationController(), 10, 30, 0);
addAnimatedTransformToController(*grandChildOfRS2->layerAnimationController(), 10, 30, 0);
setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, FloatPoint(0.25f, 0.0f), FloatPoint(2.5f, 0.0f), IntSize(10, 10), false);
EXPECT_FALSE(childOfRS1->drawOpacityIsAnimating());
EXPECT_FALSE(grandChildOfRS1->drawOpacityIsAnimating());
EXPECT_FALSE(renderSurface2->drawOpacityIsAnimating());
- EXPECT_TRUE(renderSurface2->renderSurface()->drawOpacityIsAnimating());
+ EXPECT_FALSE(renderSurface2->renderSurface()->drawOpacityIsAnimating());
EXPECT_FALSE(childOfRS2->drawOpacityIsAnimating());
EXPECT_FALSE(grandChildOfRS2->drawOpacityIsAnimating());
// Verify drawTransformsAnimatingInTarget values
//
EXPECT_FALSE(parent->drawTransformIsAnimating());
- EXPECT_TRUE(childOfRoot->drawTransformIsAnimating());
+ EXPECT_FALSE(childOfRoot->drawTransformIsAnimating());
EXPECT_TRUE(grandChildOfRoot->drawTransformIsAnimating());
EXPECT_FALSE(renderSurface1->drawTransformIsAnimating());
EXPECT_FALSE(renderSurface1->renderSurface()->targetSurfaceTransformsAreAnimating());
// Verify drawTransformsAnimatingInScreen values
//
EXPECT_FALSE(parent->screenSpaceTransformIsAnimating());
- EXPECT_TRUE(childOfRoot->screenSpaceTransformIsAnimating());
+ EXPECT_FALSE(childOfRoot->screenSpaceTransformIsAnimating());
EXPECT_TRUE(grandChildOfRoot->screenSpaceTransformIsAnimating());
EXPECT_FALSE(renderSurface1->screenSpaceTransformIsAnimating());
EXPECT_FALSE(renderSurface1->renderSurface()->screenSpaceTransformsAreAnimating());