From 60eba1920f22d22f87925f99d31b09ea361e799f Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 17 Apr 2010 20:38:40 +0000 Subject: Progress on copy rectangle git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2608 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c | 8 +- nuttx/graphics/nxglib/nxglib_copyrun.h | 167 +++++++++++++++++++++++ nuttx/graphics/nxglib/nxglib_fillrun.h | 32 +++-- 3 files changed, 190 insertions(+), 17 deletions(-) create mode 100644 nuttx/graphics/nxglib/nxglib_copyrun.h (limited to 'nuttx/graphics') diff --git a/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c index 62307233a..8d73dcb73 100755 --- a/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c +++ b/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c @@ -1,5 +1,5 @@ /**************************************************************************** - * graphics/nxglib/lcd`/nxsglib_copyrectangle.c + * graphics/nxglib/lcd/nxsglib_copyrectangle.c * * Copyright (C) 2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -85,9 +85,7 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX) unsigned int srcstride) { FAR const uint8_t *sline; - FAR uint8_t *dline; unsigned int width; - unsigned int deststride; unsigned int rows; #if NXGLIB_BITSPERPIXEL < 8 @@ -99,10 +97,6 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX) int lnlen; #endif - /* Get the width of the framebuffer in bytes */ - - deststride = pinfo->stride; - /* Get the dimensions of the rectange to fill: width in pixels, * height in rows */ diff --git a/nuttx/graphics/nxglib/nxglib_copyrun.h b/nuttx/graphics/nxglib/nxglib_copyrun.h new file mode 100644 index 000000000..7f02512c7 --- /dev/null +++ b/nuttx/graphics/nxglib/nxglib_copyrun.h @@ -0,0 +1,167 @@ +/**************************************************************************** + * graphics/nxglib/nxsglib_copyrun.h + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __GRAPHICS_NXGLIB_NXGLIB_COPYRUN_H +#define __GRAPHICS_NXGLIB_NXGLIB_COPYRUN_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxgl_copyrun_*bpp + * + * Description: + * Copy a row from an image into run. + * + ****************************************************************************/ + +#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) +{ + uint8_t indata; + uint8_t outdata; + unsigned int inpixels = 0; + unsigned int outpixels = 0; + unsigned int outbit; + + /* Set up the input */ + + indata = *src++; + + /* Set up the output */ + + outdata = 0; + outbit = 0; + + /* Loop until all pixels have been packed into the destination */ + + while (outpixels < npixels && inpixels < npixels) + { + /* Pack pixels from the source into the destination */ + /* Check the input bit */ + + if ((*src & (1 << inbit)) != 0) + { + /* If it is set, then set the corresponding bit + * in the output (probably not the same bit. + */ + + outdata |= (1 << outbit); + } + inpixels++; + + /* Check if we have used all of the bits in the input */ + + if (++inbit >= 8) + { + /* Yes.. Get the next byte from the source and reset + * the source bit number. + */ + + indata = *src++; + inbit = 0; + } + + /* Now check if we have filled the output byte */ + + if (++outbit >= 8) + { + /* Yes.. Write the output and reset the output bit + * number + */ + + *dest++ = outdata; + outdata = 0; + outbit = 0; + outpixels += 8; + } + } + + /* Handle any bits still in outdata */ + + if (outpixels < inpixels) + { + *dest = outdata; + } +} + +#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) +{ +} + +#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) +{ +} +#endif +#endif /* __GRAPHICS_NXGLIB_NXGLIB_COPYRUN_H */ + + diff --git a/nuttx/graphics/nxglib/nxglib_fillrun.h b/nuttx/graphics/nxglib/nxglib_fillrun.h index fe1e486d2..d427cd4b3 100644 --- a/nuttx/graphics/nxglib/nxglib_fillrun.h +++ b/nuttx/graphics/nxglib/nxglib_fillrun.h @@ -55,6 +55,7 @@ #else # define NXGLIB_RUNTYPE uint32_t #endif + /**************************************************************************** * Private Types ****************************************************************************/ @@ -88,7 +89,8 @@ static uint8_t g_wide_2bpp[4] = { 0x00, 0x55, 0xaa, 0xff }; ****************************************************************************/ #if NXGLIB_BITSPERPIXEL == 1 -static inline void nxgl_fillrun_1bpp(uint8_t *run, nxgl_mxpixel_t color, size_t npixels) +static inline void nxgl_fillrun_1bpp(FAR uint8_t *run, nxgl_mxpixel_t color, + size_t npixels) { /* Get the number of bytes to fill */ @@ -98,13 +100,16 @@ static inline void nxgl_fillrun_1bpp(uint8_t *run, nxgl_mxpixel_t color, size_t uint8_t wide = (color & 1) != 0 ? 0xff : 0x00; - /* Fill the run with the color (it is okay to run a fractional byte overy the end */ + /* Fill the run with the color (it is okay to run a fractional byte over + * the end + */ memset(run, wide, nbytes); } #elif NXGLIB_BITSPERPIXEL == 2 -static inline void nxgl_fillrun_2bpp(uint8_t *run, nxgl_mxpixel_t color, size_t npixels) +static inline void nxgl_fillrun_2bpp(FAR uint8_t *run, nxgl_mxpixel_t color, + size_t npixels) { /* Get the number of bytes to fill */ @@ -114,13 +119,16 @@ static inline void nxgl_fillrun_2bpp(uint8_t *run, nxgl_mxpixel_t color, size_t uint8_t wide = g_wide_2bpp[color & 3]; - /* Fill the run with the color (it is okay to run a fractional byte overy the end */ + /* Fill the run with the color (it is okay to run a fractional byte over + * the end + */ memset(run, wide, nbytes); } #elif NXGLIB_BITSPERPIXEL == 4 -static inline void nxgl_fillrun_4bpp(uint8_t *run, nxgl_mxpixel_t color, size_t npixels) +static inline void nxgl_fillrun_4bpp(FAR uint8_t *run, nxgl_mxpixel_t color, + size_t npixels) { /* Get the number of bytes to fill */ @@ -131,13 +139,16 @@ static inline void nxgl_fillrun_4bpp(uint8_t *run, nxgl_mxpixel_t color, size_t uint8_t narrow = (uint8_t)color & 0x0f; uint8_t wide = narrow | (narrow << 4); - /* Fill the run with the color (it is okay to run a fractional byte overy the end */ + /* Fill the run with the color (it is okay to run a fractional byte over + * the end + */ memset(run, wide, nbytes); } #elif NXGLIB_BITSPERPIXEL == 8 -static inline void nxgl_fillrun_8bpp(uint8_t *run, nxgl_mxpixel_t color, size_t npixels) +static inline void nxgl_fillrun_8bpp(FAR uint8_t *run, nxgl_mxpixel_t color, + size_t npixels) { /* Fill the run with the color (it is okay to run a fractional byte overy the end */ @@ -145,7 +156,8 @@ static inline void nxgl_fillrun_8bpp(uint8_t *run, nxgl_mxpixel_t color, size_t } #elif NXGLIB_BITSPERPIXEL == 16 -static inline void nxgl_fillrun_16bpp(uint16_t *run, nxgl_mxpixel_t color, size_t npixels) +static inline void nxgl_fillrun_16bpp(FAR uint16_t *run, nxgl_mxpixel_t color, + size_t npixels) { /* Fill the run with the color (it is okay to run a fractional byte overy the end */ @@ -156,7 +168,7 @@ static inline void nxgl_fillrun_16bpp(uint16_t *run, nxgl_mxpixel_t color, size_ } #elif NXGLIB_BITSPERPIXEL == 24 -static inline void nxgl_fillrun_24bpp(uint32_t *run, nxgl_mxpixel_t color, size_t npixels) +static inline void nxgl_fillrun_24bpp(FAR uint32_t *run, nxgl_mxpixel_t color, size_t npixels) { /* Fill the run with the color (it is okay to run a fractional byte overy the end */ #warning "Assuming 24-bit color is not packed" @@ -167,7 +179,7 @@ static inline void nxgl_fillrun_24bpp(uint32_t *run, nxgl_mxpixel_t color, size_ } #elif NXGLIB_BITSPERPIXEL == 32 -static inline void nxgl_fillrun_32bpp(uint32_t *run, nxgl_mxpixel_t color, size_t npixels) +static inline void nxgl_fillrun_32bpp(FAR uint32_t *run, nxgl_mxpixel_t color, size_t npixels) { /* Fill the run with the color (it is okay to run a fractional byte overy the end */ -- cgit v1.2.3