Specify copy rules for different canvas contexts#4366
Conversation
|
Previews, as seen when this build job started (44fb51c): |
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
52711a5 to
2f1e624
Compare
|
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? |
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. |
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.
|
ping |
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.