Bug 218179 - Make GraphicsContextGL draw to ImageBuffer
Summary: Make GraphicsContextGL draw to ImageBuffer
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kimmo Kinnunen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-10-26 06:00 PDT by Kimmo Kinnunen
Modified: 2020-11-05 18:03 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kimmo Kinnunen 2020-10-26 06:00:05 PDT
Make GraphicsContextGL draw to ImageBuffer

Current ownership for WebGL canvas is roughly:

HTMLCanvasElement -> WebGLRenderingContextBase -> GraphicsContextGL -> WebGLLayer

Current ownership for 2D canvas is roughly:

HTMLCanvasElement -> CanvasBase -> ImageBuffer -> context 

This discrepancy is probably not warranted solely by the difference wrt 2D painting to document vs. WebGL "rendering to ac layer".

There appears to be a lot of confusion because WebGL does not have a concept of a HTMLCanvasElement -level manipulatable drawing buffer and display buffer.

Instead, when HTMLCanvasElement needs WebGL contents to its ImageBuffer, there is all sorts of hoops to be jumped and the code itself ends up buggy and suboptimal.

Current:
* clear logic is buggy
* print / snapshot logic is buggy
* Element::toDataURL logic is buggy
* There's disproportionally high complexity and low quality implementation of reading back the WebGL canvas for above

In addition, the webgl abstraction is wrong way around in order to do logical "remote webgl". 

The abstraction should/could be:
- HTMLCanvasElement -> ImageBuffer 
- Create GraphicsContextGL that draws to this ImageBuffer
- Create WebGLLayer (e.g. IOSurfaceLayer) that receives snapshots of the ImageBuffer during preparing the drawing buffer as display buffer
- HTMLCanvasElement (et al) would operate mostly on the ImageBuffer, not large number of "if (is<WebGLRenderingContextBase>)" type code.
Comment 1 Radar WebKit Bug Importer 2020-11-02 05:01:14 PST
<rdar://problem/70946153>