Bug 52904

Summary: PlatformCAAnimationWin is leaky and inefficient
Product: WebKit Reporter: Adam Roben (:aroben) <aroben>
Component: Layout and RenderingAssignee: Adam Roben (:aroben) <aroben>
Status: RESOLVED FIXED    
Severity: Normal CC: cmarrin, darin, simon.fraser
Priority: P2 Keywords: PlatformOnly
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows XP   
Attachments:
Description Flags
Clean up PlatformCAAnimationWin simon.fraser: review+

Description Adam Roben (:aroben) 2011-01-21 09:38:58 PST
PlatformCAAnimationWin is leaky and inefficient
Comment 1 Adam Roben (:aroben) 2011-01-21 09:40:28 PST
Created attachment 79752 [details]
Clean up PlatformCAAnimationWin
Comment 2 Simon Fraser (smfr) 2011-01-21 10:02:50 PST
Comment on attachment 79752 [details]
Clean up PlatformCAAnimationWin

View in context: https://bugs.webkit.org/attachment.cgi?id=79752&action=review

> Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp:125
> -static CACFTimingFunctionRef toCACFTimingFunction(const TimingFunction* timingFunction)
> +static RetainPtr<CACFTimingFunctionRef> toCACFTimingFunction(const TimingFunction* timingFunction)

Do we use the create moniker for things that return RetainPtrs?
Comment 3 Adam Roben (:aroben) 2011-01-21 10:09:06 PST
Comment on attachment 79752 [details]
Clean up PlatformCAAnimationWin

View in context: https://bugs.webkit.org/attachment.cgi?id=79752&action=review

>> Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp:125
>> +static RetainPtr<CACFTimingFunctionRef> toCACFTimingFunction(const TimingFunction* timingFunction)
> 
> Do we use the create moniker for things that return RetainPtrs?

I don't think we do. Since there's no way to incorrectly handle the lifetime when a RetainPtr is returned, there's no need to use the "Create" pattern.
Comment 4 Darin Adler 2011-01-21 10:32:20 PST
(In reply to comment #3)
> >> +static RetainPtr<CACFTimingFunctionRef> toCACFTimingFunction(const TimingFunction* timingFunction)
> > 
> > Do we use the create moniker for things that return RetainPtrs?
> 
> I don't think we do.

I think sometimes we do. I’d have to look to find examples, but I believe they exist.

> Since there's no way to incorrectly handle the lifetime when a RetainPtr is returned, there's no need to use the "Create" pattern.

I agree that you don’t need Create/Copy just to avoid basic reference counting mistakes with smart pointers, but I do still think a name that alludes to the fact that it’s a new object and so can be costly for memory might be helpful. So I’d use Create but not Copy in names. And it’s not going to be as precise as the “this gives you a reference you need to balance with release or adopt” rule.
Comment 5 Adam Roben (:aroben) 2011-01-21 10:32:32 PST
Committed r76358: <http://trac.webkit.org/changeset/76358>
Comment 6 Adam Roben (:aroben) 2011-01-21 10:34:40 PST
(In reply to comment #4)
> (In reply to comment #3)
> > Since there's no way to incorrectly handle the lifetime when a RetainPtr is returned, there's no need to use the "Create" pattern.
> 
> I agree that you don’t need Create/Copy just to avoid basic reference counting mistakes with smart pointers, but I do still think a name that alludes to the fact that it’s a new object and so can be costly for memory might be helpful. So I’d use Create but not Copy in names. And it’s not going to be as precise as the “this gives you a reference you need to balance with release or adopt” rule.

This function sometimes creates a new object and sometimes returns an existing object, but we could probably still come up with an accurate name.