Title: [229660] trunk/Source/WebCore
Revision
229660
Author
[email protected]
Date
2018-03-16 01:43:26 -0700 (Fri, 16 Mar 2018)

Log Message

[TexMap] Don't use the TextureMapperAnimation::Client interface to apply animation
https://bugs.webkit.org/show_bug.cgi?id=183656

Reviewed by Carlos Garcia Campos.

Don't have the TextureMapperLayer class inherit from the
TextureMapperAnimation::Client interface just for the purposes of
synchronization of animation-affected attributes in syncAnimations().
For that purpose it's enough to provide a struct that is passed to that
method, and with the TextureMapperAnimation class filling out any of the
animated attributes that need to be updated.

TextureMapperAnimation::ApplicationResult struct is introducted for that
purpose. std::optional<> members in it are assigned values during the
application process, if an appropriate animation affects them. The
relevant member values in TextureMapperLayer are then updated, or value
from the default state is used.

TextureMapperAnimation::Client is removed.

No new tests -- no change in behavior.

* platform/graphics/texmap/TextureMapperAnimation.cpp:
(WebCore::TextureMapperAnimation::apply):
(WebCore::TextureMapperAnimation::applyInternal):
(WebCore::TextureMapperAnimations::apply):
* platform/graphics/texmap/TextureMapperAnimation.h:
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::syncAnimations):
(WebCore::TextureMapperLayer::setAnimatedTransform): Deleted.
(WebCore::TextureMapperLayer::setAnimatedOpacity): Deleted.
(WebCore::TextureMapperLayer::setAnimatedFilters): Deleted.
* platform/graphics/texmap/TextureMapperLayer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (229659 => 229660)


--- trunk/Source/WebCore/ChangeLog	2018-03-16 07:01:01 UTC (rev 229659)
+++ trunk/Source/WebCore/ChangeLog	2018-03-16 08:43:26 UTC (rev 229660)
@@ -1,3 +1,39 @@
+2018-03-16  Zan Dobersek  <[email protected]>
+
+        [TexMap] Don't use the TextureMapperAnimation::Client interface to apply animation
+        https://bugs.webkit.org/show_bug.cgi?id=183656
+
+        Reviewed by Carlos Garcia Campos.
+
+        Don't have the TextureMapperLayer class inherit from the
+        TextureMapperAnimation::Client interface just for the purposes of
+        synchronization of animation-affected attributes in syncAnimations().
+        For that purpose it's enough to provide a struct that is passed to that
+        method, and with the TextureMapperAnimation class filling out any of the
+        animated attributes that need to be updated.
+
+        TextureMapperAnimation::ApplicationResult struct is introducted for that
+        purpose. std::optional<> members in it are assigned values during the
+        application process, if an appropriate animation affects them. The
+        relevant member values in TextureMapperLayer are then updated, or value
+        from the default state is used.
+
+        TextureMapperAnimation::Client is removed.
+
+        No new tests -- no change in behavior.
+
+        * platform/graphics/texmap/TextureMapperAnimation.cpp:
+        (WebCore::TextureMapperAnimation::apply):
+        (WebCore::TextureMapperAnimation::applyInternal):
+        (WebCore::TextureMapperAnimations::apply):
+        * platform/graphics/texmap/TextureMapperAnimation.h:
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::syncAnimations):
+        (WebCore::TextureMapperLayer::setAnimatedTransform): Deleted.
+        (WebCore::TextureMapperLayer::setAnimatedOpacity): Deleted.
+        (WebCore::TextureMapperLayer::setAnimatedFilters): Deleted.
+        * platform/graphics/texmap/TextureMapperLayer.h:
+
 2018-03-16  Devin Rousso  <[email protected]>
 
         Web Inspector: Canvas Tab: main WebGL canvas on acko.net has no reported size

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp (229659 => 229660)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp	2018-03-16 07:01:01 UTC (rev 229659)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp	2018-03-16 08:43:26 UTC (rev 229660)
@@ -192,7 +192,7 @@
 {
 }
 
