Get rid of TransformOperationList
authorcmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jan 2012 19:02:34 +0000 (19:02 +0000)
committercmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jan 2012 19:02:34 +0000 (19:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77249

Reviewed by Dan Bernstein.

Changed fetchTransformOperationList to validateTransformOperations and got rid of separately generated list
of transform operations. These are not needed, they are already available in the keyframe lists and they
make it more difficult to add support for hardware animated filters. No behavior changes.

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::validateTransformOperations):
* platform/graphics/GraphicsLayer.h:
(GraphicsLayer):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::appendToUncommittedAnimations):
(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
* platform/graphics/ca/GraphicsLayerCA.h:
():
* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::addAnimation):
* platform/graphics/texmap/TextureMapperAnimation.cpp:
(WebCore::applyTransformAnimation):
(WebCore::TextureMapperAnimation::TextureMapperAnimation):
(WebCore::TextureMapperAnimation::applyInternal):
* platform/graphics/texmap/TextureMapperAnimation.h:
(TextureMapperAnimation):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106190 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h

index 6c58bf9..4a59a24 100644 (file)
@@ -1,3 +1,33 @@
+2012-01-27  Chris Marrin  <cmarrin@apple.com>
+
+        Get rid of TransformOperationList
+        https://bugs.webkit.org/show_bug.cgi?id=77249
+
+        Reviewed by Dan Bernstein.
+
+        Changed fetchTransformOperationList to validateTransformOperations and got rid of separately generated list
+        of transform operations. These are not needed, they are already available in the keyframe lists and they
+        make it more difficult to add support for hardware animated filters. No behavior changes.
+
+
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::validateTransformOperations):
+        * platform/graphics/GraphicsLayer.h:
+        (GraphicsLayer):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::appendToUncommittedAnimations):
+        (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        ():
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::addAnimation):
+        * platform/graphics/texmap/TextureMapperAnimation.cpp:
+        (WebCore::applyTransformAnimation):
+        (WebCore::TextureMapperAnimation::TextureMapperAnimation):
+        (WebCore::TextureMapperAnimation::applyInternal):
+        * platform/graphics/texmap/TextureMapperAnimation.h:
+        (TextureMapperAnimation):
+
 2012-01-27  Raymond Toy  <rtoy@google.com>
 
         AudioPannerNode::setPanningModel() does not update m_panningModel properly
index 6becc54..2a5c45d 100644 (file)
@@ -385,16 +385,14 @@ static inline const TransformOperations* operationsAt(const KeyframeValueList& v
     return static_cast<const TransformAnimationValue*>(valueList.at(index))->value();
 }
 
