Title: [283193] trunk
Revision
283193
Author
[email protected]
Date
2021-09-28 14:10:21 -0700 (Tue, 28 Sep 2021)

Log Message

Preserve color space when structured cloning ImageBitmaps
https://bugs.webkit.org/show_bug.cgi?id=230429
<rdar://problem/83293533>

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

The test added in https://bugs.webkit.org/show_bug.cgi?id=230429 was
buggy, in that by the time the "message" event handler ran, the
values for the various test configuration variables had changed. The
key bugfix here is checking for the right testID value in the message
event handler, but the test is rewritten more substantially to be a bit
clearer and less indented.

* web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned-expected.txt:
* web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned.html:

Source/WebCore:

The logic for serializing the CGColorSpace is copied and adapted from
the ArgumentCoder<CGColorSpaceRef> specialization, which we cannot
easily re-use.

* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpImageBitmap):
(WebCore::CloneSerializer::write):
(WebCore::CloneDeserializer::read):
(WebCore::CloneDeserializer::readImageBitmap):

LayoutTests:

* fast/storage/serialized-script-value.html: Bump the current version
number.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (283192 => 283193)


--- trunk/LayoutTests/ChangeLog	2021-09-28 21:00:40 UTC (rev 283192)
+++ trunk/LayoutTests/ChangeLog	2021-09-28 21:10:21 UTC (rev 283193)
@@ -1,3 +1,14 @@
+2021-09-28  Cameron McCormack  <[email protected]>
+
+        Preserve color space when structured cloning ImageBitmaps
+        https://bugs.webkit.org/show_bug.cgi?id=230429
+        <rdar://problem/83293533>
+
+        Reviewed by Sam Weinig.
+
+        * fast/storage/serialized-script-value.html: Bump the current version
+        number.
+
 2021-09-28  Kate Cheney  <[email protected]>
 
         CSP: Implement 'strict-dynamic' source _expression_

Modified: trunk/LayoutTests/fast/storage/serialized-script-value.html (283192 => 283193)


--- trunk/LayoutTests/fast/storage/serialized-script-value.html	2021-09-28 21:00:40 UTC (rev 283192)
+++ trunk/LayoutTests/fast/storage/serialized-script-value.html	2021-09-28 21:10:21 UTC (rev 283193)
@@ -6,7 +6,7 @@
     <body>
         <script>
 
-const currentVersion = 0x08;
+const currentVersion = 0x09;
 
 // Here's a little Q&D helper for future adventurers needing to rebaseline this.
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (283192 => 283193)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-28 21:00:40 UTC (rev 283192)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-28 21:10:21 UTC (rev 283193)
@@ -1,3 +1,21 @@
+2021-09-28  Cameron McCormack  <[email protected]>
+
+        Preserve color space when structured cloning ImageBitmaps
+        https://bugs.webkit.org/show_bug.cgi?id=230429
+        <rdar://problem/83293533>
+
+        Reviewed by Sam Weinig.
+
+        The test added in https://bugs.webkit.org/show_bug.cgi?id=230429 was
+        buggy, in that by the time the "message" event handler ran, the
+        values for the various test configuration variables had changed. The
+        key bugfix here is checking for the right testID value in the message
+        event handler, but the test is rewritten more substantially to be a bit
+        clearer and less indented.
+
+        * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned-expected.txt:
+        * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned.html:
+
 2021-09-28  Kate Cheney  <[email protected]>
 
         CSP: Implement 'strict-dynamic' source _expression_

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned-expected.txt (283192 => 283193)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned-expected.txt	2021-09-28 21:00:40 UTC (rev 283192)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned-expected.txt	2021-09-28 21:10:21 UTC (rev 283193)
@@ -7,30 +7,30 @@
 PASS sRGB-FF0000FF.png, Context display-p3, ImageData srgb, cropSource=true
 PASS sRGB-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=false
 PASS sRGB-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=true
