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

Update to reflect WhatWG changes #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ccameron-chromium
Copy link
Contributor

In WhatWG review, a handful of changes were made to this proposal. Update to reflect these changes, to avoid confusion.

  • Note that WebGL/GPU parts are in separate review from Canvas2D changes
  • Update ImageData interface to use an attribute
  • Update getImageData and createImageData methods to use canvas's color space by default
  • Move ImageBitmap changes to be discussed under WebGL (similarly not part of the Canvas2D changes)

@@ -110,6 +103,8 @@ When an unsupported color space is requested, the color space will fall back to

### WebGL

_NOTE: This section is not finalized and is being fleshed out and reviewed in Khronos_
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you like to link to KhronosGroup/WebGL#3285 ?

@@ -125,8 +120,12 @@ In implementations in which a ``UNPACK_COLORSPACE_CONVERSION_WEBGL`` of ``BROWSE

Note that, while convenient, this behavior is likely less efficient than specifying color conversion in ``ImageBitmapOptions``, where the color conversion may be done asynchronously and simultaneously with image decode.

An mechanism for using ``ImageBitmapOptions`` to specify color space conversion will be added in the context of WebGL color space support, to support asynchronous and decode-time color space conversion for texture data upload.
Copy link
Contributor

Choose a reason for hiding this comment

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

An mechanism -> A mechanism

WebGL's spec is managed outside of the W3C, so it's infeasible for it to make changes to the ImageBitmapOptions dictionary. Those changes will need to be made in the WHATWG spec.

### WebGPU

_NOTE: This section is not finalized and is being fleshed out and reviewed in Khronos_
Copy link
Contributor

Choose a reason for hiding this comment

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

Not in Khronos - in the W3C. May want to link to https://github.com/gpuweb/gpuweb . I'm not sure there's a pull request open for this yet. cc @kainino0x @Kangz

Choose a reason for hiding this comment

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

It's in progress. The section to link to is https://gpuweb.github.io/gpuweb/#color-spaces which links to the other relevant parts of the spec. There are some open github issues still, but everything is tracked inline in the spec.

For copying into WebGPU (done): https://gpuweb.github.io/gpuweb/#gpu-image-copy-texture-tagged
Importing (done except premultiplyAlpha): https://gpuweb.github.io/gpuweb/#external-texture-creation
Canvas output (not done, has issue): https://gpuweb.github.io/gpuweb/#presentation-configuration

@@ -151,26 +150,14 @@ Canvas contents are composited in accordance with the canvas element's style (e.
The chromiumance of color values outside of [0, 1] is not to be clamped, and extended values may be used to display colors outside of the gamut defined by the canvas' color space's primaries.
This is in contrast with luminance, which is to be clamped to the maximum standard dynamic range luminance, unless high dynamic range is explicitly enabled for the canvas element.

### ImageBitmap
Copy link
Contributor

Choose a reason for hiding this comment

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

Per comment above, these changes can't be made in the WebGL or WebGPU specs; they need to be made in the WHATWG HTML spec. I think it's worth just leaving this here so that we know we have to make these changes in the WHATWG later.

### WebGPU

_NOTE: This section is not finalized and is being fleshed out and reviewed in Khronos_

Choose a reason for hiding this comment

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

It's in progress. The section to link to is https://gpuweb.github.io/gpuweb/#color-spaces which links to the other relevant parts of the spec. There are some open github issues still, but everything is tracked inline in the spec.

For copying into WebGPU (done): https://gpuweb.github.io/gpuweb/#gpu-image-copy-texture-tagged
Importing (done except premultiplyAlpha): https://gpuweb.github.io/gpuweb/#external-texture-creation
Canvas output (not done, has issue): https://gpuweb.github.io/gpuweb/#presentation-configuration

@@ -180,15 +167,14 @@ IDL:
<pre>
partial interface ImageData {
constructor(unsigned long sw, unsigned long sh, optional ImageDataSettings);

Choose a reason for hiding this comment

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

Missing an argument name.

Also, it can default to {} since that's effectively the default value. You could make the same change createImageData/getImageData too

Suggested change
constructor(unsigned long sw, unsigned long sh, optional ImageDataSettings);
constructor(unsigned long sw, unsigned long sh, optional ImageDataSettings settings = {});

constructor(ImageDataArray data, unsigned long sw, unsigned long sh, optional ImageDataSettings);
readonly ImageDataSettings getImageDataSettings();
readonly attribute ImageDataArray data;
constructor(Uint8ClampedArray data, unsigned long sw, unsigned long sh, optional ImageDataSettings);

Choose a reason for hiding this comment

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

Suggested change
constructor(Uint8ClampedArray data, unsigned long sw, unsigned long sh, optional ImageDataSettings);
constructor(Uint8ClampedArray data, unsigned long sw, unsigned long sh, optional ImageDataSettings settings = {});

### ImageData

Add the following types to be used by `ImageData`.

IDL:
<pre>
dictionary ImageDataSettings {
PredefinedColorSpaceEnum colorSpace = "srgb";
PredefinedColorSpaceEnum colorSpace;
Copy link
Member

Choose a reason for hiding this comment

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

Remove "Enum"

* The constructors now take an optional `ImageDataSettings` dictionary.
* The ImageDataSettings attribute may be queried using `getImageDataSettings`.
The changes to this interface are that the constructors now take an optional `ImageDataSettings` dictionary.
If this dictionary is specified and has a `colorSpace` entry, then the resulting `ImageData` will be created with the specified color space.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If this dictionary is specified and has a `colorSpace` entry, then the resulting `ImageData` will be created with the specified color space.
If this dictionary is specified and has a `colorSpace` member, then the resulting `ImageData` will store pixel data in the specified color space.

* The ImageDataSettings attribute may be queried using `getImageDataSettings`.
The changes to this interface are that the constructors now take an optional `ImageDataSettings` dictionary.
If this dictionary is specified and has a `colorSpace` entry, then the resulting `ImageData` will be created with the specified color space.
If no dictionary is specified, or the specified dictionary does not specify a `colorSpace` entry, then the resulting `ImageData` will be created as ``"srgb"``.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If no dictionary is specified, or the specified dictionary does not specify a `colorSpace` entry, then the resulting `ImageData` will be created as ``"srgb"``.
If no dictionary is specified, or the specified dictionary does not specify a `colorSpace` member, then the resulting `ImageData` will store pixel data in the ``"srgb"`` color space.

* The ImageDataSettings attribute may be queried using `getImageDataSettings`.
The changes to this interface are that the constructors now take an optional `ImageDataSettings` dictionary.
If this dictionary is specified and has a `colorSpace` entry, then the resulting `ImageData` will be created with the specified color space.
If no dictionary is specified, or the specified dictionary does not specify a `colorSpace` entry, then the resulting `ImageData` will be created as ``"srgb"``.

When an ``ImageData`` is used in a canvas (e.g, in ``putImageData``), the data is converted from the ``ImageData``'s color space to the color space of the canvas.
Copy link
Member

Choose a reason for hiding this comment

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

This should be rephrased to indicate that the conversion can be in either direction (put vs. get)

The changes to this interface are the addion of the optional ``ImageDataSettings`` argument. If this argument is unspecified, then the default value of ``colorSpace="srgb"`` will be used (this default match previous behavior).
The changes to this interface are the addition of the optional `ImageDataSettings` argument.
If this dictionary is specified and has a `colorSpace` entry, then the resulting `ImageData` will be created with the specified color space.
If no dictionary is specified, or the specified dictionary does not specify a `colorSpace` entry, then the resulting `ImageData` will default to using the same color space as the `CanvasRenderingContext2D` that the method is called on.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If no dictionary is specified, or the specified dictionary does not specify a `colorSpace` entry, then the resulting `ImageData` will default to using the same color space as the `CanvasRenderingContext2D` that the method is called on.
If no dictionary is specified, or the specified dictionary does not specify a `colorSpace` member, then the resulting `ImageData` will default to using the same color space as the `CanvasRenderingContext2D` that the method is called on.

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

Successfully merging this pull request may close these issues.

4 participants