Changeset 251706 in webkit
- Timestamp:
- Oct 29, 2019 9:14:58 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251698 r251706 1 2019-10-29 Antoine Quint <graouts@apple.com> 2 3 [Web Animations] Optimize blending for CSS Transitions 4 https://bugs.webkit.org/show_bug.cgi?id=203561 5 6 Reviewed by Simon Fraser. 7 8 The work performed in KeyframeEffect::setAnimatedPropertiesInStyle() has a level of complexity warranted by the 9 flexibility of how keyframes can be specified via the Web Animations JS API. However, in the case of CSS Transitions, 10 we already know that there are only two keyframes, one where offset=0 and one where offset=1, and that only a single 11 CSS property is specified so we can simplify the process greatly. 12 13 To ensure we only perform this quicker blending operation for keyframes computed for a CSS Transition and that no 14 modification to the keyframes have been applied via the Web Animations JS API after the fact, we now keep track 15 of whether the blending keyframes (KeyframeList) were generated for a CSS Transition or a CSS Animation and only 16 use this information to decide whether we're blending for declarative animations. 17 18 * animation/KeyframeEffect.cpp: 19 (WebCore::KeyframeEffect::processKeyframes): 20 (WebCore::KeyframeEffect::clearBlendingKeyframes): 21 (WebCore::KeyframeEffect::computeCSSAnimationBlendingKeyframes): 22 (WebCore::KeyframeEffect::computeCSSTransitionBlendingKeyframes): 23 (WebCore::KeyframeEffect::setTarget): 24 (WebCore::KeyframeEffect::setAnimatedPropertiesInStyle): 25 * animation/KeyframeEffect.h: 26 1 27 2019-10-29 Adrian Perez de Castro <aperez@igalia.com> 2 28 -
trunk/Source/WebCore/animation/KeyframeEffect.cpp
r251657 r251706 727 727 m_parsedKeyframes = WTFMove(parsedKeyframes); 728 728 729 m_blendingKeyframes.clear();729 clearBlendingKeyframes(); 730 730 731 731 return { }; … … 771 771 frameView->forceLayout(); 772 772 return true; 773 } 774 775 776 void KeyframeEffect::clearBlendingKeyframes() 777 { 778 m_blendingKeyframesSource = BlendingKeyframesSource::WebAnimation; 779 m_blendingKeyframes.clear(); 773 780 } 774 781 … … 910 917 } 911 918 919 m_blendingKeyframesSource = BlendingKeyframesSource::CSSAnimation; 912 920 setBlendingKeyframes(keyframeList); 913 921 } … … 937 945 keyframeList.insert(WTFMove(toKeyframeValue)); 938 946 947 m_blendingKeyframesSource = BlendingKeyframesSource::CSSTransition; 939 948 setBlendingKeyframes(keyframeList); 940 949 } … … 989 998 effectAnimation->effectTargetDidChange(previousTarget.get(), m_target.get()); 990 999 991 m_blendingKeyframes.clear();1000 clearBlendingKeyframes(); 992 1001 993 1002 // We need to invalidate the effect now that the target has changed … … 1055 1064 void KeyframeEffect::setAnimatedPropertiesInStyle(RenderStyle& targetStyle, double iterationProgress) 1056 1065 { 1066 // In the case of CSS Transitions we already know that there are only two keyframes, one where offset=0 and one where offset=1, 1067 // and only a single CSS property so we can simply blend based on the style available on those keyframes with the provided iteration 1068 // progress which already accounts for the transition's timing function. 1069 if (m_blendingKeyframesSource == BlendingKeyframesSource::CSSTransition) { 1070 ASSERT(is<CSSTransition>(animation())); 1071 CSSPropertyAnimation::blendProperties(this, downcast<CSSTransition>(animation())->property(), &targetStyle, m_blendingKeyframes[0].style(), m_blendingKeyframes[1].style(), iterationProgress); 1072 return; 1073 } 1074 1057 1075 // 4.4.3. The effect value of a keyframe effect 1058 1076 // https://drafts.csswg.org/web-animations-1/#the-effect-value-of-a-keyframe-animation-effect … … 1064 1082 if (m_blendingKeyframes.isEmpty()) 1065 1083 return; 1066 1067 bool isCSSAnimation = is<CSSAnimation>(animation());1068 bool isCSSTransition = is<CSSTransition>(animation());1069 1084 1070 1085 for (auto cssPropertyId : m_blendingKeyframes.properties()) { … … 1086 1101 // If we're dealing with a CSS animation, we consider the first and last keyframes to always have the property listed 1087 1102 // since the underlying style was provided and should be captured. 1088 if ( !isCSSAnimation || (offset && offset < 1))1103 if (m_blendingKeyframesSource == BlendingKeyframesSource::WebAnimation || (offset && offset < 1)) 1089 1104 continue; 1090 1105 } … … 1185 1200 // 17. Let transformed distance be the result of evaluating the timing function associated with the first keyframe in interval endpoints 1186 1201 // passing interval distance as the input progress. 1187 // We do not need to do this for CSS Transitions since the timing function is applied to the AnimationEffect as a whole and thus1188 // iterationProgress is already transformed.1189 1202 auto transformedDistance = intervalDistance; 1190 if ( !isCSSTransition &&startKeyframeIndex) {1203 if (startKeyframeIndex) { 1191 1204 if (auto duration = iterationDuration()) { 1192 1205 auto rangeDuration = (endOffset - startOffset) * duration.seconds(); -
trunk/Source/WebCore/animation/KeyframeEffect.h
r251425 r251706 142 142 143 143 enum class AcceleratedAction : uint8_t { Play, Pause, Seek, Stop }; 144 enum class BlendingKeyframesSource : uint8_t { CSSAnimation, CSSTransition, WebAnimation }; 144 145 145 146 void copyPropertiesFromSource(Ref<KeyframeEffect>&&); … … 152 153 void computedNeedsForcedLayout(); 153 154 void computeStackingContextImpact(); 155 void clearBlendingKeyframes(); 154 156 void updateBlendingKeyframes(RenderStyle&); 155 157 void computeCSSAnimationBlendingKeyframes(); … … 171 173 172 174 AcceleratedAction m_lastRecordedAcceleratedAction { AcceleratedAction::Stop }; 175 BlendingKeyframesSource m_blendingKeyframesSource { BlendingKeyframesSource::WebAnimation }; 173 176 IterationCompositeOperation m_iterationCompositeOperation { IterationCompositeOperation::Replace }; 174 177 CompositeOperation m_compositeOperation { CompositeOperation::Replace };
Note: See TracChangeset
for help on using the changeset viewer.