Skip to content

Specify copy rules for different canvas contexts#4366

Merged
kainino0x merged 2 commits intogpuweb:mainfrom
greggman:update-copies-spec-for-webgl-and-imagebitmap
Apr 2, 2024
Merged

Specify copy rules for different canvas contexts#4366
kainino0x merged 2 commits intogpuweb:mainfrom
greggman:update-copies-spec-for-webgl-and-imagebitmap

Conversation

@greggman
Copy link
Contributor

@greggman greggman commented Nov 7, 2023

WebGL contexts use context.drawingBufferWidth and
context.drawingBufferHeight.

ImageBitmapRenderingContexts use their internal
"output bitmap"'s width and height (which are
opaque to the app) but the app itself
added the ImageBitmap to the context
and so had it's chance to know the size.

HTMLImageElement uses naturalWidth and naturalHeight

ImageData uses width, heigh

See #4255 and #4256

Note: It wasn't clear to me what to link to. The WebGL IDL lists these properties as part of WebGLRenderingContextxBase which is used by both WebGL and WebGL2. Further, they're only specified in the WebGL spec but not the WebGL2 spec. The links current go the the place these are documented.

Also, it wasn't clear if I should break out the OffscreenCanvas ones into separate issues. I think they are the same so I combined them rather than adding 3 separate sections, one for each type of context.

Similarly I combined CanvasRenderingContext2D and GPUCanvasContext as they have the same behavior. I can separate those if that's better.

I'm guessing there's probably more specs needed for the color space issues from these sources.

@greggman greggman requested a review from kainino0x November 7, 2023 07:59
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2023

Previews, as seen when this build job started (44fb51c):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt

WebGL contexts use context.drawingBufferWidth and
context.drawingBufferHeight.

ImageBitmapRenderingContexts use their internal
"output bitmap"'s width and height (which are
opaque to the app) but the app itself
created added the ImageBitmap to the context
and so had it's chance to know the size.

HTMLImageElement uses naturalWidth and naturalHeight

ImageData uses width, height
@greggman greggman force-pushed the update-copies-spec-for-webgl-and-imagebitmap branch from 52711a5 to 2f1e624 Compare November 7, 2023 08:08
@greggman
Copy link
Contributor Author

greggman commented Nov 7, 2023

I just noticed the HTMLImageElement stuff needs all that wording you eluded to in #4256

Maybe the format of a table with source, width, height, is not a good format for this data?

Maybe it should just be table with 2 columns, source and dimensions?

@kainino0x
Copy link
Contributor

Maybe the format of a table with source, width, height, is not a good format for this data?

Maybe it should just be table with 2 columns, source and dimensions?

Any format is fine with me. Readability is most important because this is useful documentation, moreso than a precise definition (we usually use dictionary member definitions as developer-targeted documentation, and algorithms for the source of truth of key normative information).

"Officially" the dimensions should be determined indirectly, through whatever mechanism gives us the sourceImage, in the algorithm definition - except that's not very clearly defined right now.

@kainino0x
Copy link
Contributor

I just noticed the HTMLImageElement stuff needs all that wording you eluded to in #4256

This section (documentation) should maybe only explain the common case, and defer to somewhere else for the corner cases.

For HTMLImageElement it looks like naturalWidth, naturalHeight
are supposed to always work.
@greggman
Copy link
Contributor Author

greggman commented Apr 1, 2024

ping

Copy link
Contributor

@kainino0x kainino0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, missed this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copyediting Pure editorial stuff (copyediting, *.bs file syntax, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants