Bug 130529 - Add WebCore::IOSurface wrapper
Summary: Add WebCore::IOSurface wrapper
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-20 12:30 PDT by Tim Horton
Modified: 2014-03-20 15:08 PDT (History)
5 users (show)

See Also:


Attachments
patch (38.64 KB, patch)
2014-03-20 14:08 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
style (38.75 KB, patch)
2014-03-20 14:16 PDT, Tim Horton
simon.fraser: 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 2014-03-20 12:30:54 PDT
We've been spreading IOSurface code around WebCore and WebKit2 which is SPI, and picky about how it's used.

We should wrap it in a C++ class to hide some of the pickyness, drag some extra context around with them, and overall make surfaces easier to use.
Comment 1 Tim Horton 2014-03-20 12:39:29 PDT
Renamed at Anders/Sam's request.
Comment 2 Tim Horton 2014-03-20 14:08:24 PDT
Created attachment 227331 [details]
patch
Comment 3 WebKit Commit Bot 2014-03-20 14:10:12 PDT
Attachment 227331 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/cocoa/IOSurface.h:33:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h:32:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 2 in 16 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Tim Horton 2014-03-20 14:16:53 PDT
Created attachment 227333 [details]
style
Comment 5 Anders Carlsson 2014-03-20 14:21:32 PDT
Comment on attachment 227333 [details]
style

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

> Source/WebCore/platform/graphics/cocoa/IOSurface.h:52
> +    IOSurfaceRef platformSurface() const { return m_surface.get(); }

Why not call this surface().

> Source/WebCore/platform/graphics/cocoa/IOSurface.h:68
> +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
> +    bool isPurgeable() const;
> +    SurfaceState setIsPurgeable(bool);
> +#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090

Can't we just make these no-ops on older versions?
Comment 6 Simon Fraser (smfr) 2014-03-20 14:25:53 PDT
Comment on attachment 227333 [details]
style

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

> Source/WebCore/ChangeLog:20
> +        * platform/graphics/cocoa/IOSurface.h: Added.

Nope, there's a framework header with this name.
Comment 7 Tim Horton 2014-03-20 14:32:19 PDT
(In reply to comment #5)
> (From update of attachment 227333 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=227333&action=review
> 
> > Source/WebCore/platform/graphics/cocoa/IOSurface.h:52
> > +    IOSurfaceRef platformSurface() const { return m_surface.get(); }
> 
> Why not call this surface().

Sure.

> > Source/WebCore/platform/graphics/cocoa/IOSurface.h:68
> > +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
> > +    bool isPurgeable() const;
> > +    SurfaceState setIsPurgeable(bool);
> > +#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
> 
> Can't we just make these no-ops on older versions?

I guess, I'm just afraid that people will think they're getting purgeability and have issues. But since it's internal, I guess that's OK.
Comment 8 Tim Horton 2014-03-20 14:32:32 PDT
(In reply to comment #6)
> (From update of attachment 227333 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=227333&action=review
> 
> > Source/WebCore/ChangeLog:20
> > +        * platform/graphics/cocoa/IOSurface.h: Added.
> 
> Nope, there's a framework header with this name.

And yet!
Comment 9 Simon Fraser (smfr) 2014-03-20 14:46:33 PDT
Comment on attachment 227333 [details]
style

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

> Source/WebCore/platform/graphics/cocoa/IOSurface.mm:95
> +    ASSERT(m_surface);

I don't think this is very useful; it will fire if height or width is zero (maybe?), and/or on system that have run out of graphics memory.

> Source/WebCore/platform/graphics/cocoa/IOSurface.mm:150
> +    uint32_t previousState;

Maybe initailize this to 0 in case the IOSurfaceSetPurgeable fails and we use uninitialized bits.

> Source/WebCore/platform/graphics/cocoa/IOSurface.mm:151
> +    IOReturn ret = IOSurfaceSetPurgeable(m_surface.get(), kIOSurfacePurgeableKeepCurrent, &previousState);

Weird that a const function is calling IOSurfaceSetPurgeable(). Is that call a no-op?

> Source/WebCore/platform/graphics/cocoa/IOSurface.mm:163
> +    IOReturn ret = IOSurfaceSetPurgeable(m_surface.get(), kIOSurfacePurgeableKeepCurrent, &previousState);

Again.

> Source/WebCore/platform/graphics/cocoa/IOSurface.mm:171
> +    IOReturn ret = IOSurfaceSetPurgeable(m_surface.get(), isPurgeable ? kIOSurfacePurgeableVolatile : kIOSurfacePurgeableNonVolatile, &previousState);

Bored now.

Oh wait, this is a real setter.
Comment 10 Tim Horton 2014-03-20 15:08:30 PDT
http://trac.webkit.org/changeset/166005