-FAIL sRGB-FF0000CC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL sRGB-FF0000CC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL sRGB-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL sRGB-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL sRGB-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL sRGB-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL sRGB-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL sRGB-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL sRGB-BB0000FF.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,0,0,255. expected true got false
-FAIL sRGB-BB0000FF.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,0,0,255. expected true got false
-FAIL sRGB-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,255. expected true got false
-FAIL sRGB-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,255. expected true got false
-FAIL sRGB-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,1,0,255. expected true got false
-FAIL sRGB-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,1,0,255. expected true got false
-FAIL sRGB-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,255. expected true got false
-FAIL sRGB-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,255. expected true got false
-FAIL sRGB-BB0000CC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,0,0,204. expected true got false
-FAIL sRGB-BB0000CC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,0,0,204. expected true got false
-FAIL sRGB-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,204. expected true got false
-FAIL sRGB-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,204. expected true got false
-FAIL sRGB-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,1,0,204. expected true got false
-FAIL sRGB-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,1,0,204. expected true got false
-FAIL sRGB-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,204. expected true got false
-FAIL sRGB-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,204. expected true got false
+PASS sRGB-FF0000CC.png, Context srgb, ImageData srgb, cropSource=false
+PASS sRGB-FF0000CC.png, Context srgb, ImageData srgb, cropSource=true
+PASS sRGB-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS sRGB-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS sRGB-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS sRGB-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS sRGB-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS sRGB-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS sRGB-BB0000FF.png, Context srgb, ImageData srgb, cropSource=false
+PASS sRGB-BB0000FF.png, Context srgb, ImageData srgb, cropSource=true
+PASS sRGB-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=false
+PASS sRGB-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=true
+PASS sRGB-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=false
+PASS sRGB-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=true
+PASS sRGB-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS sRGB-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS sRGB-BB0000CC.png, Context srgb, ImageData srgb, cropSource=false
+PASS sRGB-BB0000CC.png, Context srgb, ImageData srgb, cropSource=true
+PASS sRGB-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS sRGB-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS sRGB-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS sRGB-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS sRGB-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS sRGB-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=true
 PASS Display-P3-FF0000FF.png, Context srgb, ImageData srgb, cropSource=false
 PASS Display-P3-FF0000FF.png, Context srgb, ImageData srgb, cropSource=true
 PASS Display-P3-FF0000FF.png, Context srgb, ImageData display-p3, cropSource=false
@@ -37,80 +37,80 @@
 PASS Display-P3-FF0000FF.png, Context srgb, ImageData display-p3, cropSource=true
 PASS Display-P3-FF0000FF.png, Context display-p3, ImageData srgb, cropSource=false
 PASS Display-P3-FF0000FF.png, Context display-p3, ImageData srgb, cropSource=true
-FAIL Display-P3-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,0,0,255. expected true got false
-FAIL Display-P3-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,0,0,255. expected true got false
-FAIL Display-P3-FF0000CC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FF0000CC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL Display-P3-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL Display-P3-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-BB0000FF.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,255. expected true got false
-FAIL Display-P3-BB0000FF.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,255. expected true got false
-FAIL Display-P3-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 188,39,26,255. expected true got false
-FAIL Display-P3-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 188,39,26,255. expected true got false
-FAIL Display-P3-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,255. expected true got false
-FAIL Display-P3-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,255. expected true got false
-FAIL Display-P3-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 187,0,0,255. expected true got false
-FAIL Display-P3-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 187,0,0,255. expected true got false
-FAIL Display-P3-BB0000CC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,204. expected true got false
-FAIL Display-P3-BB0000CC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,204. expected true got false
-FAIL Display-P3-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 188,39,26,204. expected true got false
-FAIL Display-P3-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 188,39,26,204. expected true got false
-FAIL Display-P3-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,204. expected true got false
-FAIL Display-P3-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,204. expected true got false
-FAIL Display-P3-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 187,0,0,204. expected true got false
-FAIL Display-P3-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 187,0,0,204. expected true got false
+PASS Display-P3-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Display-P3-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Display-P3-FF0000CC.png, Context srgb, ImageData srgb, cropSource=false
+PASS Display-P3-FF0000CC.png, Context srgb, ImageData srgb, cropSource=true
+PASS Display-P3-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Display-P3-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Display-P3-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Display-P3-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Display-P3-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Display-P3-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Display-P3-BB0000FF.png, Context srgb, ImageData srgb, cropSource=false
+PASS Display-P3-BB0000FF.png, Context srgb, ImageData srgb, cropSource=true
+PASS Display-P3-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Display-P3-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Display-P3-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Display-P3-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Display-P3-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Display-P3-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Display-P3-BB0000CC.png, Context srgb, ImageData srgb, cropSource=false
+PASS Display-P3-BB0000CC.png, Context srgb, ImageData srgb, cropSource=true
+PASS Display-P3-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Display-P3-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Display-P3-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Display-P3-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Display-P3-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Display-P3-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=true
 PASS Adobe-RGB-FF0000FF.png, Context srgb, ImageData srgb, cropSource=false
 PASS Adobe-RGB-FF0000FF.png, Context srgb, ImageData srgb, cropSource=true
 PASS Adobe-RGB-FF0000FF.png, Context srgb, ImageData display-p3, cropSource=false
 PASS Adobe-RGB-FF0000FF.png, Context srgb, ImageData display-p3, cropSource=true
