<!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>[186868] trunk</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/186868">186868</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2015-07-15 16:00:30 -0700 (Wed, 15 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Tag WebGL layers with sRGB colorspace
https://bugs.webkit.org/show_bug.cgi?id=146986
&lt;rdar://problem/21758704&gt;

Reviewed by Simon Fraser.

Source/WebCore:

Label a CAOpenGLLayer as using the sRGB colorspace,
like the rest of our page content.

Test: fast/canvas/webgl/match-page-color-space.html

* platform/graphics/mac/WebGLLayer.mm:
(-[WebGLLayer initWithGraphicsContext3D:]): Set the colorspace property on the layer.
(-[WebGLLayer copyCGLPixelFormatForDisplayMask:]):
(-[WebGLLayer drawInCGLContext:pixelFormat:forLayerTime:displayTime:]):
(-[WebGLLayer copyImageSnapshotWithColorSpace:]):

LayoutTests:

Add a test that embeds a WebGL canvas inside a solid div. Since both
have the same color, the canvas should seemlessly disappear into
the surrounding div.

* fast/canvas/webgl/match-page-color-space-expected.html: Added.
* fast/canvas/webgl/match-page-color-space.html: Added.
* platform/mac-mavericks/TestExpectations: Skip this test.
* platform/mac-yosemite/TestExpectations: Added. Skip this test.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacmavericksTestExpectations">trunk/LayoutTests/platform/mac-mavericks/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacWebGLLayermm">trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcanvaswebglmatchpagecolorspaceexpectedhtml">trunk/LayoutTests/fast/canvas/webgl/match-page-color-space-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcanvaswebglmatchpagecolorspacehtml">trunk/LayoutTests/fast/canvas/webgl/match-page-color-space.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacyosemiteTestExpectations">trunk/LayoutTests/platform/mac-yosemite/TestExpectations</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (186867 => 186868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-07-15 22:42:57 UTC (rev 186867)
+++ trunk/LayoutTests/ChangeLog        2015-07-15 23:00:30 UTC (rev 186868)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-07-15  Dean Jackson  &lt;dino@apple.com&gt;
+
+        Tag WebGL layers with sRGB colorspace
+        https://bugs.webkit.org/show_bug.cgi?id=146986
+        &lt;rdar://problem/21758704&gt;
+
+        Reviewed by Simon Fraser.
+
+        Add a test that embeds a WebGL canvas inside a solid div. Since both
+        have the same color, the canvas should seemlessly disappear into
+        the surrounding div.
+
+        * fast/canvas/webgl/match-page-color-space-expected.html: Added.
+        * fast/canvas/webgl/match-page-color-space.html: Added.
+        * platform/mac-mavericks/TestExpectations: Skip this test.
+        * platform/mac-yosemite/TestExpectations: Added. Skip this test.
+
</ins><span class="cx"> 2015-07-15  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Scroll snapping to elements is broken for main frame scrolling
</span></span></pre></div>
<a id="trunkLayoutTestsfastcanvaswebglmatchpagecolorspaceexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/webgl/match-page-color-space-expected.html (0 => 186868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/webgl/match-page-color-space-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/match-page-color-space-expected.html        2015-07-15 23:00:30 UTC (rev 186868)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;style&gt;
+.box {
+    position: relative;
+    display: inline-block;
+    margin: 5px;
+    width: 40px;
+    height: 40px;
+}
+&lt;/style&gt;
+
+&lt;p&gt;The boxes below should all be uniform in color. Any difference is likely to be extremely subtle.&lt;/p&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: red&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: yellow&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: green&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: orange&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: purple&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: gray&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: cornflowerblue&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: rgb(98, 178, 23)&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: rgb(111, 62, 198)&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: rgb(232, 176, 101)&quot;&gt;&lt;/div&gt;
</ins><span class="cx">Property changes on: trunk/LayoutTests/fast/canvas/webgl/match-page-color-space-expected.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestsfastcanvaswebglmatchpagecolorspacehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/webgl/match-page-color-space.html (0 => 186868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/canvas/webgl/match-page-color-space.html                                (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/match-page-color-space.html        2015-07-15 23:00:30 UTC (rev 186868)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;style&gt;
+.box {
+    position: relative;
+    display: inline-block;
+    margin: 5px;
+    width: 40px;
+    height: 40px;
+}
+
+canvas {
+    position: absolute;
+    left: 10px;
+    top: 10px;
+    width: 20px;
+    height: 20px;
+    background-color: black;
+}
+&lt;/style&gt;
+&lt;script&gt;
+
+function drawColorIntoCanvas(color, canvas) {
+    var gl = canvas.getContext(&quot;webgl&quot;);
+    gl.clearColor(color[0], color[1], color[2], 1.0);
+    gl.clear(gl.COLOR_BUFFER_BIT);
+}
+
+function run() {
+    var boxes = document.querySelectorAll(&quot;.box&quot;);
+    for (var i = 0; i &lt; boxes.length; i++) {
+        var box = boxes[i];
+        var canvas = document.createElement(&quot;canvas&quot;);
+        canvas.width = 20;
+        canvas.height = 20;
+
+        var backgroundColor = window.getComputedStyle(box).backgroundColor;
+        var matches = /rgb\((\d+),\s(\d+),\s(\d+)\)/.exec(backgroundColor);
+        drawColorIntoCanvas([matches[1] / 255, matches[2] / 255, matches[3] / 255], canvas);
+        box.appendChild(canvas);
+    }
+}
+
+window.addEventListener(&quot;load&quot;, run, false);
+&lt;/script&gt;
+&lt;body&gt;
+&lt;p&gt;The boxes below should all be uniform in color. Any difference is likely to be extremely subtle.&lt;/p&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: red&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: yellow&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: green&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: orange&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: purple&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: gray&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: cornflowerblue&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: rgb(98, 178, 23)&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: rgb(111, 62, 198)&quot;&gt;&lt;/div&gt;
+&lt;div class=&quot;box&quot; style=&quot;background-color: rgb(232, 176, 101)&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: trunk/LayoutTests/fast/canvas/webgl/match-page-color-space.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestsplatformmacmavericksTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-mavericks/TestExpectations (186867 => 186868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-mavericks/TestExpectations        2015-07-15 22:42:57 UTC (rev 186867)
+++ trunk/LayoutTests/platform/mac-mavericks/TestExpectations        2015-07-15 23:00:30 UTC (rev 186868)
</span><span class="lines">@@ -18,3 +18,6 @@
</span><span class="cx"> platform/mac/fast/ruby/ruby-expansion-cjk-2.html [ Skip ]
</span><span class="cx"> platform/mac/fast/ruby/ruby-expansion-cjk-3.html [ Skip ]
</span><span class="cx"> platform/mac/fast/ruby/ruby-expansion-cjk-4.html [ Skip ]
</span><ins>+
+# Colorspaces on CA OpenGL layers not available in Mavericks and Yosemite
+fast/canvas/webgl/match-page-color-space.html [ Skip ]
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacyosemiteTestExpectations"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-yosemite/TestExpectations (0 => 186868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-yosemite/TestExpectations                                (rev 0)
+++ trunk/LayoutTests/platform/mac-yosemite/TestExpectations        2015-07-15 23:00:30 UTC (rev 186868)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+# Colorspaces on CA OpenGL layers not available in Mavericks and Yosemite
+fast/canvas/webgl/match-page-color-space.html [ Skip ]
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (186867 => 186868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-07-15 22:42:57 UTC (rev 186867)
+++ trunk/Source/WebCore/ChangeLog        2015-07-15 23:00:30 UTC (rev 186868)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-07-15  Dean Jackson  &lt;dino@apple.com&gt;
+
+        Tag WebGL layers with sRGB colorspace
+        https://bugs.webkit.org/show_bug.cgi?id=146986
+        &lt;rdar://problem/21758704&gt;
+
+        Reviewed by Simon Fraser.
+
+        Label a CAOpenGLLayer as using the sRGB colorspace,
+        like the rest of our page content.
+
+        Test: fast/canvas/webgl/match-page-color-space.html
+
+        * platform/graphics/mac/WebGLLayer.mm:
+        (-[WebGLLayer initWithGraphicsContext3D:]): Set the colorspace property on the layer.
+        (-[WebGLLayer copyCGLPixelFormatForDisplayMask:]):
+        (-[WebGLLayer drawInCGLContext:pixelFormat:forLayerTime:displayTime:]):
+        (-[WebGLLayer copyImageSnapshotWithColorSpace:]):
+
</ins><span class="cx"> 2015-07-15  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Unreviewed build fix after r186858.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacWebGLLayermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.mm (186867 => 186868)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.mm        2015-07-15 22:42:57 UTC (rev 186867)
+++ trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.mm        2015-07-15 23:00:30 UTC (rev 186868)
</span><span class="lines">@@ -30,13 +30,15 @@
</span><span class="cx"> #import &quot;WebGLLayer.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #import &quot;GraphicsContext3D.h&quot;
</span><ins>+#import &quot;GraphicsContextCG.h&quot;
</ins><span class="cx"> #import &quot;GraphicsLayer.h&quot;
</span><ins>+#import &lt;wtf/FastMalloc.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
</ins><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> #import &lt;OpenGL/OpenGL.h&gt;
</span><span class="cx"> #import &lt;OpenGL/gl.h&gt;
</span><span class="cx"> #endif
</span><del>-#import &lt;wtf/FastMalloc.h&gt;
-#import &lt;wtf/RetainPtr.h&gt;
</del><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -49,9 +51,12 @@
</span><span class="cx">     _context = context;
</span><span class="cx">     self = [super init];
</span><span class="cx">     _devicePixelRatio = context-&gt;getContextAttributes().devicePixelRatio;
</span><del>-#if !PLATFORM(IOS)
</del><ins>+#if PLATFORM(MAC)
</ins><span class="cx">     self.contentsScale = _devicePixelRatio;
</span><ins>+#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 101100
+    self.colorspace = sRGBColorSpaceRef();
</ins><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -59,7 +64,7 @@
</span><span class="cx"> -(CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask
</span><span class="cx"> {
</span><span class="cx">     // FIXME: The mask param tells you which display (on a multi-display system)
</span><del>-    // is to be used. But since we are now getting the pixel format from the 
</del><ins>+    // is to be used. But since we are now getting the pixel format from the
</ins><span class="cx">     // Canvas CGL context, we don't use it. This seems to do the right thing on
</span><span class="cx">     // one multi-display system. But there may be cases where this is not the case.
</span><span class="cx">     // If needed we will have to set the display mask in the Canvas CGLContext and
</span><span class="lines">@@ -98,7 +103,7 @@
</span><span class="cx"> 
</span><span class="cx">     glEnable(GL_TEXTURE_2D);
</span><span class="cx">     glBindTexture(GL_TEXTURE_2D, _context-&gt;platformTexture());
</span><del>-    
</del><ins>+
</ins><span class="cx">     glBegin(GL_TRIANGLE_FAN);
</span><span class="cx">         glTexCoord2f(0, 0);
</span><span class="cx">         glVertex2f(-1, -1);
</span><span class="lines">@@ -109,7 +114,7 @@
</span><span class="cx">         glTexCoord2f(0, 1);
</span><span class="cx">         glVertex2f(-1, 1);
</span><span class="cx">     glEnd();
</span><del>-    
</del><ins>+
</ins><span class="cx">     glBindTexture(GL_TEXTURE_2D, 0);
</span><span class="cx">     glDisable(GL_TEXTURE_2D);
</span><span class="cx"> 
</span><span class="lines">@@ -139,7 +144,7 @@
</span><span class="cx">         imageColorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
</span><span class="cx"> 
</span><span class="cx">     CGRect layerBounds = CGRectIntegral([self bounds]);
</span><del>-    
</del><ins>+
</ins><span class="cx">     size_t width = layerBounds.size.width * _devicePixelRatio;
</span><span class="cx">     size_t height = layerBounds.size.height * _devicePixelRatio;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>