LadybirdBrowser / ladybird

Truly independent web browser
https://ladybird.org
BSD 2-Clause "Simplified" License
21.55k stars 947 forks source link

LibWeb: Canvas draws transparent images with a white background #1104

Closed jamierocks closed 2 months ago

jamierocks commented 2 months ago
Ladybird Expected (Firefox)
image image

Minimal reproduction

<script type="module">
    const canvas = document.querySelector('#canvas');
    const ctx = canvas.getContext('2d');

    const img = new Image();
    img.addEventListener("load", () => {
        ctx.drawImage(img, 10, 10, 100, 151);
    });
    img.src = 'https://housepoints-v2.pages.dev/assets/bar-chart/Apollo.png';
</script>
<style>
    html, body {
        height: 100%;
    }
    #canvas {
        background-image: url('https://housepoints-v2.pages.dev/assets/config/imperial-wallpaper.jpg');
        width: 100%;
        height: 100%;
    }
</style>

<canvas id="canvas"></canvas>
tcl3 commented 2 months ago

This appears to be a regression.

Bisected to: 5865cf5

Cc: @gmta

For reference, prior to this commit, the above image looked like this in Ladybird: image

gmta commented 2 months ago

Whoops, will need to check! @awesomekling has a skia branch that we need to compare this with as well.

awesomekling commented 2 months ago

FWIW here it is on my Skia-backed canvas branch:

image

Looks like some premul/unpremul tweaks still needed :)

circl-lastname commented 2 months ago

Mostly fixed by #1024

gmta commented 2 months ago

@circl-lastname I've got a final fix incoming for this issue.