-FAIL Adobe-RGB-FF0000FF.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,19,11,255. expected true got false
-FAIL Adobe-RGB-FF0000FF.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,19,11,255. expected true got false
-FAIL Adobe-RGB-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,61,43,255. expected true got false
-FAIL Adobe-RGB-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,61,43,255. expected true got false
-FAIL Adobe-RGB-FF0000CC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Adobe-RGB-FF0000CC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Adobe-RGB-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL Adobe-RGB-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL Adobe-RGB-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,19,11,204. expected true got false
-FAIL Adobe-RGB-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,19,11,204. expected true got false
-FAIL Adobe-RGB-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,61,43,204. expected true got false
-FAIL Adobe-RGB-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,61,43,204. expected true got false
-FAIL Adobe-RGB-BB0000FF.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,0,255. expected true got false
-FAIL Adobe-RGB-BB0000FF.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,0,255. expected true got false
-FAIL Adobe-RGB-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,255. expected true got false
-FAIL Adobe-RGB-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,255. expected true got false
-FAIL Adobe-RGB-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,1,255. expected true got false
-FAIL Adobe-RGB-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,1,255. expected true got false
-FAIL Adobe-RGB-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,255. expected true got false
-FAIL Adobe-RGB-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,255. expected true got false
-FAIL Adobe-RGB-BB0000CC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,0,204. expected true got false
-FAIL Adobe-RGB-BB0000CC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,0,204. expected true got false
-FAIL Adobe-RGB-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,204. expected true got false
-FAIL Adobe-RGB-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,204. expected true got false
-FAIL Adobe-RGB-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,1,204. expected true got false
-FAIL Adobe-RGB-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,1,204. expected true got false
-FAIL Adobe-RGB-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,204. expected true got false
-FAIL Adobe-RGB-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,204. expected true got false
-FAIL Generic-CMYK-FF000000.jpg, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 0,163,218,255. expected true got false
-FAIL Generic-CMYK-FF000000.jpg, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 0,163,218,255. expected true got false
-FAIL Generic-CMYK-FF000000.jpg, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 72,161,213,255. expected true got false
-FAIL Generic-CMYK-FF000000.jpg, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 72,161,213,255. expected true got false
-FAIL Generic-CMYK-FF000000.jpg, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 0,163,218,255. expected true got false
-FAIL Generic-CMYK-FF000000.jpg, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 0,163,218,255. expected true got false
-FAIL Generic-CMYK-FF000000.jpg, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 0,160,213,255. expected true got false
-FAIL Generic-CMYK-FF000000.jpg, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 0,160,213,255. expected true got false
-FAIL Generic-CMYK-BE000000.jpg, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 0,180,223,255. expected true got false
-FAIL Generic-CMYK-BE000000.jpg, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 0,180,223,255. expected true got false
-FAIL Generic-CMYK-BE000000.jpg, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 80,177,219,255. expected true got false
-FAIL Generic-CMYK-BE000000.jpg, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 80,177,219,255. expected true got false
-FAIL Generic-CMYK-BE000000.jpg, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 0,180,223,255. expected true got false
-FAIL Generic-CMYK-BE000000.jpg, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 0,180,223,255. expected true got false
-FAIL Generic-CMYK-BE000000.jpg, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 65,177,219,255. expected true got false
-FAIL Generic-CMYK-BE000000.jpg, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 65,177,219,255. expected true got false
+PASS Adobe-RGB-FF0000FF.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Adobe-RGB-FF0000FF.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Adobe-RGB-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-FF0000FF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-FF0000CC.png, Context srgb, ImageData srgb, cropSource=false
+PASS Adobe-RGB-FF0000CC.png, Context srgb, ImageData srgb, cropSource=true
+PASS Adobe-RGB-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-FF0000CC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Adobe-RGB-FF0000CC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Adobe-RGB-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-FF0000CC.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-BB0000FF.png, Context srgb, ImageData srgb, cropSource=false
+PASS Adobe-RGB-BB0000FF.png, Context srgb, ImageData srgb, cropSource=true
+PASS Adobe-RGB-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-BB0000FF.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Adobe-RGB-BB0000FF.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Adobe-RGB-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-BB0000FF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-BB0000CC.png, Context srgb, ImageData srgb, cropSource=false
+PASS Adobe-RGB-BB0000CC.png, Context srgb, ImageData srgb, cropSource=true
+PASS Adobe-RGB-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-BB0000CC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Adobe-RGB-BB0000CC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Adobe-RGB-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-BB0000CC.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Generic-CMYK-FF000000.jpg, Context srgb, ImageData srgb, cropSource=false
+PASS Generic-CMYK-FF000000.jpg, Context srgb, ImageData srgb, cropSource=true
+PASS Generic-CMYK-FF000000.jpg, Context srgb, ImageData display-p3, cropSource=false
+PASS Generic-CMYK-FF000000.jpg, Context srgb, ImageData display-p3, cropSource=true
+PASS Generic-CMYK-FF000000.jpg, Context display-p3, ImageData srgb, cropSource=false
+PASS Generic-CMYK-FF000000.jpg, Context display-p3, ImageData srgb, cropSource=true
+PASS Generic-CMYK-FF000000.jpg, Context display-p3, ImageData display-p3, cropSource=false
+PASS Generic-CMYK-FF000000.jpg, Context display-p3, ImageData display-p3, cropSource=true
+PASS Generic-CMYK-BE000000.jpg, Context srgb, ImageData srgb, cropSource=false
+PASS Generic-CMYK-BE000000.jpg, Context srgb, ImageData srgb, cropSource=true
+PASS Generic-CMYK-BE000000.jpg, Context srgb, ImageData display-p3, cropSource=false
+PASS Generic-CMYK-BE000000.jpg, Context srgb, ImageData display-p3, cropSource=true
+PASS Generic-CMYK-BE000000.jpg, Context display-p3, ImageData srgb, cropSource=false
+PASS Generic-CMYK-BE000000.jpg, Context display-p3, ImageData srgb, cropSource=true
+PASS Generic-CMYK-BE000000.jpg, Context display-p3, ImageData display-p3, cropSource=false
+PASS Generic-CMYK-BE000000.jpg, Context display-p3, ImageData display-p3, cropSource=true
 PASS sRGB-FFFF00000000FFFF.png, Context srgb, ImageData srgb, cropSource=false
 PASS sRGB-FFFF00000000FFFF.png, Context srgb, ImageData srgb, cropSource=true
 PASS sRGB-FFFF00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=false
