Commit 881881a5 authored by Majid Valipour's avatar Majid Valipour Committed by Commit Bot

Reland "[animation-worklet] Transfrom related worklet animations should respond to zoom"

This reverts commit 701add99.

Reason for revert:  The tests introduced in original CL was failing because it was not
being run with the right flags. This happened because CL landed at the same time
as another CL which migrated all the tests. Moving test and updating expectations
accordingly.

https://chromium-review.googlesource.com/c/chromium/src/+/1237235

Original change's description:
> Revert "[animation-worklet] Transfrom related worklet animations should respond to zoom"
>
> This reverts commit dec72e86.
>
> Reason for revert:
> virtual/threaded/fast/animationworklet/worklet-animation-responsive-to-zoom.html seems to be failing most of the time on all platforms.
>
> Sample failures:
> https://ci.chromium.org/p/chromium/builders/luci.chromium.try/win7_chromium_rel_ng/91172
> https://ci.chromium.org/p/chromium/builders/luci.chromium.try/mac_chromium_rel_ng/146546
> https://ci.chromium.org/p/chromium/builders/luci.chromium.try/linux_chromium_rel_ng/193114
>
> Original change's description:
> > [animation-worklet] Transfrom related worklet animations should respond to zoom
> >
> > Worklet animation compositing state should be updated when a zoom or viewport
> > resize changes css pixel to dip ratio.
> >
> > The fix is to simply match what we already do for regular animations for worklet
> > animations.
> >
> > TEST=virtual/threaded/fast/animationworklet/worklet-animation-responsive-to-zoom.html
> >
> > Bug: 879107
> > Change-Id: I0b74bd8297e83b18afd087247f09339aedcc618b
> > Reviewed-on: https://chromium-review.googlesource.com/1237133
> > Reviewed-by: Stephen McGruer <smcgruer@chromium.org>
> > Reviewed-by: Majid Valipour <majidvp@chromium.org>
> > Commit-Queue: Majid Valipour <majidvp@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#593171}
>
> TBR=majidvp@chromium.org,smcgruer@chromium.org
>
> Change-Id: I9eaf621c931ad9003fd7413aeea9f2ec3a7824a4
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 879107
> Reviewed-on: https://chromium-review.googlesource.com/1239773
> Reviewed-by: Matt Menke <mmenke@chromium.org>
> Commit-Queue: Matt Menke <mmenke@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#593414}

TBR=mmenke@chromium.org,majidvp@chromium.org,smcgruer@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 879107
Change-Id: Ib174c0e257c893d9cd5df3d1e6c5157b04603f44
Reviewed-on: https://chromium-review.googlesource.com/1243572Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Commit-Queue: Majid Valipour <majidvp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594454}
parent dcbbb2fd
......@@ -5224,6 +5224,7 @@ crbug.com/887659 animations/animationworklet/worklet-animation-local-time-undefi
crbug.com/887659 animations/animationworklet/worklet-animation-set-keyframes.html [ Crash ]
crbug.com/887659 animations/animationworklet/worklet-animation-set-timing.html [ Crash ]
crbug.com/887659 animations/animationworklet/worklet-animation-style-update.html [ Failure ]
crbug.com/887659 animations/animationworklet/worklet-animation-responsive-to-zoom.html [ Crash ]
# Sheriff 2018-09-24
crbug.com/888634 external/wpt/webrtc/RTCDTMFSender-ontonechange.https.html [ Failure ]
......
<!DOCTYPE html>
<style>
.box {
width: 100px;
height: 100px;
background-color: #00ff00;
transform: translateX(100px);
}
</style>
<div id="target" class="box"></div>
<script>
internals.setZoomFactor(2);
</script>
<!DOCTYPE html>
<style>
.box {
width: 100px;
height: 100px;
background-color: #00ff00;
}
</style>
<div id="target" class="box"></div>
<script id="visual_update" type="text/worklet">
registerAnimator("simple_animator", class {
animate(currentTime, effect) {
effect.localTime = 500;
}
});
</script>
<script src="resources/animation-worklet-tests.js"></script>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
runInAnimationWorklet(
document.getElementById('visual_update').textContent
).then(()=>{
const effect = new KeyframeEffect(
document.getElementById('target'),
[{ transform: 'translateX(0)' }, { transform: 'translateX(200px)'}],
{duration: 1000});
const animation = new WorkletAnimation('simple_animator', effect);
animation.play();
if (window.testRunner) {
waitTwoAnimationFrames(_ => {
internals.setZoomFactor(2);
waitTwoAnimationFrames(_ => {
testRunner.notifyDone();
});
});
}
});
</script>
......@@ -46,6 +46,7 @@
#include "third_party/blink/renderer/core/animation/keyframe_effect.h"
#include "third_party/blink/renderer/core/animation/keyframe_effect_model.h"
#include "third_party/blink/renderer/core/animation/transition_interpolation.h"
#include "third_party/blink/renderer/core/animation/worklet_animation_base.h"
#include "third_party/blink/renderer/core/css/css_keyframe_rule.h"
#include "third_party/blink/renderer/core/css/css_property_equality.h"
#include "third_party/blink/renderer/core/css/css_value_list.h"
......@@ -273,31 +274,40 @@ void CSSAnimations::CalculateCompositorAnimationUpdate(
bool transform_zoom_changed =
old_style->HasCurrentTransformAnimation() &&
old_style->EffectiveZoom() != style.EffectiveZoom();
for (auto& entry : element_animations->Animations()) {
Animation& animation = *entry.key;
const auto& snapshot = [&](AnimationEffect* effect) {
const KeyframeEffectModelBase* keyframe_effect =
GetKeyframeEffectModelBase(animation.effect());
GetKeyframeEffectModelBase(effect);
if (!keyframe_effect)
continue;
return false;
if ((transform_zoom_changed || was_viewport_resized) &&
(keyframe_effect->Affects(PropertyHandle(GetCSSPropertyTransform())) ||
keyframe_effect->Affects(PropertyHandle(GetCSSPropertyTranslate()))))
keyframe_effect->InvalidateCompositorKeyframesSnapshot();
bool update_compositor_keyframes = false;
if (keyframe_effect->SnapshotAllCompositorKeyframesIfNecessary(
element, style, parent_style)) {
update_compositor_keyframes = true;
return true;
} else if (keyframe_effect->HasSyntheticKeyframes() &&
keyframe_effect->SnapshotNeutralCompositorKeyframes(
element, *old_style, style, parent_style)) {
update_compositor_keyframes = true;
return true;
}
return false;
};
if (update_compositor_keyframes)
for (auto& entry : element_animations->Animations()) {
Animation& animation = *entry.key;
if (snapshot(animation.effect()))
update.UpdateCompositorKeyframes(&animation);
}
for (auto& entry : element_animations->GetWorkletAnimations()) {
WorkletAnimationBase& animation = *entry;
if (snapshot(animation.GetEffect()))
animation.InvalidateCompositingState();
}
}
void CSSAnimations::CalculateAnimationUpdate(CSSAnimationUpdate& update,
......
......@@ -26,6 +26,7 @@ class CORE_EXPORT WorkletAnimationBase : public ScriptWrappable {
// Updates the animation on the compositor side to reflect the main thread
// state.
virtual void UpdateCompositingState() = 0;
virtual void InvalidateCompositingState() = 0;
virtual Document* GetDocument() const = 0;
virtual KeyframeEffect* GetEffect() const = 0;
......
......@@ -372,8 +372,7 @@ void WorkletAnimation::UpdateIfNecessary() {
}
void WorkletAnimation::EffectInvalidated() {
effect_needs_restart_ = true;
document_->GetWorkletAnimationController().InvalidateAnimation(*this);
InvalidateCompositingState();
}
void WorkletAnimation::Update(TimingUpdateReason reason) {
......@@ -434,6 +433,11 @@ void WorkletAnimation::UpdateCompositingState() {
}
}
void WorkletAnimation::InvalidateCompositingState() {
effect_needs_restart_ = true;
document_->GetWorkletAnimationController().InvalidateAnimation(*this);
}
void WorkletAnimation::StartOnMain() {
running_on_main_thread_ = true;
SetStartTimeToNow();
......
......@@ -88,6 +88,7 @@ class MODULES_EXPORT WorkletAnimation : public WorkletAnimationBase,
// WorkletAnimationBase implementation.
void Update(TimingUpdateReason) override;
void UpdateCompositingState() override;
void InvalidateCompositingState() override;
// CompositorAnimationClient implementation.
CompositorAnimation* GetCompositorAnimation() const override {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment