Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
toDataURL() uses stale data after putImageData()
https://bugs.webkit.org/show_bug.cgi?id=65767 Source/WebCore: This patch fixes the issue we've encountered of getting back stale copies of the CGContext of accelerated ImageBuffers who have seen putImageData calls but have not been drawn into via the CG API. This issue is fixed by modifying the way we implement putImageData in ImageBufferCG to draw the bits wrapped in a CGImage while the CGContext is in a state where the data will effectively be copied (as is needed for implementing putImageData) instead of directly modifying the bits of the IOSurface. Reviewed by Chris Marrin. Test: fast/canvas/check-stale-putImageData, pixel test to check that the canvas is in fact painted. * platform/graphics/cg/ImageBufferCG.cpp: Implement new way of putting image data. * platform/graphics/ImageBuffer.h: Merged two previously separate put data calls into a single and more sensibly named 'putByteArray', since that's what it does! * WebCore.exp.in: Added new WKSI call for use in ImageBufferCG.cpp * platform/mac/WebCoreSystemInterface.h: * platform/mac/WebCoreSystemInterface.mm: Using new method name. * html/canvas/CanvasRenderingContext2D.cpp: * platform/graphics/ImageBuffer.cpp: * platform/graphics/ShadowBlur.cpp: * platform/graphics/filters/FEColorMatrix.cpp: * platform/graphics/filters/FEDropShadow.cpp: * platform/graphics/filters/FilterEffect.cpp: Updated other ports' ImageBuffers to use new method. * platform/graphics/cairo/ImageBufferCairo.cpp: * platform/graphics/qt/ImageBufferQt.cpp: * platform/graphics/skia/ImageBufferSkia.cpp: * platform/graphics/wince/ImageBufferWinCE.cpp: * platform/graphics/wx/ImageBufferWx.cpp: Source/WebKit/chromium: Reviewed by Chris Marrin. * src/WebViewImpl.cpp: Updated method name. (WebKit::WebViewImpl::doPixelReadbackToCanvas): Source/WebKit/mac: Reviewed by Chris Marrin. * WebCoreSupport/WebSystemInterface.mm: Source/WebKit2: Reviewed by Chris Marrin. * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: (InitWebCoreSystemInterface): WebKitLibraries: Added WKCGContextResetClip for use in reseting clip for new putByteArray method. Reviewed by Chris Marrin. * WebKitSystemInterface.h: Added WKCGContextResetClip. * libWebKitSystemInterfaceLeopard.a: * libWebKitSystemInterfaceSnowLeopard.a: * libWebKitSystemInterfaceLion.a: Canonical link: https://commits.webkit.org/94762@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
31 changed files
with
211 additions
and
110 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,6 @@ | ||
CONSOLE MESSAGE: line 28: a == b? false | ||
CONSOLE MESSAGE: line 35: a == c? false | ||
1, 3, and 4 should all show the same red square. 2 should show nothing. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,42 @@ | ||
<html><head></head><body> | ||
1, 3, and 4 should all show the same red square. 2 should show nothing. | ||
<ol> | ||
<li><canvas id="canvas" width="100" height="100"></canvas></li> | ||
<li><img src="" id="a"></li> | ||
<li><img src="" id="b"></li> | ||
<li><img src="" id="c"></li> | ||
</ol> | ||
|
||
<script type="text/javascript"> | ||
|
||
if (window.layoutTestController) | ||
layoutTestController.dumpAsText(true); | ||
|
||
var canvas = document.getElementById( 'canvas' ); | ||
var context = canvas.getContext( '2d' ); | ||
var img = context.getImageData( 0, 0, canvas.width, canvas.height ); | ||
|
||
var img_a = canvas.toDataURL( 'image/png' ); | ||
|
||
/* fill with red */ | ||
for ( var i = 0; i < img.data.length; i += 4 ) | ||
img.data[i] = img.data[i+3] = 255; | ||
|
||
context.putImageData( img, 0, 0 ); | ||
var img_b = canvas.toDataURL( 'image/png' ); | ||
|
||
console.log( 'a == b? ' + (img_a == img_b) ); | ||
|
||
context.moveTo( 0, 0 ); | ||
context.lineTo( 0, 0 ); | ||
context.stroke(); | ||
|
||
var img_c = canvas.toDataURL( 'image/png' ); | ||
console.log( 'a == c? ' + (img_a == img_c) ); | ||
|
||
document.getElementById( 'a' ).src = img_a; | ||
document.getElementById( 'b' ).src = img_b; | ||
document.getElementById( 'c' ).src = img_c; | ||
</script> | ||
|
||
</body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.