@@ -119,30 +119,30 @@
 PASS sRGB-FFFF00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true
 PASS sRGB-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false
 PASS sRGB-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true
-FAIL sRGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL sRGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL sRGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL sRGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL sRGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,0,0,255. expected true got false
-FAIL sRGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,0,0,255. expected true got false
-FAIL sRGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,255. expected true got false
-FAIL sRGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,255. expected true got false
-FAIL sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,1,0,255. expected true got false
-FAIL sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,1,0,255. expected true got false
-FAIL sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,255. expected true got false
-FAIL sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,255. expected true got false
-FAIL sRGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,0,0,204. expected true got false
-FAIL sRGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,0,0,204. expected true got false
-FAIL sRGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,204. expected true got false
-FAIL sRGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,204. expected true got false
-FAIL sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,1,0,204. expected true got false
-FAIL sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 187,1,0,204. expected true got false
-FAIL sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,204. expected true got false
-FAIL sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 171,35,23,204. expected true got false
+PASS sRGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false
+PASS sRGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true
+PASS sRGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS sRGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS sRGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=false
+PASS sRGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=true
+PASS sRGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=false
+PASS sRGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=true
+PASS sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=false
+PASS sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true
+PASS sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS sRGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false
+PASS sRGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true
+PASS sRGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS sRGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true
 PASS Display-P3-FFFF00000000FFFF.png, Context srgb, ImageData srgb, cropSource=false
 PASS Display-P3-FFFF00000000FFFF.png, Context srgb, ImageData srgb, cropSource=true
 PASS Display-P3-FFFF00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=false
@@ -149,62 +149,62 @@
 PASS Display-P3-FFFF00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=true
 PASS Display-P3-FFFF00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=false
 PASS Display-P3-FFFF00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true
-FAIL Display-P3-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,0,0,255. expected true got false
-FAIL Display-P3-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,0,0,255. expected true got false
-FAIL Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,255. expected true got false
-FAIL Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,255. expected true got false
-FAIL Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 188,39,26,255. expected true got false
-FAIL Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 188,39,26,255. expected true got false
-FAIL Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,255. expected true got false
-FAIL Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,255. expected true got false
-FAIL Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 187,0,0,255. expected true got false
-FAIL Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 187,0,0,255. expected true got false
-FAIL Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,204. expected true got false
-FAIL Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,204. expected true got false
-FAIL Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 188,39,26,204. expected true got false
-FAIL Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 188,39,26,204. expected true got false
-FAIL Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,204. expected true got false
-FAIL Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 205,0,0,204. expected true got false
-FAIL Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 187,0,0,204. expected true got false
-FAIL Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 187,0,0,204. expected true got false
+PASS Display-P3-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Display-P3-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false
+PASS Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true
+PASS Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=false
+PASS Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=true
+PASS Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false
+PASS Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true
+PASS Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true
 PASS Adobe-RGB-FFFF00000000FFFF.png, Context srgb, ImageData srgb, cropSource=false
 PASS Adobe-RGB-FFFF00000000FFFF.png, Context srgb, ImageData srgb, cropSource=true
 PASS Adobe-RGB-FFFF00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=false
 PASS Adobe-RGB-FFFF00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=true
