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:
patacongo
2008-12-02 12:41:05 +00:00
parent 6bf0e7f97b
commit 981d2a73be
5 changed files with 183 additions and 36 deletions

View File

@@ -43,12 +43,12 @@ TFILL1_CSRCS = nxglib_filltrapezoid_1bpp.c nxglib_filltrapezoid_2bpp.c \
nxglib_filltrapezoid_4bpp.c nxglib_filltrapezoid_4bpp.c
TFILL2_CSRCS = nxglib_filltrapezoid_8bpp.c nxglib_filltrapezoid_16bpp.c \ TFILL2_CSRCS = nxglib_filltrapezoid_8bpp.c nxglib_filltrapezoid_16bpp.c \
nxglib_filltrapezoid_24bpp.c nxglib_filltrapezoid_32bpp.c nxglib_filltrapezoid_24bpp.c nxglib_filltrapezoid_32bpp.c
#RMOVE1_CSRCS = nxglib_moverectangle_1bpp.c nxglib_moverectangle_2bpp.c \ RMOVE1_CSRCS = nxglib_moverectangle_1bpp.c nxglib_moverectangle_2bpp.c \
# nxglib_moverectangle_4bpp.c nxglib_moverectangle_4bpp.c
RMOVE2_CSRCS = nxglib_moverectangle_8bpp.c nxglib_moverectangle_16bpp.c \ RMOVE2_CSRCS = nxglib_moverectangle_8bpp.c nxglib_moverectangle_16bpp.c \
nxglib_moverectangle_24bpp.c nxglib_moverectangle_32bpp.c nxglib_moverectangle_24bpp.c nxglib_moverectangle_32bpp.c
#RCOPY1_CSRCS = nxglib_copyrectangle_1bpp.c nxglib_copyrectangle_2bpp.c \ RCOPY1_CSRCS = nxglib_copyrectangle_1bpp.c nxglib_copyrectangle_2bpp.c \
# nxglib_copyrectangle_4bpp.c nxglib_copyrectangle_4bpp.c
RCOPY2_CSRCS = nxglib_copyrectangle_8bpp.c nxglib_copyrectangle_16bpp.c \ RCOPY2_CSRCS = nxglib_copyrectangle_8bpp.c nxglib_copyrectangle_16bpp.c \
nxglib_copyrectangle_24bpp.c nxglib_copyrectangle_32bpp.c nxglib_copyrectangle_24bpp.c nxglib_copyrectangle_32bpp.c
RECT_CSRCS = nxglib_rectcopy.c nxglib_rectoffset.c nxglib_vectoradd.c \ RECT_CSRCS = nxglib_rectcopy.c nxglib_rectoffset.c nxglib_vectoradd.c \

View File

@@ -83,12 +83,21 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX)
FAR const void *src, FAR const struct nxgl_point_s *origin, FAR const void *src, FAR const struct nxgl_point_s *origin,
unsigned int srcstride) unsigned int srcstride)
{ {
const ubyte *sptr; FAR const ubyte *sline;
ubyte *dptr; FAR ubyte *dline;
unsigned int width; unsigned int width;
unsigned int deststride; unsigned int deststride;
unsigned int rows; 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 */ /* Get the width of the framebuffer in bytes */
deststride = pinfo->stride; deststride = pinfo->stride;
@@ -98,15 +107,70 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX)
width = NXGL_SCALEX(dest->pt2.x - dest->pt1.x); width = NXGL_SCALEX(dest->pt2.x - dest->pt1.x);
rows = dest->pt2.y - dest->pt1.y; 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 */ /* Then copy the image */
sptr = (const ubyte*)src + NXGL_SCALEX(dest->pt1.x - origin->x) + (dest->pt1.y - origin->y) * srcstride; sline = (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); dline = pinfo->fbmem + dest->pt1.y * deststride + NXGL_SCALEX(dest->pt1.x);
while (rows--) while (rows--)
{ {
NXGL_MEMCPY((NXGL_PIXEL_T*)dest, (NXGL_PIXEL_T*)sptr, width); #if NXGLIB_BITSPERPIXEL < 8
dptr += deststride; /* Handle masking of the fractional initial byte */
sptr += srcstride;
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;
} }
} }

View File