-void TextureMapperAnimation::apply(Client& client, MonotonicTime time)
+void TextureMapperAnimation::apply(ApplicationResult& applicationResults, MonotonicTime time)
 {
     if (!isActive())
         return;
@@ -208,18 +208,18 @@
     }
 
     if (!normalizedValue) {
-        applyInternal(client, m_keyframes.at(0), m_keyframes.at(1), 0);
+        applyInternal(applicationResults, m_keyframes.at(0), m_keyframes.at(1), 0);
         return;
     }
 
     if (normalizedValue == 1.0) {
-        applyInternal(client, m_keyframes.at(m_keyframes.size() - 2), m_keyframes.at(m_keyframes.size() - 1), 1);
+        applyInternal(applicationResults, m_keyframes.at(m_keyframes.size() - 2), m_keyframes.at(m_keyframes.size() - 1), 1);
         return;
     }
     if (m_keyframes.size() == 2) {
         auto& timingFunction = timingFunctionForAnimationValue(m_keyframes.at(0), *m_animation);
         normalizedValue = timingFunction.transformTime(normalizedValue, m_animation->duration());
-        applyInternal(client, m_keyframes.at(0), m_keyframes.at(1), normalizedValue);
+        applyInternal(applicationResults, m_keyframes.at(0), m_keyframes.at(1), normalizedValue);
         return;
     }
 
@@ -232,7 +232,7 @@
         normalizedValue = (normalizedValue - from.keyTime()) / (to.keyTime() - from.keyTime());
         auto& timingFunction = timingFunctionForAnimationValue(from, *m_animation);
         normalizedValue = timingFunction.transformTime(normalizedValue, m_animation->duration());
-        applyInternal(client, from, to, normalizedValue);
+        applyInternal(applicationResults, from, to, normalizedValue);
         break;
     }
 }
@@ -269,17 +269,17 @@
     return m_state != AnimationState::Stopped || m_animation->fillsForwards();
 }
 
-void TextureMapperAnimation::applyInternal(Client& client, const AnimationValue& from, const AnimationValue& to, float progress)
+void TextureMapperAnimation::applyInternal(ApplicationResult& applicationResults, const AnimationValue& from, const AnimationValue& to, float progress)
 {
     switch (m_keyframes.property()) {
+    case AnimatedPropertyTransform:
+        applicationResults.transform = applyTransformAnimation(static_cast<const TransformAnimationValue&>(from).value(), static_cast<const TransformAnimationValue&>(to).value(), progress, m_boxSize, m_listsMatch);
+        return;
     case AnimatedPropertyOpacity:
-        client.setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue&>(from).value()), (static_cast<const FloatAnimationValue&>(to).value()), progress));
+        applicationResults.opacity = applyOpacityAnimation((static_cast<const FloatAnimationValue&>(from).value()), (static_cast<const FloatAnimationValue&>(to).value()), progress);
         return;
-    case AnimatedPropertyTransform:
-        client.setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue&>(from).value(), static_cast<const TransformAnimationValue&>(to).value(), progress, m_boxSize, m_listsMatch));
-        return;
     case AnimatedPropertyFilter:
-        client.setAnimatedFilters(applyFilterAnimation(static_cast<const FilterAnimationValue&>(from).value(), static_cast<const FilterAnimationValue&>(to).value(), progress, m_boxSize));
+        applicationResults.filters = applyFilterAnimation(static_cast<const FilterAnimationValue&>(from).value(), static_cast<const FilterAnimationValue&>(to).value(), progress, m_boxSize);
         return;
     default:
         ASSERT_NOT_REACHED();
@@ -330,10 +330,10 @@
         animation.resume();
 }
 
-void TextureMapperAnimations::apply(TextureMapperAnimation::Client& client, MonotonicTime time)
+void TextureMapperAnimations::apply(TextureMapperAnimation::ApplicationResult& applicationResults, MonotonicTime time)
 {
     for (auto& animation : m_animations)
-        animation.apply(client, time);
+        animation.apply(applicationResults, time);
 }
 
 bool TextureMapperAnimations::hasActiveAnimationsOfType(AnimatedPropertyID type) const

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h (229659 => 229660)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h	2018-03-16 07:01:01 UTC (rev 229659)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h	2018-03-16 08:43:26 UTC (rev 229660)
@@ -30,11 +30,10 @@
 public:
     enum class AnimationState { Playing, Paused, Stopped };
 
