Title: [284600] trunk/Source/WebCore
Revision
284600
Author
grao...@webkit.org
Date
2021-10-21 04:51:12 -0700 (Thu, 21 Oct 2021)

Log Message

Pass CompositeOperation to CSSPropertyAnimation::blendProperties and through more blending functions
https://bugs.webkit.org/show_bug.cgi?id=232069

Reviewed by Antti Koivisto.

In preparation for support of CompositeOperation when blending, we need to pass it down from blendProperties()
to other blending functions. Currently we only ever pass Replace so there is no change in behavior.

* animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyBlendingContext::CSSPropertyBlendingContext):
(WebCore::AnimationPropertyWrapperBase::canInterpolate const):
(WebCore::CSSPropertyAnimation::blendProperties):
(WebCore::CSSPropertyAnimation::canPropertyBeInterpolated):
* animation/CSSPropertyAnimation.h:
* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::setAnimatedPropertiesInStyle):
* platform/LengthSize.h:
(WebCore::blend):
* platform/animation/AnimationUtilities.h:
(WebCore::BlendingContext::BlendingContext):
* platform/graphics/transforms/AffineTransform.cpp:
(WebCore::AffineTransform::blend):
* platform/graphics/transforms/AffineTransform.h:
* platform/graphics/transforms/RotateTransformOperation.cpp:
(WebCore::RotateTransformOperation::blend):
* platform/graphics/transforms/TransformOperation.h:
* platform/graphics/transforms/TransformationMatrix.cpp:
(WebCore::blendFloat):
(WebCore::TransformationMatrix::blend2):
(WebCore::TransformationMatrix::blend4):
(WebCore::TransformationMatrix::blend):
* platform/graphics/transforms/TransformationMatrix.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (284599 => 284600)


--- trunk/Source/WebCore/ChangeLog	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/ChangeLog	2021-10-21 11:51:12 UTC (rev 284600)
@@ -1,3 +1,38 @@
+2021-10-21  Antoine Quint  <grao...@webkit.org>
+
+        Pass CompositeOperation to CSSPropertyAnimation::blendProperties and through more blending functions
+        https://bugs.webkit.org/show_bug.cgi?id=232069
+
+        Reviewed by Antti Koivisto.
+
+        In preparation for support of CompositeOperation when blending, we need to pass it down from blendProperties()
+        to other blending functions. Currently we only ever pass Replace so there is no change in behavior.
+
+        * animation/CSSPropertyAnimation.cpp:
+        (WebCore::CSSPropertyBlendingContext::CSSPropertyBlendingContext):
+        (WebCore::AnimationPropertyWrapperBase::canInterpolate const):
+        (WebCore::CSSPropertyAnimation::blendProperties):
+        (WebCore::CSSPropertyAnimation::canPropertyBeInterpolated):
+        * animation/CSSPropertyAnimation.h:
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::setAnimatedPropertiesInStyle):
+        * platform/LengthSize.h:
+        (WebCore::blend):
+        * platform/animation/AnimationUtilities.h:
+        (WebCore::BlendingContext::BlendingContext):
+        * platform/graphics/transforms/AffineTransform.cpp:
+        (WebCore::AffineTransform::blend):
+        * platform/graphics/transforms/AffineTransform.h:
+        * platform/graphics/transforms/RotateTransformOperation.cpp:
+        (WebCore::RotateTransformOperation::blend):
+        * platform/graphics/transforms/TransformOperation.h:
+        * platform/graphics/transforms/TransformationMatrix.cpp:
+        (WebCore::blendFloat):
+        (WebCore::TransformationMatrix::blend2):
+        (WebCore::TransformationMatrix::blend4):
+        (WebCore::TransformationMatrix::blend):
+        * platform/graphics/transforms/TransformationMatrix.h:
+
 2021-10-21  Chris Lord  <cl...@igalia.com>
 
         [GTK] Slow scrolling (not matching GTK native scroll amount)

Modified: trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp (284599 => 284600)


--- trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2021-10-21 11:51:12 UTC (rev 284600)
@@ -43,6 +43,7 @@
 #include "CalculationValue.h"
 #include "ClipPathOperation.h"
 #include "ColorBlending.h"
+#include "CompositeOperation.h"
 #include "FloatConversion.h"
 #include "FontCascade.h"
 #include "FontSelectionAlgorithm.h"
@@ -75,8 +76,8 @@
 struct CSSPropertyBlendingContext : BlendingContext {
     const CSSPropertyBlendingClient* client { nullptr };
 
-    CSSPropertyBlendingContext(double progress, bool isDiscrete, const CSSPropertyBlendingClient* client)
-        : BlendingContext(progress, isDiscrete)
+    CSSPropertyBlendingContext(double progress, bool isDiscrete, CompositeOperation compositeOperation, const CSSPropertyBlendingClient* client)
+        : BlendingContext(progress, isDiscrete, compositeOperation)
         , client(client)
     {
     }
@@ -592,7 +593,7 @@
 
     virtual bool isShorthandWrapper() const { return false; }
     virtual bool equals(const RenderStyle&, const RenderStyle&) const = 0;
-    virtual bool canInterpolate(const RenderStyle&, const RenderStyle&) const { return true; }
+    virtual bool canInterpolate(const RenderStyle&, const RenderStyle&, CompositeOperation) const { return true; }
     virtual void blend(RenderStyle&, const RenderStyle&, const RenderStyle&, const CSSPropertyBlendingContext&) const = 0;
     
 #if !LOG_DISABLED
@@ -693,7 +694,7 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle&, const RenderStyle&) const final { return false; }
+    bool canInterpolate(const RenderStyle&, const RenderStyle&, CompositeOperation) const final { return false; }
 
     void (RenderStyle::*m_setter)(T);
 };
@@ -705,7 +706,7 @@
     GridTemplateTracksWrapper();
 
 private:
-    bool canInterpolate(const RenderStyle&, const RenderStyle&) const final { return false; }
+    bool canInterpolate(const RenderStyle&, const RenderStyle&, CompositeOperation) const final { return false; }
 
     bool equals(const RenderStyle& a, const RenderStyle& b) const override
     {
@@ -777,7 +778,7 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle&, const RenderStyle&) const final { return false; }
+    bool canInterpolate(const RenderStyle&, const RenderStyle&, CompositeOperation) const final { return false; }
 
     bool equals(const RenderStyle& a, const RenderStyle& b) const override
     {
@@ -854,7 +855,7 @@
     }
 
 protected:
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const override
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const override
     {
         return canInterpolateLengths(value(from), value(to), m_flags.contains(Flags::IsLengthPercentage));
     }
@@ -916,7 +917,7 @@
 private:
     // Check if it's possible to interpolate between the from and to values. In particular,
     // it's only possible if they're both not auto.
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const override 
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         bool fromIsAuto = value(from).x().isAuto() && value(from).y().isAuto();
         bool toIsAuto = value(to).x().isAuto() && value(to).y().isAuto();
@@ -936,7 +937,7 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         return canInterpolateLengthVariants(this->value(from), this->value(to));
     }
@@ -964,7 +965,7 @@
     {
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const override
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const override
     {
         if (m_flags.contains(Flags::UsesFillKeyword) && from.borderImage().fill() != to.borderImage().fill())
             return false;
@@ -1006,9 +1007,9 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation compositeOperation) const final
     {
-        return from.hasClip() && to.hasClip() && LengthBoxPropertyWrapper::canInterpolate(from, to);
+        return from.hasClip() && to.hasClip() && LengthBoxPropertyWrapper::canInterpolate(from, to, compositeOperation);
     }
 
     void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final
@@ -1061,7 +1062,7 @@
         return value(a) == value(b);
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         auto fromVariationSettings = value(from);
         auto toVariationSettings = value(to);
@@ -1104,7 +1105,7 @@
         return *shapeA == *shapeB;
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         auto* fromShape = value(from);
         auto* toShape = value(to);
@@ -1141,7 +1142,7 @@
         return arePointingToEqualData(imageA, imageB);
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         return value(from) && value(to);
     }
@@ -1264,7 +1265,7 @@
         return true;
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         const ShadowData* fromShadow = (from.*m_getter)();
         const ShadowData* toShadow = (to.*m_getter)();
@@ -1497,7 +1498,7 @@
             && PropertyWrapperMaybeInvalidColor::equals(a, b);
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         return !from.hasAutoAccentColor() && !to.hasAutoAccentColor();
     }
@@ -1504,7 +1505,7 @@
 
     void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final
     {
-        if (canInterpolate(from, to)) {
+        if (canInterpolate(from, to, context.compositeOperation)) {
             PropertyWrapperMaybeInvalidColor::blend(destination, from, to, context);
             return;
         }
@@ -1541,7 +1542,7 @@
             && PropertyWrapperVisitedAffectedColor::equals(a, b);
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         return canInterpolateCaretColor(from, to, false) || canInterpolateCaretColor(from, to, true);
     }
@@ -1843,7 +1844,7 @@
         return true;
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         auto* fromLayer = &(from.*m_layersGetter)();
         auto* toLayer = &(to.*m_layersGetter)();
@@ -1958,7 +1959,7 @@
         return a.flexBasis() == b.flexBasis() && a.flexGrow() == b.flexGrow() && a.flexShrink() == b.flexShrink();
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         return from.flexGrow() != to.flexGrow() && from.flexShrink() != to.flexShrink() && canInterpolateLengths(from.flexBasis(), to.flexBasis(), false);
     }
@@ -2060,7 +2061,7 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         return from.fontItalic() && to.fontItalic() && from.fontDescription().fontStyleAxis() == FontStyleAxis::slnt && to.fontDescription().fontStyleAxis() == FontStyleAxis::slnt;
     }
@@ -2099,7 +2100,7 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         return !(from.*m_autoGetter)() && !(to.*m_autoGetter)();
     }
@@ -2154,9 +2155,9 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation compositeOperation) const final
     {
-        return from.verticalAlign() == VerticalAlign::Length && to.verticalAlign() == VerticalAlign::Length && LengthPropertyWrapper::canInterpolate(from, to);
+        return from.verticalAlign() == VerticalAlign::Length && to.verticalAlign() == VerticalAlign::Length && LengthPropertyWrapper::canInterpolate(from, to, compositeOperation);
     }
 
     void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final
@@ -2176,13 +2177,13 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation compositeOperation) const final
     {
         if (from.textIndentLine() != to.textIndentLine())
             return false;
         if (from.textIndentType() != to.textIndentType())
             return false;
-        return LengthPropertyWrapper::canInterpolate(from, to);
+        return LengthPropertyWrapper::canInterpolate(from, to, compositeOperation);
     }
 
     void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final
@@ -2203,11 +2204,11 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation compositeOperation) const final
     {
         if (!from.hasPerspective() || !to.hasPerspective())
             return false;
-        return NonNegativeFloatPropertyWrapper::canInterpolate(from, to);
+        return NonNegativeFloatPropertyWrapper::canInterpolate(from, to, compositeOperation);
     }
 
     void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final
@@ -2228,7 +2229,7 @@
     }
 
 private:
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         return value(from).isSpaces() == value(to).isSpaces();
     }
@@ -2258,7 +2259,7 @@
         return a.aspectRatioType() == b.aspectRatioType() && a.aspectRatioWidth() == b.aspectRatioWidth() && a.aspectRatioHeight() == b.aspectRatioHeight();
     }
 
-    bool canInterpolate(const RenderStyle& from, const RenderStyle& to) const final
+    bool canInterpolate(const RenderStyle& from, const RenderStyle& to, CompositeOperation) const final
     {
         return (from.aspectRatioType() == AspectRatioType::Ratio && to.aspectRatioType() == AspectRatioType::Ratio) || (from.aspectRatioType() == AspectRatioType::AutoAndRatio && to.aspectRatioType() == AspectRatioType::AutoAndRatio);
     }