-FAIL Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,19,11,255. expected true got false
-FAIL Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,19,11,255. expected true got false
-FAIL Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,61,43,255. expected true got false
-FAIL Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,61,43,255. expected true got false
-FAIL Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,0,0,204. expected true got false
-FAIL Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 234,51,35,204. expected true got false
-FAIL Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,19,11,204. expected true got false
-FAIL Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 255,19,11,204. expected true got false
-FAIL Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,61,43,204. expected true got false
-FAIL Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 255,61,43,204. expected true got false
-FAIL Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,0,255. expected true got false
-FAIL Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,0,255. expected true got false
-FAIL Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,255. expected true got false
-FAIL Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,255. expected true got false
-FAIL Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,1,255. expected true got false
-FAIL Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,1,255. expected true got false
-FAIL Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,255. expected true got false
-FAIL Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,255. expected true got false
-FAIL Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,0,204. expected true got false
-FAIL Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,0,204. expected true got false
-FAIL Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,204. expected true got false
-FAIL Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,204. expected true got false
-FAIL Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,1,204. expected true got false
-FAIL Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true assert_true: Actual pixel value 255,0,0,255 is approximately equal to 219,0,1,204. expected true got false
-FAIL Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,204. expected true got false
-FAIL Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true assert_true: Actual pixel value 234,51,35,255 is approximately equal to 201,42,29,204. expected true got false
+PASS Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=false
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb, cropSource=true
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=false
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb, cropSource=true
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3, cropSource=true
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=false
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb, cropSource=true
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=false
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3, cropSource=true
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned.html (283192 => 283193)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned.html	2021-09-28 21:00:40 UTC (rev 283192)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-cloned.html	2021-09-28 21:10:21 UTC (rev 283193)
@@ -6,45 +6,64 @@
 // Test that drawing structured cloned ImageBitmaps with different image source
 // bit depths and color profiles into sRGB and Display P3 canvases works, by
 // reading pixels with getImageData() as sRGB and Display P3 values.
