Bug 225140 - Add support for display-p3 canvas and ImageData
Summary: Add support for display-p3 canvas and ImageData
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: InRadar
Depends on: 225173 225177 225237 225263 225271 225280 225286 225813 225836 225841
Blocks:
  Show dependency treegraph
 
Reported: 2021-04-27 23:04 PDT by Christopher Cameron
Modified: 2021-07-22 16:14 PDT (History)
4 users (show)

See Also:


Attachments
basic test case (3.39 KB, text/html)
2021-04-28 16:51 PDT, Sam Weinig
no flags Details
Proof of concept patch that gets things working (51.27 KB, patch)
2021-04-28 16:54 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Now with ImageData support (126.94 KB, patch)
2021-04-30 18:25 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Cameron 2021-04-27 23:04:13 PDT
Proposal document:
https://github.com/WICG/canvas-color-space/blob/main/CanvasColorSpaceProposal.md

Syntax for creating such a canvas is
     var context = canvas.getContext('2d', {colorSpace:'display-p3'});

Similar syntax for use with ImageData.

Corresponding bugs:
Chromium: crbug.com/1083693
Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1703654
Comment 1 Sam Weinig 2021-04-28 16:51:47 PDT
Created attachment 427308 [details]
basic test case
Comment 2 Sam Weinig 2021-04-28 16:54:54 PDT
Created attachment 427309 [details]
Proof of concept patch that gets things working
Comment 3 Sam Weinig 2021-04-30 18:25:12 PDT
Created attachment 427479 [details]
Now with ImageData support
Comment 4 Christopher Cameron 2021-05-01 16:23:55 PDT
Very excited to see this!

There are a couple of things that changed from the proposal to what was agreed upon in the WhatWG PR. To draw your attention to them:

* The PredefinedColorSpace interface to query for valid PredefinedColorSpaceEnum values is gone. There's just PredefinedColorSpace as an enum (with "srgb" and "display-p3" as options). 

* For ImageDataSettings, the PredefinedColorSpace is optional. The canvas methods getImageData and createImageData will use the color space of the canvas if colorSpace was not specified in ImageDataSettings.

* The ImageBitmap part was taken out (ImageBitmapOptions will change to have an optional PredefinedColorSpace, rather than a required one, so that the ImageBitmap will default internally to "whatever is the best internal color space")

I think that's it. We're working on upstreaming WPT tests for all of this. Feel free to reach out.
Comment 5 Sam Weinig 2021-05-02 10:39:55 PDT
(In reply to Christopher Cameron from comment #4)
> Very excited to see this!
> 
> There are a couple of things that changed from the proposal to what was
> agreed upon in the WhatWG PR. To draw your attention to them:

Great. Thanks for letting me know and continuing to drive this.

Is that PR up for review anywhere?
Comment 6 Sam Weinig 2021-05-03 16:43:07 PDT
(In reply to Sam Weinig from comment #5)
> (In reply to Christopher Cameron from comment #4)
> > Very excited to see this!
> > 
> > There are a couple of things that changed from the proposal to what was
> > agreed upon in the WhatWG PR. To draw your attention to them:
> 
> Great. Thanks for letting me know and continuing to drive this.
> 
> Is that PR up for review anywhere?

Found it. Better yet, it is now in main!

https://github.com/whatwg/html/commit/85cb202a052c462bd6830b3dda96e7edbd1dcd75
Comment 7 Sam Weinig 2021-05-03 16:44:06 PDT
Tracking initial support (no ImageData) in https://bugs.webkit.org/show_bug.cgi?id=225286.
Comment 8 Radar WebKit Bug Importer 2021-05-04 23:05:16 PDT
<rdar://problem/77542907>
Comment 9 Sam Weinig 2021-05-14 21:05:38 PDT
ImageData support now being worked on in https://bugs.webkit.org/show_bug.cgi?id=225841.
Comment 10 Sam Weinig 2021-05-14 21:13:18 PDT
Additional things to do after ImageData:
- Ensure it works and add tests for drawing non-sRGB CanvasImageSources (image, videos, other canvases) into canvas (including patterns).
- Ensure it works and add tests for drawing non-sRGB gradients.
- Ensure it works and add tests for drawing non-sRGB shadows.