Changeset 76358 in webkit


Ignore:
Timestamp:
Jan 21, 2011 10:31:02 AM (13 years ago)
Author:
Adam Roben
Message:

Clean up PlatformCAAnimationWin

Fixes <http://webkit.org/b/52904> PlatformCAAnimationWin is leaky and inefficient

Reviewed by Simon Fraser.

  • platform/graphics/ca/win/PlatformCAAnimationWin.cpp:

(toCACFFillModeType):
(fromCACFFillModeType):
(toCACFValueFunctionType):
(fromCACFValueFunctionType):
Changed to take and return CFStringRefs. There's no need to convert to WebCore::String just
so we can later convert back to CFStringRef.

(toCACFTimingFunction): Fixed leaks by changing this to return a RetainPtr and adopting the
results of CACFTimingFunctionCreate.
(PlatformCAAnimation::PlatformCAAnimation): Changed not to needlessly roundtrip through
WebCore::String. Also changed an ASSERT(0) to ASSERT_NOT_REACHED().

(PlatformCAAnimation::setFillMode):
(PlatformCAAnimation::setTimingFunction):
(PlatformCAAnimation::setValueFunction):
(PlatformCAAnimation::setTimingFunctions):
Updated for changes to the above conversion functions.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76357 r76358  
     12011-01-21  Adam Roben  <aroben@apple.com>
     2
     3        Clean up PlatformCAAnimationWin
     4
     5        Fixes <http://webkit.org/b/52904> PlatformCAAnimationWin is leaky and inefficient
     6
     7        Reviewed by Simon Fraser.
     8
     9        * platform/graphics/ca/win/PlatformCAAnimationWin.cpp:
     10        (toCACFFillModeType):
     11        (fromCACFFillModeType):
     12        (toCACFValueFunctionType):
     13        (fromCACFValueFunctionType):
     14        Changed to take and return CFStringRefs. There's no need to convert to WebCore::String just
     15        so we can later convert back to CFStringRef.
     16
     17        (toCACFTimingFunction): Fixed leaks by changing this to return a RetainPtr and adopting the
     18        results of CACFTimingFunctionCreate.
     19        (PlatformCAAnimation::PlatformCAAnimation): Changed not to needlessly roundtrip through
     20        WebCore::String. Also changed an ASSERT(0) to ASSERT_NOT_REACHED().
     21
     22        (PlatformCAAnimation::setFillMode):
     23        (PlatformCAAnimation::setTimingFunction):
     24        (PlatformCAAnimation::setValueFunction):
     25        (PlatformCAAnimation::setTimingFunctions):
     26        Updated for changes to the above conversion functions.
     27
    1282011-01-21  Charlie Reis  <creis@chromium.org>
    229
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp

    r75262 r76358  
    4242using namespace WebCore;
    4343
    44 static String toCACFFillModeType(PlatformCAAnimation::FillModeType type)
     44static CFStringRef toCACFFillModeType(PlatformCAAnimation::FillModeType type)
    4545{
    4646    switch (type) {
     
    5050    case PlatformCAAnimation::Both: return kCACFFillModeBoth;
    5151    }
    52     return "";
    53 }
    54 
    55 static PlatformCAAnimation::FillModeType fromCACFFillModeType(const String& string)
     52    ASSERT_NOT_REACHED();
     53    return 0;
     54}
     55
     56static PlatformCAAnimation::FillModeType fromCACFFillModeType(CFStringRef string)
    5657{
    5758    if (string == kCACFFillModeBackwards)
     
    6465}
    6566
    66 static String toCACFValueFunctionType(PlatformCAAnimation::ValueFunctionType type)
     67static CFStringRef toCACFValueFunctionType(PlatformCAAnimation::ValueFunctionType type)
    6768{
    6869    switch (type) {
    69     case PlatformCAAnimation::NoValueFunction: return "";
     70    case PlatformCAAnimation::NoValueFunction: return 0;
    7071    case PlatformCAAnimation::RotateX: return kCACFValueFunctionRotateX;
    7172    case PlatformCAAnimation::RotateY: return kCACFValueFunctionRotateY;
     
    8081    case PlatformCAAnimation::Translate: return kCACFValueFunctionTranslate;
    8182    }
    82     return "";
    83 }
    84 
    85 static PlatformCAAnimation::ValueFunctionType fromCACFValueFunctionType(const String string)
     83    ASSERT_NOT_REACHED();
     84    return 0;
     85}
     86
     87static PlatformCAAnimation::ValueFunctionType fromCACFValueFunctionType(CFStringRef string)
    8688{
    8789    if (string == kCACFValueFunctionRotateX)
     
    121123}
    122124
    123 static CACFTimingFunctionRef toCACFTimingFunction(const TimingFunction* timingFunction)
     125static RetainPtr<CACFTimingFunctionRef> toCACFTimingFunction(const TimingFunction* timingFunction)
    124126{
    125127    if (!timingFunction)
    126         return CACFTimingFunctionCreate(0.25f, 0.1f, 0.25f, 0.1f);
     128        return RetainPtr<CACFTimingFunctionRef>(AdoptCF, CACFTimingFunctionCreate(0.25f, 0.1f, 0.25f, 0.1f));
    127129           
    128130    if (timingFunction->isCubicBezierTimingFunction()) {
    129131        const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(timingFunction);
    130         return CACFTimingFunctionCreate(static_cast<float>(ctf->x1()), static_cast<float>(ctf->y1()), static_cast<float>(ctf->x2()), static_cast<float>(ctf->y2()));
     132        return RetainPtr<CACFTimingFunctionRef>(AdoptCF, CACFTimingFunctionCreate(static_cast<float>(ctf->x1()), static_cast<float>(ctf->y1()), static_cast<float>(ctf->x2()), static_cast<float>(ctf->y2())));
    131133    }
    132134   
     
    163165PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
    164166{
    165     if (String(CACFAnimationGetClass(animation)) == kCACFBasicAnimation)
     167    if (CACFAnimationGetClass(animation) == kCACFBasicAnimation)
    166168        m_type = Basic;
    167     else if (String(CACFAnimationGetClass(animation)) == kCACFKeyframeAnimation)
     169    else if (CACFAnimationGetClass(animation) == kCACFKeyframeAnimation)
    168170        m_type = Keyframe;
    169171    else {
    170         ASSERT(0);
     172        ASSERT_NOT_REACHED();
    171173        return;
    172174    }
     
    290292void PlatformCAAnimation::setFillMode(FillModeType value)
    291293{
    292     RetainPtr<CFStringRef> keyPath(AdoptCF, toCACFFillModeType(value).createCFString());
    293     CACFAnimationSetFillMode(m_animation.get(), keyPath.get());
     294    CACFAnimationSetFillMode(m_animation.get(), toCACFFillModeType(value));
    294295}
    295296
    296297void PlatformCAAnimation::setTimingFunction(const TimingFunction* value)
    297298{
    298     CACFAnimationSetTimingFunction(m_animation.get(), toCACFTimingFunction(value));
     299    CACFAnimationSetTimingFunction(m_animation.get(), toCACFTimingFunction(value).get());
    299300}
    300301
     
    331332void PlatformCAAnimation::setValueFunction(ValueFunctionType value)
    332333{
    333     RetainPtr<CFStringRef> keyPath(AdoptCF, toCACFValueFunctionType(value).createCFString());
    334     CACFAnimationSetValueFunction(m_animation.get(), CACFValueFunctionGetFunctionWithName(keyPath.get()));
     334    CACFAnimationSetValueFunction(m_animation.get(), CACFValueFunctionGetFunctionWithName(toCACFValueFunctionType(value)));
    335335}
    336336
     
    525525    for (size_t i = 0; i < value.size(); ++i) {
    526526        RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value[i]));
    527         CFArrayAppendValue(array.get(), toCACFTimingFunction(value[i]));
     527        CFArrayAppendValue(array.get(), toCACFTimingFunction(value[i]).get());
    528528    }
    529529
Note: See TracChangeset for help on using the changeset viewer.