trevorlinton / webkit.js

Pure JavaScript Port of WebKit
1.95k stars 87 forks source link

wrong colors #31

Closed mscdex closed 10 years ago

mscdex commented 10 years ago

I know this is still a WIP but I thought I'd mention that blue and red seem to be swapped in element styles (e.g. 'body style="background-color: red"' gives a blue background, same if you use the hex representation of #FF0000).

trevorlinton commented 10 years ago

Thanks Brian,

The issue comes down to SDL using a pre-multiplied RGBA big endian format, cairo using a per-pixel-multiplied ARGB big endian format, and subsequent bitblts coming out of the pipeline are getting mixed up. Since this is going back into a RGBA canvas pre-multiplied format as little endian with only the first three blocks it essentially enters into the canvas as BGR without an alpha (you may notice that using transparent colors doesnt do anything.)

This is sadly a much harder problem to fix, I can switch around the channels right before the write to the canvas in the example.html, but it still leaves the per-pixel multiply issue (colors are actually slightly off, but no one has noticed) and the lack of alpha transparency. Not to mention its just bad performance going pixel by pixel flipping channels :).

trevorlinton commented 10 years ago

Fixed as of v0.1

mscdex commented 10 years ago

:thumbsup: