Bug 225508 - Add an experimental alternative display-list-based RemoteLayerBackingStore implementation
Summary: Add an experimental alternative display-list-based RemoteLayerBackingStore im...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-07 03:33 PDT by Tim Horton
Modified: 2021-05-07 16:57 PDT (History)
4 users (show)

See Also:


Attachments
Patch (42.57 KB, patch)
2021-05-07 03:38 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (42.88 KB, patch)
2021-05-07 03:44 PDT, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (42.75 KB, patch)
2021-05-07 12:06 PDT, Tim Horton
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Horton 2021-05-07 03:33:33 PDT
Add an experimental alternative display-list-based RemoteLayerBackingStore implementation
Comment 1 Tim Horton 2021-05-07 03:38:30 PDT
Created attachment 427987 [details]
Patch
Comment 2 Tim Horton 2021-05-07 03:44:21 PDT
Created attachment 427988 [details]
Patch
Comment 3 Sam Weinig 2021-05-07 08:31:58 PDT
Comment on attachment 427988 [details]
Patch

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

Really excellent work.

> Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:416
> +#if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
> +        , [&] (IPC::SharedBufferCopy& buffer) {
> +            ASSERT(m_type == Type::CGDisplayList);
> +            ASSERT([layer isKindOfClass:[WKCompositingLayer class]]);
> +            if (![layer isKindOfClass:[WKCompositingLayer class]])
> +                return;
> +            [layer setValue:@1 forKeyPath:WKCGDisplayListEnabledKey];
> +            auto data = buffer.buffer()->createCFData();
> +            [(WKCompositingLayer *)layer _setWKContentsDisplayList:data.get()];
>          }

Perhaps in the future we can make this function take a WKCompositingLayer rather than a vanilla CALayer and just typedef WKCompositingLayer to CALayer on platforms where they can be the same thing?

> Source/WebKit/UIProcess/RemoteLayerTree/cocoa/RemoteLayerTreeLayers.h:26
> +#if PLATFORM(COCOA)

#pragma once?

> Source/WebKit/UIProcess/RemoteLayerTree/cocoa/RemoteLayerTreeLayers.h:34
> +@property (nonatomic, retain, setter=_setWKContentsDisplayList:)__attribute__((NSObject)) CFDataRef _wkContentsDisplayList;

I think you want a space before the __attribute__. Also, this can probably be direct.

> Source/WebKit/WebProcess/GPU/graphics/ImageBufferBackendHandle.h:-40
>  #if PLATFORM(COCOA) // FIXME: This is really about IOSurface.
> -    MachSendRight,
> +    MachSendRight
> +#endif
> +    , ShareableBitmap::Handle
> +#if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
> +    , IPC::SharedBufferCopy
>  #endif
> -    ShareableBitmap::Handle

I think this could be a bit neater if we made ShareableBitmap::Handle first here.

using ImageBufferBackendHandle = Variant<
    ShareableBitmap::Handle
#if PLATFORM(COCOA) // really should be HAVE(IOSURFACE) or something like that
    , MachSendRight
#endif
#if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
    , IPC::SharedBufferCopy
#endif
>;


Additionally, I think we should probably add struct wrappers for MachSendRight and IPC::SharedBufferCopy in the future to indicate their use a bit better.

struct IOSurfaceImageBufferBackendHandle { MachSendRight handle };
struct CGDisplayListImageBufferBackendHandle { IPC::SharedBufferCopy handle };

using ImageBufferBackendHandle = Variant<
    ShareableBitmap::Handle
#if PLATFORM(COCOA)
    , IOSurfaceImageBufferBackendHandle
#endif
#if ENABLE(CG_DISPLAY_LIST_BACKED_IMAGE_BUFFER)
    , CGDisplayListImageBufferBackendHandle
#endif
>;

This would let the type system tell the story a bit nicer. Not needed in this pass though.
Comment 4 Tim Horton 2021-05-07 12:06:08 PDT
Created attachment 428019 [details]
Patch
Comment 5 EWS 2021-05-07 16:46:13 PDT
Committed r277210 (237482@main): <https://commits.webkit.org/237482@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 428019 [details].
Comment 6 Radar WebKit Bug Importer 2021-05-07 16:47:18 PDT
<rdar://problem/77678782>