Bug 32188 - texImage2D pixel junk for transparency
Summary: texImage2D pixel junk for transparency
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.6
: P2 Major
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-05 20:57 PST by Keith Bauer
Modified: 2009-12-06 03:38 PST (History)
1 user (show)

See Also:


Attachments
Patch (1.59 KB, patch)
2009-12-06 03:30 PST, Oliver Hunt
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Bauer 2009-12-05 20:57:36 PST
When using texImage2D with an Image or Canvas as the source of the data, WebKit draws the underlying CGImage to a CGBitmapContext to get access to the pixels.  The context is created with memory from fastMalloc(), and therefore undefined.  When the CGImage being drawn contains transparency, this undefined data shows through, causing pixel junk in the resulting WebGL texture image.

There is no workaround for this; there is no way to affect the pixels of that CGBitmapContext in such a way that the pixel junk is cleared without also making the resulting texture opaque.

The patch is trivial (using calloc, or adding a memset, or CGClearRect, or similar to zero the bitmap context's data before drawing the image in imageToTexture() in WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp.  I'm having trouble building WebKit though so I can't offer a tested patch.
Comment 1 Oliver Hunt 2009-12-06 02:47:31 PST
This problem can be fixed by forcing the blend mode to kCGBlendCopy.  Have  a patch in my tree, but haven't yet worked out how to make a testcase.
Comment 2 Oliver Hunt 2009-12-06 03:30:19 PST
Created attachment 44359 [details]
Patch
Comment 3 Maciej Stachowiak 2009-12-06 03:33:37 PST
Comment on attachment 44359 [details]
Patch

r=me
Comment 4 Oliver Hunt 2009-12-06 03:38:11 PST
Committed r51740