[Pkg-wmaker-commits] [wmbubble] 42/207: Add less stupid API for doing the colorspace conversion (wmbubble's native rgb24 to native XImage)

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 04:17:59 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbubble.

commit 43eb33c99c0b1b2c1ee409ed1deefe3ccb1b50c5
Author: Robert Jacobs <rnjacobs at mit.edu>
Date:   Fri Jul 29 19:56:29 2011 -0700

    Add less stupid API for doing the colorspace conversion (wmbubble's native rgb24 to native XImage)
---
 bubblemon.c   |  7 +++----
 wmx11pixmap.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 wmx11pixmap.h |  1 +
 3 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/bubblemon.c b/bubblemon.c
index d736f79..4ec0b71 100644
--- a/bubblemon.c
+++ b/bubblemon.c
@@ -449,10 +449,9 @@ int main(int argc, char **argv) {
 			from[yy+(BOX_SIZE-1)*3+2]=(255+from[yy+(BOX_SIZE-1)*3]+2)/2;
 		}
 
-		for (yy=0;yy<BOX_SIZE;yy++)
-			for (xx=0;xx<BOX_SIZE;xx++,from+=3)
-				wmPutPixel(bm.xim,xx,yy,from[0],from[1],from[2]);
-
+		/* Our colorspace conversion: 3M times in 56sec -> 53561fps or 19us/frame */
+		RGBtoXIm(bm.rgb_buf,bm.xim);
+		/* X11 XImage->Pixmap->display: 400k times in 60sec -> 6667fps or 150us/frame */
 		RedrawWindow(bm.xim);
 
 		/* update graph histories */
diff --git a/wmx11pixmap.c b/wmx11pixmap.c
index 1245409..9205146 100644
--- a/wmx11pixmap.c
+++ b/wmx11pixmap.c
@@ -28,6 +28,52 @@ static int flush_expose(Window w) {
 	return i;
 }
 
+void RGBtoXIm(const unsigned char * from, XImage * ximout) {
+	unsigned long * p32 = ximout->data;
+	unsigned short * p16 = ximout->data;
+	unsigned char * p8 = ximout->data;
+	unsigned long pxl;
+	int i, yy;
+	/* violatin' the abstractions! */
+	switch (ximout->depth | ((ximout->red_mask|ximout->green_mask)<<8)) {
+	case 0xFFFF0020: /* 24bpp RGB */
+		for (i=0;i<BOX_SIZE*BOX_SIZE;i++,from+=3)
+			p32[i] = (from[0]<<16) | (from[1]<<8) | (from[2]);
+		break;
+	case 0x00FFFF20: /* 24bpp BGR */
+		for (i=0;i<BOX_SIZE*BOX_SIZE;i++,from+=3)
+			p32[i] = (from[2]<<16) | (from[1]<<8) | (from[0]);
+		break;
+	case 0xFFE010: /* 16bpp RGB */
+		for (i=0;i<BOX_SIZE*BOX_SIZE;i++,from+=3)
+			p16[i] = ((from[0]&0xF8)<<8) | ((from[1]&0xFC)<<3) | ((from[2]&0xF8)>>3);
+		break;
+	case 0x07FF10: /* 16bpp BGR */
+		for (i=0;i<BOX_SIZE*BOX_SIZE;i++,from+=3)
+			p16[i] = ((from[2]&0xF8)<<8) | ((from[1]&0xFC)<<3) | ((from[0]&0xF8)>>3);
+		break;
+	case 0x7FE010: /* 15bpp RGB */
+		for (i=0;i<BOX_SIZE*BOX_SIZE;i++,from+=3)
+			p16[i] = ((from[0]&0xF8)<<7) | ((from[1]&0xF8)<<2) | ((from[2]&0xF8)>>3);
+		break;
+	case 0x03FF10: /* 15bpp BGR */
+		for (i=0;i<BOX_SIZE*BOX_SIZE;i++,from+=3)
+			p16[i] = ((from[2]&0xF8)<<7) | ((from[1]&0xF8)<<2) | ((from[0]&0xF8)>>3);
+		break;
+	default:
+		for (yy=0;yy<BOX_SIZE;yy++)
+			for (i=0;i<BOX_SIZE;i++,from+=3) {
+				pxl = ((from[0]*ximout->red_mask/255)&ximout->red_mask) |
+					((from[1]*ximout->green_mask/255)&ximout->green_mask) |
+					((from[2]*ximout->blue_mask/255)&ximout->blue_mask);
+
+				XPutPixel(ximout, i, yy, pxl);
+			}
+		break;
+	}
+}
+
+
 /* RedrawWindow
    redraws both windows from the contents of the passed Ximage */
 void RedrawWindow(XImage * xim) {
diff --git a/wmx11pixmap.h b/wmx11pixmap.h
index 30ebba6..99c84ac 100644
--- a/wmx11pixmap.h
+++ b/wmx11pixmap.h
@@ -11,6 +11,7 @@
 
 XImage * initwmX11pixmap(int argc, char *argv[]);
 void RedrawWindow(XImage * xim);
+void RGBtoXIm(const unsigned char * from, XImage * ximout);
 
 #define wmPutPixel(xim, x, y, r, g, b) {\
 	unsigned long pxl;\

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbubble.git



More information about the Pkg-wmaker-commits mailing list