From 7060857f2a90945f13294ea055309520cd93cd45 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 26 Nov 2008 23:42:51 +0000 Subject: Make prototypes of rasterizers same at all resolutions git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1317 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/Makefile | 13 +++- nuttx/graphics/Makefile | 2 +- nuttx/graphics/nxglib/nxglib_copyrectangle.c | 8 +-- nuttx/graphics/nxglib/nxglib_fillrectangle.c | 4 +- nuttx/graphics/nxglib/nxglib_filltrapezoid.c | 4 +- nuttx/include/nuttx/nxglib.h | 97 ++++++++++++++++------------ 6 files changed, 75 insertions(+), 53 deletions(-) diff --git a/nuttx/Makefile b/nuttx/Makefile index eafdc5e01..c24f8f6e6 100644 --- a/nuttx/Makefile +++ b/nuttx/Makefile @@ -61,13 +61,17 @@ ADDON_DIRS := $(PCODE_DIR) $(NX_DIR) # (except for parts of FSDIRS). We will exclude FSDIRS # from the build if file descriptor support is disabled -NONFSDIRS = sched lib $(ARCH_SRC) mm examples/$(CONFIG_EXAMPLE) $(ADDON_DIRS) graphics +NONFSDIRS = sched lib $(ARCH_SRC) mm examples/$(CONFIG_EXAMPLE) $(ADDON_DIRS) FSDIRS = fs drivers ifeq ($(CONFIG_NET),y) NONFSDIRS += net netutils endif +ifeq ($(CONFIG_NXGRAPHICS),y) +NONFSDIRS += graphics +endif + # CLEANDIRS are the directories that will clean in. These are # all directories that we know about. # MAKEDIRS are the directories in which we will build targets @@ -92,8 +96,7 @@ endif # is disabled. LINKLIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT) mm/libmm$(LIBEXT) \ - lib/liblib$(LIBEXT) examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE)$(LIBEXT) \ - graphics/libgraphics$(LIBEXT) + lib/liblib$(LIBEXT) examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE)$(LIBEXT) ifeq ($(CONFIG_NET),y) LINKLIBS += net/libnet$(LIBEXT) netutils/libnetutils$(LIBEXT) @@ -118,6 +121,10 @@ ifneq ($(NX_DIR),) LINKLIBS += $(NX_DIR)/libnx$(LIBEXT) endif +ifeq ($(CONFIG_NXGRAPHICS),y) +LINKLIBS += graphics/libgraphics$(LIBEXT) +endif + # This is the name of the final target BIN = nuttx$(EXEEXT) diff --git a/nuttx/graphics/Makefile b/nuttx/graphics/Makefile index 63f1b82de..34e0c6984 100644 --- a/nuttx/graphics/Makefile +++ b/nuttx/graphics/Makefile @@ -42,7 +42,7 @@ include nxglib/Make.defs DEPPATH += --dep-path nxglib CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh "$(CC)" $(TOPDIR)/graphics/nxglib} -HAVENX = `if [ -d nx ]; then echo "y"; else echo "n";fi` +HAVENX := ${shell if [ -d nx ]; then echo "y"; else echo "n";fi} ifeq ($(HAVENX),y) include nx/Make.defs DEPPATH += --dep-path nx diff --git a/nuttx/graphics/nxglib/nxglib_copyrectangle.c b/nuttx/graphics/nxglib/nxglib_copyrectangle.c index 0dd01853c..03068b89e 100644 --- a/nuttx/graphics/nxglib/nxglib_copyrectangle.c +++ b/nuttx/graphics/nxglib/nxglib_copyrectangle.c @@ -70,7 +70,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: nxs_copyrectangle_*bpp + * Name: nxgl_copyrectangle_*bpp * * Descripton: * Copy a rectangular bitmap image into the specific position in the @@ -78,9 +78,9 @@ * ****************************************************************************/ -void NXGL_FUNCNAME(nxs_copyrectangle,NXGLIB_SUFFIX) +void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX) (FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *dest, - FAR const NXGL_PIXEL_T *src, FAR const struct nxgl_point_s *origin, + FAR const void *src, FAR const struct nxgl_point_s *origin, unsigned int srcstride) { const ubyte *sptr; @@ -105,7 +105,7 @@ void NXGL_FUNCNAME(nxs_copyrectangle,NXGLIB_SUFFIX) while (rows--) { - NXGL_MEMCPY(dest, sptr, width); + NXGL_MEMCPY((NXGL_PIXEL_T*)dest, (NXGL_PIXEL_T*)sptr, width); dptr += deststride; sptr += srcstride; } diff --git a/nuttx/graphics/nxglib/nxglib_fillrectangle.c b/nuttx/graphics/nxglib/nxglib_fillrectangle.c index 727c57580..b5ed8d581 100644 --- a/nuttx/graphics/nxglib/nxglib_fillrectangle.c +++ b/nuttx/graphics/nxglib/nxglib_fillrectangle.c @@ -82,7 +82,7 @@ ****************************************************************************/ void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX) -(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, NXGL_PIXEL_T color) +(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, nxgl_mxpixel_t color) { ubyte *line; unsigned int width; @@ -106,7 +106,7 @@ void NXGL_FUNCNAME(nxgl_fillrectangle,NXGLIB_SUFFIX) while (rows--) { - NXGL_MEMSET(line, color, width); + NXGL_MEMSET(line, (NXGL_PIXEL_T)color, width); line += stride; } } diff --git a/nuttx/graphics/nxglib/nxglib_filltrapezoid.c b/nuttx/graphics/nxglib/nxglib_filltrapezoid.c index f1f13a00f..2343a4680 100644 --- a/nuttx/graphics/nxglib/nxglib_filltrapezoid.c +++ b/nuttx/graphics/nxglib/nxglib_filltrapezoid.c @@ -86,7 +86,7 @@ void NXGL_FUNCNAME(nxglib_filltrapezoid,NXGLIB_SUFFIX) (FAR struct fb_videoinfo_s *vinfo, FAR struct fb_planeinfo_s *pinfo, - FAR const struct nxgl_trapezoid_s *trap, NXGL_PIXEL_T color) + FAR const struct nxgl_trapezoid_s *trap, nxgl_mxpixel_t color) { unsigned int stride; ubyte *line; @@ -152,7 +152,7 @@ void NXGL_FUNCNAME(nxglib_filltrapezoid,NXGLIB_SUFFIX) /* Then draw the run from (line + clipx1) to (line + clipx2) */ - NXGL_MEMSET(line + NXGL_SCALEX(ix1), color, ix2 - ix1 + 1); + NXGL_MEMSET(line + NXGL_SCALEX(ix1), (NXGL_PIXEL_T)color, ix2 - ix1 + 1); } /* Move to the start of the next line */ diff --git a/nuttx/include/nuttx/nxglib.h b/nuttx/include/nuttx/nxglib.h index 6e2d6a794..cc065ab6a 100644 --- a/nuttx/include/nuttx/nxglib.h +++ b/nuttx/include/nuttx/nxglib.h @@ -59,6 +59,21 @@ * Public Types ****************************************************************************/ +/* Pixels *******************************************************************/ + +/* The size of graphics solutions can be reduced by disabling support for + * specific resolutions. One thing we can do, for example, is to select + * the smallest common pixel representation: + */ + +#if !defined(CONFIG_NXGLIB_DISABLE_32BPP) || defined(CONFIG_NXGLIB_DISABLE_24BPP) +typedef uint32 nxgl_mxpixel_t; +#elif !defined(CONFIG_NXGLIB_DISABLE_16BPP) +typedef uint16 nxgl_mxpixel_t; +#else +typedef ubyte nxgl_mxpixel_t; +#endif + /* Graphics structures ******************************************************/ /* A given coordinate is limited to the screen height an width. If either @@ -156,25 +171,25 @@ EXTERN void nxgl_yuv2rgb(ubyte y, ubyte u, ubyte v, ubyte *r, ubyte *g, ubyte *b EXTERN void nxgl_fillrectangle_1bpp(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, - ubyte color); + nxgl_mxpixel_t color); EXTERN void nxgl_fillrectangle_2bpp(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, - ubyte color); + nxgl_mxpixel_t color); EXTERN void nxgl_fillrectangle_4bpp(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, - ubyte color); + nxgl_mxpixel_t color); EXTERN void nxgl_fillrectangle_8bpp(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, - ubyte color); + nxgl_mxpixel_t color); EXTERN void nxgl_fillrectangle_16bpp(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, - uint16 color); + nxgl_mxpixel_t color); EXTERN void nxgl_fillrectangle_24bpp(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, - uint32 color); + nxgl_mxpixel_t color); EXTERN void nxgl_fillrectangle_32bpp(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *rect, - uint32 color); + nxgl_mxpixel_t color); /**************************************************************************** * Name: nxglib_filltrapezoid_*bpp @@ -189,31 +204,31 @@ EXTERN void nxgl_fillrectangle_32bpp(FAR struct fb_planeinfo_s *pinfo, EXTERN void nxglib_filltrapezoid_1bpp(FAR struct fb_videoinfo_s *vinfo, FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_trapezoid_s *trap, - ubyte color); + nxgl_mxpixel_t color); EXTERN void nxglib_filltrapezoid_2bpp(FAR struct fb_videoinfo_s *vinfo, FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_trapezoid_s *trap, - ubyte color); + nxgl_mxpixel_t color); EXTERN void nxglib_filltrapezoid_4bpp(FAR struct fb_videoinfo_s *vinfo, FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_trapezoid_s *trap, - ubyte color); + nxgl_mxpixel_t color); EXTERN void nxglib_filltrapezoid_8bpp(FAR struct fb_videoinfo_s *vinfo, FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_trapezoid_s *trap, - ubyte color); + nxgl_mxpixel_t color); EXTERN void nxglib_filltrapezoid_16bpp(FAR struct fb_videoinfo_s *vinfo, FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_trapezoid_s *trap, - uint16 color); + nxgl_mxpixel_t color); EXTERN void nxglib_filltrapezoid_24bpp(FAR struct fb_videoinfo_s *vinfo, FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_trapezoid_s *trap, - uint32 color); + nxgl_mxpixel_t color); EXTERN void nxglib_filltrapezoid_32bpp(FAR struct fb_videoinfo_s *vinfo, FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_trapezoid_s *trap, - uint32 color); + nxgl_mxpixel_t color); /**************************************************************************** * Name: nxgl_moverectangle_*bpp @@ -247,7 +262,7 @@ EXTERN void nxgl_moverectangle_32bpp(FAR struct fb_planeinfo_s *pinfo, FAR struct nxgl_point_s *offset); /**************************************************************************** - * Name: nxs_copyrectangle_*bpp + * Name: nxgl_copyrectangle_*bpp * * Descripton: * Copy a rectangular bitmap image into the specific position in the @@ -255,41 +270,41 @@ EXTERN void nxgl_moverectangle_32bpp(FAR struct fb_planeinfo_s *pinfo, * ****************************************************************************/ -EXTERN void nxs_copyrectangle_1bpp(FAR struct fb_planeinfo_s *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const ubyte *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxs_copyrectangle_2bpp(FAR struct fb_planeinfo_s *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const ubyte *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxs_copyrectangle_4bpp(FAR struct fb_planeinfo_s *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const ubyte *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxs_copyrectangle_8bpp(FAR struct fb_planeinfo_s *pinfo, - FAR const struct nxgl_rect_s *dest, - FAR const ubyte *src, - FAR const struct nxgl_point_s *origin, - unsigned int srcstride); -EXTERN void nxs_copyrectangle_16bpp(FAR struct fb_planeinfo_s *pinfo, +EXTERN void nxgl_copyrectangle_1bpp(FAR struct fb_planeinfo_s *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 struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *dest, - FAR const uint16 *src, + FAR const void *src, FAR const struct nxgl_point_s *origin, unsigned int srcstride); -EXTERN void nxs_copyrectangle_24bpp(FAR struct fb_planeinfo_s *pinfo, +EXTERN void nxgl_copyrectangle_4bpp(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *dest, - FAR const uint32 *src, + FAR const void *src, FAR const struct nxgl_point_s *origin, unsigned int srcstride); -EXTERN void nxs_copyrectangle_32bpp(FAR struct fb_planeinfo_s *pinfo, +EXTERN void nxgl_copyrectangle_8bpp(FAR struct fb_planeinfo_s *pinfo, FAR const struct nxgl_rect_s *dest, - FAR const uint32 *src, + FAR const void *src, FAR const struct nxgl_point_s *origin, unsigned int srcstride); +EXTERN void nxgl_copyrectangle_16bpp(FAR struct fb_planeinfo_s *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 struct fb_planeinfo_s *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 struct fb_planeinfo_s *pinfo, + FAR const struct nxgl_rect_s *dest, + FAR const void *src, + FAR const struct nxgl_point_s *origin, + unsigned int srcstride); #undef EXTERN #if defined(__cplusplus) -- cgit v1.2.3