summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-31 17:33:24 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-31 17:33:24 +0000
commit1b532f4111bba2d91cd794b2826b2276c868c494 (patch)
treebdc3c10e4e6b1c105b0cb0f1e684ea2c6f4ae121
parent695f514e3e873873984ab83e1193bc9d0b4e4985 (diff)
downloadpx4-nuttx-1b532f4111bba2d91cd794b2826b2276c868c494.tar.gz
px4-nuttx-1b532f4111bba2d91cd794b2826b2276c868c494.tar.bz2
px4-nuttx-1b532f4111bba2d91cd794b2826b2276c868c494.zip
Add low level routines to draw single pixels (not used yet)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3833 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/ChangeLog1
-rw-r--r--nuttx/graphics/nxglib/Make.defs13
-rw-r--r--nuttx/graphics/nxglib/Makefile.sources24
-rw-r--r--nuttx/graphics/nxglib/fb/nxglib_fillrectangle.c4
-rw-r--r--nuttx/graphics/nxglib/fb/nxglib_filltrapezoid.c2
-rw-r--r--nuttx/graphics/nxglib/fb/nxglib_setpixel.c156
-rw-r--r--[-rwxr-xr-x]nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c0
-rw-r--r--[-rwxr-xr-x]nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c4
-rw-r--r--[-rwxr-xr-x]nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c10
-rw-r--r--[-rwxr-xr-x]nuttx/graphics/nxglib/lcd/nxglib_moverectangle.c0
-rw-r--r--nuttx/graphics/nxglib/lcd/nxglib_setpixel.c153
-rw-r--r--nuttx/include/nuttx/nx/nxglib.h62
12 files changed, 400 insertions, 29 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 0650dac62..5c9428e04 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -1958,4 +1958,5 @@
* drivers/input/tsc2007.c and include/nuttx/input/*: Add a generic NuttX
touchscreen interface. Add a driver for the TI TSC2007 touchscreen
controller.
+ * graphics/nxglib/lcd and fb: Add low level routines to set single pixels.
diff --git a/nuttx/graphics/nxglib/Make.defs b/nuttx/graphics/nxglib/Make.defs
index 69ad19451..44b2801a0 100644
--- a/nuttx/graphics/nxglib/Make.defs
+++ b/nuttx/graphics/nxglib/Make.defs
@@ -35,6 +35,12 @@
NXGLIB_ASRCS =
+SETP1_CSRCS = nxglib_setpixel_1bpp.c nxglib_setpixel_2bpp.c \
+ nxglib_setpixel_4bpp.c
+
+SETP2_CSRCS = nxglib_setpixel_8bpp.c nxglib_setpixel_16bpp.c \
+ nxglib_setpixel_24bpp.c nxglib_setpixel_32bpp.c
+
RFILL1_CSRCS = nxglib_fillrectangle_1bpp.c nxglib_fillrectangle_2bpp.c \
nxglib_fillrectangle_4bpp.c
@@ -72,7 +78,8 @@ COLOR_CSRCS = nxglib_colorcopy.c
LCD_CSRCS =
NXGLIB_CSRCS = nxglib_rgb2yuv.c nxglib_yuv2rgb.c \
- $(RFILL1_CSRCS) $(RFILL2_CSRCS) $(TFILL1_CSRCS) $(TFILL2_CSRCS) \
- $(RMOVE1_CSRCS) $(RMOVE2_CSRCS) $(RCOPY1_CSRCS) $(RCOPY2_CSRCS) \
- $(RECT_CSRCS) $(TRAP_CSRCS) $(COLOR_CSRCS) $(LCD_CSRCS)
+ $(SETP1_CSRCS) $(SETP2_CSRCS) $(RFILL1_CSRCS) $(RFILL2_CSRCS) \
+ $(TFILL1_CSRCS) $(TFILL2_CSRCS) $(RMOVE1_CSRCS) $(RMOVE2_CSRCS) \
+ $(RCOPY1_CSRCS) $(RCOPY2_CSRCS) $(RECT_CSRCS) $(TRAP_CSRCS) \
+ $(COLOR_CSRCS) $(LCD_CSRCS)
diff --git a/nuttx/graphics/nxglib/Makefile.sources b/nuttx/graphics/nxglib/Makefile.sources
index fe2812e42..8e63f434a 100644
--- a/nuttx/graphics/nxglib/Makefile.sources
+++ b/nuttx/graphics/nxglib/Makefile.sources
@@ -38,6 +38,7 @@
ifeq ($(NXGLIB_BITSPERPIXEL),1)
NXGLIB_SUFFIX := _1bpp
+SETP_CSRC := nxglib_setpixel_1bpp.c
RFILL_CSRC := nxglib_fillrectangle_1bpp.c
TFILL_CSRC := nxglib_filltrapezoid_1bpp.c
RMOVE_CSRC := nxglib_moverectangle_1bpp.c
@@ -45,6 +46,7 @@ RCOPY_CSRC := nxglib_copyrectangle_1bpp.c
endif
ifeq ($(NXGLIB_BITSPERPIXEL),2)
NXGLIB_SUFFIX := _2bpp
+SETP_CSRC := nxglib_setpixel_2bpp.c
RFILL_CSRC := nxglib_fillrectangle_2bpp.c
TFILL_CSRC := nxglib_filltrapezoid_2bpp.c
RMOVE_CSRC := nxglib_moverectangle_2bpp.c
@@ -52,6 +54,7 @@ RCOPY_CSRC := nxglib_copyrectangle_2bpp.c
endif
ifeq ($(NXGLIB_BITSPERPIXEL),4)
NXGLIB_SUFFIX := _4bpp
+SETP_CSRC := nxglib_setpixel_4bpp.c
RFILL_CSRC := nxglib_fillrectangle_4bpp.c
TFILL_CSRC := nxglib_filltrapezoid_4bpp.c
RMOVE_CSRC := nxglib_moverectangle_4bpp.c
@@ -59,6 +62,7 @@ RCOPY_CSRC := nxglib_copyrectangle_4bpp.c
endif
ifeq ($(NXGLIB_BITSPERPIXEL),8)
NXGLIB_SUFFIX := _8bpp
+SETP_CSRC := nxglib_setpixel_8bpp.c
RFILL_CSRC := nxglib_fillrectangle_8bpp.c
TFILL_CSRC := nxglib_filltrapezoid_8bpp.c
RMOVE_CSRC := nxglib_moverectangle_8bpp.c
@@ -66,6 +70,7 @@ RCOPY_CSRC := nxglib_copyrectangle_8bpp.c
endif
ifeq ($(NXGLIB_BITSPERPIXEL),16)
NXGLIB_SUFFIX := _16bpp
+SETP_CSRC := nxglib_setpixel_16bpp.c
RFILL_CSRC := nxglib_fillrectangle_16bpp.c
TFILL_CSRC := nxglib_filltrapezoid_16bpp.c
RMOVE_CSRC := nxglib_moverectangle_16bpp.c
@@ -73,6 +78,7 @@ RCOPY_CSRC := nxglib_copyrectangle_16bpp.c
endif
ifeq ($(NXGLIB_BITSPERPIXEL),24)
NXGLIB_SUFFIX := _24bpp
+SETP_CSRC := nxglib_setpixel_24bpp.c
RFILL_CSRC := nxglib_fillrectangle_24bpp.c
TFILL_CSRC := nxglib_filltrapezoid_24bpp.c
RMOVE_CSRC := nxglib_moverectangle_24bpp.c
@@ -80,6 +86,7 @@ RCOPY_CSRC := nxglib_copyrectangle_24bpp.c
endif
ifeq ($(NXGLIB_BITSPERPIXEL),32)
NXGLIB_SUFFIX := _32bpp
+SETP_CSRC := nxglib_setpixel_32bpp.c
RFILL_CSRC := nxglib_fillrectangle_32bpp.c
TFILL_CSRC := nxglib_filltrapezoid_32bpp.c
RMOVE_CSRC := nxglib_moverectangle_32bpp.c
@@ -89,12 +96,13 @@ endif
CPPFLAGS += -DNXGLIB_BITSPERPIXEL=$(NXGLIB_BITSPERPIXEL)
CPPFLAGS += -DNXGLIB_SUFFIX=$(NXGLIB_SUFFIX)
+SETP_TMP = $(SETP_CSRC:.c=.i)
RFILL_TMP = $(RFILL_CSRC:.c=.i)
TFILL_TMP = $(TFILL_CSRC:.c=.i)
RMOVE_TMP = $(RMOVE_CSRC:.c=.i)
RCOPY_TMP = $(RCOPY_CSRC:.c=.i)
-GEN_CSRCS = $(RFILL_CSRC) $(TFILL_CSRC) $(RMOVE_CSRC) $(RCOPY_CSRC)
+GEN_CSRCS = $(SETP_CSRC) $(RFILL_CSRC) $(TFILL_CSRC) $(RMOVE_CSRC) $(RCOPY_CSRC)
ifeq ($(CONFIG_NX_LCDDRIVER),y)
BLITDIR = lcd
@@ -105,6 +113,13 @@ endif
all: $(GEN_CSRCS)
.PHONY : clean distclean
+$(SETP_CSRC) : $(BLITDIR)/nxglib_setpixel.c nxglib_bitblit.h
+ifneq ($(NXGLIB_BITSPERPIXEL),)
+ @$(call PREPROCESS, $(BLITDIR)/nxglib_setpixel.c, $(SETP_TMP))
+ @cat $(SETP_TMP) | sed -e "/^#/d" >$@
+ @rm -f $(SETP_TMP)
+endif
+
$(RFILL_CSRC) : $(BLITDIR)/nxglib_fillrectangle.c nxglib_bitblit.h
ifneq ($(NXGLIB_BITSPERPIXEL),)
@$(call PREPROCESS, $(BLITDIR)/nxglib_fillrectangle.c, $(RFILL_TMP))
@@ -137,6 +152,9 @@ clean:
@rm -f *~ .*.swp *.i
distclean: clean
- @rm -f nxglib_fillrectangle_*bpp.c nxglib_filltrapezoid_*bpp.c
- @rm -f nxglib_moverectangle_*bpp.c nxglib_copyrectangle_*bpp.c
+ @rm -f nxglib_setpixel_*bpp.c
+ @rm -f nxglib_fillrectangle_*bpp.c
+ @rm -f nxglib_filltrapezoid_*bpp.c
+ @rm -f nxglib_moverectangle_*bpp.c
+ @rm -f nxglib_copyrectangle_*bpp.c
diff --git a/nuttx/graphics/nxglib/fb/nxglib_fillrectangle.c b/nuttx/graphics/nxglib/fb/nxglib_fillrectangle.c
index 62b2718ee..cb9483c98 100644
--- a/nuttx/graphics/nxglib/fb/nxglib_fillrectangle.c
+++ b/nuttx/graphics/nxglib/fb/nxglib_fillrectangle.c
@@ -83,7 +83,9 @@
****************************************************************************/
void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX)
-(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color)
+ (FAR struct fb_planeinfo_s *pinfo,
+ FAR const struct nxgl_rect_s *rect,
+ NXGL_PIXEL_T color)
{
FAR uint8_t *line;
unsigned int width;
diff --git a/nuttx/graphics/nxglib/fb/nxglib_filltrapezoid.c b/nuttx/graphics/nxglib/fb/nxglib_filltrapezoid.c
index dbfdb4780..2f16b58ed 100644
--- a/nuttx/graphics/nxglib/fb/nxglib_filltrapezoid.c
+++ b/nuttx/graphics/nxglib/fb/nxglib_filltrapezoid.c
@@ -89,7 +89,7 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)(
FAR struct fb_planeinfo_s *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
FAR const struct nxgl_rect_s *bounds,
- nxgl_mxpixel_t color)
+ NXGL_PIXEL_T color)
{
unsigned int stride;
unsigned int width;
diff --git a/nuttx/graphics/nxglib/fb/nxglib_setpixel.c b/nuttx/graphics/nxglib/fb/nxglib_setpixel.c
new file mode 100644
index 000000000..bd34f8f43
--- /dev/null
+++ b/nuttx/graphics/nxglib/fb/nxglib_setpixel.c
@@ -0,0 +1,156 @@
+/****************************************************************************
+ * graphics/nxglib/fb/nxglib_setpixel.c
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * 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/fb.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 frambuffer 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 fb_planeinfo_s *pinfo,
+ FAR const struct nxgl_point_s *pos,
+ NXGL_PIXEL_T color)
+{
+ FAR uint8_t *dest;
+
+#if NXGLIB_BITSPERPIXEL < 8
+ uint8_t shift;
+ uint8_t mask;
+#else
+ FAR NXGL_PIXEL_T *pixel;
+#endif
+
+ /* Get the address of the first byte of the pixel to write */
+
+ dest = pinfo->fbmem + pos->y * pinfo->stride + NXGL_SCALEX(pos->x);
+
+#if NXGLIB_BITSPERPIXEL < 8
+
+ /* 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 */
+
+ *dest = (*dest & ~mask) | (color & mask);
+#else
+
+ /* Write the pixel (proper alignment assumed) */
+
+ pixel = (FAR NXGL_PIXEL_T *)dest;
+ *pixel = color;
+#endif
+}
diff --git a/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c
index 988b6cb94..988b6cb94 100755..100644
--- a/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c
+++ b/nuttx/graphics/nxglib/lcd/nxglib_copyrectangle.c
diff --git a/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c
index 90271e51c..c1a30d66f 100755..100644
--- a/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c
+++ b/nuttx/graphics/nxglib/lcd/nxglib_fillrectangle.c
@@ -85,7 +85,9 @@
****************************************************************************/
void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX)
-(FAR struct lcd_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color)
+ (FAR struct lcd_planeinfo_s *pinfo,
+ FAR const struct nxgl_rect_s *rect,
+ NXGL_PIXEL_T color)
{
unsigned int ncols;
unsigned int row;
diff --git a/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c b/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c
index c0e18d116..0c8611088 100755..100644
--- a/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c
+++ b/nuttx/graphics/nxglib/lcd/nxglib_filltrapezoid.c
@@ -86,11 +86,11 @@
*
****************************************************************************/
-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_mxpixel_t color)
+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 dy;
diff --git a/nuttx/graphics/nxglib/lcd/nxglib_moverectangle.c b/nuttx/graphics/nxglib/lcd/nxglib_moverectangle.c
index f82187ae3..f82187ae3 100755..100644
--- a/nuttx/graphics/nxglib/lcd/nxglib_moverectangle.c
+++ b/nuttx/graphics/nxglib/lcd/nxglib_moverectangle.c
diff --git a/nuttx/graphics/nxglib/lcd/nxglib_setpixel.c b/nuttx/graphics/nxglib/lcd/nxglib_setpixel.c
new file mode 100644
index 000000000..efe08fa10
--- /dev/null
+++ b/nuttx/graphics/nxglib/lcd/nxglib_setpixel.c
@@ -0,0 +1,153 @@
+/****************************************************************************
+ * graphics/nxglib/lcd/nxglib_setpixel.c
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * 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
+}
diff --git a/nuttx/include/nuttx/nx/nxglib.h b/nuttx/include/nuttx/nx/nxglib.h
index fe73d2536..06208b39f 100644
--- a/nuttx/include/nuttx/nx/nxglib.h
+++ b/nuttx/include/nuttx/nx/nxglib.h
@@ -211,34 +211,66 @@ EXTERN void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v,
/* Rasterizers **************************************************************/
/****************************************************************************
+ * Name: nxgl_setpixel_*bpp
+ *
+ * Descripton:
+ * Draw a single pixel in graphics memory 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.
+ *
+ ****************************************************************************/
+
+EXTERN void nxgl_setpixel_1bpp(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t color);
+EXTERN void nxgl_setpixel_2bpp(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t color);
+EXTERN void nxgl_setpixel_4bpp(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t color);
+EXTERN void nxgl_setpixel_8bpp(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t color);
+EXTERN void nxgl_setpixel_16bpp(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_point_s *pos,
+ uint16_t color);
+EXTERN void nxgl_setpixel_24bpp(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_point_s *pos,
+ uint32_t color);
+EXTERN void nxgl_setpixel_32bpp(FAR NX_PLANEINFOTYPE *pinfo,
+ FAR const struct nxgl_point_s *pos,
+ uint32_t color);
+
+/****************************************************************************
* Name: nxgl_fillrectangle_*bpp
*
* Descripton:
- * Fill a rectangle region in the framebuffer memory with a fixed color
+ * Fill a rectangle region in the graphics memory with a fixed color
*
****************************************************************************/
EXTERN void nxgl_fillrectangle_1bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect,
- nxgl_mxpixel_t color);
+ uint8_t color);
EXTERN void nxgl_fillrectangle_2bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect,
- nxgl_mxpixel_t color);
+ uint8_t color);
EXTERN void nxgl_fillrectangle_4bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect,
- nxgl_mxpixel_t color);
+ uint8_t color);
EXTERN void nxgl_fillrectangle_8bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect,
- nxgl_mxpixel_t color);
+ uint8_t color);
EXTERN void nxgl_fillrectangle_16bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect,
- nxgl_mxpixel_t color);
+ uint16_t color);
EXTERN void nxgl_fillrectangle_24bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect,
- nxgl_mxpixel_t color);
+ uint32_t color);
EXTERN void nxgl_fillrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_rect_s *rect,
- nxgl_mxpixel_t color);
+ uint32_t color);
/****************************************************************************
* Name: nxglib_filltrapezoid_*bpp
@@ -253,31 +285,31 @@ EXTERN void nxgl_fillrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo,
EXTERN void nxgl_filltrapezoid_1bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
FAR const struct nxgl_rect_s *bounds,
- nxgl_mxpixel_t color);
+ uint8_t color);
EXTERN void nxgl_filltrapezoid_2bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
FAR const struct nxgl_rect_s *bounds,
- nxgl_mxpixel_t color);
+ uint8_t color);
EXTERN void nxgl_filltrapezoid_4bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
FAR const struct nxgl_rect_s *bounds,
- nxgl_mxpixel_t color);
+ uint8_t color);
EXTERN void nxgl_filltrapezoid_8bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
FAR const struct nxgl_rect_s *bounds,
- nxgl_mxpixel_t color);
+ uint8_t color);
EXTERN void nxgl_filltrapezoid_16bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
FAR const struct nxgl_rect_s *bounds,
- nxgl_mxpixel_t color);
+ uint16_t color);
EXTERN void nxgl_filltrapezoid_24bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
FAR const struct nxgl_rect_s *bounds,
- nxgl_mxpixel_t color);
+ uint32_t color);
EXTERN void nxgl_filltrapezoid_32bpp(FAR NX_PLANEINFOTYPE *pinfo,
FAR const struct nxgl_trapezoid_s *trap,
FAR const struct nxgl_rect_s *bounds,
- nxgl_mxpixel_t color);
+ uint32_t color);
/****************************************************************************
* Name: nxgl_moverectangle_*bpp