changeset 1189:e1afd37f2f1d

Support BGR233 mode
author gthomas
date Tue, 02 Sep 2003 02:42:36 +0000
parents deed043a388c
children d53522870fc0
files packages/services/gfx/mw/current/ChangeLog packages/services/gfx/mw/current/include/microwin/device.h packages/services/gfx/mw/current/include/microwin/mwtypes.h packages/services/gfx/mw/current/src/Configs/config.ecos packages/services/gfx/mw/current/src/demos/nanox/ntetris.c packages/services/gfx/mw/current/src/drivers/scr_vnc_ecos.c packages/services/gfx/mw/current/src/engine/devdraw.c packages/services/gfx/mw/current/src/engine/devfont.c packages/services/gfx/mw/current/src/engine/devfont.caching.c packages/services/gfx/mw/current/src/engine/devopen.c packages/services/gfx/mw/current/src/mwin/wingdi.c packages/services/gfx/mw/current/src/nanox/client.c
diffstat 12 files changed, 111 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/packages/services/gfx/mw/current/ChangeLog
+++ b/packages/services/gfx/mw/current/ChangeLog
@@ -1,3 +1,18 @@
+2003-09-01  Gary Thomas  <gary@mlbassoc.com>
+
+	* src/nanox/client.c: 
+	* src/mwin/wingdi.c: 
+	* src/engine/devopen.c: 
+	* src/engine/devfont.caching.c: 
+	* src/engine/devfont.c: 
+	* src/engine/devdraw.c: 
+	* src/drivers/scr_vnc_ecos.c: 
+	* src/demos/nanox/ntetris.c: 
+	* src/Configs/config.ecos: 
+	* include/microwin/mwtypes.h: 
+	* include/microwin/device.h: Support BGR233 mode which is used by
+	the VNC server.
+
 2003-08-30  Gary Thomas  <gary@mlbassoc.com>
 
 	* src/ecos/world_thread.c: 
--- a/packages/services/gfx/mw/current/include/microwin/device.h
+++ b/packages/services/gfx/mw/current/include/microwin/device.h
@@ -280,6 +280,10 @@ typedef struct {
 #define RGB2PIXEL332(r,g,b)	\
 	(((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
 
+/* create 8 bit 2/3/3 format pixel from RBG triplet*/
+#define RGB2PIXEL233(r,g,b)	\
+	((((r) & 0xe0) >> 5) | (((g) & 0xe0) >> 2) | (((b) & 0xc0) >> 0))
+
 /*
  * Conversion from MWCOLORVAL to MWPIXELVAL
  */
@@ -304,7 +308,11 @@ typedef struct {
 
 /* create 8 bit 3/3/2 format pixel from RGB colorval (0x00BBGGRR)*/
 #define COLOR2PIXEL332(c)	\
-	(((c) & 0xe0) | (((c) & 0xe000) >> 11) | (((c) & 0xc00000) >> 22))
+	((((c) & 0xe0) >> 5) | (((c) & 0xe000) >> 9) | (((c) & 0xc00000) >> 16))
+
+/* create 8 bit 2/3/3 format pixel from RGB colorval (0x00BBGGRR)*/
+#define COLOR2PIXEL233(c)	\
+        ((((c) & 0xC00000) >> 16) | (((c) & 0x00E000) >> 10) | (((c) & 0xE0) >> 5))
 
 /*
  * Conversion from MWPIXELVAL to red, green or blue components
@@ -329,6 +337,11 @@ typedef struct {
 #define PIXEL332GREEN(pixelval)		(((pixelval) >> 2) & 0x07)
 #define PIXEL332BLUE(pixelval)		((pixelval) & 0x03)
 
+/* return 2/3/3 bit b, g, r component of 8 bit pixelval*/
+#define PIXEL233RED(pixelval)		((pixelval) & 0x07)
+#define PIXEL233GREEN(pixelval)		(((pixelval) >> 3) & 0x07)
+#define PIXEL233BLUE(pixelval)		(((pixelval) >> 6) & 0x03)
+
 /*
  * Conversion from MWPIXELVAL to MWCOLORVAL
  */
@@ -347,6 +360,10 @@ typedef struct {
 #define PIXEL332TOCOLORVAL(p)	\
 	((((p) & 0xe0)) | (((p) & 0x1c) << 11) | (((p) & 0x03) << 19))
 
+/* create RGB colorval (0x00BBGGRR) from 2/3/3 format pixel*/
+#define PIXEL233TOCOLORVAL(p)	\
+	(((p) & 0x07) | (((p) & 0x38) << 5) | (((p) & 0xC0) << 14))
+
 #if (MWPIXEL_FORMAT == MWPF_TRUECOLOR888) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR0888)
 #define RGB2PIXEL(r,g,b)	RGB2PIXEL888(r,g,b)
 #define COLORVALTOPIXELVAL(c)	COLOR2PIXEL888(c)
@@ -383,6 +400,15 @@ typedef struct {
 #define PIXEL2BLUE(p)		PIXEL332BLUE(p)
 #endif
 
+#if MWPIXEL_FORMAT == MWPF_TRUECOLOR233
+#define RGB2PIXEL(r,g,b)	RGB2PIXEL233(r,g,b)
+#define COLORVALTOPIXELVAL(c)	COLOR2PIXEL233(c)
+#define PIXELVALTOCOLORVAL(p)	PIXEL233TOCOLORVAL(p)
+#define PIXEL2RED(p)		PIXEL233RED(p)
+#define PIXEL2GREEN(p)		PIXEL233GREEN(p)
+#define PIXEL2BLUE(p)		PIXEL233BLUE(p)
+#endif
+
 /* Alpha blend two pixels using 8-bit alpha */
 /* FIXME this will be quite a bit faster as an inlined function */
 #define ALPHAPIXELRED(pixelvalsrc, pixelvaldest, alpha)	\
--- a/packages/services/gfx/mw/current/include/microwin/mwtypes.h
+++ b/packages/services/gfx/mw/current/include/microwin/mwtypes.h
@@ -122,6 +122,7 @@
 #define MWPF_TRUECOLOR565  5	/* pixel is packed 16 bits 5/6/5 truecolor*/
 #define MWPF_TRUECOLOR555  6	/* pixel is packed 16 bits 5/5/5 truecolor*/
 #define MWPF_TRUECOLOR332  7	/* pixel is packed 8 bits 3/3/2 truecolor*/
+#define MWPF_TRUECOLOR233  8	/* pixel is packed 8 bits 2/3/3 truecolor (BGR) */
 
 /*
  * MWPIXELVAL definition: changes based on target system
@@ -153,7 +154,7 @@
 #if (MWPIXEL_FORMAT == MWPF_TRUECOLOR565) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR555)
 typedef unsigned short MWPIXELVAL;
 #else
-  #if MWPIXEL_FORMAT == MWPF_TRUECOLOR332
+  #if (MWPIXEL_FORMAT == MWPF_TRUECOLOR332) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR233)
   typedef unsigned char MWPIXELVAL;
   #else
     #if MWPIXEL_FORMAT == MWPF_PALETTE
--- a/packages/services/gfx/mw/current/src/Configs/config.ecos
+++ b/packages/services/gfx/mw/current/src/Configs/config.ecos
@@ -90,6 +90,7 @@ NANOWM                   = Y
 # define MWPF_TRUECOLOR565  /* pixel is packed 16 bits 5/6/5 truecolor*/
 # define MWPF_TRUECOLOR555  /* pixel is packed 16 bits 5/5/5 truecolor*/
 # define MWPF_TRUECOLOR332  /* pixel is packed 8 bits 3/3/2 truecolor*/
+# define MWPF_TRUECOLOR233  /* pixel is packed 8 bits 3/3/2 truecolor (BGR) */
 #
 ####################################################################
 #SCREEN_PIXTYPE           = MWPF_TRUECOLOR565
--- a/packages/services/gfx/mw/current/src/demos/nanox/ntetris.c
+++ b/packages/services/gfx/mw/current/src/demos/nanox/ntetris.c
@@ -700,6 +700,7 @@ static int random8(int limit)
 
 static void choose_new_shape(nstate *state)
 {
+    diag_printf("%s - state: %x\n", __FUNCTION__, state);
 	state->current_shape.type = state->next_shape.type;
 	state->current_shape.orientation = state->next_shape.orientation;
 	state->current_shape.colour = state->next_shape.colour;
--- a/packages/services/gfx/mw/current/src/drivers/scr_vnc_ecos.c
+++ b/packages/services/gfx/mw/current/src/drivers/scr_vnc_ecos.c
@@ -177,6 +177,12 @@ static PSD vnc_open(PSD psd)
         psd->ncolors = 0xFFFF + 1;
         psd->pixtype = MWPF_TRUECOLOR565;
     }
+    else if (frame_format->bgr233)
+    {
+        psd->bpp = 8;
+        psd->ncolors = 0xFF + 1;
+        psd->pixtype = MWPF_TRUECOLOR233;
+    }
     else
     {
         EPRINTF("Unsupported display type\n");
@@ -229,6 +235,11 @@ static void vnc_getscreeninfo(PSD psd,PM
         psi->gmask = 0x1C;
         psi->bmask = 0x03;
         break;
+    case MWPF_TRUECOLOR233:
+        psi->rmask = 0x07;
+        psi->gmask = 0x38;
+        psi->bmask = 0xC0;
+        break;
     case MWPF_TRUECOLOR555:
         psi->rmask = 0x7c00;
         psi->gmask = 0x03e0;
--- a/packages/services/gfx/mw/current/src/engine/devdraw.c
+++ b/packages/services/gfx/mw/current/src/engine/devdraw.c
@@ -640,6 +640,9 @@ GdDrawImage(PSD psd, MWCOORD x, MWCOORD 
 		case MWPF_TRUECOLOR332:
 			pixel = COLOR2PIXEL332(cr);
 			break;
+		case MWPF_TRUECOLOR233:
+			pixel = COLOR2PIXEL233(cr);
+			break;
 		}
 		break;
 	default:
@@ -734,6 +737,7 @@ GdReadArea(PSD psd, MWCOORD x, MWCOORD y
  * MWPF_TRUECOLOR565	unsigned short
  * MWPF_TRUECOLOR555	unsigned short
  * MWPF_TRUECOLOR332	unsigned char
+ * MWPF_TRUECOLOR233	unsigned char
  *
  * NOTE: Currently, no translation is performed if the pixtype
  * is not MWPF_RGB.  Pixtype is only then used to determine the 
@@ -859,6 +863,7 @@ GdArea(PSD psd, MWCOORD x, MWCOORD y, MW
 		break;
 	case MWPF_PALETTE:
 	case MWPF_TRUECOLOR332:
+	case MWPF_TRUECOLOR233:
 		pixsize = sizeof(unsigned char);
 		break;
 	case MWPF_TRUECOLOR0888:
@@ -891,6 +896,7 @@ GdArea(PSD psd, MWCOORD x, MWCOORD y, MW
 		break;
 	case MWPF_PALETTE:
 	case MWPF_TRUECOLOR332:
+	case MWPF_TRUECOLOR233:
 		gr_foreground = *PIXELS++;
 		break;
 	case MWPF_TRUECOLOR0888:
@@ -934,6 +940,7 @@ GdArea(PSD psd, MWCOORD x, MWCOORD y, MW
 			break;
 		case MWPF_PALETTE:
 		case MWPF_TRUECOLOR332:
+		case MWPF_TRUECOLOR233:
 			if(gr_foreground != *(unsigned char *)PIXELS)
 				goto breakwhile;
 			++PIXELS;
@@ -1365,6 +1372,7 @@ GdCalcMemGCAlloc(PSD psd, unsigned int w
  * MWPF_TRUECOLOR565	unsigned short
  * MWPF_TRUECOLOR555	unsigned short
  * MWPF_TRUECOLOR332	unsigned char
+ * MWPF_TRUECOLOR233	unsigned char
  */
 void
 GdTranslateArea(MWCOORD width, MWCOORD height, void *in, int inpixtype,
@@ -1405,6 +1413,10 @@ GdTranslateArea(MWCOORD width, MWCOORD h
 			pixelval = *inbuf++;
 			colorval = PIXEL332TOCOLORVAL(pixelval);
 			break;
+		case MWPF_TRUECOLOR233:
+			pixelval = *inbuf++;
+			colorval = PIXEL233TOCOLORVAL(pixelval);
+			break;
 		case MWPF_TRUECOLOR0888:
 			pixelval = *(unsigned long *)inbuf;
 			colorval = PIXEL888TOCOLORVAL(pixelval);
@@ -1453,6 +1465,9 @@ GdTranslateArea(MWCOORD width, MWCOORD h
 		case MWPF_TRUECOLOR332:
 			*outbuf++ = COLOR2PIXEL332(colorval);
 			break;
+		case MWPF_TRUECOLOR233:
+			*outbuf++ = COLOR2PIXEL233(colorval);
+			break;
 		case MWPF_TRUECOLOR0888:
 			*(unsigned long *)outbuf = COLOR2PIXEL888(colorval);
 			outbuf += sizeof(unsigned long);
--- a/packages/services/gfx/mw/current/src/engine/devfont.c
+++ b/packages/services/gfx/mw/current/src/engine/devfont.c
@@ -722,6 +722,16 @@ alphablend(PSD psd, OUTPIXELVAL *out, MW
 		    *out++ = (r << 5) | (g << 2) | b;
 		    break;
 
+	        case MWPF_TRUECOLOR233:
+		    d = BITS(dst, 0, 0x07);
+		    r = (unsigned char)(((BITS(src, 0, 0x07) - d)*a)>>8) + d;
+		    d = BITS(dst, 3, 0x07);
+		    g = (unsigned char)(((BITS(src, 3, 0x07) - d)*a)>>8) + d;
+		    d = BITS(dst, 6, 0x03);
+		    b = (unsigned char)(((BITS(src, 6, 0x03) - d)*a)>>8) + d;
+		    *out++ = (b << 6) | (g << 3) | r;
+		    break;
+
 	        case MWPF_PALETTE:
 		    /* reverse lookup palette entry for blend ;-)*/
 		    palsrc = GETPALENTRY(gr_palette, src);
--- a/packages/services/gfx/mw/current/src/engine/devfont.caching.c
+++ b/packages/services/gfx/mw/current/src/engine/devfont.caching.c
@@ -1080,6 +1080,16 @@ alphablend(PSD psd, OUTPIXELVAL *out, MW
 		    *out++ = (r << 5) | (g << 2) | b;
 		    break;
 
+	        case MWPF_TRUECOLOR233:
+		    d = BITS(dst, 0, 0x07);
+		    r = (unsigned char)(((BITS(src, 0, 0x07) - d)*a)>>8) + d;
+		    d = BITS(dst, 3, 0x07);
+		    g = (unsigned char)(((BITS(src, 3, 0x07) - d)*a)>>8) + d;
+		    d = BITS(dst, 6, 0x03);
+		    b = (unsigned char)(((BITS(src, 6, 0x03) - d)*a)>>8) + d;
+		    *out++ = (r << 0) | (g << 3) | (b << 6);
+		    break;
+
 	        case MWPF_PALETTE:
 		    /* reverse lookup palette entry for blend ;-)*/
 		    palsrc = GETPALENTRY(gr_palette, src);
--- a/packages/services/gfx/mw/current/src/engine/devopen.c
+++ b/packages/services/gfx/mw/current/src/engine/devopen.c
@@ -257,6 +257,11 @@ GdFindColor(MWCOLORVAL c)
 		/* create 8 bit 3/3/2 format pixel from RGB colorval*/
 		/*RGB2PIXEL332(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
 		return COLOR2PIXEL332(c);
+
+	case MWPF_TRUECOLOR233:
+		/* create 8 bit 2/3/3 format pixel from RGB colorval*/
+		/*RGB2PIXEL332(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
+		return COLOR2PIXEL233(c);
 	}
 
 	/* case MWPF_PALETTE: must be running 1, 2, 4 or 8 bit palette*/
@@ -358,6 +363,9 @@ typedef struct {
 #define RMASK332	0xe0
 #define GMASK332	0x1c
 #define BMASK332	0x03
+#define RMASK233	0x07
+#define GMASK233	0x38
+#define BMASK233	0xC0
 #define RMASK555	0x7c00
 #define GMASK555	0x03e0
 #define BMASK555	0x001f
@@ -480,6 +488,11 @@ GdCaptureScreen(char *path)
 				gmask = GMASK332;
 				bmask = BMASK332;
 				break;
+			case MWPF_TRUECOLOR233:
+				rmask = RMASK233;
+				gmask = GMASK233;
+				bmask = BMASK233;
+				break;
 			}
 			putdw(rmask, ofp);
 			putdw(gmask, ofp);
--- a/packages/services/gfx/mw/current/src/mwin/wingdi.c
+++ b/packages/services/gfx/mw/current/src/mwin/wingdi.c
@@ -376,6 +376,10 @@ GetPixel(HDC hdc, int x, int y)
 		/* create RGB colorval from 3/3/2 pixel*/
 		return PIXEL332TOCOLORVAL(pixel);
 
+	case MWPF_TRUECOLOR233:
+		/* create RGB colorval from 2/3/3 pixel*/
+		return PIXEL233TOCOLORVAL(pixel);
+
 	case MWPF_PALETTE:
 		if(GdGetPalette(hdc->psd, pixel, 1, &rgb))
 			return RGB(rgb.r, rgb.g, rgb.b);
--- a/packages/services/gfx/mw/current/src/nanox/client.c
+++ b/packages/services/gfx/mw/current/src/nanox/client.c
@@ -2567,6 +2567,7 @@ void GrDrawImageFromBuffer(GR_DRAW_ID id
  * MWPF_TRUECOLOR565	unsigned short
  * MWPF_TRUECOLOR555	unsigned short
  * MWPF_TRUECOLOR332	unsigned char
+ * MWPF_TRUECOLOR223	unsigned char
  */
 /**
  * GrArea:
@@ -2603,6 +2604,7 @@ GrArea(GR_DRAW_ID id, GR_GC_ID gc, GR_CO
 		break;
 	case MWPF_PALETTE:
 	case MWPF_TRUECOLOR332:
+	case MWPF_TRUECOLOR233:
 		pixsize = sizeof(unsigned char);
 		break;
 	case MWPF_TRUECOLOR0888: