cederom commented on PR #4173:
URL: https://github.com/apache/nuttx-apps/pull/4173#issuecomment-7247627022

   Thanks, nice cleanup — the three fixes are each correct as far as I can 
tell, and splitting them per commit makes review easy. A few comments, one of 
which I think should be addressed before merge.
   
   ### 1. `fbcon_renderglyph()` still overflows the glyph buffer when 
`nxgl_mxpixel_t` is wider than `FBCON_BPP` (please fix)
   
   Not touched by this PR, but it undermines the 16 bpp fix. `nxgl_mxpixel_t` 
is `uint32_t` whenever 24 or 32 bpp is enabled in NX 
(`include/nuttx/nx/nxtypes.h`), independent of `FBCON_BPP`. The background-init 
loop for 8/16/32 bpp does:
   
   ```c
   ptr = (FAR nxgl_mxpixel_t *)glyph->bitmap;
   for (row = 0; row < glyph->height; row++)
     for (col = 0; col < glyph->width; col++)
       *ptr++ = st->bcolor;
   ```
   
   while the buffer is only `stride * height` bytes, with `stride = (width * 
FBCON_BPP + 7) / 8`. With `FBCON_BPP == 16` and `CONFIG_NX_DISABLE_32BPP=n` 
(e.g. `CONFIG_EXAMPLES_FBCON_16BPP` on a config that also enables 32 bpp), this 
writes 2x the allocation (4x at 8 bpp), so it corrupts the heap. The `RENDERER` 
call also passes `nxgl_mxpixel_t *` to `nxf_convert_16bpp(FAR uint16_t *, 
...)`, which gives an incompatible-pointer warning in that config.
   
   I guess the test board has only 16 bpp enabled, so `nxgl_mxpixel_t` is 
`uint16_t` and this doesn't show up. Since the PR's aim is making 16 bpp work, 
could you fix it in the first commit (or a separate one)? Use a pointer of the 
pixel type that matches `FBCON_BPP` (`uint8_t` / `uint16_t` / `uint32_t`), or 
fill the rows using the same per-depth logic as the new `fbcon_fill()`.
   
   ### 2. Sub-byte depths are still broken, but nothing says so
   
   For 1/2/4 bpp, `FBCON_OFFSET()` truncates to the containing byte and 
`memcpy()` / `memset()` write whole bytes. So a glyph or fill that starts at an 
x not aligned to a byte is shifted left and overwrites its neighbour's pixels. 
With proportional fonts, character x positions are generally not byte-aligned. 
This is no worse than before (the old code wrote `uint32_t`s), and the comment 
in `fbcon_fill()` mentions the assumption. Still, the commit message only says 
24 bpp is unsupported. Please either say the same for < 8 bpp, or add an 
`#error`/`#warning` alongside the 24 bpp one, so nobody assumes these depths 
work now.
   
   Minor: the nibble-packing block in `fbcon_fill()` duplicates the one in 
`fbcon_renderglyph()`. A small `fbcon_packpixel()` helper would keep them in 
sync.
   
   ### 3. `FBIO_UPDATE`: consider handling `-ENOTTY`
   
   `CONFIG_FB_UPDATE` is a global option (selected by `LCD_FRAMEBUFFER`, VNC, 
...), but `fb_ioctl()` returns `-ENOTTY` when the particular framebuffer has no 
`updatearea` method. On a config that has, say, VNC or an LCD framebuffer and 
fbcon running on a memory-mapped `/dev/fbN`, every pass that changes something 
will log `ioctl(FBIO_UPDATE) failed`. Suggestion: on `ENOTTY`, set a flag and 
stop issuing the ioctl (and stop tracking dirty areas).
   
   Otherwise the dirty tracking looks good: all framebuffer writes go through 
`fbcon_bitmap()` / `fbcon_fill()`, the initial clear in `fbcon_initialize()` is 
flushed on the first loop pass, and one union per 10 ms pass is a reasonable 
tradeoff.
   
   Nit: the new `dirty` / `isdirty` fields sit between `bm` and `glyph`, which 
splits the bitmap/glyph-cache group. Moving them to the end of the struct would 
read better.
   
   ### 4. Echo fix
   
   Correct. `buf` is the stdout/stderr buffer, so echoing it was clearly wrong. 
I also checked that readline doesn't echo normally inserted characters itself 
(it relies on the terminal's echo and only redraws the tail when inserting 
mid-line), so echoing `ch` here doesn't produce double characters.
   
   ### Optional (pre-existing)
   
   There's no runtime check that `pinfo->bpp == FBCON_BPP`. A mismatch (e.g. 
`FBCON_BPP` 32 on a 16 bpp framebuffer) makes `fbcon_bitmap()` / `fbcon_fill()` 
write up to 2x past `fblen`. A one-line check after `FBIOGET_PLANEINFO` that 
fails cleanly would be cheap insurance, though it may be better as a follow-up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to