diff --git a/source b/source index 904af003371..aca1fca2637 100644 --- a/source +++ b/source @@ -2845,6 +2845,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • overridden constructor steps
  • internally create a new object implementing the interface
  • array index property name
  • +
  • buffer source byte length
  • supports indexed properties
  • supported property indices
  • determine the value of an indexed property
  • @@ -2907,6 +2908,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • DOMString
  • double
  • enumeration
  • +
  • Float16Array
  • Function
  • long
  • object
  • @@ -66035,19 +66037,25 @@ interface TextMetrics { readonly attribute double ideographicBaseline; }; +typedef (Uint8ClampedArray or Float16Array) ImageDataArray; + +enum ImageDataPixelFormat { "rgba-unorm8", "rgba-float16" }; + dictionary ImageDataSettings { PredefinedColorSpace colorSpace; + ImageDataPixelFormat pixelFormat = "rgba-unorm8"; }; [Exposed=(Window,Worker), Serializable] interface ImageData { constructor(unsigned long sw, unsigned long sh, optional ImageDataSettings settings = {}); - constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh, optional ImageDataSettings settings = {}); + constructor(ImageDataArray data, unsigned long sw, optional unsigned long sh, optional ImageDataSettings settings = {}); readonly attribute unsigned long width; readonly attribute unsigned long height; - readonly attribute Uint8ClampedArray data; + readonly attribute ImageDataArray data; + readonly attribute ImageDataPixelFormat pixelFormat; readonly attribute PredefinedColorSpace colorSpace; }; @@ -70400,13 +70408,12 @@ try {
    imageData = new ImageData(data, sw [, sh [, settings ] ])
    -

    Returns an ImageData object using the data provided in the Uint8ClampedArray argument, interpreted using the given - dimensions and the color space indicated by settings.

    +

    Returns an ImageData object using the data provided in the ImageDataArray + argument, interpreted using the given dimensions and the color space indicated by settings.

    -

    As each pixel in the data is represented by four numbers, the length of the data needs to be - a multiple of four times the given width. If the height is provided as well, then the length - needs to be exactly the width times the height times 4.

    +

    The byte length of the data needs to be a multiple of the number of bytes per pixel times the + given width. If the height is provided as well, then the length needs to be exactly the number of + bytes per pixel times the width times the height.

    Throws an "IndexSizeError" DOMException if the given data and dimensions can't be interpreted consistently, or if either dimension is zero.

    @@ -70480,8 +70487,7 @@ try { "IndexSizeError" DOMException.

  • Initialize this given - sw, sh, and settings set to settings.

  • + sw, sh, and settings.

  • Initialize the image data of this to transparent black.

  • @@ -70491,12 +70497,16 @@ try { constructor steps are:

      -
    1. Let length be the number of bytes in data.

    2. +
    3. Let bytesPerPixel be 4 if + settings["pixelFormat"] is + "rgba-unorm8"; otherwise 8.

    4. + +
    5. Let length be the buffer source byte length of data.

    6. -
    7. If length is not a nonzero integral multiple of four, then throw an +

    8. If length is not a nonzero integral multiple of bytesPerPixel, then throw an "InvalidStateError" DOMException.

    9. -
    10. Let length be length divided by four.

      +
    11. Let length be length divided by bytesPerPixel.

    12. If length is not an integral multiple of sw, then throw an @@ -70514,13 +70524,11 @@ try {

    13. Initialize this given - sw, sh, settings set to settings, and + sw, sh, settings, and source set to data.

      This step does not set this's data to a copy of data. - It sets it to the actual Uint8ClampedArray object - passed as data.

      + It sets it to the actual ImageDataArray object passed as data.

    @@ -70535,10 +70543,10 @@ try {
  • Let newImageData be a new ImageData object.

  • Initialize newImageData - given the absolute magnitude of sw, the absolute magnitude of sh, settings set to settings, and - defaultColorSpace set to - this's color space.

  • + given the absolute magnitude of sw, the absolute magnitude of sh, + settings, and + defaultColorSpace set to this's + color space.

  • Initialize the image data of newImageData to transparent black.

  • @@ -70553,12 +70561,16 @@ try {
    1. Let newImageData be a new ImageData object.

    2. +
    3. Let settings be the ImageDataSettings object «[ + "colorSpace" → + this's colorSpace, + "pixelFormat" → + this's pixelFormat ]».

    4. +
    5. Initialize newImageData given the value of imageData's width attribute, the value of imageData's height - attribute, and defaultColorSpace set to the value of - imageData's colorSpace attribute.

    6. + attribute, and settings.

    7. Initialize the image data of newImageData to transparent black.

    8. @@ -70581,8 +70593,7 @@ try {
    9. Let imageData be a new ImageData object.

    10. Initialize imageData given - sw, sh, settings set to settings, and + sw, sh, settings, and defaultColorSpace set to this's color space.

    11. @@ -70607,32 +70618,63 @@ try {

      To initialize an ImageData object imageData, given a - positive integer number of rows rows, a positive integer number of pixels per row - pixelsPerRow, an optional ImageDataSettings settings, an optional Uint8ClampedArray source, and an optional - PredefinedColorSpace pixelsPerRow, a positive integer number + of rows rows, an ImageDataSettings settings, an optional + ImageDataArray source, + and an optional PredefinedColorSpace defaultColorSpace:

        -
      1. If source was given, then initialize the data attribute of imageData to - source.

      2. +
      3. +

        If source was given:

        + +
          +
        1. If settings["pixelFormat"] + equals "rgba-unorm8" and + source is not a Uint8ClampedArray, + then throw an "InvalidStateError" DOMException.

        2. + +
        3. If settings["pixelFormat"] + is "rgba-float16" and + source is not a Float16Array, + then throw an "InvalidStateError" DOMException.

        4. + +
        5. Initialize the data attribute of imageData to + source.

        6. +
        +
      4. -

        Otherwise (source was not given), initialize the data attribute of imageData to a new Uint8ClampedArray object. The Uint8ClampedArray object must use a new Canvas - Pixel ArrayBuffer for its storage, and must have a - zero start offset and a length equal to the length of its storage, in bytes. The Canvas - Pixel ArrayBuffer must have the correct size to - store rows × pixelsPerRow pixels.

        +

        Otherwise (source was not given):

        + +
          +
        1. If settings["pixelFormat"] is "rgba-unorm8", then initialize the data attribute of imageData to a new Uint8ClampedArray object. The Uint8ClampedArray object must use a new + ArrayBuffer for its storage, and must have + a zero byte offset and byte length equal to the length of its storage, in bytes. + The storage ArrayBuffer must have a length + of 4 × rows × pixelsPerRow bytes.

        2. + +
        3. Otherwise, if settings["pixelFormat"] is "rgba-float16", then initialize the data attribute of imageData to a new Float16Array object. The Float16Array object must use a new + ArrayBuffer for its storage, and must have + a zero byte offset and byte length equal to the length of its storage, in bytes. + The storage ArrayBuffer must have a length + of 8 × rows × pixelsPerRow bytes.

        4. -

          If the Canvas Pixel ArrayBuffer cannot be - allocated, then rethrow the RangeError thrown by JavaScript, - and return.

          +
        5. If the storage ArrayBuffer could not be + allocated, then rethrow the RangeError thrown by JavaScript, + and return.

        6. +
      5. Initialize the height attribute of imageData to rows.

      6. -
      7. If settings was given and settings["colorSpace"] exists, then initialize the

        Initialize the + pixelFormat + attribute of imageData to + settings["pixelFormat"].

      8. + +
      9. If settings["colorSpace"] + exists, then initialize the colorSpace attribute of imageData to settings["colorSpace"].

      10. -
      11. Otherwise, if defaultColorSpace was given, then initialize the colorSpace attribute of imageData to - defaultColorSpace.

      12. -
      13. Otherwise, initialize the colorSpace attribute of imageData to "srgb".

      14. @@ -70674,6 +70717,9 @@ try {
      15. Set serialized.[[ColorSpace]] to the value of value's colorSpace attribute.

      16. + +
      17. Set serialized.[[PixelFormat]] to the value of value's pixelFormat attribute.

      Their deserialization steps, given serialized, value, @@ -70691,15 +70737,38 @@ try {

    12. Initialize value's colorSpace attribute to serialized.[[ColorSpace]].

    13. -
    -

    A Canvas Pixel ArrayBuffer is an ArrayBuffer whose data is represented in left-to-right order, row - by row top to bottom, starting with the top left, with each pixel's red, green, blue, and alpha - components being given in that order for each pixel. Each component of each pixel represented in - this array must be in the range 0..255, representing the 8 bit value for that component. The - components must be assigned consecutive indices starting with 0 for the top left pixel's red - component.

    +
  • Initialize value's pixelFormat + attribute to serialized.[[PixelFormat]].

  • + + +

    The ImageDataPixelFormat enumeration is used to specify type of the + data attribute of an ImageData + and the arrangement and numerical representation of the color components for each pixel.

    + +

    The "rgba-unorm8" value indicates that the + data attribute of an ImageData must be of + type Uint8ClampedArray. The color components of each + pixel must be stored in four sequential elements in the order of red, green, blue, and then alpha. + Each element represents the 8-bit unsigned normalized value for that component.

    + +

    The "rgba-float16" value indicates that the + data attribute of an ImageData must be of + type Float16Array. The color components of each pixel must + be stored in four sequential elements in the order of red, green, blue, and then alpha. Each + element represents the value for that component.

    + +

    An ImageData object + represents a rectanglar bitmap with width equal to the + width attribute and height equal to the height + attribute. The pixel values of this bitmap are stored in the + data attribute in left-to-right order, row by row from top to bottom, starting with 0 for + the top left pixel, with the order and numerical representation of the color components of each + pixel determined by the pixelFormat attribute. + The color space of the pixel values of the bitmap is determined by the colorSpace attribute.

    The putImageData(imageData, @@ -70777,7 +70846,7 @@ try { set the pixel with coordinate (dx+x, dy+y) in bitmap to the color of the pixel at coordinate (x, y) in the imageData data structure's - Canvas Pixel ArrayBuffer, + bitmap, converted from imageData's colorSpace to the color space of bitmap using 'relative-colorimetric' rendering intent.