Changeset 261756 in webkit
- Timestamp:
- May 15, 2020 1:07:26 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r261753 r261756 1 2020-05-15 Antoine Quint <graouts@apple.com> 2 3 [Web Animations] Animation with a single keyframe is not accelerated 4 https://bugs.webkit.org/show_bug.cgi?id=188730 5 <rdar://problem/43481113> 6 7 Reviewed by Dean Jackson. 8 9 Add a new test that runs a single-keyframe transform animation and checks that it runs accelerated. 10 11 * webanimations/accelerated-animation-single-keyframe-expected.txt: Added. 12 * webanimations/accelerated-animation-single-keyframe.html: Added. 13 1 14 2020-05-15 Eric Carlson <eric.carlson@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r261752 r261756 1 2020-05-15 Antoine Quint <graouts@apple.com> 2 3 [Web Animations] Animation with a single keyframe is not accelerated 4 https://bugs.webkit.org/show_bug.cgi?id=188730 5 <rdar://problem/43481113> 6 7 Reviewed by Dean Jackson. 8 9 Test: webanimations/accelerated-animation-single-keyframe.html 10 11 Prior to attempting to run an accelerated effect, ensure that the KeyframeList passed to 12 RenderLayerModelObject::startAnimation() does not have implicit keyframes since eventually 13 GraphicsLayerCA::animationCanBeAccelerated() would be called and would reject a single-keyframe 14 animation. To do this, we use the same code used in Style::Resolver::keyframeStylesForAnimation() 15 which we refactor in the new KeyframeList::fillImplicitKeyframes() method. 16 17 * animation/KeyframeEffect.cpp: 18 (WebCore::KeyframeEffect::copyPropertiesFromSource): 19 (WebCore::KeyframeEffect::applyPendingAcceleratedActions): 20 * rendering/style/KeyframeList.cpp: 21 (WebCore::KeyframeList::hasImplicitKeyframes const): 22 (WebCore::KeyframeList::copyKeyframes): 23 (WebCore::zeroPercentKeyframe): 24 (WebCore::hundredPercentKeyframe): 25 (WebCore::KeyframeList::fillImplicitKeyframes): 26 * rendering/style/KeyframeList.h: 27 * style/StyleResolver.cpp: 28 (WebCore::Style::Resolver::keyframeStylesForAnimation): 29 1 30 2020-05-15 Said Abou-Hallawa <sabouhallawa@apple.com> 2 31 -
trunk/Source/WebCore/animation/KeyframeEffect.cpp
r261637 r261756 566 566 567 567 KeyframeList keyframeList("keyframe-effect-" + createCanonicalUUIDString()); 568 for (auto& keyframe : source->m_blendingKeyframes.keyframes()) { 569 KeyframeValue keyframeValue(keyframe.key(), RenderStyle::clonePtr(*keyframe.style())); 570 for (auto propertyId : keyframe.properties()) 571 keyframeValue.addProperty(propertyId); 572 keyframeList.insert(WTFMove(keyframeValue)); 573 } 568 keyframeList.copyKeyframes(source->m_blendingKeyframes); 574 569 setBlendingKeyframes(keyframeList); 575 570 } … … 1579 1574 auto timeOffset = animation()->currentTime().valueOr(0_s).seconds() - delay().seconds(); 1580 1575 1576 auto startAnimation = [&]() -> bool { 1577 renderer->animationFinished(m_blendingKeyframes.animationName()); 1578 1579 if (!m_blendingKeyframes.hasImplicitKeyframes()) 1580 return renderer->startAnimation(timeOffset, backingAnimationForCompositedRenderer(), m_blendingKeyframes); 1581 1582 ASSERT(m_unanimatedStyle); 1583 ASSERT(m_target); 1584 KeyframeList explicitKeyframes(m_blendingKeyframes.animationName()); 1585 explicitKeyframes.copyKeyframes(m_blendingKeyframes); 1586 explicitKeyframes.fillImplicitKeyframes(*m_target, m_target->styleResolver(), m_unanimatedStyle.get()); 1587 return renderer->startAnimation(timeOffset, backingAnimationForCompositedRenderer(), explicitKeyframes); 1588 }; 1589 1581 1590 for (const auto& action : pendingAcceleratedActions) { 1582 1591 switch (action) { 1583 1592 case AcceleratedAction::Play: 1584 renderer->animationFinished(m_blendingKeyframes.animationName()); 1585 m_isRunningAccelerated = renderer->startAnimation(timeOffset, backingAnimationForCompositedRenderer(), m_blendingKeyframes); 1593 m_isRunningAccelerated = startAnimation(); 1586 1594 if (!m_isRunningAccelerated) { 1587 1595 m_lastRecordedAcceleratedAction = AcceleratedAction::Stop; … … 1593 1601 break; 1594 1602 case AcceleratedAction::UpdateTiming: 1595 renderer->animationFinished(m_blendingKeyframes.animationName()); 1596 renderer->startAnimation(timeOffset, backingAnimationForCompositedRenderer(), m_blendingKeyframes); 1603 startAnimation(); 1597 1604 if (animation()->playState() == WebAnimation::PlayState::Paused) 1598 1605 renderer->animationPaused(timeOffset, m_blendingKeyframes.animationName()); -
trunk/Source/WebCore/rendering/style/KeyframeList.cpp
r233666 r261756 24 24 25 25 #include "Animation.h" 26 #include "CSSKeyframeRule.h" 26 27 #include "RenderObject.h" 28 #include "StyleResolver.h" 27 29 28 30 namespace WebCore { … … 75 77 } 76 78 79 bool KeyframeList::hasImplicitKeyframes() const 80 { 81 return size() && (m_keyframes[0].key() || m_keyframes[size() - 1].key() != 1); 82 } 83 84 void KeyframeList::copyKeyframes(KeyframeList& other) 85 { 86 for (auto& keyframe : other.keyframes()) { 87 KeyframeValue keyframeValue(keyframe.key(), RenderStyle::clonePtr(*keyframe.style())); 88 for (auto propertyId : keyframe.properties()) 89 keyframeValue.addProperty(propertyId); 90 insert(WTFMove(keyframeValue)); 91 } 92 } 93 94 static const StyleRuleKeyframe& zeroPercentKeyframe() 95 { 96 static LazyNeverDestroyed<Ref<StyleRuleKeyframe>> rule; 97 static std::once_flag onceFlag; 98 std::call_once(onceFlag, [] { 99 rule.construct(StyleRuleKeyframe::create(MutableStyleProperties::create())); 100 rule.get()->setKey(0); 101 }); 102 return rule.get().get(); 103 } 104 105 static const StyleRuleKeyframe& hundredPercentKeyframe() 106 { 107 static LazyNeverDestroyed<Ref<StyleRuleKeyframe>> rule; 108 static std::once_flag onceFlag; 109 std::call_once(onceFlag, [] { 110 rule.construct(StyleRuleKeyframe::create(MutableStyleProperties::create())); 111 rule.get()->setKey(1); 112 }); 113 return rule.get().get(); 114 } 115 116 void KeyframeList::fillImplicitKeyframes(const Element& element, Style::Resolver& styleResolver, const RenderStyle* elementStyle) 117 { 118 // If the 0% keyframe is missing, create it (but only if there is at least one other keyframe). 119 auto initialSize = size(); 120 if (initialSize > 0 && m_keyframes[0].key()) { 121 KeyframeValue keyframeValue(0, nullptr); 122 keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, &zeroPercentKeyframe(), keyframeValue)); 123 insert(WTFMove(keyframeValue)); 124 } 125 126 // If the 100% keyframe is missing, create it (but only if there is at least one other keyframe). 127 if (initialSize > 0 && (m_keyframes[size() - 1].key() != 1)) { 128 KeyframeValue keyframeValue(1, nullptr); 129 keyframeValue.setStyle(styleResolver.styleForKeyframe(element, elementStyle, &hundredPercentKeyframe(), keyframeValue)); 130 insert(WTFMove(keyframeValue)); 131 } 132 } 133 77 134 } // namespace WebCore -
trunk/Source/WebCore/rendering/style/KeyframeList.h
r246490 r261756 35 35 class TimingFunction; 36 36 37 namespace Style { 38 class Resolver; 39 } 40 37 41 class KeyframeValue { 38 42 public: … … 55 59 TimingFunction* timingFunction() const { return m_timingFunction.get(); } 56 60 void setTimingFunction(const RefPtr<TimingFunction>& timingFunction) { m_timingFunction = timingFunction; } 57 61 58 62 private: 59 63 double m_key; … … 89 93 const Vector<KeyframeValue>& keyframes() const { return m_keyframes; } 90 94 95 void copyKeyframes(KeyframeList&); 96 bool hasImplicitKeyframes() const; 97 void fillImplicitKeyframes(const Element&, Style::Resolver&, const RenderStyle*); 98 91 99 private: 92 100 AtomString m_animationName; -
trunk/Source/WebCore/style/StyleResolver.cpp
r260951 r261756 360 360 } 361 361 362 // If the 0% keyframe is missing, create it (but only if there is at least one other keyframe). 363 int initialListSize = list.size(); 364 if (initialListSize > 0 && list[0].key()) { 365 static StyleRuleKeyframe* zeroPercentKeyframe; 366 if (!zeroPercentKeyframe) { 367 zeroPercentKeyframe = &StyleRuleKeyframe::create(MutableStyleProperties::create()).leakRef(); 368 zeroPercentKeyframe->setKey(0); 369 } 370 KeyframeValue keyframeValue(0, nullptr); 371 keyframeValue.setStyle(styleForKeyframe(element, elementStyle, zeroPercentKeyframe, keyframeValue)); 372 list.insert(WTFMove(keyframeValue)); 373 } 374 375 // If the 100% keyframe is missing, create it (but only if there is at least one other keyframe). 376 if (initialListSize > 0 && (list[list.size() - 1].key() != 1)) { 377 static StyleRuleKeyframe* hundredPercentKeyframe; 378 if (!hundredPercentKeyframe) { 379 hundredPercentKeyframe = &StyleRuleKeyframe::create(MutableStyleProperties::create()).leakRef(); 380 hundredPercentKeyframe->setKey(1); 381 } 382 KeyframeValue keyframeValue(1, nullptr); 383 keyframeValue.setStyle(styleForKeyframe(element, elementStyle, hundredPercentKeyframe, keyframeValue)); 384 list.insert(WTFMove(keyframeValue)); 385 } 362 list.fillImplicitKeyframes(element, *this, elementStyle); 386 363 } 387 364
Note: See TracChangeset
for help on using the changeset viewer.