Bug 141578 - Make WebCore::IOSurface have single ownership instead of refcounting
Summary: Make WebCore::IOSurface have single ownership instead of refcounting
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-13 14:44 PST by Tim Horton
Modified: 2015-02-13 16:16 PST (History)
3 users (show)

See Also:


Attachments
Patch (21.22 KB, patch)
2015-02-13 14:44 PST, Tim Horton
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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