Title: [154793] trunk
Revision
154793
Author
[email protected]
Date
2013-08-28 16:54:05 -0700 (Wed, 28 Aug 2013)

Log Message

[WebGL] CoreGraphics can provide greyscale image data
https://webkit.org/b/120443

Reviewed by Simon Fraser.

Source/WebCore:

CoreGraphics can decode greyscale or greyscale+alpha images
while preserving the format. Our WebGL texture unpacker
was seeing this and assuming it meant the data did not come
from an <img> element. Since that method already special cased
CoreGraphics, the fix was to simply return true for these
extra types.

I also renamed srcFormatComeFromDOMElementOrImageData
to srcFormatComesFromDOMElementOrImageData.

Test: fast/canvas/webgl/tex-image-with-greyscale-image.html

* platform/graphics/GraphicsContext3D.cpp: Call new name.
* platform/graphics/GraphicsContext3D.h:
(WebCore::GraphicsContext3D::srcFormatComesFromDOMElementOrImageData):
Add support for R8, AR8, A8, and RA8 data formats.

LayoutTests:

New test that attempts to load and draw an image that only has grey
and alpha channels.

* fast/canvas/webgl/resources/greyscale.png: Added.
* fast/canvas/webgl/tex-image-with-greyscale-image-expected.txt: Added.
* fast/canvas/webgl/tex-image-with-greyscale-image.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (154792 => 154793)


--- trunk/LayoutTests/ChangeLog	2013-08-28 23:46:02 UTC (rev 154792)
+++ trunk/LayoutTests/ChangeLog	2013-08-28 23:54:05 UTC (rev 154793)
@@ -1,3 +1,17 @@
+2013-08-28  Dean Jackson  <[email protected]>
+
+        [WebGL] CoreGraphics can provide greyscale image data
+        https://webkit.org/b/120443
+
+        Reviewed by Simon Fraser.
+
+        New test that attempts to load and draw an image that only has grey
+        and alpha channels.
+
+        * fast/canvas/webgl/resources/greyscale.png: Added.
+        * fast/canvas/webgl/tex-image-with-greyscale-image-expected.txt: Added.
+        * fast/canvas/webgl/tex-image-with-greyscale-image.html: Added.
+
 2013-08-28  Simon Fraser  <[email protected]>
 
         Fix compositing layers in columns

Added: trunk/LayoutTests/fast/canvas/webgl/resources/greyscale.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/canvas/webgl/resources/greyscale.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/canvas/webgl/tex-image-with-greyscale-image-expected.txt (0 => 154793)


--- trunk/LayoutTests/fast/canvas/webgl/tex-image-with-greyscale-image-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/tex-image-with-greyscale-image-expected.txt	2013-08-28 23:54:05 UTC (rev 154793)
@@ -0,0 +1,10 @@
+Verify we can handle 2 sample per pixel images (e.g. greyscale with alpha)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS getError was expected value: NO_ERROR : should be no errors
+Testing texImage2D
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/canvas/webgl/tex-image-with-greyscale-image-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/canvas/webgl/tex-image-with-greyscale-image.html (0 => 154793)


--- trunk/LayoutTests/fast/canvas/webgl/tex-image-with-greyscale-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/tex-image-with-greyscale-image.html	2013-08-28 23:54:05 UTC (rev 154793)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+var wtu = WebGLTestUtils;
+var gl = null;
+var textureLoc = null;
+var successfullyParsed = false;
+
+function init()
+{
+    if (window.initNonKhronosFramework)
+        window.initNonKhronosFramework(true);
+
+    description('Verify we can handle 2 sample per pixel images (e.g. greyscale with alpha)');
+
+    gl = wtu.create3DContext("example");
+
+    var program = wtu.setupTexturedQuad(gl);
+
+    gl.clearColor(0,0,0,1);
+    gl.clearDepth(1);
+
+    textureLoc = gl.getUniformLocation(program, "tex");
+    wtu.loadTexture(gl, "resources/greyscale.png", runTest);
+}
+
+function runTest()
+{
+    glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+
+    debug('Testing texImage2D');
+    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+    // Point the uniform sampler to texture unit 0
+    gl.uniform1i(textureLoc, 0);
+    // Draw the triangles
+    wtu.drawQuad(gl, [0, 0, 0, 255]);
+    finishTest();
+}
+
+</script>
+</head>
+<body _onload_='init()'>
+<canvas id="example" width="32px" height="32px"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/canvas/webgl/tex-image-with-greyscale-image.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (154792 => 154793)


--- trunk/Source/WebCore/ChangeLog	2013-08-28 23:46:02 UTC (rev 154792)
+++ trunk/Source/WebCore/ChangeLog	2013-08-28 23:54:05 UTC (rev 154793)
@@ -1,3 +1,27 @@
+2013-08-28  Dean Jackson  <[email protected]>
+
+        [WebGL] CoreGraphics can provide greyscale image data
+        https://webkit.org/b/120443
+
+        Reviewed by Simon Fraser.
+
+        CoreGraphics can decode greyscale or greyscale+alpha images
+        while preserving the format. Our WebGL texture unpacker
+        was seeing this and assuming it meant the data did not come
+        from an <img> element. Since that method already special cased
+        CoreGraphics, the fix was to simply return true for these
+        extra types.
+
+        I also renamed srcFormatComeFromDOMElementOrImageData
+        to srcFormatComesFromDOMElementOrImageData.
+
+        Test: fast/canvas/webgl/tex-image-with-greyscale-image.html
+
+        * platform/graphics/GraphicsContext3D.cpp: Call new name.
+        * platform/graphics/GraphicsContext3D.h:
+        (WebCore::GraphicsContext3D::srcFormatComesFromDOMElementOrImageData):
+        Add support for R8, AR8, A8, and RA8 data formats.
+
 2013-08-28  Gustavo Noronha Silva  <[email protected]>
 
         [GTK] HTMLElement lost setID and getID - need to add compatibility symbols

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp (154792 => 154793)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp	2013-08-28 23:46:02 UTC (rev 154792)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp	2013-08-28 23:54:05 UTC (rev 154793)
@@ -1301,7 +1301,7 @@
     }
 
     // Only textures uploaded from DOM elements or ImageData can allow DstFormat != SrcFormat.
-    const bool srcFormatComesFromDOMElementOrImageData = GraphicsContext3D::srcFormatComeFromDOMElementOrImageData(SrcFormat);
+    const bool srcFormatComesFromDOMElementOrImageData = GraphicsContext3D::srcFormatComesFromDOMElementOrImageData(SrcFormat);
     if (!srcFormatComesFromDOMElementOrImageData && SrcFormat != DstFormat) {
         ASSERT_NOT_REACHED();
         return;

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h (154792 => 154793)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2013-08-28 23:46:02 UTC (rev 154792)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h	2013-08-28 23:54:05 UTC (rev 154793)
@@ -607,16 +607,19 @@
     // Check if the format is one of the formats from the ImageData or DOM elements.
     // The formats from ImageData is always RGBA8.
     // The formats from DOM elements vary with Graphics ports. It can only be RGBA8 or BGRA8 for non-CG port while a little more for CG port.
-    static ALWAYS_INLINE bool srcFormatComeFromDOMElementOrImageData(DataFormat SrcFormat)
+    static ALWAYS_INLINE bool srcFormatComesFromDOMElementOrImageData(DataFormat SrcFormat)
     {
 #if USE(CG)
 #if CPU(BIG_ENDIAN)
-    return SrcFormat == DataFormatRGBA8 || SrcFormat == DataFormatARGB8 || SrcFormat == DataFormatRGB8;
+    return SrcFormat == DataFormatRGBA8 || SrcFormat == DataFormatARGB8 || SrcFormat == DataFormatRGB8
+        || SrcFormat == DataFormatRA8 || SrcFormat == DataFormatAR8 || SrcFormat == DataFormatR8 || SrcFormat == DataFormatA8;
 #else
     // That LITTLE_ENDIAN case has more possible formats than BIG_ENDIAN case is because some decoded image data is actually big endian
     // even on little endian architectures.
     return SrcFormat == DataFormatBGRA8 || SrcFormat == DataFormatABGR8 || SrcFormat == DataFormatBGR8
-        || SrcFormat == DataFormatRGBA8 || SrcFormat == DataFormatARGB8 || SrcFormat == DataFormatRGB8;
+        || SrcFormat == DataFormatRGBA8 || SrcFormat == DataFormatARGB8 || SrcFormat == DataFormatRGB8
+        || SrcFormat == DataFormatR8 || SrcFormat == DataFormatA8
+        || SrcFormat == DataFormatRA8 || SrcFormat == DataFormatAR8;
 #endif
 #else
     return SrcFormat == DataFormatBGRA8 || SrcFormat == DataFormatRGBA8;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to