@@ -2700,7 +2701,7 @@
     return contained;
 }
 
-void CSSPropertyAnimation::blendProperties(const CSSPropertyBlendingClient* client, CSSPropertyID property, RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, double progress)
+void CSSPropertyAnimation::blendProperties(const CSSPropertyBlendingClient* client, CSSPropertyID property, RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, double progress, CompositeOperation compositeOperation)
 {
     ASSERT(property != CSSPropertyInvalid);
 
@@ -2709,10 +2710,13 @@
         // https://drafts.csswg.org/web-animations-1/#discrete
         // The property's values cannot be meaningfully combined, thus it is not additive and
         // interpolation swaps from Va to Vb at 50% (p=0.5).
-        auto isDiscrete = !wrapper->canInterpolate(from, to);
-        if (isDiscrete)
+        auto isDiscrete = !wrapper->canInterpolate(from, to, compositeOperation);
+        if (isDiscrete) {
+            // If we want additive, we should specify progress at 0 actually and return from.
             progress = progress < 0.5 ? 0 : 1;
-        wrapper->blend(destination, from, to, { progress, isDiscrete, client });
+            compositeOperation = CompositeOperation::Replace;
+        }
+        wrapper->blend(destination, from, to, { progress, isDiscrete, compositeOperation, client });
 #if !LOG_DISABLED
         wrapper->logBlend(from, to, destination, progress);
 #endif
@@ -2754,7 +2758,7 @@
 {
     AnimationPropertyWrapperBase* wrapper = CSSPropertyAnimationWrapperMap::singleton().wrapperForProperty(property);
     if (wrapper)
-        return wrapper->canInterpolate(from, to);
+        return wrapper->canInterpolate(from, to, CompositeOperation::Replace);
     return false;
 }
 

Modified: trunk/Source/WebCore/animation/CSSPropertyAnimation.h (284599 => 284600)


--- trunk/Source/WebCore/animation/CSSPropertyAnimation.h	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/animation/CSSPropertyAnimation.h	2021-10-21 11:51:12 UTC (rev 284600)
@@ -47,7 +47,7 @@
 
     static HashSet<CSSPropertyID> animatableShorthandsAffectingProperty(CSSPropertyID);
 
-    static void blendProperties(const CSSPropertyBlendingClient*, CSSPropertyID, RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, double progress);
+    static void blendProperties(const CSSPropertyBlendingClient*, CSSPropertyID, RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, double progress, CompositeOperation);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (284599 => 284600)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2021-10-21 11:51:12 UTC (rev 284600)
@@ -1423,7 +1423,7 @@
     // progress which already accounts for the transition's timing function.
     if (m_blendingKeyframesSource == BlendingKeyframesSource::CSSTransition) {
         ASSERT(properties.size() == 1);
-        CSSPropertyAnimation::blendProperties(this, *properties.begin(), targetStyle, *m_blendingKeyframes[0].style(), *m_blendingKeyframes[1].style(), iterationProgress);
+        CSSPropertyAnimation::blendProperties(this, *properties.begin(), targetStyle, *m_blendingKeyframes[0].style(), *m_blendingKeyframes[1].style(), iterationProgress, CompositeOperation::Replace);
         return;
     }
 
@@ -1537,7 +1537,7 @@
         if (intervalEndpoints.size() == 1) {
             auto keyframeIndex = intervalEndpoints[0];
             auto keyframeStyle = !keyframeIndex ? &targetStyle : m_blendingKeyframes[keyframeIndex.value()].style();
-            CSSPropertyAnimation::blendProperties(this, cssPropertyId, targetStyle, *keyframeStyle, *keyframeStyle, 0);
+            CSSPropertyAnimation::blendProperties(this, cssPropertyId, targetStyle, *keyframeStyle, *keyframeStyle, 0, CompositeOperation::Replace);
             continue;
         }
 
@@ -1568,7 +1568,7 @@
         //     distance as the interpolation parameter p.
         auto startStyle = !startKeyframeIndex ? &targetStyle : m_blendingKeyframes[startKeyframeIndex.value()].style();
         auto endStyle = !endKeyframeIndex ? &targetStyle : m_blendingKeyframes[endKeyframeIndex.value()].style();
-        CSSPropertyAnimation::blendProperties(this, cssPropertyId, targetStyle, *startStyle, *endStyle, transformedDistance);
+        CSSPropertyAnimation::blendProperties(this, cssPropertyId, targetStyle, *startStyle, *endStyle, transformedDistance, CompositeOperation::Replace);
     }
 }
 

