forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Make
new ImageData()
use unpremultiplied color data
This was already the case for `context.createImageData()`, but I forgot to do the same for `new ImageData()`. Add a regression test for both cases.
- Loading branch information
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
Tests/LibWeb/Text/expected/HTML/canvas-putImageData-unpremultiplied.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,2 @@ | ||
PASS | ||
PASS |
29 changes: 29 additions & 0 deletions
29
Tests/LibWeb/Text/input/HTML/canvas-putImageData-unpremultiplied.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,29 @@ | ||
<script src="../include.js"></script> | ||
<body><canvas id=c width=1 height=2></div> | ||
<script> | ||
test(() => { | ||
// Test createImageData + putImageData | ||
let ctx1 = c.getContext('2d'); | ||
let img1 = ctx1.createImageData(1, 1); | ||
img1.data[0] = 50; | ||
img1.data[1] = 100; | ||
img1.data[2] = 200; | ||
img1.data[3] = 0; | ||
ctx1.putImageData(img1, 0, 0); | ||
let buf1 = ctx1.getImageData(0, 0, 1, 1); | ||
if (buf1.data[0] === 0 && buf1.data[1] === 0 && buf1.data[2] === 0 && buf1.data[3] === 0) | ||
println("PASS"); | ||
else | ||
println("FAIL"); | ||
|
||
// Test new ImageData + putImageData | ||
let ctx2 = c.getContext('2d'); | ||
let img2 = new ImageData(new Uint8ClampedArray([50, 100, 200, 0]), 1, 1); | ||
ctx2.putImageData(img2, 0, 0); | ||
let buf2 = ctx2.getImageData(0, 0, 1, 1); | ||
if (buf2.data[0] === 0 && buf2.data[1] === 0 && buf2.data[2] === 0 && buf2.data[3] === 0) | ||
println("PASS"); | ||
else | ||
println("FAIL"); | ||
}); | ||
</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