Title: [186868] trunk
Revision
186868
Author
[email protected]
Date
2015-07-15 16:00:30 -0700 (Wed, 15 Jul 2015)

Log Message

Tag WebGL layers with sRGB colorspace
https://bugs.webkit.org/show_bug.cgi?id=146986
<rdar://problem/21758704>

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (186867 => 186868)


--- trunk/LayoutTests/ChangeLog	2015-07-15 22:42:57 UTC (rev 186867)
+++ trunk/LayoutTests/ChangeLog	2015-07-15 23:00:30 UTC (rev 186868)
@@ -1,3 +1,20 @@
+2015-07-15  Dean Jackson  <[email protected]>
+
+        Tag WebGL layers with sRGB colorspace
+        https://bugs.webkit.org/show_bug.cgi?id=146986
+        <rdar://problem/21758704>
+
+        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.
+
 2015-07-15  Wenson Hsieh  <[email protected]>
 
         Scroll snapping to elements is broken for main frame scrolling

Added: trunk/LayoutTests/fast/canvas/webgl/match-page-color-space-expected.html (0 => 186868)


--- 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)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<style>
+.box {
+    position: relative;
+    display: inline-block;
+    margin: 5px;
+    width: 40px;
+    height: 40px;
+}
+</style>
+
+<p>The boxes below should all be uniform in color. Any difference is likely to be extremely subtle.</p>
+<div class="box" style="background-color: red"></div>
+<div class="box" style="background-color: yellow"></div>
+<div class="box" style="background-color: green"></div>
+<div class="box" style="background-color: orange"></div>
+<div class="box" style="background-color: purple"></div>
+<div class="box" style="background-color: gray"></div>
+<div class="box" style="background-color: cornflowerblue"></div>
+<div class="box" style="background-color: rgb(98, 178, 23)"></div>
+<div class="box" style="background-color: rgb(111, 62, 198)"></div>
+<div class="box" style="background-color: rgb(232, 176, 101)"></div>
Property changes on: trunk/LayoutTests/fast/canvas/webgl/match-page-color-space-expected.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/canvas/webgl/match-page-color-space.html (0 => 186868)


--- 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)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<style>
+.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;
+}
+</style>
+<script>
+
+function drawColorIntoCanvas(color, canvas) {
+    var gl = canvas.getContext("webgl");
+    gl.clearColor(color[0], color[1], color[2], 1.0);
+    gl.clear(gl.COLOR_BUFFER_BIT);
+}
+
+function run() {
+    var boxes = document.querySelectorAll(".box");
+    for (var i = 0; i < boxes.length; i++) {
+        var box = boxes[i];
+        var canvas = document.createElement("canvas");
+        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("load", run, false);
+</script>
+<body>
+<p>The boxes below should all be uniform in color. Any difference is likely to be extremely subtle.</p>
+<div class="box" style="background-color: red"></div>
+<div class="box" style="background-color: yellow"></div>
+<div class="box" style="background-color: green"></div>
+<div class="box" style="background-color: orange"></div>
+<div class="box" style="background-color: purple"></div>
+<div class="box" style="background-color: gray"></div>
+<div class="box" style="background-color: cornflowerblue"></div>
+<div class="box" style="background-color: rgb(98, 178, 23)"></div>
+<div class="box" style="background-color: rgb(111, 62, 198)"></div>
+<div class="box" style="background-color: rgb(232, 176, 101)"></div>
+</body>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/canvas/webgl/match-page-color-space.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/LayoutTests/platform/mac-mavericks/TestExpectations (186867 => 186868)


--- 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)
@@ -18,3 +18,6 @@
 platform/mac/fast/ruby/ruby-expansion-cjk-2.html [ Skip ]
 platform/mac/fast/ruby/ruby-expansion-cjk-3.html [ Skip ]
 platform/mac/fast/ruby/ruby-expansion-cjk-4.html [ Skip ]
+
+# Colorspaces on CA OpenGL layers not available in Mavericks and Yosemite
+fast/canvas/webgl/match-page-color-space.html [ Skip ]

Added: trunk/LayoutTests/platform/mac-yosemite/TestExpectations (0 => 186868)


--- trunk/LayoutTests/platform/mac-yosemite/TestExpectations	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-yosemite/TestExpectations	2015-07-15 23:00:30 UTC (rev 186868)
@@ -0,0 +1,2 @@
+# Colorspaces on CA OpenGL layers not available in Mavericks and Yosemite
+fast/canvas/webgl/match-page-color-space.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (186867 => 186868)


--- 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)
@@ -1,3 +1,22 @@
+2015-07-15  Dean Jackson  <[email protected]>
+
+        Tag WebGL layers with sRGB colorspace
+        https://bugs.webkit.org/show_bug.cgi?id=146986
+        <rdar://problem/21758704>
+
+        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:]):
+
 2015-07-15  Brent Fulgham  <[email protected]>
 
         [Win] Unreviewed build fix after r186858.

Modified: trunk/Source/WebCore/platform/graphics/mac/WebGLLayer.mm (186867 => 186868)


--- 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)
@@ -30,13 +30,15 @@
 #import "WebGLLayer.h"
 
 #import "GraphicsContext3D.h"
+#import "GraphicsContextCG.h"
 #import "GraphicsLayer.h"
+#import <wtf/FastMalloc.h>
+#import <wtf/RetainPtr.h>
+
 #if !PLATFORM(IOS)
 #import <OpenGL/OpenGL.h>
 #import <OpenGL/gl.h>
 #endif
-#import <wtf/FastMalloc.h>
-#import <wtf/RetainPtr.h>
 
 using namespace WebCore;
 
@@ -49,9 +51,12 @@
     _context = context;
     self = [super init];
     _devicePixelRatio = context->getContextAttributes().devicePixelRatio;
-#if !PLATFORM(IOS)
+#if PLATFORM(MAC)
     self.contentsScale = _devicePixelRatio;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+    self.colorspace = sRGBColorSpaceRef();
 #endif
+#endif
     return self;
 }
 
@@ -59,7 +64,7 @@
 -(CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask
 {
     // FIXME: The mask param tells you which display (on a multi-display system)
-    // is to be used. But since we are now getting the pixel format from the 
+    // is to be used. But since we are now getting the pixel format from the
     // Canvas CGL context, we don't use it. This seems to do the right thing on
     // one multi-display system. But there may be cases where this is not the case.
     // If needed we will have to set the display mask in the Canvas CGLContext and
@@ -98,7 +103,7 @@
 
     glEnable(GL_TEXTURE_2D);
     glBindTexture(GL_TEXTURE_2D, _context->platformTexture());
-    
+
     glBegin(GL_TRIANGLE_FAN);
         glTexCoord2f(0, 0);
         glVertex2f(-1, -1);
@@ -109,7 +114,7 @@
         glTexCoord2f(0, 1);
         glVertex2f(-1, 1);
     glEnd();
-    
+
     glBindTexture(GL_TEXTURE_2D, 0);
     glDisable(GL_TEXTURE_2D);
 
@@ -139,7 +144,7 @@
         imageColorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
 
     CGRect layerBounds = CGRectIntegral([self bounds]);
-    
+
     size_t width = layerBounds.size.width * _devicePixelRatio;
     size_t height = layerBounds.size.height * _devicePixelRatio;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to