KhronosGroup/WebGL

Clarify "compositing operation" and preserveDrawingBuffer==false

Opened this issue · 1 comments

  1. Can WebGL context of a non-attached HTMLCanvasElement ever be subject to "compositing operation"?

  2. Is capture done by CanvasCaptureMediaStreamTrack.requestCapture() a "compositing operation" https://w3c.github.io/mediacapture-fromelement/#the-canvascapturemediastreamtrack

https://registry.khronos.org/webgl/specs/latest/1.0/#2.2

WebGL presents its drawing buffer to the HTML page compositor immediately before a compositing operation, but only if clear, drawArrays or drawElements have been called since the last compositing operation, while the drawing buffer is the currently bound framebuffer. Before the drawing buffer is presented for compositing the implementation shall ensure that all rendering operations have been flushed to the drawing buffer. By default, after compositing the contents of the drawing buffer shall be cleared to their default values, as shown in the table above.

This default behavior can be changed by setting the preserveDrawingBuffer attribute of the WebGLContextAttributes object. If this flag is true, the contents of the drawing buffer shall be preserved until the author either clears or overwrites them. If this flag is false, attempting to perform operations using this context as a source image after the rendering function has returned can lead to undefined behavior. This includes readPixels or toDataURL calls, or using this context as the source image of another context's texImage2D or drawImage call.

In the above, it begins with :

WebGL presents its drawing buffer to the HTML page compositor immediately before a compositing operation

This appears to leave the not-in-the-tree case undefined, as it it is informally not logical to say "WebGL presents the drawing buffer", since detached elements obviously do not present anything to the HTML page compositor.

The not-in-tree case is important to define what happens with the canvas capture media stream track behavior, with in-tree and out-of-tree elements. Most notably, it should be clarified whether or not not-in-tree but captures canvases are ever subject to the clear.

It is slightly important to define also if OffscreenCanvas.transferToImageBitmap would be codified better, for example to be defined as a "compositing operation".