-
Notifications
You must be signed in to change notification settings - Fork 345
Allow reading back from canvases after present #2905
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
Conversation
This allows drawImage/toDataURL/etc. to see the canvas contents presented in the previous frame, as long as getCurrentTexture (or configure/unconfigure) hasn't been called yet this frame. alphaMode (née compositingAlphaMode) now affects using the canvas as an image source (drawImage/etc.) as well as compositing, so that the observed contents don't change on a frame boundary. As a weird aside (necessary to fully define the image source behavior), defines super-luminant values as being in the extended color space (i.e. once un-premultiplied). This definition emerges naturally, but it's also weird. Fixes gpuweb#2743 Fixes gpuweb#1847 Fixes a leftover bit from gpuweb#2373 (placeholder canvases)
|
@toji @kdashg @shaoboyan PTAL, but don't worry about the fine details just yet because we still need to bring this proposal to the group. |
|
For some examples of the behavior of this proposal, see here: |
This fixes several problems: - Unnecessary complexity in how currentTexture logic works. - Errors in the previous commit, where this was just not fully handled. - Using the "destroyed" state on the content process (minor issue).
This fixes several problems:
|
|
The proposal for readback after present is accepted, so @toji PTAL |
toji
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Something wrong with CI, forcing merge |
SHA: b085e00 Reason: push, by @kainino0x Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: b085e00 Reason: push, by @kainino0x Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Syncs up Blink with change recently made to the WebGPU spec. See: gpuweb/gpuweb#2905 Bug: 1069302 Change-Id: I091aceabaa1d2998dc39dd575bc0de92e596026f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3673936 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Brandon Jones <bajones@chromium.org> Cr-Commit-Position: refs/heads/main@{#1009248}
Without this, `getCurrentTexture()` doesn't know it's supposed to allocate a new texture, it just keeps using the destroyed one. And related language tweaks. Issue introduced in gpuweb#2905. This PR still implements the behavior described and agreed upon there. Issue found in whatwg/html#8123.
* Set currentTexture to null on presentation Without this, `getCurrentTexture()` doesn't know it's supposed to allocate a new texture, it just keeps using the destroyed one. And related language tweaks. Issue introduced in #2905. This PR still implements the behavior described and agreed upon there. Issue found in whatwg/html#8123. * nit
* Allow reading back from canvases after present This allows drawImage/toDataURL/etc. to see the canvas contents presented in the previous frame, as long as getCurrentTexture (or configure/unconfigure) hasn't been called yet this frame. alphaMode (née compositingAlphaMode) now affects using the canvas as an image source (drawImage/etc.) as well as compositing, so that the observed contents don't change on a frame boundary. As a weird aside (necessary to fully define the image source behavior), defines super-luminant values as being in the extended color space (i.e. once un-premultiplied). This definition emerges naturally, but it's also weird. Fixes gpuweb#2743 Fixes gpuweb#1847 Fixes a leftover bit from gpuweb#2373 (placeholder canvases) * nit * Remove the "cancel present" behavior of destroy() This fixes several problems: - Unnecessary complexity in how currentTexture logic works. - Errors in the previous commit, where this was just not fully handled. - Using the "destroyed" state on the content process (minor issue). * nits * nit
* Set currentTexture to null on presentation Without this, `getCurrentTexture()` doesn't know it's supposed to allocate a new texture, it just keeps using the destroyed one. And related language tweaks. Issue introduced in gpuweb#2905. This PR still implements the behavior described and agreed upon there. Issue found in whatwg/html#8123. * nit
Proposal.
This allows drawImage/toDataURL/etc. to see the canvas contents
presented in the previous frame, as long as getCurrentTexture (or
configure/unconfigure) hasn't been called yet this frame.
alphaMode (née compositingAlphaMode) now affects using the canvas as an
image source (drawImage/etc.) as well as compositing, so that the
observed contents don't change on a frame boundary.
REVISION: destroy()ing a canvas texture now does not cancel presentation.
Instead, it just terminates writable-access to the drawing buffer early.
You can't get a new texture in the same frame without reallocating the
drawing buffer (configure or resize).
As a weird aside (necessary to fully define the image source behavior),
defines super-luminant values as being in the extended color space (i.e.
once un-premultiplied). This definition emerges naturally, but it's also
weird.
Fixes #2743
Fixes #1847
Fixes a leftover bit from #2373 (placeholder canvases)never mind that was for copyExternalImageToTexturePreview | Diff