ReneHollander / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
www.automattic.com
3 stars 1 forks source link

Fixing fbdev #7

Closed piranna closed 9 years ago

piranna commented 9 years ago

Use fb_vinfo.xres_virtual to define stride. It works on my Lenovo laptop.

piranna commented 9 years ago

:+1:

piranna commented 9 years ago

I've managed to find the problem with QEmu framebuffer, it's an issue with the emulated Cirrus graphic card that only allows 24 bits colors while Caire 24 bits format is in fact 32 bits ignoring the alpha channel, so there was a bitrod. I've changed to the stdvga emulated graphic cand and use a 32 bits color depth mode and it work flawlessly, so I think the FbDev backend is finished at all :-)

ReneHollander commented 9 years ago

Thats good news! I maybe need to look into a better way of detecting the color format from the framebuffer device to create cairo surface.

piranna commented 9 years ago

Problem is, Cairo don't support real 24 bits mode... :-/ Don't know if something could be done with the colors masks or some similar trick, but if not, only option for this particular use case will be to have two buffers (one for Cairo and another for framebuffer) and copy and addapt the pixels info between them... :-/ Ideally Cairo should work directly with real 24 bits, but if this is not possible... :-(

ReneHollander commented 9 years ago

Hmm. Then I will leave it as is for now...

piranna commented 9 years ago

Maybe we can ask Cairo guys...

piranna commented 9 years ago

I've been reviewing the code and found we are using a bad 8 bits format too, since A8 is only to define an alpha channel. The same happens with the 1 bit format, so only ones that have a direct translation between Cairo and FbDev are ARGB and 565 modes, and Cairo RGB24 could be easily converted to FbDev 24 bits but with a penalty on performance. I think the best option would be to only allow to use ARGB (32 bits) and 565 (16 bits) modes and throw an exception when trying to use any other format, and "maybe" craft a conversion function for 24 bits. What do you think?

ReneHollander commented 9 years ago

Sounds good

piranna commented 9 years ago

Done ;-)