-for (let [filename, expectedPixels] of Object.entries(imageTests)) {
-    for (let contextColorSpace of ["srgb", "display-p3"]) {
-        for (let imageDataColorSpace of ["srgb", "display-p3"]) {
-            for (let cropSource of [false, true]) {
-                async_test(function(t) {
-                    let image = new Image();
-                    image._onload_ = t.step_func(function() {
 
-                        let canvas = document.createElement("canvas");
-                        canvas.width = 2;
-                        canvas.height = 2;
+let nextTestID = 0;
 
-                        let ctx = canvas.getContext("2d", { colorSpace: contextColorSpace });
+class Test {
+    constructor(testConfiguration) {
+        Object.assign(this, testConfiguration);
+        this.testID = nextTestID++;
+    }
 
-                        let imageBitmapPromise;
-                        if (cropSource)
-                            imageBitmapPromise = createImageBitmap(image, 1, 1, 1, 1);
-                        else
-                            imageBitmapPromise = createImageBitmap(image);
+    run() {
+        let self = this;
+        async_test(function(t) {
+            self.t = t;
+            self.image = new Image();
+            self.image._onload_ = t.step_func(self.onImageLoaded.bind(self));
+            self.image.src = ""
+        }, `${this.filename}, Context ${this.contextColorSpace}, ImageData ${this.imageDataColorSpace}, cropSource=${this.cropSource}`);
+    }
 
-                        imageBitmapPromise.then(t.step_func(function(imageBitmap) {
-                            window.addEventListener(
-                                "message",
-                                t.step_func_done(function(message) {
-                                    ctx.drawImage(message.data, 0, 0);
+    onImageLoaded() {
+        let imageBitmapPromise;
+        if (this.cropSource)
+            imageBitmapPromise = createImageBitmap(this.image, 1, 1, 1, 1);
+        else
+            imageBitmapPromise = createImageBitmap(this.image);
+        imageBitmapPromise.then(this.t.step_func(this.onImageBitmapCreated.bind(this)));
+    }
 
-                                    let imageData = ctx.getImageData(0, 0, 1, 1, { colorSpace: imageDataColorSpace });
+    onImageBitmapCreated(imageBitmap) {
+        window.addEventListener("message", this.t.step_func(this.onMessage.bind(this)));
+        window.postMessage({ imageBitmap, testID: this.testID });
+    }
 
-                                    let expected = expectedPixels[`${contextColorSpace} ${imageDataColorSpace}`];
-                                    assert_true(pixelsApproximatelyEqual(imageData.data, expected), `Actual pixel value ${[...imageData.data]} is approximately equal to ${expected}.`);
-                                }),
-                                { once: true }
-                            );
-                            window.postMessage(imageBitmap);
-                        }));
-                    });
-                    image.src = ""
-                }, `${filename}, Context ${contextColorSpace}, ImageData ${imageDataColorSpace}, cropSource=${cropSource}`);
-            }
+    onMessage(message) {
+        if (message.data.testID != this.testID)
+            return;
+
+        let canvas = document.createElement("canvas");
+        canvas.width = 2;
+        canvas.height = 2;
+
+        let ctx = canvas.getContext("2d", { colorSpace: this.contextColorSpace });
+        ctx.drawImage(message.data.imageBitmap, 0, 0);
+
+        let imageData = ctx.getImageData(0, 0, 1, 1, { colorSpace: this.imageDataColorSpace });
+
+        let expected = this.expectedPixels[`${this.contextColorSpace} ${this.imageDataColorSpace}`];
+        assert_true(pixelsApproximatelyEqual(imageData.data, expected), `Actual pixel value ${[...imageData.data]} is approximately equal to ${expected}.`);
+
+        this.t.done();
+    }
+}
+
+for (let [filename, expectedPixels] of Object.entries(imageTests)) {
+    for (let contextColorSpace of ["srgb", "display-p3"]) {
+        for (let imageDataColorSpace of ["srgb", "display-p3"]) {
+            for (let cropSource of [false, true])
+                new Test({ filename, expectedPixels, contextColorSpace, imageDataColorSpace, cropSource }).run();
         }
     }
 }

Modified: trunk/Source/WebCore/ChangeLog (283192 => 283193)


--- trunk/Source/WebCore/ChangeLog	2021-09-28 21:00:40 UTC (rev 283192)
+++ trunk/Source/WebCore/ChangeLog	2021-09-28 21:10:21 UTC (rev 283193)
@@ -1,3 +1,21 @@
+2021-09-28  Cameron McCormack  <[email protected]>
+
+        Preserve color space when structured cloning ImageBitmaps
+        https://bugs.webkit.org/show_bug.cgi?id=230429
+        <rdar://problem/83293533>
+
+        Reviewed by Sam Weinig.
+
+        The logic for serializing the CGColorSpace is copied and adapted from
+        the ArgumentCoder<CGColorSpaceRef> specialization, which we cannot
+        easily re-use.
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::CloneSerializer::dumpImageBitmap):
+        (WebCore::CloneSerializer::write):
+        (WebCore::CloneDeserializer::read):
+        (WebCore::CloneDeserializer::readImageBitmap):
+
 2021-09-28  Kate Cheney  <[email protected]>
 
         CSP: Implement 'strict-dynamic' source _expression_

Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (283192 => 283193)


--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2021-09-28 21:00:40 UTC (rev 283192)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2021-09-28 21:10:21 UTC (rev 283193)
@@ -59,6 +59,12 @@
 #include "ScriptState.h"
 #include "SharedBuffer.h"
 #include "WebCoreJSClientData.h"
+#if PLATFORM(COCOA)
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+#if USE(CG)
+#include <CoreGraphics/CoreGraphics.h>
+#endif
 #include <_javascript_Core/APICast.h>
 #include <_javascript_Core/BigIntObject.h>
 #include <_javascript_Core/BooleanObject.h>
@@ -242,6 +248,20 @@
 #endif
 };
 
+enum DestinationColorSpaceTag {
+    DestinationColorSpaceSRGBTag = 0,
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+    DestinationColorSpaceLinearSRGBTag = 1,
+#endif
+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3)
+    DestinationColorSpaceDisplayP3Tag = 2,
+#endif
+#if PLATFORM(COCOA)
+    DestinationColorSpaceCGColorSpaceNameTag = 3,
+    DestinationColorSpaceCGColorSpacePropertyListTag = 4,
+#endif
+};
+
 #if ENABLE(WEB_CRYPTO)
 
 const uint32_t currentKeyFormatVersion = 1;
@@ -321,8 +341,9 @@
  * Version 6. added support for 8-bit strings.
  * Version 7. added support for File's lastModified attribute.
  * Version 8. added support for ImageData's colorSpace attribute.
+ * Version 9. added support for ImageBitmap color space.
  */
-static const unsigned CurrentVersion = 8;
+static const unsigned CurrentVersion = 9;
 static const unsigned TerminatorTag = 0xFFFFFFFF;
 static const unsigned StringPoolTag = 0xFFFFFFFE;
 static const unsigned NonIndexPropertiesTag = 0xFFFFFFFD;
@@ -386,7 +407,7 @@
  *    | DOMQuad
  *    | ImageBitmapTransferTag <value:uint32_t>
  *    | RTCCertificateTag
- *    | ImageBitmapTag <originClean:uint8_t> <logicalWidth:int32_t> <logicalHeight:int32_t> <resolutionScale:double> <byteLength:uint32_t>(<imageByteData:uint8_t>)
+ *    | ImageBitmapTag <originClean:uint8_t> <logicalWidth:int32_t> <logicalHeight:int32_t> <resolutionScale:double> DestinationColorSpace <byteLength:uint32_t>(<imageByteData:uint8_t>)
  *    | OffscreenCanvasTransferTag <value:uint32_t>
  *    | WasmMemoryTag <value:uint32_t>
  *    | RTCDataChannelTransferTag <processIdentifier:uint64_t><rtcDataChannelIdentifier:uint64_t><label:String>
