forked from qtwebkit/qtwebkit
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OffscreenCanvas.transferToImageBitmap() context specific code should …
…exist in the context https://bugs.webkit.org/show_bug.cgi?id=275105 rdar://129217576 Reviewed by Antti Koivisto. OffscreenCanvas::transferToImageBitmap() has code conditionalized to different canvas rendering contexts. Move this code to the contexts, into overrides of new virtual function CanvasRenderingContext::transferToImageBuffer(). This way the contexts are able to manage the buffers themselves in future commits. Fix the error-case where the out-of-memory causes an exception instead of null ImageBitmap for all backends. The exception should be DOM UnknownError, that is used to signify out-of-memory. * Source/WebCore/html/CanvasBase.h: * Source/WebCore/html/OffscreenCanvas.cpp: (WebCore::OffscreenCanvas::transferToImageBitmap): * Source/WebCore/html/canvas/CanvasRenderingContext.cpp: (WebCore::CanvasRenderingContext::transferToImageBuffer): * Source/WebCore/html/canvas/CanvasRenderingContext.h: * Source/WebCore/html/canvas/GPUCanvasContext.h: * Source/WebCore/html/canvas/GPUCanvasContextCocoa.h: * Source/WebCore/html/canvas/GPUCanvasContextCocoa.mm: (WebCore::GPUCanvasContextCocoa::transferToImageBuffer): (WebCore::GPUCanvasContextCocoa::getCurrentTextureAsImageBitmap): Deleted. * Source/WebCore/html/canvas/ImageBitmapRenderingContext.cpp: (WebCore::ImageBitmapRenderingContext::setOutputBitmap): (WebCore::ImageBitmapRenderingContext::setBlank): (WebCore::ImageBitmapRenderingContext::transferToImageBuffer): * Source/WebCore/html/canvas/ImageBitmapRenderingContext.h: * Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.cpp: (WebCore::OffscreenCanvasRenderingContext2D::transferToImageBuffer): * Source/WebCore/html/canvas/OffscreenCanvasRenderingContext2D.h: * Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp: (WebCore::WebGLRenderingContextBase::transferToImageBuffer): (WebCore::WebGLRenderingContextBase::markDrawingBuffersDirtyAfterTransfer): Deleted. * Source/WebCore/html/canvas/WebGLRenderingContextBase.h: Canonical link: https://commits.webkit.org/279872@main
- Loading branch information
1 parent
b4ed929
commit 5b1469a
Showing
17 changed files
with
234 additions
and
98 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
LayoutTests/fast/canvas/offscreen-giant-transfer-to-imagebitmap-expected.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456). | ||
Testing height: 100 type: none | ||
Got exception: "InvalidStateError: The object is in an invalid state." | ||
Testing height: 100 type: 2d | ||
Got context: "[object OffscreenCanvasRenderingContext2D]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: webgl | ||
Got context: "[object WebGLRenderingContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: webgl2 | ||
Got context: "[object WebGL2RenderingContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: webgpu | ||
Got context: "null" | ||
Got exception: "InvalidStateError: The object is in an invalid state." | ||
Testing height: 100 type: bitmaprenderer | ||
Got context: "[object ImageBitmapRenderingContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100000000 type: none | ||
Got exception: "InvalidStateError: The object is in an invalid state." | ||
Testing height: 100000000 type: 2d | ||
Got context: "[object OffscreenCanvasRenderingContext2D]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: webgl | ||
Got context: "[object WebGLRenderingContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: webgl2 | ||
Got context: "[object WebGL2RenderingContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: webgpu | ||
Got context: "null" | ||
Got exception: "InvalidStateError: The object is in an invalid state." | ||
Testing height: 100000000 type: bitmaprenderer | ||
Got context: "[object ImageBitmapRenderingContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
41 changes: 33 additions & 8 deletions
41
LayoutTests/fast/canvas/offscreen-giant-transfer-to-imagebitmap.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
<body> | ||
<script src="../../resources/js-test.js"></script> | ||
<script> | ||
onload = () => { | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
function runTest() { | ||
if (!window.OffscreenCanvas) { | ||
debug("OffscreenCanvas not enabled"); | ||
return; | ||
} | ||
let offscreenCanvas = new OffscreenCanvas(1, 100000000); | ||
offscreenCanvas.getContext('2d'); | ||
offscreenCanvas.width = 100; | ||
offscreenCanvas.transferToImageBitmap(); | ||
} | ||
let types = ["none", "2d", "webgl", "webgl2", "webgpu", "bitmaprenderer"]; | ||
let heights = [100, 100000000]; | ||
for (let height of heights) { | ||
for (let type of types) { | ||
debug(`Testing height: ${height} type: ${type} `); | ||
let canvas = new OffscreenCanvas(1, height); | ||
if (type != "none") { | ||
let ctx = canvas.getContext(type); | ||
debug(`Got context: "${ctx}"`); | ||
} | ||
canvas.width = 100; | ||
try { | ||
let result = canvas.transferToImageBitmap(); | ||
if (result) | ||
debug(`Got result with size: ${result.width}x${result.height}`); | ||
else | ||
debug(`Got result: "${result}"`); | ||
} catch (e) { | ||
debug(`Got exception: "${e}"`); | ||
} | ||
delete ctx; | ||
delete canvas; | ||
} | ||
} | ||
} | ||
runTest(); | ||
</script> | ||
</body> |
41 changes: 41 additions & 0 deletions
41
LayoutTests/platform/ios/fast/canvas/offscreen-giant-transfer-to-imagebitmap-expected.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,43 @@ | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 67108864). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 67108864). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 67108864). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 67108864). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 67108864). | ||
Testing height: 100 type: none | ||
Got exception: "InvalidStateError: The object is in an invalid state." | ||
Testing height: 100 type: 2d | ||
Got context: "[object OffscreenCanvasRenderingContext2D]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: webgl | ||
Got context: "[object WebGLRenderingContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: webgl2 | ||
Got context: "[object WebGL2RenderingContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: webgpu | ||
Got context: "[object GPUCanvasContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: bitmaprenderer | ||
Got context: "[object ImageBitmapRenderingContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100000000 type: none | ||
Got exception: "InvalidStateError: The object is in an invalid state." | ||
Testing height: 100000000 type: 2d | ||
Got context: "[object OffscreenCanvasRenderingContext2D]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: webgl | ||
Got context: "[object WebGLRenderingContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: webgl2 | ||
Got context: "[object WebGL2RenderingContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: webgpu | ||
Got context: "[object GPUCanvasContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: bitmaprenderer | ||
Got context: "[object ImageBitmapRenderingContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
43 changes: 43 additions & 0 deletions
43
...utTests/platform/mac-wk2/fast/canvas/offscreen-giant-transfer-to-imagebitmap-expected.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456). | ||
CONSOLE MESSAGE: Canvas area exceeds the maximum limit (width * height > 268435456). | ||
Testing height: 100 type: none | ||
Got exception: "InvalidStateError: The object is in an invalid state." | ||
Testing height: 100 type: 2d | ||
Got context: "[object OffscreenCanvasRenderingContext2D]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: webgl | ||
Got context: "[object WebGLRenderingContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: webgl2 | ||
Got context: "[object WebGL2RenderingContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: webgpu | ||
Got context: "[object GPUCanvasContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100 type: bitmaprenderer | ||
Got context: "[object ImageBitmapRenderingContext]" | ||
Got result with size: 100x100 | ||
Testing height: 100000000 type: none | ||
Got exception: "InvalidStateError: The object is in an invalid state." | ||
Testing height: 100000000 type: 2d | ||
Got context: "[object OffscreenCanvasRenderingContext2D]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: webgl | ||
Got context: "[object WebGLRenderingContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: webgl2 | ||
Got context: "[object WebGL2RenderingContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: webgpu | ||
Got context: "[object GPUCanvasContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
Testing height: 100000000 type: bitmaprenderer | ||
Got context: "[object ImageBitmapRenderingContext]" | ||
Got exception: "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." | ||
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
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.