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
REGRESSION(r294536): NativeImages copied from ImageBufferIOSurfaceBac…
…kend are mutated after copy https://bugs.webkit.org/show_bug.cgi?id=241367 Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2022-06-22 Reviewed by Said Abou-Hallawa. With GPUP, ImageBuffer IOSurface modifications happen in the GPUP. In r294536 it was changed that WP creates NativeImage instances with CGImage instances created from IOSurfaces mapped in WP. These CGImages do not know that the underlying IOSurface changes in the other process. Detach the CGImages from the IOSurface before the first write to the ImageBuffer is being sent to GPUP. This is done with the ensureNativeImagesHaveCopiedBackingStore() call. * LayoutTests/fast/canvas/canvas-pattern-from-modified-canvas-expected.txt: Added. * LayoutTests/fast/canvas/canvas-pattern-from-modified-canvas.html: Added. * Source/WebCore/platform/graphics/ImageBuffer.h: (WebCore::ImageBuffer::backingStoreWillChange): (WebCore::ImageBuffer::setNeedsFlush): Deleted. * Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.cpp: (WebCore::ImageBufferIOSurfaceBackend::~ImageBufferIOSurfaceBackend): (WebCore::ImageBufferIOSurfaceBackend::invalidateCachedNativeImage const): (WebCore::ImageBufferIOSurfaceBackend::copyNativeImage const): (WebCore::ImageBufferIOSurfaceBackend::ensureNativeImagesHaveCopiedBackingStore): * Source/WebCore/platform/graphics/cg/ImageBufferIOSurfaceBackend.h: * Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h: (WebKit::RemoteDisplayListRecorderProxy::send): * Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h: (WebKit::RemoteImageBufferProxy::setNeedsFlush): (WebKit::RemoteImageBufferProxy::prepareForBackingStoreChange): Canonical link: https://commits.webkit.org/251751@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295746 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
1d79030
commit 6c003d7df0ee682e4e5b3e80f248f20da9d1ff7c
Showing
7 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
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,15 @@ | ||
Test to ensure that modifications to canvas are not visible from already captured patterns. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS c[0] is 255 | ||
PASS c[1] is 0 | ||
PASS c[2] is 0 | ||
PASS c[0] is 0 | ||
PASS c[1] is 255 | ||
PASS c[2] is 0 | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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,47 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Test to ensure that modifications to canvas are not visible from already captured patterns."); | ||
// At the time of writing this would fail for Cocoa in case where Canvas backing store image was accessed as | ||
// mapped in WP but the modifications would happen in GPUP. At the time, GPUP DOM rendering == off, GPUP Canvas | ||
// rendering == on. | ||
var ctx = document.createElement('canvas').getContext('2d'); | ||
var pcanvas = document.createElement('canvas'); | ||
pcanvas.width = 100; | ||
pcanvas.height = 100; | ||
var pctx = pcanvas.getContext('2d'); | ||
|
||
var c; | ||
|
||
pctx.fillStyle = 'lime'; | ||
pctx.fillRect(0, 0, 50, 50); | ||
|
||
// 1. Capture pattern before modification (green). | ||
var pattern = ctx.createPattern(pcanvas, 'repeat'); | ||
|
||
// 2. Modify the canvas that was the pattern source (the source is red, the pattern is expected to be green). | ||
pctx.fillStyle = 'red'; | ||
pctx.fillRect(0, 0, 50, 50); | ||
c = pctx.getImageData(0, 0, 1, 1).data; | ||
shouldBe("c[0]", "255"); | ||
shouldBe("c[1]", "0"); | ||
shouldBe("c[2]", "0"); | ||
|
||
// 3. Assert that the modification is not visible through the captured pattern. | ||
ctx.fillStyle = pattern; | ||
ctx.fillRect(0, 0, 100, 100); | ||
c = ctx.getImageData(0, 0, 1, 1).data; | ||
shouldBe("c[0]", "0"); | ||
shouldBe("c[1]", "255"); | ||
shouldBe("c[2]", "0"); | ||
|
||
</script> | ||
<script src="../../resources/js-test-post.js"></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