@@ -84,18 +84,18 @@
void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX) void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX)
(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color) (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 width;
unsigned int stride; unsigned int stride;
int rows; int rows;
#if NXGLIB_BITSPERPIXEL < 8 #if NXGLIB_BITSPERPIXEL < 8
ubyte *dest; FAR ubyte *dest;
ubyte mpixel = NXGL_MULTIPIXEL(color); ubyte mpixel = NXGL_MULTIPIXEL(color);
ubyte leadmask; ubyte leadmask;
ubyte tailmask; ubyte tailmask;
ubyte mask; ubyte mask;
int lnlen; int lnlen;
#endif #endif
/* Get the width of the framebuffer in bytes */ /* Get the width of the framebuffer in bytes */

View File

@@ -92,7 +92,7 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)(
{ {
unsigned int stride; unsigned int stride;
unsigned int width; unsigned int width;
ubyte *line; FAR ubyte *line;
int nrows; int nrows;
b16_t x1; b16_t x1;
b16_t x2; b16_t x2;
@@ -102,10 +102,10 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)(
b16_t dx2dy; b16_t dx2dy;
#if NXGLIB_BITSPERPIXEL < 8 #if NXGLIB_BITSPERPIXEL < 8
ubyte *dest; FAR ubyte *dest;
ubyte mpixel = NXGL_MULTIPIXEL(color); ubyte mpixel = NXGL_MULTIPIXEL(color);
ubyte mask; ubyte mask;
int lnlen; int lnlen;
#endif #endif
/* Get the width of the framebuffer in bytes */ /* Get the width of the framebuffer in bytes */

View File

@@ -65,6 +65,54 @@
* Private Functions * 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 * 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 fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect,
FAR struct nxgl_point_s *offset) FAR struct nxgl_point_s *offset)
{ {
const ubyte *sptr; FAR const ubyte *sline;
ubyte *dptr; FAR ubyte *dline;
unsigned int width; unsigned int width;
unsigned int stride; unsigned int stride;
unsigned int rows; unsigned int rows;
#if NXGLIB_BITSPERPIXEL < 8
ubyte leadmask;
ubyte tailmask;
#endif
/* Get the width of the framebuffer in bytes */ /* Get the width of the framebuffer in bytes */
stride = pinfo->stride; stride = pinfo->stride;
@@ -97,30 +150,60 @@ void NXGL_FUNCNAME(nxgl_moverectangle,NXGLIB_SUFFIX)
width = NXGL_SCALEX(rect->pt2.x - rect->pt1.x); width = NXGL_SCALEX(rect->pt2.x - rect->pt1.x);
rows = rect->pt2.y - rect->pt1.y; 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 */ /* Case 1: The starting position is above the display */
if (offset->y < 0) if (offset->y < 0)
{ {
dptr = pinfo->fbmem + rect->pt1.y * stride + NXGL_SCALEX(rect->pt1.x); dline = pinfo->fbmem + rect->pt1.y * stride + NXGL_SCALEX(rect->pt1.x);
sptr = dptr - offset->y * stride - NXGL_SCALEX(offset->x); sline = dline - offset->y * stride - NXGL_SCALEX(offset->x);
while (rows--) while (rows--)
{ {
NXGL_MEMCPY(dptr, sptr, width); #if NXGLIB_BITSPERPIXEL < 8
dptr += stride; nxgl_lowresmemcpy(dline, sline, width, leadmask, tailmask);
sptr += stride; #else
NXGL_MEMCPY(dline, sline, width);
#endif
dline += stride;
sline += stride;
} }
} }
/* Case 2: It's not */
else else
{ {
dptr = pinfo->fbmem + rect->pt2.y * stride + NXGL_SCALEX(rect->pt1.x); dline = pinfo->fbmem + rect->pt2.y * stride + NXGL_SCALEX(rect->pt1.x);
sptr = dptr - offset->y * stride - NXGL_SCALEX(offset->x); sline = dline - offset->y * stride - NXGL_SCALEX(offset->x);
while (rows--) while (rows--)
{ {
dptr -= stride; dline -= stride;
sptr -= stride; sline -= stride;
NXGL_MEMCPY(dptr, sptr, width); #if NXGLIB_BITSPERPIXEL < 8
nxgl_lowresmemcpy(dline, sline, width, leadmask, tailmask);
#else
NXGL_MEMCPY(dline, sline, width);
#endif
} }
} }
} }