ghaerr / microwindows

The Nano-X Window System
Other
658 stars 90 forks source link

GrArea() with MWPF_PIXELVAL will crash #89

Closed ChauncyZhang closed 1 month ago

ChauncyZhang commented 1 month ago

When I call GrArea() with MWPF_PIXELVAL, it will be crash, but when I change to MWPF_TRUECOLORRGB, it can show correctly. My frame format is RGB888, and my device fb' information below that

fbset -i

mode "1280x720" geometry 1280 720 1920 1080 32 timings 0 0 0 0 0 0 0 accel true rgba 8/16,8/8,8/0,0/0 endmode

Frame buffer device information: Name : sun4i-drmdrmfb Address : 0 Size : 8294400 Type : PACKED PIXELS Visual : TRUECOLOR XPanStep : 1 YPanStep : 1 YWrapStep : 0 LineLength : 7680 Accelerator : No

So I think my frame format is matching the fb format, it can use MWPF_PIXELVAL. I use MWPF_PIXELVAL, because using RGB888 is will slowly. So how can I do?

ChauncyZhang commented 1 month ago

Hello @ghaerr

ghaerr commented 1 month ago

I'm traveling right now, so can't fully look at the code involved. In general, using MWPF_PIXELVAL will default to using whatever your config file SCREEN_PIXTYPE is set to. Is that SCREEN_PIXTYPE = MWPF_TRUECOLORARGB?

If so, perhaps try passing MWPF_TRUECOLORARGB (or MWPF_TRUECOLORRGBA) jnstead. Long story short, Microwindows does best when the data passed to GrArea is the same format as the hardware. This allows a direct screen copy to occur, while otherwise it may convert to pixel-by-pixel drawing, which is likely the case if you pass MWPF_RGB888. So perhaps convert your images to ARGB before trying to draw them? I would need more data on the exact layouts of the screen and draw data to understand fully, as well as the CPU type and config.

Are you on a RISC machine? I don't yet understand the reason for the crash, unless the draw code is possibly trying to access the framebuffer at a byte rather than long-word address (which shouldn't normally happen).

ChauncyZhang commented 1 month ago

OK,I will check the format, Wish you have a good time.