diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-28 18:01:10 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-28 18:01:10 +0000 |
commit | 6736fbdba4dd6de0f60e80afd64ede783f192b5d (patch) | |
tree | 3688ee34b38f2e96f8d8a234db1e0b1d58cb37b4 /nuttx/graphics/nxglib/nxglib_fillrectangle.c | |
parent | 2bc440dc23bf8bb26198f1a853d7edf29b9c91ec (diff) | |
download | px4-nuttx-6736fbdba4dd6de0f60e80afd64ede783f192b5d.tar.gz px4-nuttx-6736fbdba4dd6de0f60e80afd64ede783f192b5d.tar.bz2 px4-nuttx-6736fbdba4dd6de0f60e80afd64ede783f192b5d.zip |
Add fill support for BPP < 8
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1335 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxglib/nxglib_fillrectangle.c')
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_fillrectangle.c | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/nuttx/graphics/nxglib/nxglib_fillrectangle.c b/nuttx/graphics/nxglib/nxglib_fillrectangle.c index b5ed8d581..ca94a1092 100644 --- a/nuttx/graphics/nxglib/nxglib_fillrectangle.c +++ b/nuttx/graphics/nxglib/nxglib_fillrectangle.c @@ -87,7 +87,16 @@ void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX) ubyte *line; unsigned int width; unsigned int stride; - unsigned int rows; + int rows; + +#if NXGLIB_BITSPERPIXEL < 8 + ubyte *dest; + ubyte mpixel = NXGL_MULTIPIXEL(color); + ubyte leadmask; + ubyte tailmask; + ubyte mask; + int lnlen; +#endif /* Get the width of the framebuffer in bytes */ @@ -102,11 +111,64 @@ void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX) line = pinfo->fbmem + rect->pt1.y * stride + NXGL_SCALEX(rect->pt1.x); +#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 + /* Then fill the rectangle line-by-line */ - while (rows--) + while (rows-- > 0) { +#if NXGLIB_BITSPERPIXEL < 8 + /* Handle masking of the fractional initial byte */ + + mask = leadmask; + dest = line; + lnlen = width; + + if (lnlen > 1 && mask) + { + dest[0] = (dest[0] & ~mask) | (mpixel & mask); + mask = 0xff; + dest++; + lnlen--; + } + + /* Handle masking of the fractional final byte */ + + mask &= tailmask; + if (lnlen > 0 && mask) + { + dest[lnlen-1] = (dest[lnlen-1] & ~mask) | (mpixel & mask); + lnlen--; + } + + /* Handle all of the unmasked bytes in-between */ + + if (lnlen > 0) + { + NXGL_MEMSET(dest, (NXGL_PIXEL_T)color, lnlen); + } +#else + /* Draw the entire raster line */ + NXGL_MEMSET(line, (NXGL_PIXEL_T)color, width); +#endif line += stride; } } |