-void GraphicsLayer::fetchTransformOperationList(const KeyframeValueList& valueList, TransformOperationList& list, bool& isValid, bool& hasBigRotation)
+int GraphicsLayer::validateTransformOperations(const KeyframeValueList& valueList, bool& hasBigRotation)
 {
     ASSERT(valueList.property() == AnimatedPropertyWebkitTransform);
 
-    list.clear();
-    isValid = false;
     hasBigRotation = false;
     
     if (valueList.size() < 2)
-        return;
+        return -1;
     
     // Empty transforms match anything, so find the first non-empty entry as the reference.
     size_t firstIndex = 0;
@@ -404,7 +402,7 @@ void GraphicsLayer::fetchTransformOperationList(const KeyframeValueList& valueLi
     }
     
     if (firstIndex >= valueList.size())
-        return;
+        return -1;
         
     const TransformOperations* firstVal = operationsAt(valueList, firstIndex);
     
@@ -417,19 +415,15 @@ void GraphicsLayer::fetchTransformOperationList(const KeyframeValueList& valueLi
             continue;
             
         if (!firstVal->operationsMatch(*val))
-            return;
+            return -1;
     }
 
-    // Keyframes are valid, fill in the list.
-    isValid = true;
-    
+    // Keyframes are valid, check for big rotations.    
     double lastRotAngle = 0.0;
     double maxRotAngle = -1.0;
         
-    list.resize(firstVal->operations().size());
     for (size_t j = 0; j < firstVal->operations().size(); ++j) {
         TransformOperation::OperationType type = firstVal->operations().at(j)->getOperationType();
-        list[j] = type;
         
         // if this is a rotation entry, we need to see if any angle differences are >= 180 deg
         if (type == TransformOperation::ROTATE_X ||
@@ -453,6 +447,8 @@ void GraphicsLayer::fetchTransformOperationList(const KeyframeValueList& valueLi
     }
     
     hasBigRotation = maxRotAngle >= 180.0;
+    
+    return firstIndex;
 }
 
 
index dc6e8b8..9061520 100644 (file)
@@ -423,10 +423,12 @@ protected:
     void clearFilters() { m_filters.clear(); }
 #endif
 
-    typedef Vector<TransformOperation::OperationType> TransformOperationList;
-    // Given a list of TransformAnimationValues, return an array of transform operations.
-    // On return, if hasBigRotation is true, functions contain rotations of >= 180 degrees
-    static void fetchTransformOperationList(const KeyframeValueList&, TransformOperationList&, bool& isValid, bool& hasBigRotation);
+    // Given a list of TransformAnimationValues, see if all the operations for each keyframe match. If so
+    // return the index of the KeyframeValueList entry that has that list of operations (it may not be
+    // the first entry because some keyframes might have an empty transform and those match any list).
+    // If the lists don't match return -1. On return, if hasBigRotation is true, functions contain 
+    // rotations of >= 180 degrees
+    static int validateTransformOperations(const KeyframeValueList&, bool& hasBigRotation);
 
     virtual void setOpacityInternal(float) { }
 
index d4d20ae..299c921 100644 (file)
@@ -1756,9 +1756,9 @@ bool GraphicsLayerCA::createAnimationFromKeyframes(const KeyframeValueList& valu
     return true;
 }
 
-bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& valueList, const TransformOperationList& functionList, const Animation* animation, const String& animationName, const IntSize& boxSize, int animationIndex, double timeOffset, bool isMatrixAnimation)
+bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& valueList, const TransformOperations* operations, const Animation* animation, const String& animationName, const IntSize& boxSize, int animationIndex, double timeOffset, bool isMatrixAnimation)
 {
-    TransformOperation::OperationType transformOp = isMatrixAnimation ? TransformOperation::MATRIX_3D : functionList[animationIndex];
+    TransformOperation::OperationType transformOp = isMatrixAnimation ? TransformOperation::MATRIX_3D : operations->operations().at(animationIndex)->getOperationType();
     bool additive = animationIndex > 0;
     bool isKeyframe = valueList.size() > 2;
 
@@ -1783,23 +1783,23 @@ bool GraphicsLayerCA::createTransformAnimationsFromKeyframes(const KeyframeValue
 {
     ASSERT(valueList.property() == AnimatedPropertyWebkitTransform);
 
-    TransformOperationList functionList;
-    bool listsMatch, hasBigRotation;
-    fetchTransformOperationList(valueList, functionList, listsMatch, hasBigRotation);
+    bool hasBigRotation;
+    int listIndex = validateTransformOperations(valueList, hasBigRotation);
+    const TransformOperations* operations = (listIndex >= 0) ? static_cast<const TransformAnimationValue*>(valueList.at(listIndex))->value() : 0;
 
     // We need to fall back to software animation if we don't have setValueFunction:, and
     // we would need to animate each incoming transform function separately. This is the
     // case if we have a rotation >= 180 or we have more than one transform function.
-    if ((hasBigRotation || functionList.size() > 1) && !PlatformCAAnimation::supportsValueFunction())
+    if ((hasBigRotation || (operations && operations->size() > 1)) && !PlatformCAAnimation::supportsValueFunction())
         return false;
 
     bool validMatrices = true;
 
-    // If functionLists don't match we do a matrix animation, otherwise we do a component hardware animation.
+    // If function lists don't match we do a matrix animation, otherwise we do a component hardware animation.
     // Also, we can't do component animation unless we have valueFunction, so we need to do matrix animation
     // if that's not true as well.
-    bool isMatrixAnimation = !listsMatch || !PlatformCAAnimation::supportsValueFunction();
-    int numAnimations = isMatrixAnimation ? 1 : functionList.size();
+    bool isMatrixAnimation = listIndex < 0 || !PlatformCAAnimation::supportsValueFunction();
+    int numAnimations = isMatrixAnimation ? 1 : operations->size();
 
     bool reverseAnimationList = true;
 #if !defined(BUILDING_ON_SNOW_LEOPARD) && !PLATFORM(WIN)
@@ -1814,14 +1814,14 @@ bool GraphicsLayerCA::createTransformAnimationsFromKeyframes(const KeyframeValue
 #endif
     if (reverseAnimationList) {
         for (int animationIndex = numAnimations - 1; animationIndex >= 0; --animationIndex) {
-            if (!appendToUncommittedAnimations(valueList, functionList, animation, animationName, boxSize, animationIndex, timeOffset, isMatrixAnimation)) {
+            if (!appendToUncommittedAnimations(valueList, operations, animation, animationName, boxSize, animationIndex, timeOffset, isMatrixAnimation)) {
                 validMatrices = false;
                 break;
             }
         }
     } else {
         for (int animationIndex = 0; animationIndex < numAnimations; ++animationIndex) {
-            if (!appendToUncommittedAnimations(valueList, functionList, animation, animationName, boxSize, animationIndex, timeOffset, isMatrixAnimation)) {
+            if (!appendToUncommittedAnimations(valueList, operations, animation, animationName, boxSize, animationIndex, timeOffset, isMatrixAnimation)) {
                 validMatrices = false;
                 break;
             }
index 93e0e64..f0da630 100644 (file)
@@ -321,7 +321,7 @@ private:
     static void moveOrCopyLayerAnimation(MoveOrCopy, const String& animationIdentifier, PlatformCALayer *fromLayer, PlatformCALayer *toLayer);
     void moveOrCopyAnimationsForProperty(MoveOrCopy, AnimatedPropertyID, PlatformCALayer * fromLayer, PlatformCALayer * toLayer);
     
-    bool appendToUncommittedAnimations(const KeyframeValueList&, const TransformOperationList&, const Animation*, const String& animationName, const IntSize& boxSize, int animationIndex, double timeOffset, bool isMatrixAnimation);
+    bool appendToUncommittedAnimations(const KeyframeValueList&, const TransformOperations*, const Animation*, const String& animationName, const IntSize& boxSize, int animationIndex, double timeOffset, bool isMatrixAnimation);
     
     enum LayerChange {
         NoChange = 0,
index f478b9f..b521d1a 100644 (file)
@@ -365,14 +365,13 @@ bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList
     if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() < 2 || (valueList.property() != AnimatedPropertyWebkitTransform && valueList.property() != AnimatedPropertyOpacity))
         return false;
 
-    bool listsMatch;
+    bool listsMatch = false;
     bool hasBigRotation;
-    Vector<TransformOperation::OperationType> functionList;
 
     if (valueList.property() == AnimatedPropertyWebkitTransform)
-        fetchTransformOperationList(valueList, functionList, listsMatch, hasBigRotation);
+        listsMatch = validateTransformOperations(valueList, hasBigRotation) >= 0;
 
-    m_animations.add(keyframesName, TextureMapperAnimation(valueList, boxSize, anim, timeOffset, functionList, listsMatch));
+    m_animations.add(keyframesName, TextureMapperAnimation(valueList, boxSize, anim, timeOffset, listsMatch));
     notifyChange(TextureMapperNode::AnimationChange);
     m_animationStartedTimer.startOneShot(0);
     return true;
index d4d196d..09714d9 100644 (file)
@@ -85,7 +85,7 @@ static inline float applyTimingFunction(const TimingFunction* timingFunction, fl
     return progress;
 }
 
-static TransformationMatrix applyTransformAnimation(const TransformOperations* from, const TransformOperations* to, double progress, const IntSize& boxSize, const Vector<TransformOperation::OperationType> functionList, bool listsMatch)
+static TransformationMatrix applyTransformAnimation(const TransformOperations* from, const TransformOperations* to, double progress, const IntSize& boxSize, bool listsMatch)
 {
     TransformationMatrix matrix;
 
@@ -134,11 +134,10 @@ static TransformationMatrix applyTransformAnimation(const TransformOperations* f
 }
 
 
-TextureMapperAnimation::TextureMapperAnimation(const KeyframeValueList& keyframes, const IntSize& boxSize, const Animation* animation, double timeOffset, const Vector<TransformOperation::OperationType>& functionList, bool listsMatch)
+TextureMapperAnimation::TextureMapperAnimation(const KeyframeValueList& keyframes, const IntSize& boxSize, const Animation* animation, double timeOffset, bool listsMatch)
     : m_keyframes(keyframes)
     , m_boxSize(boxSize)
     , m_animation(Animation::create(animation))
-    , m_functionList(functionList)
     , m_listsMatch(listsMatch)
     , m_startTime(WTF::currentTime() - timeOffset)
     , m_pauseTime(0)
@@ -153,7 +152,7 @@ void TextureMapperAnimation::applyInternal(TextureMapperAnimationClient* client,
         client->setOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue*>(from)->value()), (static_cast<const FloatAnimationValue*>(to)->value()), progress));
         return;
     case AnimatedPropertyWebkitTransform:
-        client->setTransform(applyTransformAnimation(static_cast<const TransformAnimationValue*>(from)->value(), static_cast<const TransformAnimationValue*>(to)->value(), progress, m_boxSize, m_functionList, m_listsMatch));
+        client->setTransform(applyTransformAnimation(static_cast<const TransformAnimationValue*>(from)->value(), static_cast<const TransformAnimationValue*>(to)->value(), progress, m_boxSize, m_listsMatch));
         return;
     default:
         ASSERT_NOT_REACHED();
index 5e226e8..a3f1ca6 100644 (file)
@@ -41,7 +41,7 @@ public:
     TextureMapperAnimation()
         : m_keyframes(AnimatedPropertyInvalid)
     { }
-    TextureMapperAnimation(const KeyframeValueList&, const IntSize&, const Animation*, double, const Vector<TransformOperation::OperationType>&, bool);
+    TextureMapperAnimation(const KeyframeValueList&, const IntSize&, const Animation*, double, bool);
     void apply(TextureMapperAnimationClient*);
     void pause(double);
     AnimationState state() const { return m_state; }
@@ -55,7 +55,6 @@ private:
     IntSize m_boxSize;
     RefPtr<Animation> m_animation;
     String m_name;
-    Vector<TransformOperation::OperationType> m_functionList;
     bool m_listsMatch;
     bool m_hasBigRotation;
     double m_startTime;