Bug 227538

Summary: Use vImage for WebGL toDataURL image y-flip
Product: WebKit Reporter: Kimmo Kinnunen <kkinnunen>
Component: WebGLAssignee: Kimmo Kinnunen <kkinnunen>
Status: ASSIGNED ---    
Severity: Normal CC: dino, kbr, kkinnunen, sabouhallawa, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=156129
Bug Depends on: 227539    
Bug Blocks:    

Description Kimmo Kinnunen 2021-06-30 11:00:32 PDT
Use vImage for WebGL toDataURL image y-flip

Came up in bug 223920 review
Comment 1 Kimmo Kinnunen 2021-06-30 11:01:35 PDT
Sam, do you have a suggestion how to expose this through the layers so that it's consistent with PixelBufferConversion.h API
Comment 2 Said Abou-Hallawa 2021-06-30 12:43:17 PDT
Came up in bug 156129 review.
Comment 3 Sam Weinig 2021-07-01 10:32:02 PDT
I think my best idea is that instead of flipping at all we should see if we can just pass the flipped PixelBuffer to data() and dataURL() (with some indication it is flipped, maybe a new FlippedPixelBuffer type) and have the code that actually encodes the data and use a custom CGDataProvider to feed the data row by row backwards.
Comment 4 Said Abou-Hallawa 2021-07-01 11:14:14 PDT
Or you add the following function to PixelBuffer:

    PixelBuffer yFlipped() const;

And the code in GraphicsContextGLOpenGL::paintRenderingResultsToPixelBuffer() can look like this:

    if (auto results = readRenderingResultsForPainting())
        return results->yFlipped();
    return std::nullopt;
Comment 5 Sam Weinig 2021-07-01 12:36:51 PDT
(In reply to Said Abou-Hallawa from comment #4)
> Or you add the following function to PixelBuffer:
> 
>     PixelBuffer yFlipped() const;
> 
> And the code in
> GraphicsContextGLOpenGL::paintRenderingResultsToPixelBuffer() can look like
> this:
> 
>     if (auto results = readRenderingResultsForPainting())
>         return results->yFlipped();
>     return std::nullopt;

I think rather than adding members to PixelBuffer, I would prefer a free function like in PixelBufferConversion.h that takes a PixelBufferConversionView (perhaps renamed to PixelBufferView).
Comment 6 Radar WebKit Bug Importer 2021-07-07 11:01:18 PDT
<rdar://problem/80279046>