Title: [134816] trunk
- Revision
- 134816
- Author
- [email protected]
- Date
- 2012-11-15 12:35:40 -0800 (Thu, 15 Nov 2012)
Log Message
[chromium] WebGL texImage2D fails with deferred image decoding
https://bugs.webkit.org/show_bug.cgi?id=102310
Reviewed by Kenneth Russell.
Source/WebCore:
Skia's implementation of GraphicsContext3D::getImageData() uses ImageSource
to decode an image. When deferred image decoding is enabled this class
generates an ImageFrame marked as incomplete, which WebGL rejects. This results
in failing of texImage2D.
This change uses ImageDecoder directly instead of ImageSource. This skips
the code path of deferred image decoding. This behavior is correct because
GraphicsContext3D wants to decode the image differently with alpha not
premultiplied and color profile applied optionally.
Added a test to prove this change fixed the bug.
Test: fast/images/webgl-teximage2d.html
* platform/graphics/skia/GraphicsContext3DSkia.cpp:
(WebCore::GraphicsContext3D::getImageData):
LayoutTests:
Added a test to exercise texImage2D with an Image object.
* fast/images/webgl-teximage2d-expected.txt: Added.
* fast/images/webgl-teximage2d.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (134815 => 134816)
--- trunk/LayoutTests/ChangeLog 2012-11-15 20:34:33 UTC (rev 134815)
+++ trunk/LayoutTests/ChangeLog 2012-11-15 20:35:40 UTC (rev 134816)
@@ -1,3 +1,15 @@
+2012-11-15 Alpha Lam <[email protected]>
+
+ [chromium] WebGL texImage2D fails with deferred image decoding
+ https://bugs.webkit.org/show_bug.cgi?id=102310
+
+ Reviewed by Kenneth Russell.
+
+ Added a test to exercise texImage2D with an Image object.
+
+ * fast/images/webgl-teximage2d-expected.txt: Added.
+ * fast/images/webgl-teximage2d.html: Added.
+
2012-11-15 Stephen Chenney <[email protected]>
Test rebaselines after SK_IGNORE_FAST_BLURRECT has been removed
Added: trunk/LayoutTests/fast/images/webgl-teximage2d-expected.txt (0 => 134816)
--- trunk/LayoutTests/fast/images/webgl-teximage2d-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/images/webgl-teximage2d-expected.txt 2012-11-15 20:35:40 UTC (rev 134816)
@@ -0,0 +1,3 @@
+PASS context exists
+PASS OK
+
Added: trunk/LayoutTests/fast/images/webgl-teximage2d.html (0 => 134816)
--- trunk/LayoutTests/fast/images/webgl-teximage2d.html (rev 0)
+++ trunk/LayoutTests/fast/images/webgl-teximage2d.html 2012-11-15 20:35:40 UTC (rev 134816)
@@ -0,0 +1,39 @@
+<script src=""
+<script src=""
+<canvas id="canvas" width="0" height="0"> </canvas>
+<img src="" width="0" height="0" id="image"></img>
+<script>
+
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+var gl = create3DContext(document.getElementById("canvas"));
+if (!gl) {
+ testFailed("context does not exist");
+} else {
+ testPassed("context exists");
+}
+
+var enums = new Array();
+for (var name in gl) {
+ if (typeof gl[name] == 'number')
+ enums[gl[name]] = name;
+}
+
+var img = document.getElementById("image");
+img._onload_ = function() {
+ var texture = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ try {
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img);
+ var err = gl.getError();
+ if (err != gl.NO_ERROR)
+ throw "WebGL error: " + enums[err];
+ testPassed("OK");
+ } catch (e) {
+ testFailed(e.toString());
+ }
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+</script>
Modified: trunk/Source/WebCore/ChangeLog (134815 => 134816)
--- trunk/Source/WebCore/ChangeLog 2012-11-15 20:34:33 UTC (rev 134815)
+++ trunk/Source/WebCore/ChangeLog 2012-11-15 20:35:40 UTC (rev 134816)
@@ -1,3 +1,27 @@
+2012-11-15 Alpha Lam <[email protected]>
+
+ [chromium] WebGL texImage2D fails with deferred image decoding
+ https://bugs.webkit.org/show_bug.cgi?id=102310
+
+ Reviewed by Kenneth Russell.
+
+ Skia's implementation of GraphicsContext3D::getImageData() uses ImageSource
+ to decode an image. When deferred image decoding is enabled this class
+ generates an ImageFrame marked as incomplete, which WebGL rejects. This results
+ in failing of texImage2D.
+
+ This change uses ImageDecoder directly instead of ImageSource. This skips
+ the code path of deferred image decoding. This behavior is correct because
+ GraphicsContext3D wants to decode the image differently with alpha not
+ premultiplied and color profile applied optionally.
+
+ Added a test to prove this change fixed the bug.
+
+ Test: fast/images/webgl-teximage2d.html
+
+ * platform/graphics/skia/GraphicsContext3DSkia.cpp:
+ (WebCore::GraphicsContext3D::getImageData):
+
2012-11-15 Jer Noble <[email protected]>
Further unreviewed build fix. Add explicit static_casts to avoid implicit precision warnings.
Modified: trunk/Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp (134815 => 134816)
--- trunk/Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp 2012-11-15 20:34:33 UTC (rev 134815)
+++ trunk/Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp 2012-11-15 20:35:40 UTC (rev 134816)
@@ -32,7 +32,7 @@
#include "BitmapImage.h"
#include "Image.h"
-#include "ImageSource.h"
+#include "ImageDecoder.h"
#include "NativeImageSkia.h"
#include "SkColorPriv.h"
#include <wtf/OwnPtr.h>
@@ -56,14 +56,20 @@
AlphaOp neededAlphaOp = AlphaDoNothing;
bool hasAlpha = skiaImage ? !skiaImage->bitmap().isOpaque() : true;
if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAlpha)) && image->data()) {
- ImageSource decoder(ImageSource::AlphaNotPremultiplied,
- ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied);
- // Attempt to get raw unpremultiplied image data
- decoder.setData(image->data(), true);
- if (!decoder.frameCount() || !decoder.frameIsCompleteAtIndex(0))
+ // Attempt to get raw unpremultiplied image data.
+ OwnPtr<ImageDecoder> decoder(adoptPtr(ImageDecoder::create(
+ *(image->data()), ImageSource::AlphaNotPremultiplied,
+ ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied)));
+ if (!decoder)
return false;
- hasAlpha = decoder.frameHasAlphaAtIndex(0);
- pixels = adoptPtr(decoder.createFrameAtIndex(0));
+ decoder->setData(image->data(), true);
+ if (!decoder->frameCount())
+ return false;
+ ImageFrame* frame = decoder->frameBufferAtIndex(0);
+ if (!frame || frame->status() != ImageFrame::FrameComplete)
+ return false;
+ hasAlpha = frame->hasAlpha();
+ pixels = adoptPtr(frame->asNewNativeImage());
if (!pixels.get() || !pixels->isDataComplete() || !pixels->bitmap().width() || !pixels->bitmap().height())
return false;
SkBitmap::Config skiaConfig = pixels->bitmap().config();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes