Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/element/manual/imagebitmap/imageBitmapRendering-transferFromImageBitmap-webgl.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<link rel="match" href="imageBitmapRendering-transferFromImageBitmap-webgl-expected.html" />
<body>
<p>
Test creating an ImageBitmap from the transferToImageBitmap of a webgl OffscreenCanvas, and then
transferred to an ImageBitmapRenderingContext.
</p>
<canvas id="canvas" width="300" height="300"></canvas>
</body>
<script>
function drawSquares(ctx) {
ctx.enable(ctx.SCISSOR_TEST);
ctx.scissor(0, 150, 150, 150);
ctx.clearColor(1, 0, 0, 1);
ctx.clear(ctx.COLOR_BUFFER_BIT);
ctx.scissor(150, 150, 300, 150);
ctx.clearColor(0, 1, 0, 1);
ctx.clear(ctx.COLOR_BUFFER_BIT);
ctx.scissor(0, 0, 150, 150);
ctx.clearColor(0, 0, 1, 1);
ctx.clear(ctx.COLOR_BUFFER_BIT);
}
async function runTest() {
const offscreen = new OffscreenCanvas(300, 300);
const ctxOffscreen = offscreen.getContext('webgl');
drawSquares(ctxOffscreen);
const image = offscreen.transferToImageBitmap();
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('bitmaprenderer');
ctx.transferFromImageBitmap(image);
}
runTest();
</script>