<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[283829] branches/safari-612-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/283829">283829</a></dd>
<dt>Author</dt> <dd>alancoon@apple.com</dd>
<dt>Date</dt> <dd>2021-10-08 12:44:38 -0700 (Fri, 08 Oct 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/282630">r282630</a>. rdar://problem/83956741

    Support patterns with a wide gamut source painting into a display-p3 canvas
    https://bugs.webkit.org/show_bug.cgi?id=229023
    <rdar://problem/81828466>

    Reviewed by Sam Weinig.

    LayoutTests/imported/w3c:

    Add tests for wide gamut <img> and <canvas> sources for patterns.

    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html:
    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas-expected.txt: Added.
    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html: Added.
    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image-expected.txt: Added.
    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html: Added.
    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3.js:

    Source/WebKit:

    Patterns are sent to the GPU process using ShareableBitmaps created
    from ImageBuffers. Ensure we pass along the pattern source color space
    to ShareableBitmap::create.

    Tests: imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html
           imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html

    * GPUProcess/graphics/RemoteRenderingBackend.cpp:
    (WebKit::RemoteRenderingBackend::getShareableBitmapForImageBuffer):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282630 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari612branchLayoutTestsTestExpectations">branches/safari-612-branch/LayoutTests/TestExpectations</a></li>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cChangeLog">branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3drawImagehtml">branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html</a></li>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3js">branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3.js</a></li>
<li><a href="#branchessafari612branchLayoutTestsplatformiosTestExpectations">branches/safari-612-branch/LayoutTests/platform/ios/TestExpectations</a></li>
<li><a href="#branchessafari612branchLayoutTestsplatformios14TestExpectations">branches/safari-612-branch/LayoutTests/platform/ios-14/TestExpectations</a></li>
<li><a href="#branchessafari612branchLayoutTestsplatformmacTestExpectations">branches/safari-612-branch/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#branchessafari612branchSourceWebKitChangeLog">branches/safari-612-branch/Source/WebKit/ChangeLog</a></li>
<li><a href="#branchessafari612branchSourceWebKitGPUProcessgraphicsRemoteRenderingBackendcpp">branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3patterncanvasexpectedtxt">branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas-expected.txt</a></li>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3patterncanvashtml">branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html</a></li>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3patternimageexpectedtxt">branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image-expected.txt</a></li>
<li><a href="#branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3patternimagehtml">branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari612branchLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/LayoutTests/TestExpectations (283828 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/TestExpectations  2021-10-08 19:44:31 UTC (rev 283828)
+++ branches/safari-612-branch/LayoutTests/TestExpectations     2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -5117,6 +5117,8 @@
</span><span class="cx"> 
</span><span class="cx"> # display-p3 canvas and ImageData are Cocoa only for now.
</span><span class="cx"> imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html [ Failure ]
</span><ins>+imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html [ Failure ]
+imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html [ Failure ]
</ins><span class="cx"> imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-settings.html [ Failure ]
</span><span class="cx"> imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.jpeg.p3.canvas.html [ Failure ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog (283828 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog    2021-10-08 19:44:31 UTC (rev 283828)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog       2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -1,5 +1,58 @@
</span><span class="cx"> 2021-10-08  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r282630. rdar://problem/83956741
+
+    Support patterns with a wide gamut source painting into a display-p3 canvas
+    https://bugs.webkit.org/show_bug.cgi?id=229023
+    <rdar://problem/81828466>
+    
+    Reviewed by Sam Weinig.
+    
+    LayoutTests/imported/w3c:
+    
+    Add tests for wide gamut <img> and <canvas> sources for patterns.
+    
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html:
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas-expected.txt: Added.
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html: Added.
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image-expected.txt: Added.
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html: Added.
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3.js:
+    
+    Source/WebKit:
+    
+    Patterns are sent to the GPU process using ShareableBitmaps created
+    from ImageBuffers. Ensure we pass along the pattern source color space
+    to ShareableBitmap::create.
+    
+    Tests: imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html
+           imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html
+    
+    * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+    (WebKit::RemoteRenderingBackend::getShareableBitmapForImageBuffer):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-16  Cameron McCormack  <heycam@apple.com>
+
+            Support patterns with a wide gamut source painting into a display-p3 canvas
+            https://bugs.webkit.org/show_bug.cgi?id=229023
+            <rdar://problem/81828466>
+
+            Reviewed by Sam Weinig.
+
+            Add tests for wide gamut <img> and <canvas> sources for patterns.
+
+            * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html:
+            * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas-expected.txt: Added.
+            * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html: Added.
+            * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image-expected.txt: Added.
+            * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html: Added.
+            * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3.js:
+
+2021-10-08  Russell Epstein  <repstein@apple.com>
+
</ins><span class="cx">         Cherry-pick r283099. rdar://problem/83957623
</span><span class="cx"> 
</span><span class="cx">     Remove old test files from canvas WPTs that were moved
</span></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3drawImagehtml"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html (283828 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html     2021-10-08 19:44:31 UTC (rev 283828)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html        2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -6,7 +6,7 @@
</span><span class="cx"> // Test that drawing images with different bit depths and color profiles into
</span><span class="cx"> // sRGB and Display P3 canvases works, by reading pixels with getImageData()
</span><span class="cx"> // as sRGB and Display P3 values.
</span><del>-for (let [filename, expectedPixels] of Object.entries(tests)) {
</del><ins>+for (let [filename, expectedPixels] of Object.entries(imageTests)) {
</ins><span class="cx">     for (let contextColorSpace of ["srgb", "display-p3"]) {
</span><span class="cx">         for (let imageDataColorSpace of ["srgb", "display-p3"]) {
</span><span class="cx">             for (let scaleImage of [false, true]) {
</span></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3patterncanvasexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas-expected.txt (0 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas-expected.txt                                (rev 0)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas-expected.txt   2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+
+PASS Source srgb, destination display-p3, color 255,0,0,255
+PASS Source srgb, destination display-p3, color 255,0,0,204
+PASS Source srgb, destination display-p3, color 187,0,0,255
+PASS Source srgb, destination display-p3, color 187,0,0,204
+PASS Source display-p3, destination srgb, color 255,0,0,255
+PASS Source display-p3, destination srgb, color 255,0,0,204
+PASS Source display-p3, destination srgb, color 187,0,0,255
+PASS Source display-p3, destination srgb, color 187,0,0,204
+
</ins></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3patterncanvashtml"></a>
<div class="addfile"><h4>Added: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html (0 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html                                (rev 0)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html   2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+<!DOCTYPE HTML>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="canvas-display-p3.js"></script>
+<script>
+// Test that patterns created from canvas sources with different color spaces
+// can be drawn into sRGB and Display P3 canvases, by reading pixels with
+// getImageData() as sRGB and Display P3 values.
+function runTest(sourceColorSpace, destinationColorSpace, colors) {
+    for (let [sourceColorString, expectedColor] of Object.entries(colors)) {
+        test(function() {
+            let source = document.createElement("canvas");
+            source.width = 2;
+            source.height = 2;
+
+            let sourceContext = source.getContext("2d", { colorSpace: sourceColorSpace });
+
+            let sourceColor = sourceColorString.split(",").map(x => +x);
+
+            let sourceImageData = new ImageData(2, 2, { colorSpace: sourceColorSpace });
+            for (let i = 0; i < 2 * 2 * 4; i += 4) {
+                for (let c = 0; c < 4; ++c)
+                    sourceImageData.data[i + c] = sourceColor[c];
+            }
+            sourceContext.putImageData(sourceImageData, 0, 0);
+
+            let destination = document.createElement("canvas");
+            destination.width = 4;
+            destination.height = 4;
+
+            let destinationContext = destination.getContext("2d", { colorSpace: destinationColorSpace });
+            destinationContext.fillStyle = destinationContext.createPattern(source, "repeat");
+            destinationContext.fillRect(0, 0, 4, 4);
+
+            let destinationImageData = destinationContext.getImageData(2, 2, 1, 1);
+
+            assert_true(pixelsApproximatelyEqual(destinationImageData.data, expectedColor), `Actual pixel value ${[...destinationImageData.data]} is approximately equal to ${expectedColor}.`);
+        }, `Source ${sourceColorSpace}, destination ${destinationColorSpace}, color ${sourceColorString}`);
+    }
+}
+
+runTest("srgb", "display-p3", fromSRGBToDisplayP3);
+runTest("display-p3", "srgb", fromDisplayP3ToSRGB);
+</script>
</ins></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3patternimageexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image-expected.txt (0 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image-expected.txt                         (rev 0)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image-expected.txt    2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -0,0 +1,106 @@
</span><ins>+
+PASS sRGB-FF0000FF.png, Context srgb, ImageData srgb
+PASS sRGB-FF0000FF.png, Context srgb, ImageData display-p3
+PASS sRGB-FF0000FF.png, Context display-p3, ImageData srgb
+PASS sRGB-FF0000FF.png, Context display-p3, ImageData display-p3
+PASS sRGB-FF0000CC.png, Context srgb, ImageData srgb
+PASS sRGB-FF0000CC.png, Context srgb, ImageData display-p3
+PASS sRGB-FF0000CC.png, Context display-p3, ImageData srgb
+PASS sRGB-FF0000CC.png, Context display-p3, ImageData display-p3
+PASS sRGB-BB0000FF.png, Context srgb, ImageData srgb
+PASS sRGB-BB0000FF.png, Context srgb, ImageData display-p3
+PASS sRGB-BB0000FF.png, Context display-p3, ImageData srgb
+PASS sRGB-BB0000FF.png, Context display-p3, ImageData display-p3
+PASS sRGB-BB0000CC.png, Context srgb, ImageData srgb
+PASS sRGB-BB0000CC.png, Context srgb, ImageData display-p3
+PASS sRGB-BB0000CC.png, Context display-p3, ImageData srgb
+PASS sRGB-BB0000CC.png, Context display-p3, ImageData display-p3
+PASS Display-P3-FF0000FF.png, Context srgb, ImageData srgb
+PASS Display-P3-FF0000FF.png, Context srgb, ImageData display-p3
+PASS Display-P3-FF0000FF.png, Context display-p3, ImageData srgb
+PASS Display-P3-FF0000FF.png, Context display-p3, ImageData display-p3
+PASS Display-P3-FF0000CC.png, Context srgb, ImageData srgb
+PASS Display-P3-FF0000CC.png, Context srgb, ImageData display-p3
+PASS Display-P3-FF0000CC.png, Context display-p3, ImageData srgb
+PASS Display-P3-FF0000CC.png, Context display-p3, ImageData display-p3
+PASS Display-P3-BB0000FF.png, Context srgb, ImageData srgb
+PASS Display-P3-BB0000FF.png, Context srgb, ImageData display-p3
+PASS Display-P3-BB0000FF.png, Context display-p3, ImageData srgb
+PASS Display-P3-BB0000FF.png, Context display-p3, ImageData display-p3
+PASS Display-P3-BB0000CC.png, Context srgb, ImageData srgb
+PASS Display-P3-BB0000CC.png, Context srgb, ImageData display-p3
+PASS Display-P3-BB0000CC.png, Context display-p3, ImageData srgb
+PASS Display-P3-BB0000CC.png, Context display-p3, ImageData display-p3
+PASS Adobe-RGB-FF0000FF.png, Context srgb, ImageData srgb
+PASS Adobe-RGB-FF0000FF.png, Context srgb, ImageData display-p3
+PASS Adobe-RGB-FF0000FF.png, Context display-p3, ImageData srgb
+PASS Adobe-RGB-FF0000FF.png, Context display-p3, ImageData display-p3
+PASS Adobe-RGB-FF0000CC.png, Context srgb, ImageData srgb
+PASS Adobe-RGB-FF0000CC.png, Context srgb, ImageData display-p3
+PASS Adobe-RGB-FF0000CC.png, Context display-p3, ImageData srgb
+PASS Adobe-RGB-FF0000CC.png, Context display-p3, ImageData display-p3
+PASS Adobe-RGB-BB0000FF.png, Context srgb, ImageData srgb
+PASS Adobe-RGB-BB0000FF.png, Context srgb, ImageData display-p3
+PASS Adobe-RGB-BB0000FF.png, Context display-p3, ImageData srgb
+PASS Adobe-RGB-BB0000FF.png, Context display-p3, ImageData display-p3
+PASS Adobe-RGB-BB0000CC.png, Context srgb, ImageData srgb
+PASS Adobe-RGB-BB0000CC.png, Context srgb, ImageData display-p3
+PASS Adobe-RGB-BB0000CC.png, Context display-p3, ImageData srgb
+PASS Adobe-RGB-BB0000CC.png, Context display-p3, ImageData display-p3
+PASS Generic-CMYK-FF000000.jpg, Context srgb, ImageData srgb
+PASS Generic-CMYK-FF000000.jpg, Context srgb, ImageData display-p3
+PASS Generic-CMYK-FF000000.jpg, Context display-p3, ImageData srgb
+PASS Generic-CMYK-FF000000.jpg, Context display-p3, ImageData display-p3
+PASS Generic-CMYK-BE000000.jpg, Context srgb, ImageData srgb
+PASS Generic-CMYK-BE000000.jpg, Context srgb, ImageData display-p3
+PASS Generic-CMYK-BE000000.jpg, Context display-p3, ImageData srgb
+PASS Generic-CMYK-BE000000.jpg, Context display-p3, ImageData display-p3
+PASS sRGB-FFFF00000000FFFF.png, Context srgb, ImageData srgb
+PASS sRGB-FFFF00000000FFFF.png, Context srgb, ImageData display-p3
+PASS sRGB-FFFF00000000FFFF.png, Context display-p3, ImageData srgb
+PASS sRGB-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3
+PASS sRGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb
+PASS sRGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3
+PASS sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb
+PASS sRGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3
+PASS sRGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb
+PASS sRGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3
+PASS sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb
+PASS sRGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3
+PASS sRGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb
+PASS sRGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3
+PASS sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb
+PASS sRGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3
+PASS Display-P3-FFFF00000000FFFF.png, Context srgb, ImageData srgb
+PASS Display-P3-FFFF00000000FFFF.png, Context srgb, ImageData display-p3
+PASS Display-P3-FFFF00000000FFFF.png, Context display-p3, ImageData srgb
+PASS Display-P3-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3
+PASS Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData srgb
+PASS Display-P3-FFFF00000000CCCC.png, Context srgb, ImageData display-p3
+PASS Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData srgb
+PASS Display-P3-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3
+PASS Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData srgb
+PASS Display-P3-BBBC00000000FFFF.png, Context srgb, ImageData display-p3
+PASS Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData srgb
+PASS Display-P3-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3
+PASS Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData srgb
+PASS Display-P3-BBBC00000000CCCC.png, Context srgb, ImageData display-p3
+PASS Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData srgb
+PASS Display-P3-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3
+PASS Adobe-RGB-FFFF00000000FFFF.png, Context srgb, ImageData srgb
+PASS Adobe-RGB-FFFF00000000FFFF.png, Context srgb, ImageData display-p3
+PASS Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData srgb
+PASS Adobe-RGB-FFFF00000000FFFF.png, Context display-p3, ImageData display-p3
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData srgb
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context srgb, ImageData display-p3
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData srgb
+PASS Adobe-RGB-FFFF00000000CCCC.png, Context display-p3, ImageData display-p3
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData srgb
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context srgb, ImageData display-p3
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData srgb
+PASS Adobe-RGB-BBBC00000000FFFF.png, Context display-p3, ImageData display-p3
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData srgb
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context srgb, ImageData display-p3
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData srgb
+PASS Adobe-RGB-BBBC00000000CCCC.png, Context display-p3, ImageData display-p3
+
</ins></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3patternimagehtml"></a>
<div class="addfile"><h4>Added: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html (0 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html                         (rev 0)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html    2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+<!DOCTYPE HTML>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="canvas-display-p3.js"></script>
+<script>
+// Test that patterns created from images with different bit depths and color
+// profiles into can be drawn into sRGB and Display P3 canvases, 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"]) {
+            async_test(function(t) {
+                let image = new Image();
+                image.onload = t.step_func_done(function() {
+
+                    let canvas = document.createElement("canvas");
+                    canvas.width = 4;
+                    canvas.height = 4;
+
+                    let ctx = canvas.getContext("2d", { colorSpace: contextColorSpace });
+                    ctx.fillStyle = ctx.createPattern(image, "repeat");
+                    ctx.fillRect(0, 0, 4, 4);
+
+                    let imageData = ctx.getImageData(2, 2, 1, 1, { colorSpace: imageDataColorSpace });
+
+                    let expected = expectedPixels[`${contextColorSpace} ${imageDataColorSpace}`];
+                    assert_true(pixelsApproximatelyEqual(imageData.data, expected), `Actual pixel value ${[...imageData.data]} is approximately equal to ${expected}.`);
+
+                    t.done();
+
+                });
+                image.src = `resources/${filename}`;
+            }, `${filename}, Context ${contextColorSpace}, ImageData ${imageDataColorSpace}`);
+        }
+    }
+}
+</script>
</ins></span></pre></div>
<a id="branchessafari612branchLayoutTestsimportedw3cwebplatformtestshtmlcanvaselementmanualwidegamutcanvascanvasdisplayp3js"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3.js (283828 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3.js 2021-10-08 19:44:31 UTC (rev 283828)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3.js    2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -8,7 +8,7 @@
</span><span class="cx"> 
</span><span class="cx"> // Top level key is the image filename. Second level key is the pair of
</span><span class="cx"> // CanvasRenderingContext2DSettings.colorSpace and ImageDataSettings.colorSpace.
</span><del>-const tests = {
</del><ins>+const imageTests = {
</ins><span class="cx">     // 8 bit source images
</span><span class="cx"> 
</span><span class="cx">     "sRGB-FF0000FF.png": {
</span><span class="lines">@@ -177,6 +177,20 @@
</span><span class="cx">     },
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+const fromSRGBToDisplayP3 = {
+    "255,0,0,255": [234, 51, 35, 255],
+    "255,0,0,204": [234, 51, 35, 204],
+    "187,0,0,255": [171, 35, 23, 255],
+    "187,0,0,204": [171, 35, 23, 204],
+};
+
+const fromDisplayP3ToSRGB = {
+    "255,0,0,255": [255, 0, 0, 255],
+    "255,0,0,204": [255, 0, 0, 204],
+    "187,0,0,255": [205, 0, 0, 255],
+    "187,0,0,204": [205, 0, 0, 204],
+};
+
</ins><span class="cx"> function pixelsApproximatelyEqual(p1, p2) {
</span><span class="cx">     for (let i = 0; i < 4; ++i) {
</span><span class="cx">         if (Math.abs(p1[i] - p2[i]) > 2)
</span></span></pre></div>
<a id="branchessafari612branchLayoutTestsplatformiosTestExpectations"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/LayoutTests/platform/ios/TestExpectations (283828 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/platform/ios/TestExpectations     2021-10-08 19:44:31 UTC (rev 283828)
+++ branches/safari-612-branch/LayoutTests/platform/ios/TestExpectations        2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -3474,5 +3474,7 @@
</span><span class="cx"> 
</span><span class="cx"> # display-p3 canvas and ImageData are Cocoa only for now.
</span><span class="cx"> imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html [ Pass ]
</span><ins>+imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html [ Pass ]
+imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html [ Pass ]
</ins><span class="cx"> imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-settings.html [ Pass ]
</span><span class="cx"> imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.jpeg.p3.canvas.html [ Pass ]
</span></span></pre></div>
<a id="branchessafari612branchLayoutTestsplatformios14TestExpectations"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/LayoutTests/platform/ios-14/TestExpectations (283828 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/platform/ios-14/TestExpectations  2021-10-08 19:44:31 UTC (rev 283828)
+++ branches/safari-612-branch/LayoutTests/platform/ios-14/TestExpectations     2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -92,6 +92,8 @@
</span><span class="cx"> 
</span><span class="cx"> # display-p3 canvas and ImageData are iOS 15+.
</span><span class="cx"> imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html [ Failure ]
</span><ins>+imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html [ Failure ]
+imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html [ Failure ]
</ins><span class="cx"> imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-settings.html [ Failure ]
</span><span class="cx"> imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.jpeg.p3.canvas.html [ Failure ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari612branchLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/LayoutTests/platform/mac/TestExpectations (283828 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/LayoutTests/platform/mac/TestExpectations     2021-10-08 19:44:31 UTC (rev 283828)
+++ branches/safari-612-branch/LayoutTests/platform/mac/TestExpectations        2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -2323,5 +2323,7 @@
</span><span class="cx"> 
</span><span class="cx"> # display-p3 canvas and ImageData are Cocoa only for now.
</span><span class="cx"> [ Monterey+ ] imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html [ Pass ]
</span><ins>+[ Monterey+ ] imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html [ Pass ]
+[ Monterey+ ] imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html [ Pass ]
</ins><span class="cx"> [ Monterey+ ] imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-settings.html [ Pass ]
</span><span class="cx"> [ Monterey+ ] imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.toDataURL.jpeg.p3.canvas.html [ Pass ]
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (283828 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/ChangeLog       2021-10-08 19:44:31 UTC (rev 283828)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog  2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -1,5 +1,59 @@
</span><span class="cx"> 2021-10-08  Russell Epstein  <repstein@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r282630. rdar://problem/83956741
+
+    Support patterns with a wide gamut source painting into a display-p3 canvas
+    https://bugs.webkit.org/show_bug.cgi?id=229023
+    <rdar://problem/81828466>
+    
+    Reviewed by Sam Weinig.
+    
+    LayoutTests/imported/w3c:
+    
+    Add tests for wide gamut <img> and <canvas> sources for patterns.
+    
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage.html:
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas-expected.txt: Added.
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html: Added.
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image-expected.txt: Added.
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html: Added.
+    * web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3.js:
+    
+    Source/WebKit:
+    
+    Patterns are sent to the GPU process using ShareableBitmaps created
+    from ImageBuffers. Ensure we pass along the pattern source color space
+    to ShareableBitmap::create.
+    
+    Tests: imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html
+           imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html
+    
+    * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+    (WebKit::RemoteRenderingBackend::getShareableBitmapForImageBuffer):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-16  Cameron McCormack  <heycam@apple.com>
+
+            Support patterns with a wide gamut source painting into a display-p3 canvas
+            https://bugs.webkit.org/show_bug.cgi?id=229023
+            <rdar://problem/81828466>
+
+            Reviewed by Sam Weinig.
+
+            Patterns are sent to the GPU process using ShareableBitmaps created
+            from ImageBuffers. Ensure we pass along the pattern source color space
+            to ShareableBitmap::create.
+
+            Tests: imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-canvas.html
+                   imported/w3c/web-platform-tests/html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-pattern-image.html
+
+            * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+            (WebKit::RemoteRenderingBackend::getShareableBitmapForImageBuffer):
+
+2021-10-08  Russell Epstein  <repstein@apple.com>
+
</ins><span class="cx">         Cherry-pick r282626. rdar://problem/83956767
</span><span class="cx"> 
</span><span class="cx">     Support drawImage with a wide gamut image painting into a display-p3 canvas
</span></span></pre></div>
<a id="branchessafari612branchSourceWebKitGPUProcessgraphicsRemoteRenderingBackendcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (283828 => 283829)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp  2021-10-08 19:44:31 UTC (rev 283828)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp     2021-10-08 19:44:38 UTC (rev 283829)
</span><span class="lines">@@ -466,7 +466,7 @@
</span><span class="cx">             return;
</span><span class="cx">         auto backendSize = imageBuffer->backendSize();
</span><span class="cx">         auto resultSize = preserveResolution == WebCore::PreserveResolution::Yes ? backendSize : imageBuffer->logicalSize();
</span><del>-        auto bitmap = ShareableBitmap::createShareable(resultSize, { });
</del><ins>+        auto bitmap = ShareableBitmap::createShareable(resultSize, { imageBuffer->colorSpace() });
</ins><span class="cx">         if (!bitmap)
</span><span class="cx">             return;
</span><span class="cx">         auto context = bitmap->createGraphicsContext();
</span></span></pre>
</div>
</div>

</body>
</html>