Add support for low resolution rasterizers
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1388 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
6bf0e7f97b
commit
981d2a73be
@ -43,12 +43,12 @@ TFILL1_CSRCS = nxglib_filltrapezoid_1bpp.c nxglib_filltrapezoid_2bpp.c \
|
||||
nxglib_filltrapezoid_4bpp.c
|
||||
TFILL2_CSRCS = nxglib_filltrapezoid_8bpp.c nxglib_filltrapezoid_16bpp.c \
|
||||
nxglib_filltrapezoid_24bpp.c nxglib_filltrapezoid_32bpp.c
|
||||
#RMOVE1_CSRCS = nxglib_moverectangle_1bpp.c nxglib_moverectangle_2bpp.c \
|
||||
# nxglib_moverectangle_4bpp.c
|
||||
RMOVE1_CSRCS = nxglib_moverectangle_1bpp.c nxglib_moverectangle_2bpp.c \
|
||||
nxglib_moverectangle_4bpp.c
|
||||
RMOVE2_CSRCS = nxglib_moverectangle_8bpp.c nxglib_moverectangle_16bpp.c \
|
||||
nxglib_moverectangle_24bpp.c nxglib_moverectangle_32bpp.c
|
||||
#RCOPY1_CSRCS = nxglib_copyrectangle_1bpp.c nxglib_copyrectangle_2bpp.c \
|
||||
# nxglib_copyrectangle_4bpp.c
|
||||
RCOPY1_CSRCS = nxglib_copyrectangle_1bpp.c nxglib_copyrectangle_2bpp.c \
|
||||
nxglib_copyrectangle_4bpp.c
|
||||
RCOPY2_CSRCS = nxglib_copyrectangle_8bpp.c nxglib_copyrectangle_16bpp.c \
|
||||
nxglib_copyrectangle_24bpp.c nxglib_copyrectangle_32bpp.c
|
||||
RECT_CSRCS = nxglib_rectcopy.c nxglib_rectoffset.c nxglib_vectoradd.c \
|
||||
|
@ -83,12 +83,21 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX)
|
||||
FAR const void *src, FAR const struct nxgl_point_s *origin,
|
||||
unsigned int srcstride)
|
||||
{
|
||||
const ubyte *sptr;
|
||||
ubyte *dptr;
|
||||
FAR const ubyte *sline;
|
||||
FAR ubyte *dline;
|
||||
unsigned int width;
|
||||
unsigned int deststride;
|
||||
unsigned int rows;
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
FAR const ubyte *sptr;
|
||||
FAR ubyte *dptr;
|
||||
ubyte leadmask;
|
||||
ubyte tailmask;
|
||||
ubyte mask;
|
||||
int lnlen;
|
||||
#endif
|
||||
|
||||
/* Get the width of the framebuffer in bytes */
|
||||
|
||||
deststride = pinfo->stride;
|
||||
@ -98,15 +107,70 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX)
|
||||
width = NXGL_SCALEX(dest->pt2.x - dest->pt1.x);
|
||||
rows = dest->pt2.y - dest->pt1.y;
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
# ifdef CONFIG_NXGL_PACKEDMSFIRST
|
||||
|
||||
/* Get the mask for pixels that are ordered so that they pack from the
|
||||
* MS byte down.
|
||||
*/
|
||||
|
||||
leadmask = (ubyte)(0xff >> (8 - NXGL_REMAINDERX(dest->pt1.x)));
|
||||
tailmask = (ubyte)(0xff << (8 - NXGL_REMAINDERX(dest->pt2.x-1)));
|
||||
# else
|
||||
/* Get the mask for pixels that are ordered so that they pack from the
|
||||
* LS byte up.
|
||||
*/
|
||||
|
||||
leadmask = (ubyte)(0xff << (8 - NXGL_REMAINDERX(dest->pt1.x)));
|
||||
tailmask = (ubyte)(0xff >> (8 - NXGL_REMAINDERX(dest->pt1.x-1)));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Then copy the image */
|
||||
|
||||
sptr = (const ubyte*)src + NXGL_SCALEX(dest->pt1.x - origin->x) + (dest->pt1.y - origin->y) * srcstride;
|
||||
dptr = pinfo->fbmem + dest->pt1.y * deststride + NXGL_SCALEX(dest->pt1.x);
|
||||
sline = (const ubyte*)src + NXGL_SCALEX(dest->pt1.x - origin->x) + (dest->pt1.y - origin->y) * srcstride;
|
||||
dline = pinfo->fbmem + dest->pt1.y * deststride + NXGL_SCALEX(dest->pt1.x);
|
||||
|
||||
while (rows--)
|
||||
{
|
||||
NXGL_MEMCPY((NXGL_PIXEL_T*)dest, (NXGL_PIXEL_T*)sptr, width);
|
||||
dptr += deststride;
|
||||
sptr += srcstride;
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
/* Handle masking of the fractional initial byte */
|
||||
|
||||
mask = leadmask;
|
||||
sptr = sline;
|
||||
dptr = dline;
|
||||
lnlen = width;
|
||||
|
||||
if (lnlen > 1 && mask)
|
||||
{
|
||||
dptr[0] = (dptr[0] & ~mask) | (sptr[0] & mask);
|
||||
mask = 0xff;
|
||||
dptr++;
|
||||
sptr++;
|
||||
lnlen--;
|
||||
}
|
||||
|
||||
/* Handle masking of the fractional final byte */
|
||||
|
||||
mask &= tailmask;
|
||||
if (lnlen > 0 && mask)
|
||||
{
|
||||
dptr[lnlen-1] = (dptr[lnlen-1] & ~mask) | (sptr[lnlen-1] & mask);
|
||||
lnlen--;
|
||||
}
|
||||
|
||||
/* Handle all of the unmasked bytes in-between */
|
||||
|
||||
if (lnlen > 0)
|
||||
{
|
||||
NXGL_MEMCPY(dptr, sptr, lnlen);
|
||||
}
|
||||
#else
|
||||
/* Copy the whole line */
|
||||
|
||||
NXGL_MEMCPY((NXGL_PIXEL_T*)dest, (NXGL_PIXEL_T*)sline, width);
|
||||
#endif
|
||||
dline += deststride;
|
||||
sline += srcstride;
|
||||
}
|
||||
}
|
||||
|
@ -84,18 +84,18 @@
|
||||
void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX)
|
||||
(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color)
|
||||
{
|
||||
ubyte *line;
|
||||
FAR ubyte *line;
|
||||
unsigned int width;
|
||||
unsigned int stride;
|
||||
int rows;
|
||||
int rows;
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
ubyte *dest;
|
||||
ubyte mpixel = NXGL_MULTIPIXEL(color);
|
||||
ubyte leadmask;
|
||||
ubyte tailmask;
|
||||
ubyte mask;
|
||||
int lnlen;
|
||||
FAR ubyte *dest;
|
||||
ubyte mpixel = NXGL_MULTIPIXEL(color);
|
||||
ubyte leadmask;
|
||||
ubyte tailmask;
|
||||
ubyte mask;
|
||||
int lnlen;
|
||||
#endif
|
||||
|
||||
/* Get the width of the framebuffer in bytes */
|
||||
|
@ -92,7 +92,7 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)(
|
||||
{
|
||||
unsigned int stride;
|
||||
unsigned int width;
|
||||
ubyte *line;
|
||||
FAR ubyte *line;
|
||||
int nrows;
|
||||
b16_t x1;
|
||||
b16_t x2;
|
||||
@ -102,10 +102,10 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)(
|
||||
b16_t dx2dy;
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
ubyte *dest;
|
||||
ubyte mpixel = NXGL_MULTIPIXEL(color);
|
||||
ubyte mask;
|
||||
int lnlen;
|
||||
FAR ubyte *dest;
|
||||
ubyte mpixel = NXGL_MULTIPIXEL(color);
|
||||
ubyte mask;
|
||||
int lnlen;
|
||||
#endif
|
||||
|
||||
/* Get the width of the framebuffer in bytes */
|
||||
|
@ -65,6 +65,54 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxgl_lowresmemcpy
|
||||
****************************************************************************/
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
static inline void nxgl_lowresmemcpy(FAR ubyte *dline, FAR const ubyte *sline,
|
||||
unsigned int width,
|
||||
ubyte leadmask, ubyte tailmask)
|
||||
{
|
||||
FAR const ubyte *sptr;
|
||||
FAR ubyte *dptr;
|
||||
ubyte mask;
|
||||
int lnlen;
|
||||
|
||||
/* Handle masking of the fractional initial byte */
|
||||
|
||||
mask = leadmask;
|
||||
sptr = sline;
|
||||
dptr = dline;
|
||||
lnlen = width;
|
||||
|
||||
if (lnlen > 1 && mask)
|
||||
{
|
||||
dptr[0] = (dptr[0] & ~mask) | (sptr[0] & mask);
|
||||
mask = 0xff;
|
||||
dptr++;
|
||||
sptr++;
|
||||
lnlen--;
|
||||
}
|
||||
|
||||
/* Handle masking of the fractional final byte */
|
||||
|
||||
mask &= tailmask;
|
||||
if (lnlen > 0 && mask)
|
||||
{
|
||||
dptr[lnlen-1] = (dptr[lnlen-1] & ~mask) | (sptr[lnlen-1] & mask);
|
||||
lnlen--;
|
||||
}
|
||||
|
||||
/* Handle all of the unmasked bytes in-between */
|
||||
|
||||
if (lnlen > 0)
|
||||
{
|
||||
NXGL_MEMCPY(dptr, sptr, lnlen);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -82,12 +130,17 @@ void NXGL_FUNCNAME(nxgl_moverectangle,NXGLIB_SUFFIX)
|
||||
(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect,
|
||||
FAR struct nxgl_point_s *offset)
|
||||
{
|
||||
const ubyte *sptr;
|
||||
ubyte *dptr;
|
||||
FAR const ubyte *sline;
|
||||
FAR ubyte *dline;
|
||||
unsigned int width;
|
||||
unsigned int stride;
|
||||
unsigned int rows;
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
ubyte leadmask;
|
||||
ubyte tailmask;
|
||||
#endif
|
||||
|
||||
/* Get the width of the framebuffer in bytes */
|
||||
|
||||
stride = pinfo->stride;
|
||||
@ -97,30 +150,60 @@ void NXGL_FUNCNAME(nxgl_moverectangle,NXGLIB_SUFFIX)
|
||||
width = NXGL_SCALEX(rect->pt2.x - rect->pt1.x);
|
||||
rows = rect->pt2.y - rect->pt1.y;
|
||||
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
# ifdef CONFIG_NXGL_PACKEDMSFIRST
|
||||
|
||||
/* Get the mask for pixels that are ordered so that they pack from the
|
||||
* MS byte down.
|
||||
*/
|
||||
|
||||
leadmask = (ubyte)(0xff >> (8 - NXGL_REMAINDERX(rect->pt1.x)));
|
||||
tailmask = (ubyte)(0xff << (8 - NXGL_REMAINDERX(rect->pt2.x-1)));
|
||||
# else
|
||||
/* Get the mask for pixels that are ordered so that they pack from the
|
||||
* LS byte up.
|
||||
*/
|
||||
|
||||
leadmask = (ubyte)(0xff << (8 - NXGL_REMAINDERX(rect->pt1.x)));
|
||||
tailmask = (ubyte)(0xff >> (8 - NXGL_REMAINDERX(rect->pt1.x-1)));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Case 1: The starting position is above the display */
|
||||
|
||||
if (offset->y < 0)
|
||||
{
|
||||
dptr = pinfo->fbmem + rect->pt1.y * stride + NXGL_SCALEX(rect->pt1.x);
|
||||
sptr = dptr - offset->y * stride - NXGL_SCALEX(offset->x);
|
||||
dline = pinfo->fbmem + rect->pt1.y * stride + NXGL_SCALEX(rect->pt1.x);
|
||||
sline = dline - offset->y * stride - NXGL_SCALEX(offset->x);
|
||||
|
||||
while (rows--)
|
||||
{
|
||||
NXGL_MEMCPY(dptr, sptr, width);
|
||||
dptr += stride;
|
||||
sptr += stride;
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
nxgl_lowresmemcpy(dline, sline, width, leadmask, tailmask);
|
||||
#else
|
||||
NXGL_MEMCPY(dline, sline, width);
|
||||
#endif
|
||||
dline += stride;
|
||||
sline += stride;
|
||||
}
|
||||
}
|
||||
|
||||
/* Case 2: It's not */
|
||||
|
||||
else
|
||||
{
|
||||
dptr = pinfo->fbmem + rect->pt2.y * stride + NXGL_SCALEX(rect->pt1.x);
|
||||
sptr = dptr - offset->y * stride - NXGL_SCALEX(offset->x);
|
||||
dline = pinfo->fbmem + rect->pt2.y * stride + NXGL_SCALEX(rect->pt1.x);
|
||||
sline = dline - offset->y * stride - NXGL_SCALEX(offset->x);
|
||||
|
||||
while (rows--)
|
||||
{
|
||||
dptr -= stride;
|
||||
sptr -= stride;
|
||||
NXGL_MEMCPY(dptr, sptr, width);
|
||||
dline -= stride;
|
||||
sline -= stride;
|
||||
#if NXGLIB_BITSPERPIXEL < 8
|
||||
nxgl_lowresmemcpy(dline, sline, width, leadmask, tailmask);
|
||||
#else
|
||||
NXGL_MEMCPY(dline, sline, width);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user