From 69ef693d6f964404ef5d278f2f29ab7d26022f04 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 30 Nov 2008 18:52:14 +0000 Subject: There is at least some X11 output now git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1361 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/graphics/nxbe/nxbe.h | 6 +++++- nuttx/graphics/nxbe/nxbe_colormap.c | 24 ++++++++++++++---------- nuttx/graphics/nxglib/nxglib_filltrapezoid.c | 25 +++++++++++++++++-------- nuttx/graphics/nxmu/nxmu_server.c | 2 -- 4 files changed, 36 insertions(+), 21 deletions(-) (limited to 'nuttx/graphics') diff --git a/nuttx/graphics/nxbe/nxbe.h b/nuttx/graphics/nxbe/nxbe.h index 393a06075..5f5e14b76 100644 --- a/nuttx/graphics/nxbe/nxbe.h +++ b/nuttx/graphics/nxbe/nxbe.h @@ -55,6 +55,10 @@ # define CONFIG_NX_NPLANES 1 /* Max number of color planes supported */ #endif +#ifndef CONFIG_NX_NCOLORS +# define CONFIG_NX_NCOLORS 256 +#endif + /* These are the values for the clipping order provided to nx_clipper */ #define NX_CLIPORDER_TLRB (0) /* Top-left-right-bottom */ @@ -199,7 +203,7 @@ extern "C" { ****************************************************************************/ #if CONFIG_FB_CMAP -EXTERN int nxbe_colormap(FAR const fb_vtable_s *fb); +EXTERN int nxbe_colormap(FAR struct fb_vtable_s *fb); #endif /**************************************************************************** diff --git a/nuttx/graphics/nxbe/nxbe_colormap.c b/nuttx/graphics/nxbe/nxbe_colormap.c index 2d4b34b7f..509cf4f45 100644 --- a/nuttx/graphics/nxbe/nxbe_colormap.c +++ b/nuttx/graphics/nxbe/nxbe_colormap.c @@ -40,9 +40,13 @@ #include #include +#include +#include #include #include +#include + #include "nxbe.h" /**************************************************************************** @@ -78,9 +82,9 @@ ****************************************************************************/ #if CONFIG_FB_CMAP -int nxbe_colormap(FAR const fb_vtable_s *fb) +int nxbe_colormap(FAR struct fb_vtable_s *fb) { - struct fb_cmap cmap; + struct fb_cmap_s cmap; ubyte *alloc; ubyte *red; ubyte *green; @@ -94,7 +98,7 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) /* Allocate the color map tables */ - size = 3 * NX_NCOLORS * sizeof(uint16); + size = 3 * CONFIG_NX_NCOLORS * sizeof(uint16); alloc = (ubyte*)malloc(size); if (alloc < 0) { @@ -103,8 +107,8 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) memset(alloc, 0xff, size); red = alloc; - green = &alloc[NX_NCOLORS]; - blue = &alloc[2*NX_NCOLORS]; + green = &alloc[CONFIG_NX_NCOLORS]; + blue = &alloc[2*CONFIG_NX_NCOLORS]; /* Initialize the color map tables. 6*6*6 = 216, the rest * are (0xffff, 0xffff, 0xffff) @@ -113,15 +117,15 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) ndx = 0; for (i = 0; i < 6; i++) { - rval = (i * (NX_NCOLORS-1) / 5) << 8; + rval = (i * (CONFIG_NX_NCOLORS-1) / 5) << 8; for (j = 0; j < 6; j++) { - gval = (j * (NX_NCOLORS-1) / 5) << 8; + gval = (j * (CONFIG_NX_NCOLORS-1) / 5) << 8; for (k = 0; k < 6; k++) { red[ndx] = rval; green[ndx] = gval; - blue[ndx] = k * (NX_NCOLORS-1) / 5; + blue[ndx] = k * (CONFIG_NX_NCOLORS-1) / 5; ndx++; } } @@ -129,7 +133,7 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) /* Now configure the cmap structure */ - cmap.len = NX_NCOLORS; + cmap.len = CONFIG_NX_NCOLORS; cmap.red = red; cmap.green = green; cmap.blue = blue; @@ -141,7 +145,7 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) ret =fb->putcmap(fb, &cmap); - free(cmap); + free(alloc); return ret; } #endif diff --git a/nuttx/graphics/nxglib/nxglib_filltrapezoid.c b/nuttx/graphics/nxglib/nxglib_filltrapezoid.c index 35ded6139..b20b46570 100644 --- a/nuttx/graphics/nxglib/nxglib_filltrapezoid.c +++ b/nuttx/graphics/nxglib/nxglib_filltrapezoid.c @@ -117,6 +117,12 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)( x1 = trap->top.x1; x2 = trap->top.x2; + /* Calculate the number of rows to render */ + + y1 = trap->top.y; + y2 = trap->bot.y; + nrows = y2 - y1 + 1; + /* Calculate the slope of the left and right side of the trapezoid */ dx1dy = b16divi((trap->bot.x1 - x1), nrows); @@ -124,28 +130,31 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)( /* Perform vertical clipping */ - y1 = trap->top.y; if (y1 < bounds->pt1.y) { + /* Calculate the x values for the new top run */ + int dy = bounds->pt1.y - y1; x1 += dy * dx1dy; x2 += dy * dx2dy; + + /* Clip and re-calculate the number of rows to render */ + y1 = bounds->pt1.y; + nrows = y2 - y1 + 1; } - y2 = trap->bot.y; if (y2 > bounds->pt2.y) { - y2 = bounds->pt2.y; - } + /* Clip and re-calculate the number of rows to render */ - /* Then calculate the number of rows to render */ - - nrows = y2 - y1 + 1; + y2 = bounds->pt2.y; + nrows = y2 - y1 + 1; + } /* Get the address of the first byte on the first line */ - line = pinfo->fbmem + y1 * stride ; + line = pinfo->fbmem + y1 * stride ; /* Then fill the trapezoid line-by-line */ diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c index c193dc7cb..186a22ea8 100644 --- a/nuttx/graphics/nxmu/nxmu_server.c +++ b/nuttx/graphics/nxmu/nxmu_server.c @@ -56,8 +56,6 @@ * Pre-Processor Definitions ****************************************************************************/ -#define NX_NCOLORS 256 - /**************************************************************************** * Private Types ****************************************************************************/ -- cgit v1.2.3