Bug 141578

Summary: Make WebCore::IOSurface have single ownership instead of refcounting
Product: WebKit Reporter: Tim Horton <thorton>
Component: New BugsAssignee: Tim Horton <thorton>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, sam, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch andersca: review+

Description Tim Horton 2015-02-13 14:44:22 PST
Make WebCore::IOSurface have single ownership instead of refcounting
Comment 1 Tim Horton 2015-02-13 14:44:45 PST
Created attachment 246551 [details]
Patch
Comment 2 Anders Carlsson 2015-02-13 15:17:08 PST
Comment on attachment 246551 [details]
Patch

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

Looks like most of the member variables of IOSurface can be const.

> Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp:138
> +        return WTF::move(surface);

No need to use WTF::move here.

> Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp:155
> +        return WTF::move(surface);

No need to use WTF::move here.

> Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp:174
> +    willAddSurface(surface.get(), surfaceIsInUse);

Maybe this should take a reference.

> Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp:210
> +    std::unique_ptr<IOSurface> surface = m_inUseSurfaces.takeLast();

This should be auto.

> Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp:224
> +    std::unique_ptr<IOSurface> surface = surfaceQueueIter->value.takeLast();

auto.

> Source/WebCore/platform/graphics/cocoa/IOSurface.mm:70
> +    std::unique_ptr<IOSurface> surface = IOSurface::create(IntSize(width, height), ColorSpaceDeviceRGB);

auto.

> Source/WebCore/platform/graphics/cocoa/IOSurface.mm:75
> +    return WTF::move(surface);

No need to use WTF::move here.

> Source/WebKit2/UIProcess/API/mac/WKView.mm:3229
> +    std::unique_ptr<IOSurface> surface = IOSurface::createFromImage(croppedSnapshotImage.get());

auto!

> Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm:137
> +PassRefPtr<ViewSnapshot> ViewSnapshot::create(std::unique_ptr<IOSurface> surface)

This should return a Ref.

> Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm:161
> +#if USE_IOSURFACE_VIEW_SNAPSHOTS
> +    m_imageSizeInBytes = m_surface->totalBytes();
> +    m_size = m_surface->size();
> +#endif

These can be member initializers.
Comment 3 Tim Horton 2015-02-13 16:08:41 PST
http://trac.webkit.org/changeset/180088
Comment 4 Tim Horton 2015-02-13 16:16:13 PST
And a build fix: http://trac.webkit.org/changeset/180089