-    class Client {
-    public:
-        virtual void setAnimatedTransform(const TransformationMatrix&) = 0;
-        virtual void setAnimatedOpacity(float) = 0;
-        virtual void setAnimatedFilters(const FilterOperations&) = 0;
+    struct ApplicationResult {
+        std::optional<TransformationMatrix> transform;
+        std::optional<double> opacity;
+        std::optional<FilterOperations> filters;
     };
 
     TextureMapperAnimation()
@@ -43,7 +42,7 @@
     TextureMapperAnimation(const String&, const KeyframeValueList&, const FloatSize&, const Animation&, bool, MonotonicTime, Seconds, AnimationState);
     WEBCORE_EXPORT TextureMapperAnimation(const TextureMapperAnimation&);
 
-    void apply(Client&, MonotonicTime);
+    void apply(ApplicationResult&, MonotonicTime);
     void pause(Seconds);
     void resume();
     bool isActive() const;
@@ -54,7 +53,7 @@
     AnimationState state() const { return m_state; }
 
 private:
-    void applyInternal(Client&, const AnimationValue& from, const AnimationValue& to, float progress);
+    void applyInternal(ApplicationResult&, const AnimationValue& from, const AnimationValue& to, float progress);
     Seconds computeTotalRunningTime(MonotonicTime);
 
     String m_name;
@@ -80,7 +79,7 @@
     void suspend(MonotonicTime);
     void resume();
 
-    void apply(TextureMapperAnimation::Client&, MonotonicTime);
+    void apply(TextureMapperAnimation::ApplicationResult&, MonotonicTime);
 
     bool isEmpty() const { return m_animations.isEmpty(); }
     size_t size() const { return m_animations.size(); }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (229659 => 229660)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2018-03-16 07:01:01 UTC (rev 229659)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2018-03-16 08:43:26 UTC (rev 229660)
@@ -216,26 +216,11 @@
     paintSelfAndChildren(options);
 }
 
-void TextureMapperLayer::setAnimatedTransform(const TransformationMatrix& matrix)
-{
-    m_currentTransform.setLocalTransform(matrix);
-}
-
-void TextureMapperLayer::setAnimatedOpacity(float opacity)
-{
-    m_currentOpacity = opacity;
-}
-
 TransformationMatrix TextureMapperLayer::replicaTransform()
 {
     return TransformationMatrix(m_state.replicaLayer->m_currentTransform.combined()).multiply(m_currentTransform.combined().inverse().value_or(TransformationMatrix()));
 }
 
-void TextureMapperLayer::setAnimatedFilters(const FilterOperations& filters)
-{
-    m_currentFilters = filters;
-}
-
 static void resolveOverlaps(Region& newRegion, Region& overlapRegion, Region& nonOverlapRegion)
 {
     Region newOverlapRegion(newRegion);
@@ -652,14 +637,12 @@
 
 void TextureMapperLayer::syncAnimations(MonotonicTime time)
 {
-    m_animations.apply(*this, time);
-    if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyTransform))
-        m_currentTransform.setLocalTransform(m_state.transform);
-    if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity))
-        m_currentOpacity = m_state.opacity;
+    TextureMapperAnimation::ApplicationResult applicationResults;
+    m_animations.apply(applicationResults, time);
 
-    if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyFilter))
-        m_currentFilters = m_state.filters;
+    m_currentTransform.setLocalTransform(applicationResults.transform.value_or(m_state.transform));
+    m_currentOpacity = applicationResults.opacity.value_or(m_state.opacity);
+    m_currentFilters = applicationResults.filters.value_or(m_state.filters);
 }
 
 bool TextureMapperLayer::isAncestorFixedToViewport() const

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h (229659 => 229660)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2018-03-16 07:01:01 UTC (rev 229659)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2018-03-16 08:43:26 UTC (rev 229660)
@@ -34,7 +34,7 @@
 class TextureMapperPaintOptions;
 class TextureMapperPlatformLayer;
 
-class WEBCORE_EXPORT TextureMapperLayer : public TextureMapperAnimation::Client {
+class TextureMapperLayer {
     WTF_MAKE_NONCOPYABLE(TextureMapperLayer);
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -146,11 +146,6 @@
     void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&);
     void applyMask(const TextureMapperPaintOptions&);
 
-    // TextureMapperAnimation::Client
-    void setAnimatedTransform(const TransformationMatrix&) override;
-    void setAnimatedOpacity(float) override;
-    void setAnimatedFilters(const FilterOperations&) override;
-
     bool isVisible() const;
 
     bool shouldBlend() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to