-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebKit export of https://bugs.webkit.org/show_bug.cgi?id=229025 (#31226)
- Loading branch information
Showing
13 changed files
with
202 additions
and
23 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
55 changes: 55 additions & 0 deletions
55
...anvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-ImageBitmap-video.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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE HTML> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="canvas-display-p3.js"></script> | ||
<body> | ||
<script> | ||
// Test that drawing ImageBitmaps with different video source color profiles | ||
// into sRGB and Display P3 canvases works, by reading pixels with | ||
// getImageData() as sRGB and Display P3 values. | ||
for (let [filenameBase, expectedPixels] of Object.entries(videoTests)) { | ||
for (let contextColorSpace of ["srgb", "display-p3"]) { | ||
for (let imageDataColorSpace of ["srgb", "display-p3"]) { | ||
for (let cropSource of [false, true]) { | ||
async_test(function(t) { | ||
let video = document.createElement("video"); | ||
video.onloadeddata = t.step_func(function() { | ||
|
||
let canvas = document.createElement("canvas"); | ||
canvas.width = 2; | ||
canvas.height = 2; | ||
|
||
let ctx = canvas.getContext("2d", { colorSpace: contextColorSpace }); | ||
|
||
let imageBitmapPromise; | ||
if (cropSource) | ||
imageBitmapPromise = createImageBitmap(video, 1, 1, 1, 1); | ||
else | ||
imageBitmapPromise = createImageBitmap(video); | ||
|
||
imageBitmapPromise.then(t.step_func_done(function(imageBitmap) { | ||
video.remove(); | ||
ctx.drawImage(imageBitmap, 0, 0); | ||
|
||
let imageData = ctx.getImageData(0, 0, 1, 1, { colorSpace: imageDataColorSpace }); | ||
|
||
let expected = expectedPixels[`${contextColorSpace} ${imageDataColorSpace}`]; | ||
assert_true(pixelsApproximatelyEqual(imageData.data, expected), `Actual pixel value ${[...imageData.data]} is approximately equal to ${expected}.`); | ||
}), t.step_func(function(error) { | ||
video.remove(); | ||
throw error; | ||
})); | ||
}); | ||
for (let format of ["mp4", "webm"]) { | ||
let source = document.createElement("source"); | ||
source.src = `resources/${filenameBase}.${format}`; | ||
source.type = `video/${format}`; | ||
video.append(source); | ||
} | ||
document.body.append(video); | ||
}, `${filenameBase}, Context ${contextColorSpace}, ImageData ${imageDataColorSpace}, cropSource=${cropSource}`); | ||
} | ||
} | ||
} | ||
} | ||
</script> |
46 changes: 46 additions & 0 deletions
46
html/canvas/element/manual/wide-gamut-canvas/canvas-display-p3-drawImage-video.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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE HTML> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="canvas-display-p3.js"></script> | ||
<body> | ||
<script> | ||
// Test that drawing videos with different color spaces into sRGB and Display P3 | ||
// canvases works, by reading pixels with getImageData() as sRGB and Display P3 | ||
// values. | ||
for (let [filenameBase, expectedPixels] of Object.entries(videoTests)) { | ||
for (let contextColorSpace of ["srgb", "display-p3"]) { | ||
for (let imageDataColorSpace of ["srgb", "display-p3"]) { | ||
for (let scaleImage of [false, true]) { | ||
async_test(function(t) { | ||
let video = document.createElement("video"); | ||
video.onloadeddata = t.step_func_done(function() { | ||
|
||
let canvas = document.createElement("canvas"); | ||
canvas.width = 2; | ||
canvas.height = 2; | ||
|
||
let ctx = canvas.getContext("2d", { colorSpace: contextColorSpace }); | ||
if (scaleImage) | ||
ctx.drawImage(video, 0, 0, 10, 10); | ||
else | ||
ctx.drawImage(video, 0, 0); | ||
video.remove(); | ||
|
||
let imageData = ctx.getImageData(0, 0, 1, 1, { colorSpace: imageDataColorSpace }); | ||
|
||
let expected = expectedPixels[`${contextColorSpace} ${imageDataColorSpace}`]; | ||
assert_true(pixelsApproximatelyEqual(imageData.data, expected), `Actual pixel value ${[...imageData.data]} is approximately equal to ${expected}.`); | ||
}); | ||
for (let format of ["mp4", "webm"]) { | ||
let source = document.createElement("source"); | ||
source.src = `resources/${filenameBase}.${format}`; | ||
source.type = `video/${format}`; | ||
video.append(source); | ||
} | ||
document.body.append(video); | ||
}, `${filenameBase}, Context ${contextColorSpace}, ImageData ${imageDataColorSpace}, scaleImage=${scaleImage}`); | ||
} | ||
} | ||
} | ||
} | ||
</script> |
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
Binary file added
BIN
+3.2 KB
html/canvas/element/manual/wide-gamut-canvas/resources/Rec2020-222000000.mp4
Binary file not shown.
Binary file added
BIN
+604 Bytes
html/canvas/element/manual/wide-gamut-canvas/resources/Rec2020-222000000.webm
Binary file not shown.
Binary file added
BIN
+3.2 KB
html/canvas/element/manual/wide-gamut-canvas/resources/Rec2020-3FF000000.mp4
Binary file not shown.
Binary file added
BIN
+605 Bytes
html/canvas/element/manual/wide-gamut-canvas/resources/Rec2020-3FF000000.webm
Binary file not shown.
Binary file added
BIN
+1.56 KB
html/canvas/element/manual/wide-gamut-canvas/resources/sRGB-BB0000.mp4
Binary file not shown.
Binary file added
BIN
+604 Bytes
html/canvas/element/manual/wide-gamut-canvas/resources/sRGB-BB0000.webm
Binary file not shown.
Binary file added
BIN
+1.56 KB
html/canvas/element/manual/wide-gamut-canvas/resources/sRGB-FF0100.mp4
Binary file not shown.
Binary file added
BIN
+605 Bytes
html/canvas/element/manual/wide-gamut-canvas/resources/sRGB-FF0100.webm
Binary file not shown.