Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[GPU Process] REGRESSION: Drawing a large SVG image on a canvas may t…
…ake too much memory https://bugs.webkit.org/show_bug.cgi?id=230886 rdar://83628607 Reviewed by Simon Fraser. Source/WebCore: For the GPUProcess rendering on a canvas, we have to draw the SVGImage to a temporary ImageBuffer, get a NativeImage from this ImageBuffer and send it to GPUProcess through a DrawNativeImage display list item. The fix is: 1. Make sure the size of temporary ImageBuffer is scaled to the Graphics Context CTM. 2. Clamp the scaled size to the MaxClampedArea. So ImageBuffer::create() returns a valid ImageBuffer. 3. Scale the destination GraphicsContext to the reciprocal of the scaling factor before drawing the NativeImage. Test: fast/canvas/canvas-draw-large-svg-image.html * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::drawAsNativeImage): LayoutTests: * fast/canvas/canvas-draw-large-svg-image-expected.html: Added. * fast/canvas/canvas-draw-large-svg-image.html: Added. Canonical link: https://commits.webkit.org/243449@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284740 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
107 additions
and 2 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
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,11 @@ | ||
<body> | ||
<canvas id="canvas" width="100" height="100"> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext("2d"); | ||
|
||
const { width, height } = canvas; | ||
ctx.fillStyle = "green"; | ||
ctx.fillRect(0, 0, width, height); | ||
</script> | ||
</body> |
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,34 @@ | ||
<body> | ||
<canvas id="canvas" width="100" height="100"> | ||
<script> | ||
const canvas = document.getElementById("canvas"); | ||
const ctx = canvas.getContext("2d"); | ||
|
||
const { width, height } = canvas; | ||
ctx.fillStyle = "red"; | ||
ctx.fillRect(0, 0, width, height); | ||
|
||
function drawImage(image, scale) { | ||
ctx.save(); | ||
|
||
ctx.scale(1 / scale, 1 / scale); | ||
ctx.drawImage(image, 0, 0, 1000, 1000, 0, 0, width * scale, height * scale); | ||
|
||
ctx.restore(); | ||
} | ||
|
||
if (window.testRunner) | ||
testRunner.waitUntilDone(); | ||
|
||
const image = new Image(); | ||
image.onload = (() => { | ||
drawImage(image, 500); | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}); | ||
image.src = `data:image/svg+xml, | ||
<svg xmlns='http://www.w3.org/2000/svg' width='1000' height='1000'> | ||
<rect width='1000' height='1000' fill='green'/> | ||
</svg>`; | ||
</script> | ||
</body> |
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