Modified: trunk/Source/WebCore/platform/LengthSize.h (284599 => 284600)


--- trunk/Source/WebCore/platform/LengthSize.h	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/platform/LengthSize.h	2021-10-21 11:51:12 UTC (rev 284600)
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include "CompositeOperation.h"
 #include "Length.h"
 
 namespace WebCore {
@@ -43,6 +44,11 @@
     return { blend(from.width, to.width, context), blend(from.height, to.height, context) };
 }
 
+inline LengthSize blend(const LengthSize& from, const LengthSize& to, const BlendingContext& context, ValueRange valueRange)
+{
+    return { blend(from.width, to.width, context, valueRange), blend(from.height, to.height, context, valueRange) };
+}
+
 WTF::TextStream& operator<<(WTF::TextStream&, const LengthSize&);
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/animation/AnimationUtilities.h (284599 => 284600)


--- trunk/Source/WebCore/platform/animation/AnimationUtilities.h	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/platform/animation/AnimationUtilities.h	2021-10-21 11:51:12 UTC (rev 284600)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "CompositeOperation.h"
 #include "IntPoint.h"
 #include "LayoutPoint.h"
 
@@ -33,10 +34,12 @@
 struct BlendingContext {
     double progress { 0 };
     bool isDiscrete { false };
+    CompositeOperation compositeOperation { CompositeOperation::Replace };
 
-    BlendingContext(double progress = 0, bool isDiscrete = false)
+    BlendingContext(double progress = 0, bool isDiscrete = false, CompositeOperation compositeOperation = CompositeOperation::Replace)
         : progress(progress)
         , isDiscrete(isDiscrete)
+        , compositeOperation(compositeOperation)
     {
     }
 };

Modified: trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp (284599 => 284600)


--- trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp	2021-10-21 11:51:12 UTC (rev 284600)
@@ -349,7 +349,7 @@
     return mappedRegion;
 }
 
-void AffineTransform::blend(const AffineTransform& from, double progress)
+void AffineTransform::blend(const AffineTransform& from, double progress, CompositeOperation)
 {
     DecomposedType srA, srB;
 

Modified: trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.h (284599 => 284600)


--- trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.h	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.h	2021-10-21 11:51:12 UTC (rev 284600)
@@ -26,6 +26,7 @@
 
 #pragma once
 
+#include "CompositeOperation.h"
 #include <array>
 #include <optional>
 #include <wtf/FastMalloc.h>
@@ -134,7 +135,7 @@
     bool isInvertible() const; // If you call this this, you're probably doing it wrong.
     WEBCORE_EXPORT std::optional<AffineTransform> inverse() const;
 
-    WEBCORE_EXPORT void blend(const AffineTransform& from, double progress);
+    WEBCORE_EXPORT void blend(const AffineTransform& from, double progress, CompositeOperation = CompositeOperation::Replace);
 
     WEBCORE_EXPORT TransformationMatrix toTransformationMatrix() const;
 

Modified: trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp (284599 => 284600)


--- trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp	2021-10-21 11:51:12 UTC (rev 284600)
@@ -87,7 +87,7 @@
         (toOp ? toOp->m_angle : 0));
     
     // Blend them
