Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify "compositing operation" and preserveDrawingBuffer==false #3615

Open
kkinnunen-apple opened this issue Jan 31, 2024 · 1 comment
Open
Assignees

Comments

@kkinnunen-apple
Copy link
Contributor

kkinnunen-apple commented Jan 31, 2024

  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

@kkinnunen-apple
Copy link
Contributor Author

kkinnunen-apple commented Feb 8, 2024

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants