Commit 24b242ea authored by dino@apple.com's avatar dino@apple.com

[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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154793 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0318cc27
2013-08-28 Dean Jackson <dino@apple.com>
[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 <simon.fraser@apple.com>
Fix compositing layers in columns
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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"></script>
<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>
2013-08-28 Dean Jackson <dino@apple.com>
[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 <gns@gnome.org>
[GTK] HTMLElement lost setID and getID - need to add compatibility symbols
......@@ -1301,7 +1301,7 @@ ALWAYS_INLINE void FormatConverter::convert()
}
// 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;
......
......@@ -607,16 +607,19 @@ public:
// 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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment