Clarify OffscreenCanvas.transferToImageBitmap and preserveDrawingBuffer
Opened this issue · 5 comments
Clarify OffscreenCanvas.transferToImageBitmap and preserveDrawingBuffer
It mandates that color buffer is cleared.
Are depth and stencil buffers preserved or cleared?
The transferToImageBitmap() method, when invoked, must run the following steps:
....Set this OffscreenCanvas object's bitmap to reference a newly created bitmap of the same dimensions and color space as the previous bitmap, and with its pixels initialized to [transparent black>(https://drafts.csswg.org/css-color/#transparent-black), or opaque black if the rendering context's alpha flag is set to false.
This means that if the rendering context of this OffscreenCanvas is a WebGLRenderingContext, the value of preserveDrawingBuffer will have no effect. [WEBGL]
I think the depth and stencil buffers, if they exist, should be cleared to the default values defined in https://registry.khronos.org/webgl/specs/latest/1.0/#2.2 . What do you and others think?
The depth, stencil and color buffers should be cleared if preserveDrawingBuffer == false.
The depth, stencil and color buffers should be preserved if preserveDrawingBuffer == true.
Otherwise transferToImageBitmap + Placeholder Canvas + preserveDrawingBuffer == true seems hard to implement:
- A early transferToImageBitmap would clear
- A later commit to placeholder canvas would preserve
- --> code needs to support both
I agree, clearing implies clearing depth-stencil as well.
WIP:
https://github.com/kdashg/whatwg-html/tree/transfertoimagebitmap-clear-all
kdashg/whatwg-html@2a9bce1
Needs tests I think.
- KR: Kimmo, could you write a test for this?
- KK: If someone was relying on the previous spec - we're going to say that you should change your code
- KG: thought this was just a clarification. Thought depth/stencil was cleared if and only if the color buffer was cleared.
- KK: clarity is around depth/stencil buffer. Not mentioned at all. Other thing to clarify - how does preserveDrawingBuffer affect all the buffers?
- Today, most implementations clear upon transferToImageBitmap regardless of preserveDrawingBuffer state
- KG: if you want to change the preserveDrawingBuffer semantics, that's not a clarification. But if you want to state that depth/stencil are cleared, that's a clarification.
- Agreed:
- We'll clear depth/stencil if and only if color is cleared
- AIs:
- KG to write the spec change
- KK to write the test