haikuwebkit/LayoutTests/fast/images/svg-mask-in-canvas.html

29 lines
1.1 KiB
HTML
Raw Permalink Normal View History

[GPU Process] Canvas image rendering can render arbitrary DOM content in the GPU process, which is against policy (for now) https://bugs.webkit.org/show_bug.cgi?id=227519 <rdar://problem/76678163> Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/html/canvas/element/imagebitmap/createImageBitmap-flipY-expected.txt: Source/WebCore: Rendering arbitrary DOM content in the GPU process isn't supported yet, but canvas rendering is. However, canvas has a drawImage() function which can accept an HTMLImageElement as its source, and an HTMLImageElement can have an SVG document as its source, which would end up triggering our DOM codepath in canvas and thus in the GPU process. This patch disables this for now, by rendering the SVG into an ImageBuffer and then drawing the ImageBuffer in the GPU process. When we eventually implement arbitrary DOM rendering in the GPU process, this patch will need to be reverted. Test: fast/images/svg-mask-in-canvas.html * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::nativeImage): (WebCore::SVGImage::draw): (WebCore::SVGImage::drawAsNativeImage): * svg/graphics/SVGImage.h: LayoutTests: * fast/images/resources/mask.svg: Added. * fast/images/svg-mask-in-canvas-expected.html: Added. * fast/images/svg-mask-in-canvas.html: Added. * platform/mac-wk1/imported/w3c/web-platform-tests/html/canvas/element/imagebitmap/createImageBitmap-flipY-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/imagebitmap/createImageBitmap-flipY-expected.txt. Canonical link: https://commits.webkit.org/239510@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-08 15:52:51 +00:00
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>This test passes if you see a black rectangle with a green border below.</p>
<div style="position: relative;">
<canvas id="canvas" width="300" height="300"></canvas>
<div style="position: absolute; top: 47px; left: 97px; width: 6px; height: 206px; background: green;"></div>
<div style="position: absolute; top: 47px; left: 197px; width: 6px; height: 206px; background: green;"></div>
<div style="position: absolute; top: 47px; left: 97px; width: 106px; height: 6px; background: green;"></div>
<div style="position: absolute; top: 247px; left: 97px; width: 106px; height: 6px; background: green;"></div>
</div>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
let canvas = document.getElementById("canvas");
let context = canvas.getContext("2d");
let image = document.createElement("img");
image.addEventListener("load", function() {
context.drawImage(image, 0, 0, 300, 300);
if (window.testRunner)
testRunner.notifyDone();
});
image.src = "resources/mask.svg";
</script>
</body>
</html>