-    toT.blend(fromT, context.progress);
+    toT.blend(fromT, context.progress, context.compositeOperation);
     
     // Extract the result as a quaternion
     TransformationMatrix::Decomposed4Type decomp;

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h (284599 => 284600)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h	2021-10-21 11:51:12 UTC (rev 284600)
@@ -24,6 +24,7 @@
 
 #pragma once
 
+#include "CompositeOperation.h"
 #include "FloatSize.h"
 #include "TransformationMatrix.h"
 #include <wtf/Forward.h>

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp (284599 => 284600)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp	2021-10-21 11:51:12 UTC (rev 284600)
@@ -1635,13 +1635,13 @@
                            m_matrix[1][1], m_matrix[3][0], m_matrix[3][1]);
 }
 
-static inline void blendFloat(double& from, double to, double progress)
+static inline void blendFloat(double& from, double to, double progress, CompositeOperation)
 {
     if (from != to)
         from = from + (to - from) * progress;
 }
 
-void TransformationMatrix::blend2(const TransformationMatrix& from, double progress)
+void TransformationMatrix::blend2(const TransformationMatrix& from, double progress, CompositeOperation compositeOperation)
 {
     Decomposed2Type fromDecomp;
     Decomposed2Type toDecomp;
@@ -1671,20 +1671,20 @@
             toDecomp.angle -= 360;
     }
 
-    blendFloat(fromDecomp.m11, toDecomp.m11, progress);
-    blendFloat(fromDecomp.m12, toDecomp.m12, progress);
-    blendFloat(fromDecomp.m21, toDecomp.m21, progress);
-    blendFloat(fromDecomp.m22, toDecomp.m22, progress);
-    blendFloat(fromDecomp.translateX, toDecomp.translateX, progress);
-    blendFloat(fromDecomp.translateY, toDecomp.translateY, progress);
-    blendFloat(fromDecomp.scaleX, toDecomp.scaleX, progress);
-    blendFloat(fromDecomp.scaleY, toDecomp.scaleY, progress);
-    blendFloat(fromDecomp.angle, toDecomp.angle, progress);
+    blendFloat(fromDecomp.m11, toDecomp.m11, progress, compositeOperation);
+    blendFloat(fromDecomp.m12, toDecomp.m12, progress, compositeOperation);
+    blendFloat(fromDecomp.m21, toDecomp.m21, progress, compositeOperation);
+    blendFloat(fromDecomp.m22, toDecomp.m22, progress, compositeOperation);
+    blendFloat(fromDecomp.translateX, toDecomp.translateX, progress, compositeOperation);
+    blendFloat(fromDecomp.translateY, toDecomp.translateY, progress, compositeOperation);
+    blendFloat(fromDecomp.scaleX, toDecomp.scaleX, progress, compositeOperation);
+    blendFloat(fromDecomp.scaleY, toDecomp.scaleY, progress, compositeOperation);
+    blendFloat(fromDecomp.angle, toDecomp.angle, progress, compositeOperation);
 
     recompose2(fromDecomp);
 }
 
-void TransformationMatrix::blend4(const TransformationMatrix& from, double progress)
+void TransformationMatrix::blend4(const TransformationMatrix& from, double progress, CompositeOperation compositeOperation)
 {
     Decomposed4Type fromDecomp;
     Decomposed4Type toDecomp;
@@ -1694,19 +1694,19 @@
         return;
     }
 
-    blendFloat(fromDecomp.scaleX, toDecomp.scaleX, progress);
-    blendFloat(fromDecomp.scaleY, toDecomp.scaleY, progress);
-    blendFloat(fromDecomp.scaleZ, toDecomp.scaleZ, progress);
-    blendFloat(fromDecomp.skewXY, toDecomp.skewXY, progress);
-    blendFloat(fromDecomp.skewXZ, toDecomp.skewXZ, progress);
-    blendFloat(fromDecomp.skewYZ, toDecomp.skewYZ, progress);
-    blendFloat(fromDecomp.translateX, toDecomp.translateX, progress);
-    blendFloat(fromDecomp.translateY, toDecomp.translateY, progress);
-    blendFloat(fromDecomp.translateZ, toDecomp.translateZ, progress);
-    blendFloat(fromDecomp.perspectiveX, toDecomp.perspectiveX, progress);
-    blendFloat(fromDecomp.perspectiveY, toDecomp.perspectiveY, progress);
-    blendFloat(fromDecomp.perspectiveZ, toDecomp.perspectiveZ, progress);
-    blendFloat(fromDecomp.perspectiveW, toDecomp.perspectiveW, progress);
+    blendFloat(fromDecomp.scaleX, toDecomp.scaleX, progress, compositeOperation);
+    blendFloat(fromDecomp.scaleY, toDecomp.scaleY, progress, compositeOperation);
+    blendFloat(fromDecomp.scaleZ, toDecomp.scaleZ, progress, compositeOperation);
+    blendFloat(fromDecomp.skewXY, toDecomp.skewXY, progress, compositeOperation);
+    blendFloat(fromDecomp.skewXZ, toDecomp.skewXZ, progress, compositeOperation);
+    blendFloat(fromDecomp.skewYZ, toDecomp.skewYZ, progress, compositeOperation);
+    blendFloat(fromDecomp.translateX, toDecomp.translateX, progress, compositeOperation);
+    blendFloat(fromDecomp.translateY, toDecomp.translateY, progress, compositeOperation);
+    blendFloat(fromDecomp.translateZ, toDecomp.translateZ, progress, compositeOperation);
+    blendFloat(fromDecomp.perspectiveX, toDecomp.perspectiveX, progress, compositeOperation);
+    blendFloat(fromDecomp.perspectiveY, toDecomp.perspectiveY, progress, compositeOperation);
+    blendFloat(fromDecomp.perspectiveZ, toDecomp.perspectiveZ, progress, compositeOperation);
+    blendFloat(fromDecomp.perspectiveW, toDecomp.perspectiveW, progress, compositeOperation);
 
     slerp(&fromDecomp.quaternionX, &toDecomp.quaternionX, progress);
 
@@ -1713,7 +1713,7 @@
     recompose4(fromDecomp);
 }
 
-void TransformationMatrix::blend(const TransformationMatrix& from, double progress)
+void TransformationMatrix::blend(const TransformationMatrix& from, double progress, CompositeOperation compositeOperation)
 {
     if (!progress) {
         *this = from;
@@ -1727,9 +1727,9 @@
         return;
 
     if (from.isAffine() && isAffine())
-        blend2(from, progress);
+        blend2(from, progress, compositeOperation);
     else
-        blend4(from, progress);
+        blend4(from, progress, compositeOperation);
 }
 
 bool TransformationMatrix::decompose2(Decomposed2Type& decomp) const

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h (284599 => 284600)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h	2021-10-21 10:50:28 UTC (rev 284599)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h	2021-10-21 11:51:12 UTC (rev 284600)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "CompositeOperation.h"
 #include "FloatPoint.h"
 #include "FloatPoint3D.h"
 #include "IntPoint.h"
@@ -327,9 +328,9 @@
     bool decompose4(Decomposed4Type&) const;
     void recompose4(const Decomposed4Type&);
 
-    WEBCORE_EXPORT void blend(const TransformationMatrix& from, double progress);
-    WEBCORE_EXPORT void blend2(const TransformationMatrix& from, double progress);
-    WEBCORE_EXPORT void blend4(const TransformationMatrix& from, double progress);
+    WEBCORE_EXPORT void blend(const TransformationMatrix& from, double progress, CompositeOperation = CompositeOperation::Replace);
+    WEBCORE_EXPORT void blend2(const TransformationMatrix& from, double progress, CompositeOperation = CompositeOperation::Replace);
+    WEBCORE_EXPORT void blend4(const TransformationMatrix& from, double progress, CompositeOperation = CompositeOperation::Replace);
 
     bool isAffine() const
     {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to