mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
graphics/: Correct logic for copy of bit maps with resolution less than 8 bits from the per-window framebuffer to the device.
This commit is contained in:
@@ -179,16 +179,11 @@ static inline void nxbe_filltrapezoid_pwfb(FAR struct nxbe_window_s *wnd,
|
||||
FAR const struct nxgl_trapezoid_s *trap,
|
||||
nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
|
||||
{
|
||||
FAR const void *src[CONFIG_NX_NPLANES];
|
||||
struct nxgl_trapezoid_s reltrap;
|
||||
struct nxgl_rect_s relbounds;
|
||||
FAR const void *src[CONFIG_NX_NPLANES] =
|
||||
{
|
||||
(FAR const void *)wnd->fbmem
|
||||
};
|
||||
struct nxgl_point_s origin =
|
||||
{
|
||||
0, 0
|
||||
};
|
||||
struct nxgl_point_s origin;
|
||||
unsigned int bpp;
|
||||
|
||||
/* Both the rectangle that we receive here are in abolute device
|
||||
* coordinates. We need to restore both to windows relative coordinates.
|
||||
@@ -207,7 +202,55 @@ static inline void nxbe_filltrapezoid_pwfb(FAR struct nxbe_window_s *wnd,
|
||||
wnd->be->plane[0].pwfb.filltrapezoid(wnd, &reltrap, &relbounds,
|
||||
color[0]);
|
||||
|
||||
/* Copy the portion of the per-window framebuffer in the bounding box
|
||||
/* Get the source of address of the trapezoid bounding box in the
|
||||
* framebuffer.
|
||||
*/
|
||||
|
||||
bpp = wnd->be->plane[0].pinfo.bpp;
|
||||
src[0] = (FAR const void *)
|
||||
((FAR uint8_t *)wnd->fbmem +
|
||||
relbounds.pt1.y * wnd->stride +
|
||||
((bpp * relbounds.pt1.x) >> 3));
|
||||
|
||||
/* For resolutions less than 8-bits, the starting pixel will be contained
|
||||
* in the byte pointed to by src[0]but may not be properly aligned for
|
||||
* the transfer. We fix this by modifying the origin.
|
||||
*/
|
||||
|
||||
origin.x = relbounds.pt1.x;
|
||||
origin.y = relbounds.pt1.y;
|
||||
|
||||
switch (bpp)
|
||||
{
|
||||
#ifndef CONFIG_NX_DISABLE_1BPP
|
||||
case 1: /* 1 bit per pixel */
|
||||
{
|
||||
origin.x &= ~7;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NX_DISABLE_2BPP
|
||||
case 2: /* 2 bits per pixel */
|
||||
{
|
||||
origin.x &= ~3;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NX_DISABLE_4BPP
|
||||
case 4: /* 4 bits per pixel */
|
||||
{
|
||||
origin.x &= ~1;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Copy the portion of the per-window framebuffer in the bounding box
|
||||
* to the device graphics memory.
|
||||
*/
|
||||
|
||||
|
||||
+44
-16
@@ -294,14 +294,11 @@ static inline void nxbe_move_pwfb(FAR struct nxbe_window_s *wnd,
|
||||
FAR const struct nxgl_rect_s *rect,
|
||||
FAR const struct nxgl_point_s *offset)
|
||||
{
|
||||
FAR const void *src[CONFIG_NX_NPLANES];
|
||||
struct nxgl_point_s destpos;
|
||||
struct nxgl_point_s origin;
|
||||
struct nxgl_rect_s srcrect;
|
||||
struct nxgl_rect_s destrect;
|
||||
FAR const void *src[CONFIG_NX_NPLANES];
|
||||
FAR const struct nxgl_point_s origin =
|
||||
{
|
||||
0, 0
|
||||
};
|
||||
unsigned int bpp;
|
||||
|
||||
/* The rectangle that we receive here is in abolute device coordinates. We
|
||||
@@ -330,23 +327,54 @@ static inline void nxbe_move_pwfb(FAR struct nxbe_window_s *wnd,
|
||||
|
||||
nxgl_rectoffset(&destrect, &srcrect, offset->x, offset->y);
|
||||
|
||||
/* Update the physical device by just copying the rectangle from the
|
||||
* framebuffer to the device graphics memory.
|
||||
*
|
||||
* Get the source of address of the moved rectangle in the framebuffer.
|
||||
* REVISIT: For resolutions less than 8-bits, the starting pixel will
|
||||
* be contained in the byte pointed to by src[0]but may not be properly
|
||||
* aligned for the transfer.
|
||||
*/
|
||||
/* Get the source of address of the moved rectangle in the framebuffer. */
|
||||
|
||||
bpp = wnd->be->plane[0].pinfo.bpp;
|
||||
src[0] = (FAR void *)
|
||||
src[0] = (FAR const void *)
|
||||
((FAR uint8_t *)wnd->fbmem +
|
||||
destrect.pt1.y * wnd->stride +
|
||||
((bpp * destrect.pt1.x) >> 3));
|
||||
|
||||
/* Then transfer the rectangle to the destination rectangle in the
|
||||
* device memory.
|
||||
/* For resolutions less than 8-bits, the starting pixel will be contained
|
||||
* in the byte pointed to by src[0]but may not be properly aligned for
|
||||
* the transfer. We fix this by modifying the origin.
|
||||
*/
|
||||
|
||||
origin.x = destrect.pt1.x;
|
||||
origin.y = destrect.pt1.y;
|
||||
|
||||
switch (bpp)
|
||||
{
|
||||
#ifndef CONFIG_NX_DISABLE_1BPP
|
||||
case 1: /* 1 bit per pixel */
|
||||
{
|
||||
origin.x &= ~7;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NX_DISABLE_2BPP
|
||||
case 2: /* 2 bits per pixel */
|
||||
{
|
||||
origin.x &= ~3;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NX_DISABLE_4BPP
|
||||
case 4: /* 4 bits per pixel */
|
||||
{
|
||||
origin.x &= ~1;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the physical device by just copying the rectangle from the
|
||||
* framebuffer to the destination rectangle device graphics memory.
|
||||
*/
|
||||
|
||||
nxbe_bitmap_dev(wnd, &destrect, src, &origin, wnd->stride);
|
||||
|
||||
Reference in New Issue
Block a user