diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-12-02 12:41:05 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-12-02 12:41:05 +0000 |
commit | 81289970e26c19de2ef93ed86e43632276ff2ed2 (patch) | |
tree | 457704773385f1ed192aa7c6a375e4c2b97669eb /nuttx | |
parent | 13ee91d6e3868f4d8c73f0740515c2a3326d1b82 (diff) | |
download | px4-nuttx-81289970e26c19de2ef93ed86e43632276ff2ed2.tar.gz px4-nuttx-81289970e26c19de2ef93ed86e43632276ff2ed2.tar.bz2 px4-nuttx-81289970e26c19de2ef93ed86e43632276ff2ed2.zip |
Add support for low resolution rasterizers
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1388 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/graphics/nxglib/Make.defs | 8 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_copyrectangle.c | 78 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_fillrectangle.c | 16 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_filltrapezoid.c | 10 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_moverectangle.c | 107 |
5 files changed, 183 insertions, 36 deletions
diff --git a/nuttx/graphics/nxglib/Make.defs b/nuttx/graphics/nxglib/Make.defs index 07bf98e83..1c66d85a8 100644 --- a/nuttx/graphics/nxglib/Make.defs +++ b/nuttx/graphics/nxglib/Make.defs @@ -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 \ diff --git a/nuttx/graphics/nxglib/nxglib_copyrectangle.c b/nuttx/graphics/nxglib/nxglib_copyrectangle.c index 03068b89e..1feb0c7a9 100644 --- a/nuttx/graphics/nxglib/nxglib_copyrectangle.c +++ b/nuttx/graphics/nxglib/nxglib_copyrectangle.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; } } diff --git a/nuttx/graphics/nxglib/nxglib_fillrectangle.c b/nuttx/graphics/nxglib/nxglib_fillrectangle.c index ca94a1092..2ed923b95 100644 --- a/nuttx/graphics/nxglib/nxglib_fillrectangle.c +++ b/nuttx/graphics/nxglib/nxglib_fillrectangle.c @@ -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 */ diff --git a/nuttx/graphics/nxglib/nxglib_filltrapezoid.c b/nuttx/graphics/nxglib/nxglib_filltrapezoid.c index b20b46570..ff7eb492b 100644 --- a/nuttx/graphics/nxglib/nxglib_filltrapezoid.c +++ b/nuttx/graphics/nxglib/nxglib_filltrapezoid.c @@ -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 */ diff --git a/nuttx/graphics/nxglib/nxglib_moverectangle.c b/nuttx/graphics/nxglib/nxglib_moverectangle.c index 154cf39b1..b9579e3f5 100644 --- a/nuttx/graphics/nxglib/nxglib_moverectangle.c +++ b/nuttx/graphics/nxglib/nxglib_moverectangle.c @@ -66,6 +66,54 @@ ****************************************************************************/ /**************************************************************************** + * 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 } } } |