Changeset 40843 in webkit


Ignore:
Timestamp:
Feb 10, 2009 5:44:14 PM (15 years ago)
Author:
Simon Fraser
Message:

2009-02-10 Simon Fraser <Simon Fraser>

Reviewed by Dave Hyatt

Clean up "fallbackAnimating" logic in AnimationBase. This flag indicates
that animation of an accelerated property must run in software for some reason.

Also remove use of private headers in GraphicsLayerCA related to a case
where we may have to fall back on software animation of transform.

Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r40842 r40843  
    209209        (WebCore::SVGInlineTextBoxQueryWalker::chunkPortionCallback):
    210210        (WebCore::findInlineTextBoxInTextChunks):
     211
     2122009-02-10  Simon Fraser  <simon.fraser@apple.com>
     213
     214        Reviewed by Dave Hyatt
     215
     216        Clean up "fallbackAnimating" logic in AnimationBase. This flag indicates
     217        that animation of an accelerated property must run in software for some reason.
     218       
     219        Also remove use of private headers in GraphicsLayerCA related to a case
     220        where we may have to fall back on software animation of transform.
     221
     222        * page/animation/AnimationBase.cpp:
     223        (WebCore::AnimationBase::blendProperties):
     224        * page/animation/AnimationBase.h:
     225        * page/animation/ImplicitAnimation.cpp:
     226        (WebCore::ImplicitAnimation::animate):
     227        * page/animation/KeyframeAnimation.cpp:
     228        (WebCore::KeyframeAnimation::animate):
     229        * platform/graphics/mac/GraphicsLayerCA.h:
     230        * platform/graphics/mac/GraphicsLayerCA.mm:
     231        (WebCore::getValueFunctionNameForTransformOperation):
     232        (WebCore::caValueFunctionSupported):
     233        (WebCore::GraphicsLayerCA::setBackgroundColor):
     234        (WebCore::GraphicsLayerCA::setOpacity):
     235        (WebCore::GraphicsLayerCA::animateTransform):
     236        (WebCore::GraphicsLayerCA::animateFloat):
     237        (WebCore::GraphicsLayerCA::setBasicAnimation):
     238        (WebCore::GraphicsLayerCA::setKeyframeAnimation):
    211239
    2122402009-02-10  Simon Fraser  <simon.fraser@apple.com>
  • trunk/WebCore/page/animation/AnimationBase.cpp

    r40671 r40843  
    627627        wrapper->blend(anim, dst, a, b, progress);
    628628#if USE(ACCELERATED_COMPOSITING)
    629         return !wrapper->animationIsAccelerated();
     629        return !wrapper->animationIsAccelerated() || anim->isFallbackAnimating();
    630630#else
    631631        return true;
  • trunk/WebCore/page/animation/AnimationBase.h

    r40700 r40843  
    215215    RefPtr<Animation> m_animation;
    216216    CompositeAnimation* m_compAnim;
    217     bool m_fallbackAnimating;       // true if any animation returned false from startAnimation()
     217    bool m_fallbackAnimating;       // true when animating an accelerated property but have to fall back to software
    218218    bool m_transformFunctionListValid;
    219219    double m_totalDuration, m_nextIterationDuration;
  • trunk/WebCore/page/animation/ImplicitAnimation.cpp

    r40701 r40843  
    8080
    8181    bool needsAnim = blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0));
    82     if (needsAnim || m_fallbackAnimating)
     82    if (needsAnim)
    8383        setAnimating();
    8484
  • trunk/WebCore/page/animation/KeyframeAnimation.cpp

    r40685 r40843  
    146146    for (HashSet<int>::const_iterator it = m_keyframes.beginProperties(); it != endProperties; ++it) {
    147147        bool needsAnim = blendProperties(this, *it, animatedStyle.get(), fromStyle, toStyle, progress);
    148         if (needsAnim || m_fallbackAnimating)
     148        if (needsAnim)
    149149            setAnimating();
    150150    }
  • trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.h

    r40433 r40843  
    110110    }
    111111
    112     void setBasicAnimation(AnimatedPropertyID, const String& component, short index, void* fromVal, void* toVal, bool isTransition, const Animation*, double time);
    113     void setKeyframeAnimation(AnimatedPropertyID, const String& component, short index, void* keys, void* values, void* timingFunctions, bool isTransition, const Animation*, double time);
     112    void setBasicAnimation(AnimatedPropertyID, TransformOperation::OperationType, short index, void* fromVal, void* toVal, bool isTransition, const Animation*, double time);
     113    void setKeyframeAnimation(AnimatedPropertyID, TransformOperation::OperationType, short index, void* keys, void* values, void* timingFunctions, bool isTransition, const Animation*, double time);
    114114
    115115    virtual void removeAnimation(int index, bool reset);
  • trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.mm

    r40703 r40843  
    3030#import "GraphicsLayerCA.h"
    3131
    32 // Temporary
    33 #import <QuartzCore/CAAnimationPrivate.h>
    34 #import <QuartzCore/CAValueFunction.h>
    35 
    3632#import "Animation.h"
    3733#import "BlockExceptions.h"
     
    161157}
    162158
    163 static String getAnimationValueFunction(TransformOperation::OperationType transformType)
    164 {
     159static NSString* getValueFunctionNameForTransformOperation(TransformOperation::OperationType transformType)
     160{
     161    // Use literal strings to avoid link-time dependency on those symbols.
    165162    switch (transformType) {
    166163        case TransformOperation::ROTATE:
    167             return "rotateZ";
     164            return @"rotateZ"; // kCAValueFunctionRotateZ;
    168165        case TransformOperation::SCALE_X:
    169             return "scaleX";
     166            return @"scaleX"; // kCAValueFunctionScaleX;
    170167        case TransformOperation::SCALE_Y:
    171             return "scaleY";
     168            return @"scaleY"; // kCAValueFunctionScaleY;
    172169        case TransformOperation::TRANSLATE_X:
    173             return "translateX";
     170            return @"translateX"; // kCAValueFunctionTranslateX;
    174171        case TransformOperation::TRANSLATE_Y:
    175             return "translateY";
     172            return @"translateY"; // kCAValueFunctionTranslateY;
    176173        default:
    177             return String();
     174            return nil;
    178175    }
    179176}
     
    224221
    225222    return presLayer;
     223}
     224
     225static bool caValueFunctionSupported()
     226{
     227    static bool sHaveValueFunction = [[CALayer class] instancesRespondToSelector:@selector(setValueFunction:)];
     228    return sHaveValueFunction;
    226229}
    227230
     
    720723
    721724        CGColorRef bgColor = cgColor(color);
    722         setBasicAnimation(AnimatedPropertyBackgroundColor, "", 0, fromBackgroundColor, bgColor, true, transition, beginTime);
     725        setBasicAnimation(AnimatedPropertyBackgroundColor, TransformOperation::NONE, 0, fromBackgroundColor, bgColor, true, transition, beginTime);
    723726        CGColorRelease(bgColor);
    724727    } else {
     
    820823        float fromOpacity = [presLayer opacity];
    821824        fromOpacityValue = [NSNumber numberWithFloat:fromOpacity];
    822         setBasicAnimation(AnimatedPropertyOpacity, "", 0, fromOpacityValue, toOpacityValue, true, transition, beginTime);
     825        setBasicAnimation(AnimatedPropertyOpacity, TransformOperation::NONE, 0, fromOpacityValue, toOpacityValue, true, transition, beginTime);
    823826        didAnimate = true;
    824827    }
     
    859862    valueList.makeFunctionList(functionList, isValid, hasBigRotation);
    860863
     864    // We need to fall back to software animation if we don't have setValueFunction:, and
     865    // we have a > 180deg rotation mixed with another transform.
     866    if (hasBigRotation && functionList.size() > 1 && !caValueFunctionSupported())
     867        return false;
     868   
    861869    BEGIN_BLOCK_OBJC_EXCEPTIONS
    862870   
     
    926934            [tfArray removeLastObject];
    927935           
    928             setKeyframeAnimation(AnimatedPropertyWebkitTransform, getAnimationValueFunction(opType), functionIndex, timesArray, valArray, tfArray, isTransition, anim, beginTime);
     936            setKeyframeAnimation(AnimatedPropertyWebkitTransform, opType, functionIndex, timesArray, valArray, tfArray, isTransition, anim, beginTime);
    929937           
    930938            [timesArray release];
     
    950958            }
    951959           
    952             setBasicAnimation(AnimatedPropertyWebkitTransform, getAnimationValueFunction(opType), functionIndex, fromValue, toValue, isTransition, anim, beginTime);
     960            setBasicAnimation(AnimatedPropertyWebkitTransform, opType, functionIndex, fromValue, toValue, isTransition, anim, beginTime);
    953961        }
    954962       
     
    981989        // initialize the property to 0
    982990        [animatedLayer(property) setValue:0 forKeyPath:propertyIdToString(property)];
    983         setBasicAnimation(property, "", 0, isnan(fromVal) ? nil : [NSNumber numberWithFloat:fromVal], isnan(toVal) ? nil : [NSNumber numberWithFloat:toVal], false, animation, beginTime);
     991        setBasicAnimation(property, TransformOperation::NONE, 0, isnan(fromVal) ? nil : [NSNumber numberWithFloat:fromVal], isnan(toVal) ? nil : [NSNumber numberWithFloat:toVal], false, animation, beginTime);
    984992        return true;
    985993    }
     
    10121020    [animatedLayer(property) setValue:0 forKeyPath:propertyIdToString(property)];
    10131021    // Then set the animation.
    1014     setKeyframeAnimation(property, "", 0, timesArray, valArray, tfArray, false, animation, beginTime);
     1022    setKeyframeAnimation(property, TransformOperation::NONE, 0, timesArray, valArray, tfArray, false, animation, beginTime);
    10151023
    10161024    [timesArray release];
     
    10911099}
    10921100
    1093 void GraphicsLayerCA::setBasicAnimation(AnimatedPropertyID property, const String& valueFunction, short index, void* fromVal, void* toVal, bool isTransition, const Animation* transition, double beginTime)
     1101void GraphicsLayerCA::setBasicAnimation(AnimatedPropertyID property, TransformOperation::OperationType operationType, short index, void* fromVal, void* toVal, bool isTransition, const Animation* transition, double beginTime)
    10941102{
    10951103    ASSERT(fromVal || toVal);
     
    11261134    [basicAnim setAdditive:property == AnimatedPropertyWebkitTransform];
    11271135    [basicAnim setFillMode:@"extended"];
    1128     [basicAnim setValueFunction:[CAValueFunction functionWithName:valueFunction]];
     1136    if (caValueFunctionSupported()) {
     1137        if (NSString* valueFunctionName = getValueFunctionNameForTransformOperation(operationType))
     1138            [basicAnim setValueFunction:[CAValueFunction functionWithName:valueFunctionName]];
     1139    }
    11291140   
    11301141    // Set the delegate (and property value).
     
    11551166}
    11561167
    1157 void GraphicsLayerCA::setKeyframeAnimation(AnimatedPropertyID property, const String& valueFunction, short index, void* keys, void* values, void* timingFunctions,
     1168void GraphicsLayerCA::setKeyframeAnimation(AnimatedPropertyID property, TransformOperation::OperationType operationType, short index, void* keys, void* values, void* timingFunctions,
    11581169                                    bool isTransition, const Animation* anim, double beginTime)
    11591170{
     
    11901201    [keyframeAnim setAdditive:(property == AnimatedPropertyWebkitTransform) ? YES : NO];
    11911202    [keyframeAnim setFillMode:@"extended"];
    1192     [keyframeAnim setValueFunction:[CAValueFunction functionWithName:valueFunction]];
    1193    
     1203    if (caValueFunctionSupported()) {
     1204        if (NSString* valueFunctionName = getValueFunctionNameForTransformOperation(operationType))
     1205            [keyframeAnim setValueFunction:[CAValueFunction functionWithName:valueFunctionName]];
     1206    }
     1207
    11941208    [keyframeAnim setKeyTimes:reinterpret_cast<id>(keys)];
    11951209    [keyframeAnim setValues:reinterpret_cast<id>(values)];
Note: See TracChangeset for help on using the changeset viewer.