@@ -502,6 +523,12 @@
  * DOMQuadData :-
  *      <p1:DOMPointData> <p2:DOMPointData> <p3:DOMPointData> <p4:DOMPointData>
  *
+ * DestinationColorSpace :-
+ *        DestinationColorSpaceSRGBTag
+ *      | DestinationColorSpaceLinearSRGBTag
+ *      | DestinationColorSpaceDisplayP3Tag
+ *      | DestinationColorSpaceCGColorSpaceNameTag <nameDataLength:uint32_t> <nameData:uint8_t>{nameDataLength}
+ *      | DestinationColorSpaceCGColorSpacePropertyListTag <propertyListDataLength:uint32_t> <propertyListData:uint8_t>{propertyListDataLength}
  */
 
 using DeserializationResult = std::pair<JSC::JSValue, SerializationReturnCode>;
@@ -1082,8 +1109,8 @@
             return;
         }
 
-        // FIXME: Cloned ImageBitmaps should preserve their color space.
-        PixelBufferFormat format { AlphaPremultiplication::Premultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB() };
+        // FIXME: We should try to avoid converting pixel format.
+        PixelBufferFormat format { AlphaPremultiplication::Premultiplied, PixelFormat::RGBA8, buffer->colorSpace() };
         const IntSize& logicalSize = buffer->logicalSize();
         auto pixelBuffer = buffer->getPixelBuffer(format, { IntPoint::zero(), logicalSize });
         if (!pixelBuffer) {
@@ -1102,6 +1129,7 @@
         write(static_cast<int32_t>(logicalSize.width()));
         write(static_cast<int32_t>(logicalSize.height()));
         write(static_cast<double>(buffer->resolutionScale()));
+        write(buffer->colorSpace());
 
         write(static_cast<uint32_t>(arrayBuffer->byteLength()));
         write(static_cast<const uint8_t*>(arrayBuffer->data()), arrayBuffer->byteLength());
@@ -1422,6 +1450,11 @@
         writeLittleEndian<uint8_t>(m_buffer, static_cast<uint8_t>(tag));
     }
 
+    void write(DestinationColorSpaceTag tag)
+    {
+        writeLittleEndian<uint8_t>(m_buffer, static_cast<uint8_t>(tag));
+    }
+
 #if ENABLE(WEB_CRYPTO)
     void write(CryptoKeyClassSubtag tag)
     {
@@ -1573,6 +1606,68 @@
         }
     }
 
+#if PLATFORM(COCOA)
+    void write(const RetainPtr<CFDataRef>& data)
+    {
+        uint32_t dataLength = CFDataGetLength(data.get());
+        write(dataLength);
+        write(CFDataGetBytePtr(data.get()), dataLength);
+    }
+#endif
+
+    void write(DestinationColorSpace destinationColorSpace)
+    {
+        if (destinationColorSpace == DestinationColorSpace::SRGB()) {
+            write(DestinationColorSpaceSRGBTag);
+            return;
+        }
+
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+        if (destinationColorSpace == DestinationColorSpace::LinearSRGB()) {
+            write(DestinationColorSpaceLinearSRGBTag);
+            return;
+        }
+#endif
+
+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3)
+        if (destinationColorSpace == DestinationColorSpace::DisplayP3()) {
+            write(DestinationColorSpaceDisplayP3Tag);
+            return;
+        }
+#endif
+
+#if PLATFORM(COCOA)
+        auto colorSpace = destinationColorSpace.platformColorSpace();
+
+        if (auto name = CGColorSpaceGetName(colorSpace)) {
+            auto data = "" name, kCFStringEncodingUTF8, 0));
+            if (!data) {
+                write(DestinationColorSpaceSRGBTag);
+                return;
+            }
+
+            write(DestinationColorSpaceCGColorSpaceNameTag);
+            write(data);
+            return;
+        }
+
+        if (auto propertyList = adoptCF(CGColorSpaceCopyPropertyList(colorSpace))) {
+            auto data = "" propertyList.get(), kCFPropertyListBinaryFormat_v1_0, 0, nullptr));
+            if (!data) {
+                write(DestinationColorSpaceSRGBTag);
+                return;
+            }
+
+            write(DestinationColorSpaceCGColorSpacePropertyListTag);
+            write(data);
+            return;
+        }
+#endif
+
+        ASSERT_NOT_REACHED();
+        write(DestinationColorSpaceSRGBTag);
+    }
+
 #if ENABLE(WEB_CRYPTO)
     void write(CryptoAlgorithmIdentifier algorithm)
     {
@@ -2572,6 +2667,90 @@
         }
     }
 
