mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
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
This commit is contained in:
parent
fb35aea349
commit
ad877bf218
12 changed files with 400 additions and 29 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
156
graphics/nxglib/fb/nxglib_setpixel.c
Normal file
156
graphics/nxglib/fb/nxglib_setpixel.c
Normal file
|
@ -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
|
||||
}
|
0
graphics/nxglib/lcd/nxglib_copyrectangle.c
Executable file → Normal file
0
graphics/nxglib/lcd/nxglib_copyrectangle.c
Executable file → Normal file
4
graphics/nxglib/lcd/nxglib_fillrectangle.c
Executable file → Normal file
4
graphics/nxglib/lcd/nxglib_fillrectangle.c
Executable file → Normal file
|
@ -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;
|
||||
|
|
10
graphics/nxglib/lcd/nxglib_filltrapezoid.c
Executable file → Normal file
10
graphics/nxglib/lcd/nxglib_filltrapezoid.c
Executable file → Normal file
|
@ -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;
|
||||
|
|
0
graphics/nxglib/lcd/nxglib_moverectangle.c
Executable file → Normal file
0
graphics/nxglib/lcd/nxglib_moverectangle.c
Executable file → Normal file
153
graphics/nxglib/lcd/nxglib_setpixel.c
Normal file
153
graphics/nxglib/lcd/nxglib_setpixel.c
Normal file
|
@ -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
|
||||
}
|
|
@ -210,35 +210,67 @@ 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
|
||||
|
|
Loading…
Reference in a new issue