diff options
Diffstat (limited to 'nuttx/graphics/nxglib/lcd')
-rw-r--r-- | nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c | 141 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c | 111 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c | 259 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/lcd/nxglib_getrectangle.c | 105 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/lcd/nxglib_moverectangle.c | 131 | ||||
-rw-r--r-- | nuttx/graphics/nxglib/lcd/nxglib_setpixel.c | 153 |
6 files changed, 0 insertions, 900 deletions
diff --git a/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c deleted file mode 100644 index 40989acef..000000000 --- a/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** - * graphics/nxglib/lcd/nxsglib_copyrectangle.c - * - * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <gnutt@nuttx.org> - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> -#include <assert.h> - -#include <nuttx/lcd/lcd.h> -#include <nuttx/nx/nxglib.h> - -#include "nxglib_bitblit.h" -#include "nxglib_copyrun.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxgl_copyrectangle_*bpp - * - * Descripton: - * Copy a rectangular bitmap image into the specific position in the - * framebuffer memory. - * - ****************************************************************************/ - -void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX) -(FAR struct lcd_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *dest, - FAR const void *src, FAR const struct nxgl_point_s *origin, - unsigned int srcstride) -{ - FAR const uint8_t *sline; - unsigned int ncols; - unsigned int row; - unsigned int xoffset; -#if NXGLIB_BITSPERPIXEL < 8 - unsigned int remainder; -#endif - - /* Get the dimensions of the rectange to fill: width in pixels, - * height in rows - */ - - ncols = dest->pt2.x - dest->pt1.x + 1; - - /* Set up to copy the image */ - - 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 - - /* Copy the image, one row at a time */ - - for (row = dest->pt1.y; row <= dest->pt2.y; row++) - { -#if NXGLIB_BITSPERPIXEL < 8 - /* 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 (remainder != 0) - { - NXGL_FUNCNAME(nxgl_copyrun,NXGLIB_SUFFIX)(sline, pinfo->buffer, remainder, ncols); - (void)pinfo->putrun(row, dest->pt1.x, pinfo->buffer, ncols); - } - else -#endif - { - /* The pixel data is byte aligned. Copy the image data directly from - * the image memory. - */ - - (void)pinfo->putrun(row, dest->pt1.x, sline, ncols); - } - - /* Then adjust the source pointer to refer to the next line in the source - * image. - */ - - sline += srcstride; - } -} diff --git a/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c deleted file mode 100644 index b9554e1cc..000000000 --- a/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** - * graphics/nxglib/lcd/nxglib_fillrectangle.c - * - * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <gnutt@nuttx.org> - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <sys/types.h> -#include <stdint.h> - -#include <nuttx/lcd/lcd.h> -#include <nuttx/nx/nxglib.h> - -#include "nxglib_bitblit.h" -#include "nxglib_fillrun.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -#ifndef NXGLIB_SUFFIX -# error "NXGLIB_SUFFIX must be defined before including this header file" -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxgl_fillrectangle_*bpp - * - * Descripton: - * Fill a rectangle region in the LCD memory with a fixed color - * - ****************************************************************************/ - -void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX) - (FAR struct lcd_planeinfo_s *pinfo, - FAR const struct nxgl_rect_s *rect, - NXGL_PIXEL_T color) -{ - unsigned int ncols; - unsigned int row; - - /* Get the dimensions of the rectange to fill in pixels */ - - ncols = rect->pt2.x - rect->pt1.x + 1; - - /* Fill the run buffer with the selected color */ - - NXGL_FUNCNAME(nxgl_fillrun,NXGLIB_SUFFIX)((NXGLIB_RUNTYPE*)pinfo->buffer, color, ncols); - - /* Then fill the rectangle line-by-line */ - - for (row = rect->pt1.y; row <= rect->pt2.y; row++) - { - /* Draw the raster line at this row */ - - (void)pinfo->putrun(row, rect->pt1.x, pinfo->buffer, ncols); - } -} diff --git a/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c b/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c deleted file mode 100644 index 3ba44b34a..000000000 --- a/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************** - * graphics/nxglib/lcd/nxglib_filltrapezoid.c - * - * Copyright (C) 2010-2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <gnutt@nuttx.org> - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> -#include <fixedmath.h> - -#include <nuttx/lcd/lcd.h> -#include <nuttx/nx/nxglib.h> - -#include "nxglib_bitblit.h" -#include "nxglib_fillrun.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -#ifndef NXGLIB_SUFFIX -# error "NXGLIB_SUFFIX must be defined before including this header file" -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxglib_filltrapezoid_*bpp - * - * Descripton: - * Fill a trapezoidal region in the LCD memory with a fixed color. - * Clip the trapezoid to lie within a boundng box. This is useful for - * drawing complex shapes that can be broken into a set of trapezoids. - * - ****************************************************************************/ - -void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX) - (FAR struct lcd_planeinfo_s *pinfo, - FAR const struct nxgl_trapezoid_s *trap, - FAR const struct nxgl_rect_s *bounds, - NXGL_PIXEL_T color) -{ - unsigned int ncols; - unsigned int topy; - unsigned int boty; - unsigned int row; - unsigned int botw; - b16_t topx1; - b16_t topx2; - b16_t botx1; - b16_t botx2; - b16_t dx1dy; - b16_t dx2dy; - int dy; - int ix1; - int ix2; - - /* Get the top run endpoints */ - - topx1 = trap->top.x1; - topx2 = trap->top.x2; - - /* Calculate the number of rows to render */ - - topy = trap->top.y; - boty = trap->bot.y; - - /* Get the bottom run endpoints */ - - botx1 = trap->bot.x1; - botx2 = trap->bot.x2; - - /* Calculate the slope of the left and right side of the trapezoid */ - - dy = boty - topy; - if (dy > 0) - { - dx1dy = b16divi((botx1 - topx1), dy); - dx2dy = b16divi((botx2 - topx2), dy); - } - else - { - /* The trapezoid is a run! Use the average width. */ - - topx1 = (topx1 + botx1) >> 1; - topx2 = (topx2 + botx2) >> 1; - botx1 = topx1; - botx2 = topx2; - dx1dy = 0; - dx2dy = 0; - } - - /* Perform vertical clipping */ - - if (topy < bounds->pt1.y) - { - /* Is the entire trapezoid "above" the clipping window? */ - - if (boty < bounds->pt1.y) - { - /* Yes.. then do nothing */ - - return; - } - - /* Calculate the x values for the new top run */ - - dy = bounds->pt1.y - topy; - topx1 += dy * dx1dy; - topx2 += dy * dx2dy; - - /* Clip the top row to render */ - - topy = bounds->pt1.y; - } - - if (boty > bounds->pt2.y) - { - /* Is the entire trapezoid "below" the clipping window? */ - - if (topy > bounds->pt2.y) - { - /* Yes.. then do nothing */ - - return; - } - - /* Calculate the x values for the new bottom run */ - - dy = boty - bounds->pt2.y; - botx1 -= dy * dx1dy; - botx2 -= dy * dx2dy; - - /* Clip the bottom row to render */ - - boty = bounds->pt2.y; - } - - /* Handle the special case where the sides cross (as in an hourglass) */ - - if (botx1 > botx2) - { - b16_t tmp; - ngl_swap(botx1, botx2, tmp); - } - - /* Fill the run buffer for the maximum run that we will need */ - - ix1 = b16toi(topx1); - ix1 = ngl_clipl(ix1, bounds->pt1.x); - ix2 = b16toi(topx2); - ix2 = ngl_clipr(ix2, bounds->pt2.x); - ncols = ix2 - ix1 + 1; - - ix1 = b16toi(botx1); - ix1 = ngl_clipl(ix1, bounds->pt1.x); - ix2 = b16toi(botx2); - ix2 = ngl_clipr(ix2, bounds->pt2.x); - botw = ix2 - ix1 + 1; - - if (ncols < botw) - { - ncols = botw; - } - - NXGL_FUNCNAME(nxgl_fillrun,NXGLIB_SUFFIX)((NXGLIB_RUNTYPE*)pinfo->buffer, color, ncols); - - /* Then fill the trapezoid row-by-row */ - - for (row = topy; row <= boty; row++) - { - /* Handle the special case where the sides cross (as in an hourglass) */ - - if (topx1 > topx2) - { - b16_t tmp; - ngl_swap(topx1, topx2, tmp); - ngl_swap(dx1dy, dx2dy, tmp); - } - - /* Convert the positions to integer and get the run width, clipping to - * fit within the bounding box. - */ - - ix1 = b16toi(topx1); - ix1 = ngl_clipl(ix1, bounds->pt1.x); - ix2 = b16toi(topx2); - ix2 = ngl_clipr(ix2, bounds->pt2.x); - - /* Handle some corner cases where we draw nothing. Otherwise, we will - * always draw at least one pixel. - */ - - if (ix1 <= ix2) - { - /* Then draw the run from ix1 to ix2 at row */ - - ncols = ix2 - ix1 + 1; - (void)pinfo->putrun(row, ix1, pinfo->buffer, ncols); - } - - /* Add the dx/dy value to get the run positions on the next row */ - - topx1 += dx1dy; - topx2 += dx2dy; - } -} diff --git a/nuttx/graphics/nxglib/lcd/nxglib_getrectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_getrectangle.c deleted file mode 100644 index 9318426ba..000000000 --- a/nuttx/graphics/nxglib/lcd/nxglib_getrectangle.c +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** - * graphics/nxglib/lcd/nxglib_getrectangle.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <gnutt@nuttx.org> - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> - -#include <nuttx/lcd/lcd.h> -#include <nuttx/nx/nxglib.h> - -#include "nxglib_bitblit.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxgl_moverectangle_*bpp - * - * Descripton: - * Fetch a rectangular region from LCD GRAM memory. The source is - * expressed as a rectangle. - * - ****************************************************************************/ - -void NXGL_FUNCNAME(nxgl_getrectangle,NXGLIB_SUFFIX) -(FAR struct lcd_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, - FAR void *dest, unsigned int deststride) -{ - FAR uint8_t *dline; - unsigned int ncols; - unsigned int srcrow; - - /* Get the width of the rectange to move in pixels. */ - - ncols = rect->pt2.x - rect->pt1.x + 1; - - /* dline = address of the first row pixel */ - - dline = (FAR uint8_t *)dest; - - /* Copy the rectangle */ - - for (srcrow = rect->pt1.y; srcrow <= rect->pt2.y; srcrow++) - { - (void)pinfo->getrun(srcrow, rect->pt1.x, dline, ncols); - dline += deststride; - } -} diff --git a/nuttx/graphics/nxglib/lcd/nxglib_moverectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_moverectangle.c deleted file mode 100644 index b46a17e61..000000000 --- a/nuttx/graphics/nxglib/lcd/nxglib_moverectangle.c +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** - * graphics/nxglib/lcd/nxglib_moverectangle.c - * - * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <gnutt@nuttx.org> - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> - -#include <nuttx/lcd/lcd.h> -#include <nuttx/nx/nxglib.h> - -#include "nxglib_bitblit.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxgl_moverectangle_*bpp - * - * Descripton: - * Move a rectangular region from location to another in the - * LCD memory. The source is expressed as a rectangle; the - * destination position is expressed as a point corresponding to the - * translation of the upper, left-hand corner. - * - ****************************************************************************/ - -void NXGL_FUNCNAME(nxgl_moverectangle,NXGLIB_SUFFIX) -(FAR struct lcd_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, - FAR struct nxgl_point_s *offset) -{ - unsigned int ncols; - unsigned int srcrow; - unsigned int destrow; - - /* Get the width of the rectange to move in pixels. */ - - ncols = rect->pt2.x - rect->pt1.x + 1; - - /* Case 1: The destination position (offset) is above the displayed - * position (rect) - */ - - if (offset->y < rect->pt1.y) - { - /* Copy the rectangle from top down */ - - for (srcrow = rect->pt1.y, destrow = offset->y; - srcrow <= rect->pt2.y; - srcrow++, destrow++) - { - (void)pinfo->getrun(srcrow, rect->pt1.x, pinfo->buffer, ncols); - (void)pinfo->putrun(destrow, offset->x, pinfo->buffer, ncols); - } - } - - /* Case 2: The destination position (offset) is below the displayed - * position (rect) - */ - - else - { - unsigned int dy = rect->pt2.y - rect->pt1.y; - - /* Copy the rectangle from the bottom up */ - - for (srcrow = rect->pt2.y, destrow = offset->y + dy; - srcrow >= rect->pt1.y; - srcrow--, destrow--) - { - (void)pinfo->getrun(srcrow, rect->pt1.x, pinfo->buffer, ncols); - (void)pinfo->putrun(destrow, offset->x, pinfo->buffer, ncols); - } - } -} diff --git a/nuttx/graphics/nxglib/lcd/nxglib_setpixel.c b/nuttx/graphics/nxglib/lcd/nxglib_setpixel.c deleted file mode 100644 index c5cff99a7..000000000 --- a/nuttx/graphics/nxglib/lcd/nxglib_setpixel.c +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** - * graphics/nxglib/lcd/nxglib_setpixel.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <gnutt@nuttx.org> - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <sys/types.h> -#include <stdint.h> - -#include <nuttx/lcd/lcd.h> -#include <nuttx/nx/nxglib.h> - -#include "nxglib_bitblit.h" - -/**************************************************************************** - * Pre-Processor Definitions - ****************************************************************************/ - -#ifndef NXGLIB_SUFFIX -# error "NXGLIB_SUFFIX must be defined before including this header file" -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nxgl_setpixel_*bpp - * - * Descripton: - * Draw a single pixel in LCD memory at the given position and with the - * given color. This is equivalent to nxgl_fillrectangle_*bpp() with a 1x1 - * rectangle but is more efficient. - * - ****************************************************************************/ - -void NXGL_FUNCNAME(nxgl_setpixel,NXGLIB_SUFFIX) - (FAR struct lcd_planeinfo_s *pinfo, - FAR const struct nxgl_point_s *pos, - NXGL_PIXEL_T color) -{ -#if NXGLIB_BITSPERPIXEL < 8 - uint8_t shift; - uint8_t mask; - uint8_t pixel; - - /* Read the byte that contains the pixel to be changed */ - - (void)pinfo->getrun(pos->y, pos->x, &pixel, 8 / NXGLIB_BITSPERPIXEL); - - /* Shift the color into the proper position */ - -# ifdef CONFIG_NX_PACKEDMSFIRST - -#if NXGLIB_BITSPERPIXEL == 1 - shift = (7 - (pos->x & 7)); /* Shift is 0, 1, ... 7 */ - mask = (1 << shift); /* Mask is 0x01, 0x02, .. 0x80 */ - color <<= shift; /* Color is positioned under the mask */ -#elif NXGLIB_BITSPERPIXEL == 2 - shift = (6 - ((pos->x & 3) << 1)); /* Shift is 0, 2, 4, or 6 */ - mask = (3 << shift); /* Mask is 0x03, 0x0c, 0x30, or 0xc0 */ - color <<= shift; /* Color is positioned under the mask */ -#elif NXGLIB_BITSPERPIXEL == 4 - shift = (4 - ((pos->x & 1) << 2)); /* Shift is 0 or 4 */ - mask = (15 << shift); /* Mask is 0x0f or 0xf0 */ - color <<= shift; /* Color is positioned under the mask */ -#else -# error "Unsupport pixel depth" -#endif - -# else /* CONFIG_NX_PACKEDMSFIRST */ - -#if NXGLIB_BITSPERPIXEL == 1 - shift = (pos->x & 7); /* Shift is 0, 1, ... 7 */ - mask = (1 << shift); /* Mask is 0x01, 0x02, .. 0x80 */ - color <<= shift; /* Color is positioned under the mask */ -#elif NXGLIB_BITSPERPIXEL == 2 - shift = (pos->x & 3) << 1; /* Shift is 0, 2, 4, or 6 */ - mask = (3 << shift); /* Mask is 0x03, 0x0c, 0x30, or 0xc0 */ - color <<= shift; /* Color is positioned under the mask */ -#elif NXGLIB_BITSPERPIXEL == 4 - shift = (pos->x & 1) << 2; /* Shift is 0 or 4 */ - mask = (15 << shift); /* Mask is 0x0f or 0xf0 */ - color <<= shift; /* Color is positioned under the mask */ -#else -# error "Unsupport pixel depth" -#endif -#endif /* CONFIG_NX_PACKEDMSFIRST */ - - /* Handle masking of the fractional byte */ - - pixel = (pixel & ~mask) | (color & mask); - - /* Write the modified byte back to graphics memory */ - - (void)pinfo->putrun(pos->y, pos->x, (FAR uint8_t *)&pixel, 8 / NXGLIB_BITSPERPIXEL); -#else - /* Draw a single pixel at this position raster line at this row */ - - (void)pinfo->putrun(pos->y, pos->x, (FAR uint8_t *)&color, 1); -#endif -} |