diff --git a/configs/sama5d4-ek/nsh/defconfig b/configs/sama5d4-ek/nsh/defconfig index f7d781bdbb..40199147fa 100644 --- a/configs/sama5d4-ek/nsh/defconfig +++ b/configs/sama5d4-ek/nsh/defconfig @@ -509,6 +509,12 @@ CONFIG_DEV_ZERO=y CONFIG_ARCH_HAVE_RNG=y CONFIG_DEV_RANDOM=y # CONFIG_LOOP is not set + +# +# Buffering +# +# CONFIG_DRVR_WRITEBUFFER is not set +# CONFIG_DRVR_READAHEAD is not set # CONFIG_RAMDISK is not set # CONFIG_CAN is not set # CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set @@ -822,6 +828,7 @@ CONFIG_SYSLOG=y # CONFIG_NX=y CONFIG_NX_NPLANES=1 +CONFIG_NX_BGCOLOR=0x7b5d # CONFIG_NX_WRITEONLY is not set # diff --git a/configs/sama5d4-ek/nxwm/defconfig b/configs/sama5d4-ek/nxwm/defconfig index b4ce31b3ac..32a71f7975 100644 --- a/configs/sama5d4-ek/nxwm/defconfig +++ b/configs/sama5d4-ek/nxwm/defconfig @@ -513,6 +513,10 @@ CONFIG_DEV_ZERO=y CONFIG_ARCH_HAVE_RNG=y CONFIG_DEV_RANDOM=y # CONFIG_LOOP is not set + +# +# Buffering +# # CONFIG_DRVR_WRITEBUFFER is not set # CONFIG_DRVR_READAHEAD is not set # CONFIG_RAMDISK is not set @@ -828,6 +832,7 @@ CONFIG_SYSLOG=y # CONFIG_NX=y CONFIG_NX_NPLANES=1 +CONFIG_NX_BGCOLOR=0x7b5d # CONFIG_NX_WRITEONLY is not set # diff --git a/graphics/Kconfig b/graphics/Kconfig index 6c58478d8d..85e2164a8c 100644 --- a/graphics/Kconfig +++ b/graphics/Kconfig @@ -25,9 +25,19 @@ config NX_NPLANES int "Number of Color Planes" default 1 ---help--- - Some YUV color formats requires support for multiple planes, one for each - color component. Unless you have such special hardware, this value should be - undefined or set to 1. + Some YUV color formats requires support for multiple planes, one for + each color component. Unless you have such special hardware (and + are willing to debug a lot of untested logic), this value should be + set to 1. + +config NX_BGCOLOR + hex "Initial background color" + default 0x0 + ---help--- + NX will clear the background plane initially. This is the default + color that will be used when the background is cleared. Note: This + logic would have to be extended if you want to support multiple + color planes. config NX_WRITEONLY bool "Write-only Graphics Device" diff --git a/graphics/nxbe/nxbe_configure.c b/graphics/nxbe/nxbe_configure.c index 80c71db3a5..0abfae6592 100644 --- a/graphics/nxbe/nxbe_configure.c +++ b/graphics/nxbe/nxbe_configure.c @@ -49,6 +49,10 @@ * Pre-Processor Definitions ****************************************************************************/ +#ifndef CONFIG_NX_BGCOLOR +# define CONFIG_NX_BGCOLOR 0 +#endif + /**************************************************************************** * Private Types ****************************************************************************/ @@ -57,6 +61,15 @@ * Private Data ****************************************************************************/ +static const nxgl_mxpixel_t g_bgcolor[CONFIG_NX_NPLANES] = +{ + CONFIG_NX_BGCOLOR + +#if CONFIG_NX_NPLANES > 1 +# warning Missing logic for multiple color planes +#endif +}; + /**************************************************************************** * Public Data ****************************************************************************/ @@ -92,6 +105,10 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be) return ret; } + /* Set the initial background color */ + + nxgl_colorcopy(be->bgcolor, g_bgcolor); + /* Check the number of color planes */ #ifdef CONFIG_DEBUG diff --git a/graphics/nxmu/nxmu_server.c b/graphics/nxmu/nxmu_server.c index 44034c10e5..4cb1246b57 100644 --- a/graphics/nxmu/nxmu_server.c +++ b/graphics/nxmu/nxmu_server.c @@ -486,9 +486,18 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev) case NX_SVRMSG_SETBGCOLOR: /* Set the color of the background */ { - FAR struct nxsvrmsg_setbgcolor_s *bgcolormsg = (FAR struct nxsvrmsg_setbgcolor_s *)buffer; - nxgl_colorcopy(fe.be.bgcolor, bgcolormsg->color); - nxbe_fill(&fe.be.bkgd, &fe.be.bkgd.bounds, bgcolormsg->color); + FAR struct nxsvrmsg_setbgcolor_s *bgcolormsg = + (FAR struct nxsvrmsg_setbgcolor_s *)buffer; + + /* Has the background color changed? */ + + if (!nxgl_colorcmp(fe.be.bgcolor, bgcolormsg->color)) + { + /* Yes.. fill the background */ + + nxgl_colorcopy(fe.be.bgcolor, bgcolormsg->color); + nxbe_fill(&fe.be.bkgd, &fe.be.bkgd.bounds, bgcolormsg->color); + } } break; diff --git a/graphics/nxsu/nx_setbgcolor.c b/graphics/nxsu/nx_setbgcolor.c index 5f9818855f..8cf05edc9b 100644 --- a/graphics/nxsu/nx_setbgcolor.c +++ b/graphics/nxsu/nx_setbgcolor.c @@ -97,7 +97,15 @@ int nx_setbgcolor(NXHANDLE handle, } #endif - nxgl_colorcopy(fe->be.bgcolor, color); - nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, color); + /* Has the background color changed? */ + + if (!nxgl_colorcmp(fe.be.bgcolor, bgcolormsg->color)) + { + /* Yes.. fill the background */ + + nxgl_colorcopy(fe->be.bgcolor, color); + nxbe_fill(&fe->be.bkgd, &fe->be.bkgd.bounds, color); + } + return OK; } diff --git a/include/nuttx/nx/nxglib.h b/include/nuttx/nx/nxglib.h index 3670bbd62a..3b6037c4a9 100644 --- a/include/nuttx/nx/nxglib.h +++ b/include/nuttx/nx/nxglib.h @@ -183,7 +183,8 @@ struct nxgl_trapezoid_s #undef EXTERN #if defined(__cplusplus) # define EXTERN extern "C" -extern "C" { +extern "C" +{ #else # define EXTERN extern #endif @@ -192,7 +193,7 @@ extern "C" { * Public Function Prototypes ****************************************************************************/ -/* Color conversons *********************************************************/ +/* Color conversions ********************************************************/ /**************************************************************************** * Name: nxgl_rgb2yuv @@ -202,8 +203,8 @@ extern "C" { * ****************************************************************************/ -EXTERN void nxgl_rgb2yuv(uint8_t r, uint8_t g, uint8_t b, - uint8_t *y, uint8_t *u, uint8_t *v); +void nxgl_rgb2yuv(uint8_t r, uint8_t g, uint8_t b, + uint8_t *y, uint8_t *u, uint8_t *v); /**************************************************************************** * Name: nxgl_yuv2rgb @@ -213,8 +214,8 @@ EXTERN void nxgl_rgb2yuv(uint8_t r, uint8_t g, uint8_t b, * ****************************************************************************/ -EXTERN void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v, - uint8_t *r, uint8_t *g, uint8_t *b); +void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v, + uint8_t *r, uint8_t *g, uint8_t *b); /* Rasterizers **************************************************************/ @@ -228,27 +229,20 @@ EXTERN void nxgl_yuv2rgb(uint8_t y, uint8_t u, uint8_t v, * ****************************************************************************/ -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); +void nxgl_setpixel_1bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_point_s *pos, uint8_t color); +void nxgl_setpixel_2bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_point_s *pos, uint8_t color); +void nxgl_setpixel_4bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_point_s *pos, uint8_t color); +void nxgl_setpixel_8bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_point_s *pos, uint8_t color); +void nxgl_setpixel_16bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_point_s *pos, uint16_t color); +void nxgl_setpixel_24bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_point_s *pos, uint32_t color); +void nxgl_setpixel_32bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_point_s *pos, uint32_t color); /**************************************************************************** * Name: nxgl_fillrectangle_*bpp @@ -258,27 +252,27 @@ EXTERN void nxgl_setpixel_32bpp(FAR NX_PLANEINFOTYPE *pinfo, * ****************************************************************************/ -EXTERN void nxgl_fillrectangle_1bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - uint8_t color); -EXTERN void nxgl_fillrectangle_2bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - uint8_t color); -EXTERN void nxgl_fillrectangle_4bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - uint8_t color); -EXTERN void nxgl_fillrectangle_8bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - uint8_t color); -EXTERN void nxgl_fillrectangle_16bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - uint16_t color); -EXTERN void nxgl_fillrectangle_24bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - uint32_t color); -EXTERN void nxgl_fillrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - uint32_t color); +void nxgl_fillrectangle_1bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + uint8_t color); +void nxgl_fillrectangle_2bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + uint8_t color); +void nxgl_fillrectangle_4bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + uint8_t color); +void nxgl_fillrectangle_8bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + uint8_t color); +void nxgl_fillrectangle_16bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + uint16_t color); +void nxgl_fillrectangle_24bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + uint32_t color); +void nxgl_fillrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + uint32_t color); /**************************************************************************** * Name: nxgl_getrectangle_*bpp @@ -289,66 +283,66 @@ EXTERN void nxgl_fillrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, * ****************************************************************************/ -EXTERN void nxgl_getrectangle_1bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR void *dest, unsigned int deststride); -EXTERN void nxgl_getrectangle_2bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR void *dest, unsigned int deststride); -EXTERN void nxgl_getrectangle_4bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR void *dest, unsigned int deststride); -EXTERN void nxgl_getrectangle_8bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR void *dest, unsigned int deststride); -EXTERN void nxgl_getrectangle_16bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR void *dest, unsigned int deststride); -EXTERN void nxgl_getrectangle_24bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR void *dest, unsigned int deststride); -EXTERN void nxgl_getrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR void *dest, unsigned int deststride); +void nxgl_getrectangle_1bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR void *dest, unsigned int deststride); +void nxgl_getrectangle_2bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR void *dest, unsigned int deststride); +void nxgl_getrectangle_4bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR void *dest, unsigned int deststride); +void nxgl_getrectangle_8bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR void *dest, unsigned int deststride); +void nxgl_getrectangle_16bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR void *dest, unsigned int deststride); +void nxgl_getrectangle_24bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR void *dest, unsigned int deststride); +void nxgl_getrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR void *dest, unsigned int deststride); /**************************************************************************** * Name: nxglib_filltrapezoid_*bpp * * Descripton: * Fill a trapezoidal region in the graphics memory with a fixed color. - * Clip the trapezoid to lie within a boundng box. This is useful for + * Clip the trapezoid to lie within a bounding box. This is useful for * drawing complex shapes that can be broken into a set of trapezoids. * ****************************************************************************/ -EXTERN void nxgl_filltrapezoid_1bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_trapezoid_s *trap, - FAR const struct nxgl_rect_s *bounds, - 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, - 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, - 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, - 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, - 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, - 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, - uint32_t color); +void nxgl_filltrapezoid_1bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_trapezoid_s *trap, + FAR const struct nxgl_rect_s *bounds, + uint8_t color); +void nxgl_filltrapezoid_2bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_trapezoid_s *trap, + FAR const struct nxgl_rect_s *bounds, + uint8_t color); +void nxgl_filltrapezoid_4bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_trapezoid_s *trap, + FAR const struct nxgl_rect_s *bounds, + uint8_t color); +void nxgl_filltrapezoid_8bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_trapezoid_s *trap, + FAR const struct nxgl_rect_s *bounds, + uint8_t color); +void nxgl_filltrapezoid_16bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_trapezoid_s *trap, + FAR const struct nxgl_rect_s *bounds, + uint16_t color); +void nxgl_filltrapezoid_24bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_trapezoid_s *trap, + FAR const struct nxgl_rect_s *bounds, + uint32_t color); +void nxgl_filltrapezoid_32bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_trapezoid_s *trap, + FAR const struct nxgl_rect_s *bounds, + uint32_t color); /**************************************************************************** * Name: nxgl_moverectangle_*bpp @@ -361,27 +355,27 @@ EXTERN void nxgl_filltrapezoid_32bpp(FAR NX_PLANEINFOTYPE *pinfo, * ****************************************************************************/ -EXTERN void nxgl_moverectangle_1bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR struct nxgl_point_s *offset); -EXTERN void nxgl_moverectangle_2bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR struct nxgl_point_s *offset); -EXTERN void nxgl_moverectangle_4bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR struct nxgl_point_s *offset); -EXTERN void nxgl_moverectangle_8bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR struct nxgl_point_s *offset); -EXTERN void nxgl_moverectangle_16bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR struct nxgl_point_s *offset); -EXTERN void nxgl_moverectangle_24bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR struct nxgl_point_s *offset); -EXTERN void nxgl_moverectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *rect, - FAR struct nxgl_point_s *offset); +void nxgl_moverectangle_1bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR struct nxgl_point_s *offset); +void nxgl_moverectangle_2bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR struct nxgl_point_s *offset); +void nxgl_moverectangle_4bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR struct nxgl_point_s *offset); +void nxgl_moverectangle_8bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR struct nxgl_point_s *offset); +void nxgl_moverectangle_16bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR struct nxgl_point_s *offset); +void nxgl_moverectangle_24bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR struct nxgl_point_s *offset); +void nxgl_moverectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *rect, + FAR struct nxgl_point_s *offset); /**************************************************************************** * Name: nxgl_copyrectangle_*bpp @@ -392,41 +386,41 @@ EXTERN void nxgl_moverectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, * ****************************************************************************/ -EXTERN void nxgl_copyrectangle_1bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const void *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxgl_copyrectangle_2bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const void *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxgl_copyrectangle_4bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const void *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxgl_copyrectangle_8bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const void *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxgl_copyrectangle_16bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const void *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxgl_copyrectangle_24bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const void *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxgl_copyrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const void *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); +void nxgl_copyrectangle_1bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *dest, + FAR const void *src, + FAR const struct nxgl_point_s *origin, + unsigned int srcstride); +void nxgl_copyrectangle_2bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *dest, + FAR const void *src, + FAR const struct nxgl_point_s *origin, + unsigned int srcstride); +void nxgl_copyrectangle_4bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *dest, + FAR const void *src, + FAR const struct nxgl_point_s *origin, + unsigned int srcstride); +void nxgl_copyrectangle_8bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *dest, + FAR const void *src, + FAR const struct nxgl_point_s *origin, + unsigned int srcstride); +void nxgl_copyrectangle_16bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *dest, + FAR const void *src, + FAR const struct nxgl_point_s *origin, + unsigned int srcstride); +void nxgl_copyrectangle_24bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *dest, + FAR const void *src, + FAR const struct nxgl_point_s *origin, + unsigned int srcstride); +void nxgl_copyrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, + FAR const struct nxgl_rect_s *dest, + FAR const void *src, + FAR const struct nxgl_point_s *origin, + unsigned int srcstride); /**************************************************************************** * Name: nxgl_rectcopy @@ -437,8 +431,8 @@ EXTERN void nxgl_copyrectangle_32bpp(FAR NX_PLANEINFOTYPE *pinfo, * ****************************************************************************/ -EXTERN void nxgl_rectcopy(FAR struct nxgl_rect_s *dest, - FAR const struct nxgl_rect_s *src); +void nxgl_rectcopy(FAR struct nxgl_rect_s *dest, + FAR const struct nxgl_rect_s *src); /**************************************************************************** * Name: nxgl_rectoffset @@ -448,9 +442,9 @@ EXTERN void nxgl_rectcopy(FAR struct nxgl_rect_s *dest, * ****************************************************************************/ -EXTERN void nxgl_rectoffset(FAR struct nxgl_rect_s *dest, - FAR const struct nxgl_rect_s *src, - nxgl_coord_t dx, nxgl_coord_t dy); +void nxgl_rectoffset(FAR struct nxgl_rect_s *dest, + FAR const struct nxgl_rect_s *src, + nxgl_coord_t dx, nxgl_coord_t dy); /**************************************************************************** * Name: nxgl_vectoradd @@ -460,9 +454,9 @@ EXTERN void nxgl_rectoffset(FAR struct nxgl_rect_s *dest, * ****************************************************************************/ -EXTERN void nxgl_vectoradd(FAR struct nxgl_point_s *dest, - FAR const struct nxgl_point_s *v1, - FAR const struct nxgl_point_s *v2); +void nxgl_vectoradd(FAR struct nxgl_point_s *dest, + FAR const struct nxgl_point_s *v1, + FAR const struct nxgl_point_s *v2); /**************************************************************************** * Name: nxgl_vectorsubtract @@ -472,9 +466,9 @@ EXTERN void nxgl_vectoradd(FAR struct nxgl_point_s *dest, * ****************************************************************************/ -EXTERN void nxgl_vectsubtract(FAR struct nxgl_point_s *dest, - FAR const struct nxgl_point_s *v1, - FAR const struct nxgl_point_s *v2); +void nxgl_vectsubtract(FAR struct nxgl_point_s *dest, + FAR const struct nxgl_point_s *v1, + FAR const struct nxgl_point_s *v2); /**************************************************************************** * Name: nxgl_rectintersect @@ -484,9 +478,9 @@ EXTERN void nxgl_vectsubtract(FAR struct nxgl_point_s *dest, * ****************************************************************************/ -EXTERN void nxgl_rectintersect(FAR struct nxgl_rect_s *dest, - FAR const struct nxgl_rect_s *src1, - FAR const struct nxgl_rect_s *src2); +void nxgl_rectintersect(FAR struct nxgl_rect_s *dest, + FAR const struct nxgl_rect_s *src1, + FAR const struct nxgl_rect_s *src2); /**************************************************************************** * Name: nxgl_intersecting @@ -496,8 +490,8 @@ EXTERN void nxgl_rectintersect(FAR struct nxgl_rect_s *dest, * ****************************************************************************/ -EXTERN bool nxgl_intersecting(FAR const struct nxgl_rect_s *rect1, - FAR const struct nxgl_rect_s *rect2); +bool nxgl_intersecting(FAR const struct nxgl_rect_s *rect1, + FAR const struct nxgl_rect_s *rect2); /**************************************************************************** * Name: nxgl_rectadd @@ -507,22 +501,22 @@ EXTERN bool nxgl_intersecting(FAR const struct nxgl_rect_s *rect1, * ****************************************************************************/ -EXTERN void nxgl_rectadd(FAR struct nxgl_rect_s *dest, - FAR const struct nxgl_rect_s *src1, - FAR const struct nxgl_rect_s *src2); +void nxgl_rectadd(FAR struct nxgl_rect_s *dest, + FAR const struct nxgl_rect_s *src1, + FAR const struct nxgl_rect_s *src2); /**************************************************************************** * Name: nxgl_rectunion * * Description: - * Given two rectanges, src1 and src2, return the larger rectangle that + * Given two rectangles, src1 and src2, return the larger rectangle that * contains both, dest. * ****************************************************************************/ -EXTERN void nxgl_rectunion(FAR struct nxgl_rect_s *dest, - FAR const struct nxgl_rect_s *src1, - FAR const struct nxgl_rect_s *src2); +void nxgl_rectunion(FAR struct nxgl_rect_s *dest, + FAR const struct nxgl_rect_s *src1, + FAR const struct nxgl_rect_s *src2); /**************************************************************************** * Name: nxgl_nonintersecting @@ -534,9 +528,9 @@ EXTERN void nxgl_rectunion(FAR struct nxgl_rect_s *dest, * ****************************************************************************/ -EXTERN void nxgl_nonintersecting(FAR struct nxgl_rect_s result[4], - FAR const struct nxgl_rect_s *rect1, - FAR const struct nxgl_rect_s *rect2); +void nxgl_nonintersecting(FAR struct nxgl_rect_s result[4], + FAR const struct nxgl_rect_s *rect1, + FAR const struct nxgl_rect_s *rect2); /**************************************************************************** * Name: nxgl_rectoverlap @@ -546,8 +540,8 @@ EXTERN void nxgl_nonintersecting(FAR struct nxgl_rect_s result[4], * ****************************************************************************/ -EXTERN bool nxgl_rectoverlap(FAR struct nxgl_rect_s *rect1, - FAR struct nxgl_rect_s *rect2); +bool nxgl_rectoverlap(FAR struct nxgl_rect_s *rect1, + FAR struct nxgl_rect_s *rect2); /**************************************************************************** * Name: nxgl_rectinside @@ -557,8 +551,8 @@ EXTERN bool nxgl_rectoverlap(FAR struct nxgl_rect_s *rect1, * ****************************************************************************/ -EXTERN bool nxgl_rectinside(FAR const struct nxgl_rect_s *rect, - FAR const struct nxgl_point_s *pt); +bool nxgl_rectinside(FAR const struct nxgl_rect_s *rect, + FAR const struct nxgl_point_s *pt); /**************************************************************************** * Name: nxgl_rectsize @@ -568,18 +562,18 @@ EXTERN bool nxgl_rectinside(FAR const struct nxgl_rect_s *rect, * ****************************************************************************/ -EXTERN void nxgl_rectsize(FAR struct nxgl_size_s *size, - FAR const struct nxgl_rect_s *rect); +void nxgl_rectsize(FAR struct nxgl_size_s *size, + FAR const struct nxgl_rect_s *rect); /**************************************************************************** * Name: nxgl_nullrect * * Description: - * Return true if the area of the retangle is <= 0. + * Return true if the area of the rectangle is <= 0. * ****************************************************************************/ -EXTERN bool nxgl_nullrect(FAR const struct nxgl_rect_s *rect); +bool nxgl_nullrect(FAR const struct nxgl_rect_s *rect); /**************************************************************************** * Name: nxgl_runoffset @@ -589,9 +583,9 @@ EXTERN bool nxgl_nullrect(FAR const struct nxgl_rect_s *rect); * ****************************************************************************/ -EXTERN void nxgl_runoffset(FAR struct nxgl_run_s *dest, - FAR const struct nxgl_run_s *src, - nxgl_coord_t dx, nxgl_coord_t dy); +void nxgl_runoffset(FAR struct nxgl_run_s *dest, + FAR const struct nxgl_run_s *src, + nxgl_coord_t dx, nxgl_coord_t dy); /**************************************************************************** * Name: nxgl_runcopy @@ -602,8 +596,8 @@ EXTERN void nxgl_runoffset(FAR struct nxgl_run_s *dest, * ****************************************************************************/ -EXTERN void nxgl_runcopy(FAR struct nxgl_run_s *dest, - FAR const struct nxgl_run_s *src); +void nxgl_runcopy(FAR struct nxgl_run_s *dest, + FAR const struct nxgl_run_s *src); /**************************************************************************** * Name: nxgl_trapoffset @@ -613,9 +607,9 @@ EXTERN void nxgl_runcopy(FAR struct nxgl_run_s *dest, * ****************************************************************************/ -EXTERN void nxgl_trapoffset(FAR struct nxgl_trapezoid_s *dest, - FAR const struct nxgl_trapezoid_s *src, - nxgl_coord_t dx, nxgl_coord_t dy); +void nxgl_trapoffset(FAR struct nxgl_trapezoid_s *dest, + FAR const struct nxgl_trapezoid_s *src, + nxgl_coord_t dx, nxgl_coord_t dy); /**************************************************************************** * Name: nxgl_trapcopy @@ -626,8 +620,8 @@ EXTERN void nxgl_trapoffset(FAR struct nxgl_trapezoid_s *dest, * ****************************************************************************/ -EXTERN void nxgl_trapcopy(FAR struct nxgl_trapezoid_s *dest, - FAR const struct nxgl_trapezoid_s *src); +void nxgl_trapcopy(FAR struct nxgl_trapezoid_s *dest, + FAR const struct nxgl_trapezoid_s *src); /**************************************************************************** * Name: nxgl_colorcopy @@ -639,8 +633,21 @@ EXTERN void nxgl_trapcopy(FAR struct nxgl_trapezoid_s *dest, * ****************************************************************************/ -EXTERN void nxgl_colorcopy(nxgl_mxpixel_t dest[CONFIG_NX_NPLANES], - const nxgl_mxpixel_t src[CONFIG_NX_NPLANES]); +void nxgl_colorcopy(nxgl_mxpixel_t dest[CONFIG_NX_NPLANES], + const nxgl_mxpixel_t src[CONFIG_NX_NPLANES]); + +/**************************************************************************** + * Name: nxgl_colorcmp + * + * Description: + * This is essentially memcmp for colors. This does very little for us + * other than hide all of the conditional compilation for planar colors + * in one place. + * + ****************************************************************************/ + +bool nxgl_colorcmp(const nxgl_mxpixel_t color1[CONFIG_NX_NPLANES], + const nxgl_mxpixel_t color2[CONFIG_NX_NPLANES]); /**************************************************************************** * Name: nxgl_splitline @@ -657,7 +664,7 @@ EXTERN void nxgl_colorcopy(nxgl_mxpixel_t dest[CONFIG_NX_NPLANES], * 2. If x1 == x2 then the line is vertical and also better represented * as a rectangle. * 3. If the width of the line is 1, then there are no triangles at the - * top and bottome (this may also be the case if the width is narrow + * top and bottom (this may also be the case if the width is narrow * and the line is near vertical). * 4. If the line is oriented is certain angles, it may consist only of * the upper and lower triangles with no trapezoid in between. In @@ -680,10 +687,10 @@ EXTERN void nxgl_colorcopy(nxgl_mxpixel_t dest[CONFIG_NX_NPLANES], * ****************************************************************************/ -EXTERN int nxgl_splitline(FAR struct nxgl_vector_s *vector, - FAR struct nxgl_trapezoid_s *traps, - FAR struct nxgl_rect_s *rect, - nxgl_coord_t linewidth); +int nxgl_splitline(FAR struct nxgl_vector_s *vector, + FAR struct nxgl_trapezoid_s *traps, + FAR struct nxgl_rect_s *rect, + nxgl_coord_t linewidth); /**************************************************************************** * Name: nxgl_circlepts @@ -704,9 +711,9 @@ EXTERN int nxgl_splitline(FAR struct nxgl_vector_s *vector, * ****************************************************************************/ -EXTERN void nxgl_circlepts(FAR const struct nxgl_point_s *center, - nxgl_coord_t radius, - FAR struct nxgl_point_s *circle); +void nxgl_circlepts(FAR const struct nxgl_point_s *center, + nxgl_coord_t radius, + FAR struct nxgl_point_s *circle); /**************************************************************************** * Name: nxgl_circletraps @@ -726,9 +733,9 @@ EXTERN void nxgl_circlepts(FAR const struct nxgl_point_s *center, * ****************************************************************************/ -EXTERN void nxgl_circletraps(FAR const struct nxgl_point_s *center, - nxgl_coord_t radius, - FAR struct nxgl_trapezoid_s *circle); +void nxgl_circletraps(FAR const struct nxgl_point_s *center, + nxgl_coord_t radius, + FAR struct nxgl_trapezoid_s *circle); #undef EXTERN #if defined(__cplusplus) diff --git a/libnx/nxglib/Make.defs b/libnx/nxglib/Make.defs index 7aaff27f46..bc0ca0c934 100644 --- a/libnx/nxglib/Make.defs +++ b/libnx/nxglib/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # libnx/nxglib/Make.defs # -# Copyright (C) 2013 Gregory Nutt. All rights reserved. +# Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -37,14 +37,14 @@ ifeq ($(CONFIG_NX),y) -CSRCS += nxglib_circlepts.c nxglib_circletraps.c nxglib_colorcopy.c -CSRCS += nxglib_intersecting.c nxglib_nonintersecting.c nxglib_nullrect.c -CSRCS += nxglib_rectadd.c nxglib_rectcopy.c nxglib_rectinside.c -CSRCS += nxglib_rectintersect.c nxglib_rectoffset.c nxglib_rectoverlap.c -CSRCS += nxglib_rectsize.c nxglib_rectunion.c nxglib_rgb2yuv.c -CSRCS += nxglib_runcopy.c nxglib_runoffset.c nxglib_splitline.c -CSRCS += nxglib_trapcopy.c nxglib_trapoffset.c nxglib_vectoradd.c -CSRCS += nxglib_vectsubtract.c nxglib_yuv2rgb.c +CSRCS += nxglib_circlepts.c nxglib_circletraps.c nxglib_colorcmp.c +CSRCS += nxglib_colorcopy.c nxglib_intersecting.c nxglib_nonintersecting.c +CSRCS += nxglib_nullrect.c nxglib_rectadd.c nxglib_rectcopy.c +CSRCS += nxglib_rectinside.c nxglib_rectintersect.c nxglib_rectoffset.c +CSRCS += nxglib_rectoverlap.c nxglib_rectsize.c nxglib_rectunion.c +CSRCS += nxglib_rgb2yuv.c nxglib_runcopy.c nxglib_runoffset.c +CSRCS += nxglib_splitline.c nxglib_trapcopy.c nxglib_trapoffset.c +CSRCS += nxglib_vectoradd.c nxglib_vectsubtract.c nxglib_yuv2rgb.c # Add the nxglib/ directory to the build diff --git a/libnx/nxglib/nxglib_colorcmp.c b/libnx/nxglib/nxglib_colorcmp.c new file mode 100644 index 0000000000..e2bcaca4b3 --- /dev/null +++ b/libnx/nxglib/nxglib_colorcmp.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * libnx/nxglib/nxglib_colorcmp.c + * + * Copyright (C) 2014 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Pre-Processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxgl_colorcmp + * + * Description: + * This is essentially memcmp for colors. This does very little for us + * other than hide all of the conditional compilation for planar colors + * in one place. + * + ****************************************************************************/ + +bool nxgl_colorcmp(const nxgl_mxpixel_t color1[CONFIG_NX_NPLANES], + const nxgl_mxpixel_t color2[CONFIG_NX_NPLANES]) +{ + int i; + + for (i = 0; i < CONFIG_NX_NPLANES; i++) + { + if (color1[i] != color2[i]) + { + return false; + } + } + + return true; +}