+    bool read(DestinationColorSpaceTag& tag)
+    {
+        if (m_ptr >= m_end)
+            return false;
+        tag = static_cast<DestinationColorSpaceTag>(*m_ptr++);
+        return true;
+    }
+
+#if PLATFORM(COCOA)
+    bool read(RetainPtr<CFDataRef>& data)
+    {
+        uint32_t dataLength;
+        if (!read(dataLength) || static_cast<uint32_t>(m_end - m_ptr) < dataLength)
+            return false;
+
+        data = "" m_ptr, dataLength, kCFAllocatorNull));
+        if (!data)
+            return false;
+
+        m_ptr += dataLength;
+        return true;
+    }
+#endif
+
+    bool read(DestinationColorSpace& destinationColorSpace)
+    {
+        DestinationColorSpaceTag tag;
+        if (!read(tag))
+            return false;
+
+        switch (tag) {
+        case DestinationColorSpaceSRGBTag:
+            destinationColorSpace = DestinationColorSpace::SRGB();
+            return true;
+#if ENABLE(DESTINATION_COLOR_SPACE_LINEAR_SRGB)
+        case DestinationColorSpaceLinearSRGBTag:
+            destinationColorSpace = DestinationColorSpace::LinearSRGB();
+            return true;
+#endif
+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3)
+        case DestinationColorSpaceDisplayP3Tag:
+            destinationColorSpace = DestinationColorSpace::DisplayP3();
+            return true;
+#endif
+#if PLATFORM(COCOA)
+        case DestinationColorSpaceCGColorSpaceNameTag: {
+            RetainPtr<CFDataRef> data;
+            if (!read(data))
+                return false;
+
+            auto name = adoptCF(CFStringCreateFromExternalRepresentation(nullptr, data.get(), kCFStringEncodingUTF8));
+            if (!name)
+                return false;
+
+            auto colorSpace = adoptCF(CGColorSpaceCreateWithName(name.get()));
+            if (!colorSpace)
+                return false;
+
+            destinationColorSpace = DestinationColorSpace(colorSpace.get());
+            return true;
+        }
+        case DestinationColorSpaceCGColorSpacePropertyListTag: {
+            RetainPtr<CFDataRef> data;
+            if (!read(data))
+                return false;
+
+            auto propertyList = adoptCF(CFPropertyListCreateWithData(nullptr, data.get(), kCFPropertyListImmutable, nullptr, nullptr));
+            if (!propertyList)
+                return false;
+
+            auto colorSpace = adoptCF(CGColorSpaceCreateWithPropertyList(propertyList.get()));
+            if (!colorSpace)
+                return false;
+
+            destinationColorSpace = DestinationColorSpace(colorSpace.get());
+            return true;
+        }
+#endif
+        }
+
+        ASSERT_NOT_REACHED();
+        return false;
+    }
+
 #if ENABLE(WEB_CRYPTO)
     bool read(CryptoAlgorithmIdentifier& result)
     {
@@ -3163,9 +3342,10 @@
         int32_t logicalWidth;
         int32_t logicalHeight;
         double resolutionScale;
+        auto colorSpace = DestinationColorSpace::SRGB();
         RefPtr<ArrayBuffer> arrayBuffer;
 
-        if (!read(serializationState) || !read(logicalWidth) || !read(logicalHeight) || !read(resolutionScale) || !readArrayBuffer(arrayBuffer)) {
+        if (!read(serializationState) || !read(logicalWidth) || !read(logicalHeight) || !read(resolutionScale) || (m_version > 8 && !read(colorSpace)) || !readArrayBuffer(arrayBuffer)) {
             fail();
             return JSValue();
         }
@@ -3174,13 +3354,13 @@
         auto imageDataSize = logicalSize;
         imageDataSize.scale(resolutionScale);
 
-        auto buffer = ImageBitmap::createImageBuffer(*scriptExecutionContextFromExecState(m_lexicalGlobalObject), logicalSize, RenderingMode::Unaccelerated, DestinationColorSpace::SRGB(), resolutionScale);
+        auto buffer = ImageBitmap::createImageBuffer(*scriptExecutionContextFromExecState(m_lexicalGlobalObject), logicalSize, RenderingMode::Unaccelerated, colorSpace, resolutionScale);
         if (!buffer) {
             fail();
             return JSValue();
         }
 
-        PixelBufferFormat format { AlphaPremultiplication::Premultiplied, PixelFormat::RGBA8, DestinationColorSpace::SRGB() };
+        PixelBufferFormat format { AlphaPremultiplication::Premultiplied, PixelFormat::RGBA8, colorSpace };
         auto pixelBuffer = PixelBuffer::tryCreate(format, imageDataSize, arrayBuffer.releaseNonNull());
         if (!pixelBuffer) {
             fail();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to