diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-04-18 02:56:15 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-04-18 02:56:15 +0000 |
commit | 9503945271e3740832c5aa4d66083b27f99420ac (patch) | |
tree | a3ead8e27254ad26ee4b47a8d5b50b96e609c957 /nuttx/graphics | |
parent | eb89fdaa39dede1a8e37519ae3ec4ffa588e705c (diff) | |
download | px4-nuttx-9503945271e3740832c5aa4d66083b27f99420ac.tar.gz px4-nuttx-9503945271e3740832c5aa4d66083b27f99420ac.tar.bz2 px4-nuttx-9503945271e3740832c5aa4d66083b27f99420ac.zip |
Code complete for NX for LCD
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2610 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics')
-rw-r--r-- | nuttx/graphics/nxbe/nxbe_configure.c | 6 | ||||
-rwxr-xr-x | nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c | 92 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_copyrun.h | 18 |
3 files changed, 43 insertions, 73 deletions
diff --git a/nuttx/graphics/nxbe/nxbe_configure.c b/nuttx/graphics/nxbe/nxbe_configure.c index 527c46975..881bcd99e 100644 --- a/nuttx/graphics/nxbe/nxbe_configure.c +++ b/nuttx/graphics/nxbe/nxbe_configure.c @@ -78,14 +78,14 @@ * ****************************************************************************/ -int nxbe_configure(FAR struct fb_vtable_s *fb, FAR struct nxbe_state_s *be) +int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be) { int ret; int i; /* Get the video controller configuration */ - ret = fb->getvideoinfo(fb, &be->vinfo); + ret = dev->getvideoinfo(dev, &be->vinfo); if (ret < 0) { gdbg("Failed to get vinfo\n"); @@ -112,7 +112,7 @@ int nxbe_configure(FAR struct fb_vtable_s *fb, FAR struct nxbe_state_s *be) for (i = 0; i < be->vinfo.nplanes; i++) { - ret = fb->getplaneinfo(fb, i, &be->plane[i].pinfo); + ret = dev->getplaneinfo(dev, i, &be->plane[i].pinfo); if (ret < 0) { gdbg("Failed to get pinfo[%d]\n", i); diff --git a/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c index 8d73dcb73..893030567 100755 --- a/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c +++ b/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c @@ -40,11 +40,13 @@ #include <nuttx/config.h> #include <stdint.h> +#include <assert.h> #include <nuttx/lcd.h> #include <nuttx/nxglib.h> #include "nxglib_bitblit.h" +#include "nxglib_copyrun.h" /**************************************************************************** * Pre-Processor Definitions @@ -85,89 +87,55 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX) unsigned int srcstride) { FAR const uint8_t *sline; - unsigned int width; - unsigned int rows; - + unsigned int ncols; + unsigned int row; + unsigned int xoffset; #if NXGLIB_BITSPERPIXEL < 8 - FAR const uint8_t *sptr; - FAR uint8_t *dptr; - uint8_t leadmask; - uint8_t tailmask; - uint8_t mask; - int lnlen; + unsigned int remainder; #endif /* Get the dimensions of the rectange to fill: width in pixels, * height in rows */ - width = dest->pt2.x - dest->pt1.x + 1; - rows = dest->pt2.y - dest->pt1.y + 1; + ncols = dest->pt2.x - dest->pt1.x + 1; -#if NXGLIB_BITSPERPIXEL < 8 -# ifdef CONFIG_NX_PACKEDMSFIRST + /* Set up to copy the image */ - /* Get the mask for pixels that are ordered so that they pack from the - * MS byte down. - */ - - leadmask = (uint8_t)(0xff >> (8 - NXGL_REMAINDERX(dest->pt1.x))); - tailmask = (uint8_t)(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 = (uint8_t)(0xff << (8 - NXGL_REMAINDERX(dest->pt1.x))); - tailmask = (uint8_t)(0xff >> (8 - NXGL_REMAINDERX(dest->pt1.x-1))); -# endif + xoffset = dest->pt1.x - origin->x; + sline = (const uint8_t*)src + NXGL_SCALEX(xoffset) + (dest->pt1.y - origin->y) * srcstride; +#if NXGLIB_BITSPERPIXEL < 8 + remainder = NXGL_REMAINDERX(xoffset); #endif - /* Then copy the image */ + /* Copy the image, one row at a time */ - sline = (const uint8_t*)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--) + for (row = dest->pt1.y; row < dest->pt2.y; row++) { #if NXGLIB_BITSPERPIXEL < 8 - /* Handle masking of the fractional initial byte */ - - mask = leadmask; - sptr = sline; - dptr = dline; - lnlen = width; + /* if the source pixel is not aligned with a byte boundary, then we will + * need to copy the image data to the run buffer first. + */ - if (lnlen > 1 && mask) + if (remainder != 0) { - dptr[0] = (dptr[0] & ~mask) | (sptr[0] & mask); - mask = 0xff; - dptr++; - sptr++; - lnlen--; + NXGL_FUNCNAME(nxgl_copyrun,NXGLIB_SUFFIX)(sline, pinfo->buffer, remainder, ncols); + (void)pinfo->putrun(row, dest->pt1.x, pinfo->buffer, ncols); } - - /* Handle masking of the fractional final byte */ - - mask &= tailmask; - if (lnlen > 0 && mask) + else +#endif { - dptr[lnlen-1] = (dptr[lnlen-1] & ~mask) | (sptr[lnlen-1] & mask); - lnlen--; - } + /* The pixel data is byte aligned. Copy the image data directly from + * the image memory. + */ - /* Handle all of the unmasked bytes in-between */ - - if (lnlen > 0) - { - NXGL_MEMCPY(dptr, sptr, lnlen); + (void)pinfo->putrun(row, dest->pt1.x, sline, ncols); } -#else - /* Copy the whole line */ - NXGL_MEMCPY((NXGL_PIXEL_T*)dline, (NXGL_PIXEL_T*)sline, width); -#endif - dline += deststride; + /* Then adjust the source pointer to refer to the next line in the source + * image. + */ + sline += srcstride; } } diff --git a/nuttx/graphics/nxglib/nxglib_copyrun.h b/nuttx/graphics/nxglib/nxglib_copyrun.h index 500d2fb75..b97372bf7 100644 --- a/nuttx/graphics/nxglib/nxglib_copyrun.h +++ b/nuttx/graphics/nxglib/nxglib_copyrun.h @@ -79,10 +79,11 @@ #if NXGLIB_BITSPERPIXEL == 1 static inline void nxgl_copyrun_1bpp(FAR const uint8_t *src, FAR uint8_t *dest, - unsigned int inbit, size_t npixels) + unsigned int remainder, size_t npixels) { uint8_t indata; uint8_t outdata; + uint8_t nextdata; unsigned int outpixels = 0; DEBUGASSERT(remainder > 0 && remainder < 8); @@ -166,10 +167,11 @@ nxgl_copyrun_1bpp(FAR const uint8_t *src, FAR uint8_t *dest, #elif NXGLIB_BITSPERPIXEL == 2 static inline void nxgl_copyrun_2bpp(FAR const uint8_t *src, FAR uint8_t *dest, - unsigned int inbit, size_t npixels) + unsigned int remainder, size_t npixels) { uint8_t indata; uint8_t outdata; + uint8_t nextdata; unsigned int outpixels = 0; unsigned int shift; @@ -255,10 +257,11 @@ nxgl_copyrun_2bpp(FAR const uint8_t *src, FAR uint8_t *dest, #elif NXGLIB_BITSPERPIXEL == 4 static inline void nxgl_copyrun_4bpp(FAR const uint8_t *src, FAR uint8_t *dest, - unsigned int inbit, size_t npixels) + unsigned int remainder, size_t npixels) { uint8_t indata; uint8_t outdata; + uint8_t nextdata; unsigned int outpixels = 0; DEBUGASSERT(remainder == 1); @@ -269,7 +272,6 @@ nxgl_copyrun_4bpp(FAR const uint8_t *src, FAR uint8_t *dest, */ indata = *src++; - shift = (remainder << 1); #ifdef CONFIG_NX_PACKEDMSFIRST /* If CONFIG_NX_PACKEDMSFIRST is defined, then bits 0-3 @@ -317,8 +319,8 @@ nxgl_copyrun_4bpp(FAR const uint8_t *src, FAR uint8_t *dest, * src = BBBB CCCC - nextdata = CCCC xxxx */ - outdata |= (indata >> 4); - nextdata = (indata << 4); + outdata |= (indata >> 4); + nextdata = (indata << 4); #else /* If CONFIG_NX_PACKEDMSFIRST is NOT defined, then bits 0-(remainder-1) * are carried over from that last pass through the loop (or are @@ -328,8 +330,8 @@ nxgl_copyrun_4bpp(FAR const uint8_t *src, FAR uint8_t *dest, * src = CCCC CCBB - nextdata = xxCC CCCC */ - outdata |= (indata << 4); - nextdata = (indata >> 4); + outdata |= (indata << 4); + nextdata = (indata >> 4); #endif /* Transfer the byte to the run buffer */ |