Title: [199330] trunk
Revision
199330
Author
[email protected]
Date
2016-04-11 19:57:03 -0700 (Mon, 11 Apr 2016)

Log Message

putImageData needs to premultiply input
https://bugs.webkit.org/show_bug.cgi?id=156488
<rdar://problem/25672675>

Reviewed by Zalan Bujtas.

Source/WebCore:

I made a mistake in r187534 as I was converting get and putImageData
to use Accelerate. The incoming data is unmultiplied, and should
be premultiplied before copying into the backing store. I was
accidentally unmultiplying unmultiplied data, which caused
some pretty psychedelic results.

Test: fast/canvas/putImageData-unmultiplied.html

* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData): Call premultiply, not unpremultiply.

LayoutTests:

Tests that putImageData is taking unmultiplied data,
premultiplying it, then copying into the backing store.

* fast/canvas/putImageData-unmultiplied-expected.html: Added.
* fast/canvas/putImageData-unmultiplied.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (199329 => 199330)


--- trunk/LayoutTests/ChangeLog	2016-04-12 02:20:53 UTC (rev 199329)
+++ trunk/LayoutTests/ChangeLog	2016-04-12 02:57:03 UTC (rev 199330)
@@ -1,3 +1,17 @@
+2016-04-11  Dean Jackson  <[email protected]>
+
+        putImageData needs to premultiply input
+        https://bugs.webkit.org/show_bug.cgi?id=156488
+        <rdar://problem/25672675>
+
+        Reviewed by Zalan Bujtas.
+
+        Tests that putImageData is taking unmultiplied data,
+        premultiplying it, then copying into the backing store.
+
+        * fast/canvas/putImageData-unmultiplied-expected.html: Added.
+        * fast/canvas/putImageData-unmultiplied.html: Added.
+
 2016-04-11  Jiewen Tan  <[email protected]>
 
         Unskip imported/w3c/web-platform-tests/IndexedDB/idbindex-multientry-big.htm

Added: trunk/LayoutTests/fast/canvas/putImageData-unmultiplied-expected.html (0 => 199330)


--- trunk/LayoutTests/fast/canvas/putImageData-unmultiplied-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/putImageData-unmultiplied-expected.html	2016-04-12 02:57:03 UTC (rev 199330)
@@ -0,0 +1,20 @@
+<style>
+    canvas {
+        width: 100px;
+        height: 100px;
+    }
+</style>
+<script>
+    function run() {
+        var c = document.querySelector("canvas");
+        c.width = 1;
+        c.height = 1;
+        var ctx = c.getContext("2d");
+
+        ctx.fillStyle = "rgba(255, 180, 0, " + 163/255 + ")";
+        ctx.fillRect(0, 0, 1, 1);
+    }
+
+    window.addEventListener("load", run, false);
+</script>
+<canvas></canvas>
Property changes on: trunk/LayoutTests/fast/canvas/putImageData-unmultiplied-expected.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/canvas/putImageData-unmultiplied.html (0 => 199330)


--- trunk/LayoutTests/fast/canvas/putImageData-unmultiplied.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/putImageData-unmultiplied.html	2016-04-12 02:57:03 UTC (rev 199330)
@@ -0,0 +1,24 @@
+<style>
+    canvas {
+        width: 100px;
+        height: 100px;
+    }
+</style>
+<script>
+    function run() {
+        var c = document.querySelector("canvas");
+        c.width = 1;
+        c.height = 1;
+        var ctx = c.getContext("2d");
+
+        var data = "" 1);
+        data.data[0] = 0xff;
+        data.data[1] = 0xb4;
+        data.data[2] = 0x00;
+        data.data[3] = 0xa3;
+        ctx.putImageData(data, 0, 0);
+    }
+
+    window.addEventListener("load", run, false);
+</script>
+<canvas></canvas>
Property changes on: trunk/LayoutTests/fast/canvas/putImageData-unmultiplied.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (199329 => 199330)


--- trunk/Source/WebCore/ChangeLog	2016-04-12 02:20:53 UTC (rev 199329)
+++ trunk/Source/WebCore/ChangeLog	2016-04-12 02:57:03 UTC (rev 199330)
@@ -1,3 +1,22 @@
+2016-04-11  Dean Jackson  <[email protected]>
+
+        putImageData needs to premultiply input
+        https://bugs.webkit.org/show_bug.cgi?id=156488
+        <rdar://problem/25672675>
+
+        Reviewed by Zalan Bujtas.
+
+        I made a mistake in r187534 as I was converting get and putImageData
+        to use Accelerate. The incoming data is unmultiplied, and should
+        be premultiplied before copying into the backing store. I was
+        accidentally unmultiplying unmultiplied data, which caused
+        some pretty psychedelic results.
+
+        Test: fast/canvas/putImageData-unmultiplied.html
+
+        * platform/graphics/cg/ImageBufferDataCG.cpp:
+        (WebCore::ImageBufferData::putData): Call premultiply, not unpremultiply.
+
 2016-04-11  Jeremy Jones  <[email protected]>
 
         When clearing cache, also clear AVFoundation cache.

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp (199329 => 199330)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp	2016-04-12 02:20:53 UTC (rev 199329)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp	2016-04-12 02:57:03 UTC (rev 199330)
@@ -64,7 +64,6 @@
     vImagePermuteChannels_ARGB8888(&dest, &dest, map, kvImageNoFlags);
 }
 
-#if !PLATFORM(IOS_SIMULATOR)
 static void premultiplyBufferData(const vImage_Buffer& src, const vImage_Buffer& dest)
 {
     ASSERT(src.data);
@@ -77,7 +76,6 @@
     const uint8_t map[4] = { 2, 1, 0, 3 };
     vImagePermuteChannels_ARGB8888(&dest, &dest, map, kvImageNoFlags);
 }
-#endif // !PLATFORM(IOS_SIMULATOR)
 #endif // USE_ARGB32 || USE(IOSURFACE_CANVAS_BACKING_STORE)
 
 #if !PLATFORM(IOS_SIMULATOR)
@@ -412,7 +410,7 @@
             dest.data = ""
 
 #if USE_ARGB32
-            unpremultiplyBufferData(src, dest);
+            premultiplyBufferData(src, dest);
 #else
             if (resolutionScale != 1) {
                 affineWarpBufferData(src, dest, resolutionScale);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to