haikuwebkit/LayoutTests/webanimations/accelerated-translate-anima...

43 lines
1.1 KiB
HTML
Raw Permalink Normal View History

Support accelerated animation of individual transform CSS properties https://bugs.webkit.org/show_bug.cgi?id=217842 <rdar://problem/70391914> Reviewed by Dean Jackson. LayoutTests/imported/w3c: * web-platform-tests/css/css-transforms/animation/rotate-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/scale-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/translate-interpolation-expected.txt: Source/WebCore: In order to support accelerated animation of individual transform CSS properties, we make a list of the various animations targeting animation-related properties in GraphicsLayerCA::updateAnimations() and apply an animation for each of those properties in their expected application order – translate, scale, rotate and then transform – using Core Animation's additive animation mode. When one of those properties does not have an animation, we create a non-interpolating base transform value animation set with both from and to values matching the value set in CSS for this particular property. We use a new transformMatrixForProperty() method on the GraphicsLayerClient to obtain this value. We also add a non-additive, non-interpolating identity transform first to make sure all the additive animations build on top of a neutral transform and not the underlying value applied to the layer. Finally, when GraphicsLayerCA::setTransform() is updated, we update the animations to ensure that any base transform value animation is updated to match the current value of the CSS properties contributing to the compound layer transform. Tests: webanimations/accelerated-transform-related-animation-property-order.html webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html webanimations/accelerated-translate-animation-with-transform.html webanimations/accelerated-translate-animation.html * animation/CSSPropertyAnimation.cpp: Add the necessary animationIsAccelerated() overrides for each of the individual CSS transform property animation wrappers to indicate that accelerated animations are supported. * platform/graphics/GraphicsLayer.cpp: (WebCore::GraphicsLayer::validateTransformOperations): Update the ASSERT to check that the animated property is any of the transform-related properties. * platform/graphics/GraphicsLayer.h: (WebCore::TransformAnimationValue::TransformAnimationValue): Add a new constructor that takes a single TransformOperation* value as input instead of a TransformOperations& so that the values coming from the individual CSS transform properties can be used to create a TransformAnimationValue in RenderLayerBacking::startAnimation(). * platform/graphics/GraphicsLayerClient.h: Add the new animated property identifiers for the individual CSS transform properties. (WebCore::animatedPropertyIsTransformOrRelated): Add a new utility to identify any of the transform-related animated property identifiers. (WebCore::GraphicsLayerClient::transformMatrixForProperty const): New method called from GraphicsLayerCA::updateAnimations() to query the client, such as RenderLayerBacking, for the TransformationMatrix representing a given CSS property value to be used for base transform value non-interpolating animations. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::propertyIdToString): Account for the new animated property identifiers. (WebCore::GraphicsLayerCA::setTransform): If we are currently running a transform-related animation, a change in underlying transform value means we must re-evaluate all transform-related animations to ensure that the base value transform animations are current. (WebCore::GraphicsLayerCA::moveOrCopyAnimations): (WebCore::GraphicsLayerCA::addAnimation): (WebCore::GraphicsLayerCA::updateAnimations): When updating animations, keep track of the most recent animation applicable to each individual CSS transform property and the list of animations targeting the transform CSS property. Then, ensure those animations are applied in the specified order – translate, scale, rotate and transform – by adding those animations as additive CA animations with non-interpolating base transform value animations for each property that does not have a specified interpolating animation. (WebCore::GraphicsLayerCA::isRunningTransformAnimation const): Ensure we also consider paused animations as "running" animations. (WebCore::GraphicsLayerCA::appendToUncommittedAnimations): Whether a transform animation needs to be run using the additive mode is now determined in updateAnimations() so we remove all code related to working out whether animations ought to be additive. (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes): We force the creation of CATransform3D values for individual CSS transform properties since only this mode guarantees that additivity of such animations will yield the expected result where the transforms are multiplied rather than simply adding float values of individual components. * platform/graphics/ca/GraphicsLayerCA.h: * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::startAnimation): Ensure we start animations for the individual CSS transform properties. (WebCore::RenderLayerBacking::graphicsLayerToCSSProperty): (WebCore::RenderLayerBacking::cssToGraphicsLayerProperty): (WebCore::RenderLayerBacking::transformMatrixForProperty const): Implement the new GraphicsLayerClient method to provide a matrix that can be used as a value for non-interpolating base value transform animations in GraphicsLayerCA::updateAnimations() for any of the transform-related CSS properties. * rendering/RenderLayerBacking.h: * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): Ensure that an animation for any of the transform-related CSS properties yields composition of the target layer. (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): * rendering/style/WillChangeData.cpp: (WebCore::propertyTriggersCompositingOnBoxesOnly): Ensure that setting the will-change CSS property to any of the transform-related CSS properties yields composition of the target. LayoutTests: Add some new tests that check animations of individual CSS transform properties can be performed, checking on their relative order with the transform property, updating the transform property while an animation is in flight and adding animations while in flight. * TestExpectations: * webanimations/accelerated-transform-related-animation-property-order-expected.html: Added. * webanimations/accelerated-transform-related-animation-property-order.html: Added. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight-expected.html: Added. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html: Added. * webanimations/accelerated-translate-animation-expected.html: Added. * webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight-expected.html: Added. * webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html: Added. * webanimations/accelerated-translate-animation-with-transform-expected.html: Added. * webanimations/accelerated-translate-animation-with-transform.html: Added. * webanimations/accelerated-translate-animation.html: Added. Canonical link: https://commits.webkit.org/230577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268615 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-16 22:43:54 +00:00
<style>
#target {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
background-color: black;
}
</style>
<div id="target"></div>
<script src="../resources/ui-helper.js"></script>
<script>
(async () => {
if (window.testRunner)
testRunner.waitUntilDone();
// Start an animation that lasts a day.
const duration = 24 * 60 * 60 * 1000;
REGRESSION(r268615): certain animations break when moving from one to display to another or resizing the window https://bugs.webkit.org/show_bug.cgi?id=218080 <rdar://problem/70547132> Reviewed by Dean Jackson. Source/WebCore: Since transform-related animations include non-interpolating animations meant to insert the static base value for a given transform-related CSS property, we need to update animations on GraphicsLayerCA whenever one of the transform-related CSS properties have a new value. We used to rely on GraphicsLayerCA::setTransform() being called with a different transform than the current one to identify such cases, but that is suboptimal because that method can be called with a compound interpolated value of transform-related CSS properties when a rendering update occurs, such as during resizing or moving a window between displays. In those cases, the static base value of the transform-related CSS properties hasn't actually changed. Instead, we now provide the non-animated style from the last style change event to the function resolving keyframe effects so that for a given element we can compare that style with the new, as-yet-non-animated style and see if any of the transform- related CSS properties have been changed. If that is the case, we inform any KeyframeEffect that has a running accelerated animation for any of those CSS properties so that the effect may enqueue an accelerated action that will then notify the GraphicsLayer of such a change, and trigger an animation update. Since we were changing the applyKeyframeEffects() method signature to add the extra RenderStyle needed to compare the current and previous non-animated styles, we also moved that method from Element to KeyframeEffectStack since no Element private API was required. No new test since this was already tested by webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html and it's not clear how to test the live-resizing or display-change scenario. * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::isRunningAcceleratedTransformRelatedAnimation const): New method called from KeyframeEffectStack::applyKeyframeEffects() to indicate that a keyframe effect has a running accelerated animation targeting a transform-related property. (WebCore::KeyframeEffect::addPendingAcceleratedAction): Ensure that the new AcceleratedAction::TransformChange accelerated action recorded in transformRelatedPropertyDidChange() is not ever set as m_lastRecordedAcceleratedAction as we use this member to identify whether we have a pending running, pause or stop action. (WebCore::KeyframeEffect::transformRelatedPropertyDidChange): New method meant to be called for an effect that has a running accelerated animation targeting a transform-related property to notify that one or more of the target element's transform-related CSS property static values was changed. (WebCore::KeyframeEffect::applyPendingAcceleratedActions): Call transformRelatedPropertyDidChange() on the composited renderer for a AcceleratedAction::TransformChange action. * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: (WebCore::KeyframeEffectStack::applyKeyframeEffects): Move the method previously exposed on Element to KeyframeEffectStack. Additionally, accept an extra RenderStyle parameter to provide the non-animated style from the last style change event so that we can compare that style with the new, as-yet-non-animated style and see if any of the transform-related CSS properties have been changed and notify the effect should it run an accelerated animation for one of those properties. * animation/KeyframeEffectStack.h: * dom/Element.cpp: (WebCore::Element::applyKeyframeEffects): Deleted. Moved to KeyframeEffectStack. * dom/Element.h: * platform/graphics/GraphicsLayer.h: (WebCore::GraphicsLayer::transformRelatedPropertyDidChange): * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::setTransform): Move the animation-update logic to transformRelatedPropertyDidChange() (WebCore::GraphicsLayerCA::transformRelatedPropertyDidChange): * platform/graphics/ca/GraphicsLayerCA.h: * rendering/RenderElement.h: (WebCore::RenderElement::transformRelatedPropertyDidChange): * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::transformRelatedPropertyDidChange): * rendering/RenderLayerBacking.h: * rendering/RenderLayerModelObject.cpp: (WebCore::RenderLayerModelObject::transformRelatedPropertyDidChange): * rendering/RenderLayerModelObject.h: * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): Pass the non-animated style from the last style change event to KeyframeEffectStack::applyKeyframeEffects() to determine whether this style change event includes a change to any of the transform-related properties. * style/Styleable.h: (WebCore::Styleable::applyKeyframeEffects const): LayoutTests: Increase the fidelity of this test where the scale transform would sometimes yield some 0.01% ImageOnlyFailure results. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight-expected.html: * webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html: Canonical link: https://commits.webkit.org/230838@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268932 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-23 18:35:44 +00:00
const translateAnimation = document.getElementById("target").animate({ translate: "100px" }, duration);
Support accelerated animation of individual transform CSS properties https://bugs.webkit.org/show_bug.cgi?id=217842 <rdar://problem/70391914> Reviewed by Dean Jackson. LayoutTests/imported/w3c: * web-platform-tests/css/css-transforms/animation/rotate-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/scale-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/translate-interpolation-expected.txt: Source/WebCore: In order to support accelerated animation of individual transform CSS properties, we make a list of the various animations targeting animation-related properties in GraphicsLayerCA::updateAnimations() and apply an animation for each of those properties in their expected application order – translate, scale, rotate and then transform – using Core Animation's additive animation mode. When one of those properties does not have an animation, we create a non-interpolating base transform value animation set with both from and to values matching the value set in CSS for this particular property. We use a new transformMatrixForProperty() method on the GraphicsLayerClient to obtain this value. We also add a non-additive, non-interpolating identity transform first to make sure all the additive animations build on top of a neutral transform and not the underlying value applied to the layer. Finally, when GraphicsLayerCA::setTransform() is updated, we update the animations to ensure that any base transform value animation is updated to match the current value of the CSS properties contributing to the compound layer transform. Tests: webanimations/accelerated-transform-related-animation-property-order.html webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html webanimations/accelerated-translate-animation-with-transform.html webanimations/accelerated-translate-animation.html * animation/CSSPropertyAnimation.cpp: Add the necessary animationIsAccelerated() overrides for each of the individual CSS transform property animation wrappers to indicate that accelerated animations are supported. * platform/graphics/GraphicsLayer.cpp: (WebCore::GraphicsLayer::validateTransformOperations): Update the ASSERT to check that the animated property is any of the transform-related properties. * platform/graphics/GraphicsLayer.h: (WebCore::TransformAnimationValue::TransformAnimationValue): Add a new constructor that takes a single TransformOperation* value as input instead of a TransformOperations& so that the values coming from the individual CSS transform properties can be used to create a TransformAnimationValue in RenderLayerBacking::startAnimation(). * platform/graphics/GraphicsLayerClient.h: Add the new animated property identifiers for the individual CSS transform properties. (WebCore::animatedPropertyIsTransformOrRelated): Add a new utility to identify any of the transform-related animated property identifiers. (WebCore::GraphicsLayerClient::transformMatrixForProperty const): New method called from GraphicsLayerCA::updateAnimations() to query the client, such as RenderLayerBacking, for the TransformationMatrix representing a given CSS property value to be used for base transform value non-interpolating animations. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::propertyIdToString): Account for the new animated property identifiers. (WebCore::GraphicsLayerCA::setTransform): If we are currently running a transform-related animation, a change in underlying transform value means we must re-evaluate all transform-related animations to ensure that the base value transform animations are current. (WebCore::GraphicsLayerCA::moveOrCopyAnimations): (WebCore::GraphicsLayerCA::addAnimation): (WebCore::GraphicsLayerCA::updateAnimations): When updating animations, keep track of the most recent animation applicable to each individual CSS transform property and the list of animations targeting the transform CSS property. Then, ensure those animations are applied in the specified order – translate, scale, rotate and transform – by adding those animations as additive CA animations with non-interpolating base transform value animations for each property that does not have a specified interpolating animation. (WebCore::GraphicsLayerCA::isRunningTransformAnimation const): Ensure we also consider paused animations as "running" animations. (WebCore::GraphicsLayerCA::appendToUncommittedAnimations): Whether a transform animation needs to be run using the additive mode is now determined in updateAnimations() so we remove all code related to working out whether animations ought to be additive. (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes): We force the creation of CATransform3D values for individual CSS transform properties since only this mode guarantees that additivity of such animations will yield the expected result where the transforms are multiplied rather than simply adding float values of individual components. * platform/graphics/ca/GraphicsLayerCA.h: * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::startAnimation): Ensure we start animations for the individual CSS transform properties. (WebCore::RenderLayerBacking::graphicsLayerToCSSProperty): (WebCore::RenderLayerBacking::cssToGraphicsLayerProperty): (WebCore::RenderLayerBacking::transformMatrixForProperty const): Implement the new GraphicsLayerClient method to provide a matrix that can be used as a value for non-interpolating base value transform animations in GraphicsLayerCA::updateAnimations() for any of the transform-related CSS properties. * rendering/RenderLayerBacking.h: * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): Ensure that an animation for any of the transform-related CSS properties yields composition of the target layer. (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): * rendering/style/WillChangeData.cpp: (WebCore::propertyTriggersCompositingOnBoxesOnly): Ensure that setting the will-change CSS property to any of the transform-related CSS properties yields composition of the target. LayoutTests: Add some new tests that check animations of individual CSS transform properties can be performed, checking on their relative order with the transform property, updating the transform property while an animation is in flight and adding animations while in flight. * TestExpectations: * webanimations/accelerated-transform-related-animation-property-order-expected.html: Added. * webanimations/accelerated-transform-related-animation-property-order.html: Added. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight-expected.html: Added. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html: Added. * webanimations/accelerated-translate-animation-expected.html: Added. * webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight-expected.html: Added. * webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html: Added. * webanimations/accelerated-translate-animation-with-transform-expected.html: Added. * webanimations/accelerated-translate-animation-with-transform.html: Added. * webanimations/accelerated-translate-animation.html: Added. Canonical link: https://commits.webkit.org/230577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268615 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-16 22:43:54 +00:00
translateAnimation.currentTime = duration / 2;
// Wait until the animation has been applied.
await translateAnimation.ready;
await UIHelper.ensureStablePresentationUpdate();
// Add an extra animation.
REGRESSION(r268615): certain animations break when moving from one to display to another or resizing the window https://bugs.webkit.org/show_bug.cgi?id=218080 <rdar://problem/70547132> Reviewed by Dean Jackson. Source/WebCore: Since transform-related animations include non-interpolating animations meant to insert the static base value for a given transform-related CSS property, we need to update animations on GraphicsLayerCA whenever one of the transform-related CSS properties have a new value. We used to rely on GraphicsLayerCA::setTransform() being called with a different transform than the current one to identify such cases, but that is suboptimal because that method can be called with a compound interpolated value of transform-related CSS properties when a rendering update occurs, such as during resizing or moving a window between displays. In those cases, the static base value of the transform-related CSS properties hasn't actually changed. Instead, we now provide the non-animated style from the last style change event to the function resolving keyframe effects so that for a given element we can compare that style with the new, as-yet-non-animated style and see if any of the transform- related CSS properties have been changed. If that is the case, we inform any KeyframeEffect that has a running accelerated animation for any of those CSS properties so that the effect may enqueue an accelerated action that will then notify the GraphicsLayer of such a change, and trigger an animation update. Since we were changing the applyKeyframeEffects() method signature to add the extra RenderStyle needed to compare the current and previous non-animated styles, we also moved that method from Element to KeyframeEffectStack since no Element private API was required. No new test since this was already tested by webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html and it's not clear how to test the live-resizing or display-change scenario. * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::isRunningAcceleratedTransformRelatedAnimation const): New method called from KeyframeEffectStack::applyKeyframeEffects() to indicate that a keyframe effect has a running accelerated animation targeting a transform-related property. (WebCore::KeyframeEffect::addPendingAcceleratedAction): Ensure that the new AcceleratedAction::TransformChange accelerated action recorded in transformRelatedPropertyDidChange() is not ever set as m_lastRecordedAcceleratedAction as we use this member to identify whether we have a pending running, pause or stop action. (WebCore::KeyframeEffect::transformRelatedPropertyDidChange): New method meant to be called for an effect that has a running accelerated animation targeting a transform-related property to notify that one or more of the target element's transform-related CSS property static values was changed. (WebCore::KeyframeEffect::applyPendingAcceleratedActions): Call transformRelatedPropertyDidChange() on the composited renderer for a AcceleratedAction::TransformChange action. * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: (WebCore::KeyframeEffectStack::applyKeyframeEffects): Move the method previously exposed on Element to KeyframeEffectStack. Additionally, accept an extra RenderStyle parameter to provide the non-animated style from the last style change event so that we can compare that style with the new, as-yet-non-animated style and see if any of the transform-related CSS properties have been changed and notify the effect should it run an accelerated animation for one of those properties. * animation/KeyframeEffectStack.h: * dom/Element.cpp: (WebCore::Element::applyKeyframeEffects): Deleted. Moved to KeyframeEffectStack. * dom/Element.h: * platform/graphics/GraphicsLayer.h: (WebCore::GraphicsLayer::transformRelatedPropertyDidChange): * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::setTransform): Move the animation-update logic to transformRelatedPropertyDidChange() (WebCore::GraphicsLayerCA::transformRelatedPropertyDidChange): * platform/graphics/ca/GraphicsLayerCA.h: * rendering/RenderElement.h: (WebCore::RenderElement::transformRelatedPropertyDidChange): * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::transformRelatedPropertyDidChange): * rendering/RenderLayerBacking.h: * rendering/RenderLayerModelObject.cpp: (WebCore::RenderLayerModelObject::transformRelatedPropertyDidChange): * rendering/RenderLayerModelObject.h: * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): Pass the non-animated style from the last style change event to KeyframeEffectStack::applyKeyframeEffects() to determine whether this style change event includes a change to any of the transform-related properties. * style/Styleable.h: (WebCore::Styleable::applyKeyframeEffects const): LayoutTests: Increase the fidelity of this test where the scale transform would sometimes yield some 0.01% ImageOnlyFailure results. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight-expected.html: * webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html: Canonical link: https://commits.webkit.org/230838@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268932 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-23 18:35:44 +00:00
const transformAnimation = document.getElementById("target").animate({ transform: "translateY(100px)" }, duration);
transformAnimation.currentTime = duration / 2;
Support accelerated animation of individual transform CSS properties https://bugs.webkit.org/show_bug.cgi?id=217842 <rdar://problem/70391914> Reviewed by Dean Jackson. LayoutTests/imported/w3c: * web-platform-tests/css/css-transforms/animation/rotate-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/scale-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/translate-interpolation-expected.txt: Source/WebCore: In order to support accelerated animation of individual transform CSS properties, we make a list of the various animations targeting animation-related properties in GraphicsLayerCA::updateAnimations() and apply an animation for each of those properties in their expected application order – translate, scale, rotate and then transform – using Core Animation's additive animation mode. When one of those properties does not have an animation, we create a non-interpolating base transform value animation set with both from and to values matching the value set in CSS for this particular property. We use a new transformMatrixForProperty() method on the GraphicsLayerClient to obtain this value. We also add a non-additive, non-interpolating identity transform first to make sure all the additive animations build on top of a neutral transform and not the underlying value applied to the layer. Finally, when GraphicsLayerCA::setTransform() is updated, we update the animations to ensure that any base transform value animation is updated to match the current value of the CSS properties contributing to the compound layer transform. Tests: webanimations/accelerated-transform-related-animation-property-order.html webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html webanimations/accelerated-translate-animation-with-transform.html webanimations/accelerated-translate-animation.html * animation/CSSPropertyAnimation.cpp: Add the necessary animationIsAccelerated() overrides for each of the individual CSS transform property animation wrappers to indicate that accelerated animations are supported. * platform/graphics/GraphicsLayer.cpp: (WebCore::GraphicsLayer::validateTransformOperations): Update the ASSERT to check that the animated property is any of the transform-related properties. * platform/graphics/GraphicsLayer.h: (WebCore::TransformAnimationValue::TransformAnimationValue): Add a new constructor that takes a single TransformOperation* value as input instead of a TransformOperations& so that the values coming from the individual CSS transform properties can be used to create a TransformAnimationValue in RenderLayerBacking::startAnimation(). * platform/graphics/GraphicsLayerClient.h: Add the new animated property identifiers for the individual CSS transform properties. (WebCore::animatedPropertyIsTransformOrRelated): Add a new utility to identify any of the transform-related animated property identifiers. (WebCore::GraphicsLayerClient::transformMatrixForProperty const): New method called from GraphicsLayerCA::updateAnimations() to query the client, such as RenderLayerBacking, for the TransformationMatrix representing a given CSS property value to be used for base transform value non-interpolating animations. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::propertyIdToString): Account for the new animated property identifiers. (WebCore::GraphicsLayerCA::setTransform): If we are currently running a transform-related animation, a change in underlying transform value means we must re-evaluate all transform-related animations to ensure that the base value transform animations are current. (WebCore::GraphicsLayerCA::moveOrCopyAnimations): (WebCore::GraphicsLayerCA::addAnimation): (WebCore::GraphicsLayerCA::updateAnimations): When updating animations, keep track of the most recent animation applicable to each individual CSS transform property and the list of animations targeting the transform CSS property. Then, ensure those animations are applied in the specified order – translate, scale, rotate and transform – by adding those animations as additive CA animations with non-interpolating base transform value animations for each property that does not have a specified interpolating animation. (WebCore::GraphicsLayerCA::isRunningTransformAnimation const): Ensure we also consider paused animations as "running" animations. (WebCore::GraphicsLayerCA::appendToUncommittedAnimations): Whether a transform animation needs to be run using the additive mode is now determined in updateAnimations() so we remove all code related to working out whether animations ought to be additive. (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes): We force the creation of CATransform3D values for individual CSS transform properties since only this mode guarantees that additivity of such animations will yield the expected result where the transforms are multiplied rather than simply adding float values of individual components. * platform/graphics/ca/GraphicsLayerCA.h: * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::startAnimation): Ensure we start animations for the individual CSS transform properties. (WebCore::RenderLayerBacking::graphicsLayerToCSSProperty): (WebCore::RenderLayerBacking::cssToGraphicsLayerProperty): (WebCore::RenderLayerBacking::transformMatrixForProperty const): Implement the new GraphicsLayerClient method to provide a matrix that can be used as a value for non-interpolating base value transform animations in GraphicsLayerCA::updateAnimations() for any of the transform-related CSS properties. * rendering/RenderLayerBacking.h: * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): Ensure that an animation for any of the transform-related CSS properties yields composition of the target layer. (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): * rendering/style/WillChangeData.cpp: (WebCore::propertyTriggersCompositingOnBoxesOnly): Ensure that setting the will-change CSS property to any of the transform-related CSS properties yields composition of the target. LayoutTests: Add some new tests that check animations of individual CSS transform properties can be performed, checking on their relative order with the transform property, updating the transform property while an animation is in flight and adding animations while in flight. * TestExpectations: * webanimations/accelerated-transform-related-animation-property-order-expected.html: Added. * webanimations/accelerated-transform-related-animation-property-order.html: Added. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight-expected.html: Added. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html: Added. * webanimations/accelerated-translate-animation-expected.html: Added. * webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight-expected.html: Added. * webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html: Added. * webanimations/accelerated-translate-animation-with-transform-expected.html: Added. * webanimations/accelerated-translate-animation-with-transform.html: Added. * webanimations/accelerated-translate-animation.html: Added. Canonical link: https://commits.webkit.org/230577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268615 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-16 22:43:54 +00:00
// Wait until the new animation has been applied.
REGRESSION(r268615): certain animations break when moving from one to display to another or resizing the window https://bugs.webkit.org/show_bug.cgi?id=218080 <rdar://problem/70547132> Reviewed by Dean Jackson. Source/WebCore: Since transform-related animations include non-interpolating animations meant to insert the static base value for a given transform-related CSS property, we need to update animations on GraphicsLayerCA whenever one of the transform-related CSS properties have a new value. We used to rely on GraphicsLayerCA::setTransform() being called with a different transform than the current one to identify such cases, but that is suboptimal because that method can be called with a compound interpolated value of transform-related CSS properties when a rendering update occurs, such as during resizing or moving a window between displays. In those cases, the static base value of the transform-related CSS properties hasn't actually changed. Instead, we now provide the non-animated style from the last style change event to the function resolving keyframe effects so that for a given element we can compare that style with the new, as-yet-non-animated style and see if any of the transform- related CSS properties have been changed. If that is the case, we inform any KeyframeEffect that has a running accelerated animation for any of those CSS properties so that the effect may enqueue an accelerated action that will then notify the GraphicsLayer of such a change, and trigger an animation update. Since we were changing the applyKeyframeEffects() method signature to add the extra RenderStyle needed to compare the current and previous non-animated styles, we also moved that method from Element to KeyframeEffectStack since no Element private API was required. No new test since this was already tested by webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html and it's not clear how to test the live-resizing or display-change scenario. * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::isRunningAcceleratedTransformRelatedAnimation const): New method called from KeyframeEffectStack::applyKeyframeEffects() to indicate that a keyframe effect has a running accelerated animation targeting a transform-related property. (WebCore::KeyframeEffect::addPendingAcceleratedAction): Ensure that the new AcceleratedAction::TransformChange accelerated action recorded in transformRelatedPropertyDidChange() is not ever set as m_lastRecordedAcceleratedAction as we use this member to identify whether we have a pending running, pause or stop action. (WebCore::KeyframeEffect::transformRelatedPropertyDidChange): New method meant to be called for an effect that has a running accelerated animation targeting a transform-related property to notify that one or more of the target element's transform-related CSS property static values was changed. (WebCore::KeyframeEffect::applyPendingAcceleratedActions): Call transformRelatedPropertyDidChange() on the composited renderer for a AcceleratedAction::TransformChange action. * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: (WebCore::KeyframeEffectStack::applyKeyframeEffects): Move the method previously exposed on Element to KeyframeEffectStack. Additionally, accept an extra RenderStyle parameter to provide the non-animated style from the last style change event so that we can compare that style with the new, as-yet-non-animated style and see if any of the transform-related CSS properties have been changed and notify the effect should it run an accelerated animation for one of those properties. * animation/KeyframeEffectStack.h: * dom/Element.cpp: (WebCore::Element::applyKeyframeEffects): Deleted. Moved to KeyframeEffectStack. * dom/Element.h: * platform/graphics/GraphicsLayer.h: (WebCore::GraphicsLayer::transformRelatedPropertyDidChange): * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::setTransform): Move the animation-update logic to transformRelatedPropertyDidChange() (WebCore::GraphicsLayerCA::transformRelatedPropertyDidChange): * platform/graphics/ca/GraphicsLayerCA.h: * rendering/RenderElement.h: (WebCore::RenderElement::transformRelatedPropertyDidChange): * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::transformRelatedPropertyDidChange): * rendering/RenderLayerBacking.h: * rendering/RenderLayerModelObject.cpp: (WebCore::RenderLayerModelObject::transformRelatedPropertyDidChange): * rendering/RenderLayerModelObject.h: * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): Pass the non-animated style from the last style change event to KeyframeEffectStack::applyKeyframeEffects() to determine whether this style change event includes a change to any of the transform-related properties. * style/Styleable.h: (WebCore::Styleable::applyKeyframeEffects const): LayoutTests: Increase the fidelity of this test where the scale transform would sometimes yield some 0.01% ImageOnlyFailure results. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight-expected.html: * webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html: Canonical link: https://commits.webkit.org/230838@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268932 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-23 18:35:44 +00:00
await transformAnimation.ready;
Support accelerated animation of individual transform CSS properties https://bugs.webkit.org/show_bug.cgi?id=217842 <rdar://problem/70391914> Reviewed by Dean Jackson. LayoutTests/imported/w3c: * web-platform-tests/css/css-transforms/animation/rotate-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/scale-interpolation-expected.txt: * web-platform-tests/css/css-transforms/animation/translate-interpolation-expected.txt: Source/WebCore: In order to support accelerated animation of individual transform CSS properties, we make a list of the various animations targeting animation-related properties in GraphicsLayerCA::updateAnimations() and apply an animation for each of those properties in their expected application order – translate, scale, rotate and then transform – using Core Animation's additive animation mode. When one of those properties does not have an animation, we create a non-interpolating base transform value animation set with both from and to values matching the value set in CSS for this particular property. We use a new transformMatrixForProperty() method on the GraphicsLayerClient to obtain this value. We also add a non-additive, non-interpolating identity transform first to make sure all the additive animations build on top of a neutral transform and not the underlying value applied to the layer. Finally, when GraphicsLayerCA::setTransform() is updated, we update the animations to ensure that any base transform value animation is updated to match the current value of the CSS properties contributing to the compound layer transform. Tests: webanimations/accelerated-transform-related-animation-property-order.html webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html webanimations/accelerated-translate-animation-with-transform.html webanimations/accelerated-translate-animation.html * animation/CSSPropertyAnimation.cpp: Add the necessary animationIsAccelerated() overrides for each of the individual CSS transform property animation wrappers to indicate that accelerated animations are supported. * platform/graphics/GraphicsLayer.cpp: (WebCore::GraphicsLayer::validateTransformOperations): Update the ASSERT to check that the animated property is any of the transform-related properties. * platform/graphics/GraphicsLayer.h: (WebCore::TransformAnimationValue::TransformAnimationValue): Add a new constructor that takes a single TransformOperation* value as input instead of a TransformOperations& so that the values coming from the individual CSS transform properties can be used to create a TransformAnimationValue in RenderLayerBacking::startAnimation(). * platform/graphics/GraphicsLayerClient.h: Add the new animated property identifiers for the individual CSS transform properties. (WebCore::animatedPropertyIsTransformOrRelated): Add a new utility to identify any of the transform-related animated property identifiers. (WebCore::GraphicsLayerClient::transformMatrixForProperty const): New method called from GraphicsLayerCA::updateAnimations() to query the client, such as RenderLayerBacking, for the TransformationMatrix representing a given CSS property value to be used for base transform value non-interpolating animations. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::propertyIdToString): Account for the new animated property identifiers. (WebCore::GraphicsLayerCA::setTransform): If we are currently running a transform-related animation, a change in underlying transform value means we must re-evaluate all transform-related animations to ensure that the base value transform animations are current. (WebCore::GraphicsLayerCA::moveOrCopyAnimations): (WebCore::GraphicsLayerCA::addAnimation): (WebCore::GraphicsLayerCA::updateAnimations): When updating animations, keep track of the most recent animation applicable to each individual CSS transform property and the list of animations targeting the transform CSS property. Then, ensure those animations are applied in the specified order – translate, scale, rotate and transform – by adding those animations as additive CA animations with non-interpolating base transform value animations for each property that does not have a specified interpolating animation. (WebCore::GraphicsLayerCA::isRunningTransformAnimation const): Ensure we also consider paused animations as "running" animations. (WebCore::GraphicsLayerCA::appendToUncommittedAnimations): Whether a transform animation needs to be run using the additive mode is now determined in updateAnimations() so we remove all code related to working out whether animations ought to be additive. (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes): We force the creation of CATransform3D values for individual CSS transform properties since only this mode guarantees that additivity of such animations will yield the expected result where the transforms are multiplied rather than simply adding float values of individual components. * platform/graphics/ca/GraphicsLayerCA.h: * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::startAnimation): Ensure we start animations for the individual CSS transform properties. (WebCore::RenderLayerBacking::graphicsLayerToCSSProperty): (WebCore::RenderLayerBacking::cssToGraphicsLayerProperty): (WebCore::RenderLayerBacking::transformMatrixForProperty const): Implement the new GraphicsLayerClient method to provide a matrix that can be used as a value for non-interpolating base value transform animations in GraphicsLayerCA::updateAnimations() for any of the transform-related CSS properties. * rendering/RenderLayerBacking.h: * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): Ensure that an animation for any of the transform-related CSS properties yields composition of the target layer. (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): * rendering/style/WillChangeData.cpp: (WebCore::propertyTriggersCompositingOnBoxesOnly): Ensure that setting the will-change CSS property to any of the transform-related CSS properties yields composition of the target. LayoutTests: Add some new tests that check animations of individual CSS transform properties can be performed, checking on their relative order with the transform property, updating the transform property while an animation is in flight and adding animations while in flight. * TestExpectations: * webanimations/accelerated-transform-related-animation-property-order-expected.html: Added. * webanimations/accelerated-transform-related-animation-property-order.html: Added. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight-expected.html: Added. * webanimations/accelerated-translate-animation-additional-animation-added-in-flight.html: Added. * webanimations/accelerated-translate-animation-expected.html: Added. * webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight-expected.html: Added. * webanimations/accelerated-translate-animation-underlying-transform-changed-in-flight.html: Added. * webanimations/accelerated-translate-animation-with-transform-expected.html: Added. * webanimations/accelerated-translate-animation-with-transform.html: Added. * webanimations/accelerated-translate-animation.html: Added. Canonical link: https://commits.webkit.org/230577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268615 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-16 22:43:54 +00:00
await UIHelper.ensureStablePresentationUpdate();
if (window.testRunner)
testRunner.notifyDone();
})();
</script>