| // copyTo() of new VideoFrame(imageBitmap) for an ImageBitmap of the video-formats pattern in every | |
| // color space: the frame copied to its own format gives the values of the bitmap, and copied to RGBA | |
| // or BGRA gives the pattern color-managed from the color space of the bitmap to the requested color | |
| // space, with straight alpha. | |
| const slices = { | |
| "srgb-default-format": ({ frameColorSpace, format }) => frameColorSpace == "srgb" && !format, | |
| "display-p3-default-format": ({ frameColorSpace, format }) => frameColorSpace == "display-p3" && !format, | |
| "display-p3-rgb-format": ({ frameColorSpace, format }) => frameColorSpace == "display-p3" && !!format, | |
| }; | |
| async function testCopyTo(t, { frameColorSpace, format, colorSpace }) | |
| { | |
| const { frame, info } = await sharedSource(frameColorSpace, async () => { | |
| // Without color space conversion, the bitmap has the colors of the ImageData in its color space. | |
| const bitmap = await createImageBitmap(patternImageData(frameColorSpace), { colorSpaceConversion: "none" }); | |
| const frame = new VideoFrame(bitmap, { timestamp: 0 }); | |
| bitmap.close(); | |
| return { frame, info: imagePatternInfo(frameColorSpace), close() { frame.close(); } }; | |
| }); | |
| await assertPatternFrameCopyTo(frame, info, "none", format, colorSpace); | |
| } | |
| for (const frameColorSpace of imageColorSpaces) { | |
| for (const format of copyToFormats) { | |
| for (const colorSpace of copyToColorSpaces) { | |
| const params = { source: "ImageBitmap", frameColorSpace, format, colorSpace }; | |
| if (isInCopyToSlice(params, slices)) | |
| promise_test(t => testCopyTo(t, params), copyToTestName(params)); | |
| } | |
| } | |
| } |