[g-a-devel]gnome-mag branched; dependency changes



Hi:

I have created a gnome_2_0 branch of gnome-mag.  Gnome-mag HEAD now
depends on gtk+-2.1.0, since we use multihead features of gdkpixbuf for
fullscreen magnification (e.g. when the 'source' and 'target' screens
for the magnification service are not the same).

This allows removal of lots of difficult-to-maintain gdkpixbuf-contrib
code, in favor of standard gdkpixbuf support for grabbing and converting
pixbufs from the display.

Please see the patch below for details.

-Bill

-
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-mag/ChangeLog,v
retrieving revision 1.11
diff -u -r1.11 ChangeLog
--- ChangeLog	19 Aug 2002 12:12:37 -0000	1.11
+++ ChangeLog	19 Aug 2002 12:56:39 -0000
@@ -1,3 +1,51 @@
+2002-07-16 Bill Haneman <bill haneman sun com>
+
+	(Branched gnome_2_0 branch prior to this commit)
+	
+	* configure.in:
+	Now require gtk+-2.1.0.
+	Incremented gnome-mag revision to 0.2.0.
+
+	* magnifier/mag_image.h:
+	Added global 'spi_source_root_window' GdkWindow.
+	
+	* magnifier/mag_image.c:
+	Remove old codepath in favor of multihead gdkpixbuf image scaling...
+	(old_get_root_subimage): 
+	Removed.
+	(new_get_root_subimage): 
+	Renamed 'get_root_subimage()'.
+	(xlib_get_colormap): 
+	Removed.
+	(mask_table[], convert_map[]): 
+	Removed.
+	(rgb1, rgb1a, rgb8, rgb8a, rgb565lsb, rgb565msb, rgb565alsb):
+	Removed.
+	(rbg565amsb, rgb555lsb, rgb555msb, rgb555alsb, rgb555amsb):
+	Removed.
+	(rgb888alsb, rgb888amsb, rgb888lsb, rgb888msb, visual_decompose_mask):
+	Removed.
+	(convert_real_slow, xlib_get_colormap, get_root_image): 
+	Removed.
+	(get_root_subimage):
+	Changed to call gdk_pixbuf_get_from_drawable, rather than the old
+	'rgbconvert' method.
+	
+	* magnifier/magnifier.c:
+	(main):
+	Changed to use new codepath, i.e. 
+	spi_source_root_window = gdk_screen_get_root_window (), rathen
+	than using X calls to get the root window.  This way we can use
+	GDK more effectively and portably than having to convert XImage
+	data via the (previous, removed) various rgbconvert implementation
+	methods listed above.
+
+2002-07-16 Bill Haneman <bill haneman sun com>
+
+	* magnifier/mag_image.c:
+	rgbconvert():
+        Removed unused method; we now use gdkpixbuf to do this.
+
 2002-08-19  Bill Haneman <bill haneman sun com>
 
 	* HACKING:
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnome-mag/configure.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 configure.in
--- configure.in	9 May 2002 13:12:55 -0000	1.1.1.1
+++ configure.in	19 Aug 2002 12:56:39 -0000
@@ -3,7 +3,7 @@
 AC_INIT(magnifier/magnifier.c)
 
 GNOME_MAG_MAJOR_VERSION=0
-GNOME_MAG_MINOR_VERSION=1
+GNOME_MAG_MINOR_VERSION=2
 GNOME_MAG_MICRO_VERSION=0
 GNOME_MAG_INTERFACE_AGE=0
 GNOME_MAG_BINARY_AGE=0
@@ -103,9 +103,9 @@
 	libbonobo-2.0 >= 1.107.0 \
 	ORBit-2.0 >= 2.3.100 \
 	glib-2.0 >= 1.3.11 \
-	gtk+-2.0 >= 2.0.0 \
-	gdk-pixbuf-2.0 >= 2.0.0
-	gdk-pixbuf-xlib-2.0 >= 2.0.0)
+	gtk+-2.0 >= 2.1.0 \
+	gdk-pixbuf-2.0 >= 2.1.0
+	gdk-pixbuf-xlib-2.0 >= 2.1.0)
 AC_SUBST(DEPS_LIBS)
 AC_SUBST(DEPS_CFLAGS)
 
@@ -114,9 +114,9 @@
 	libbonobo-2.0 >= 1.107.0 \
 	ORBit-2.0 >= 2.3.100 \
 	glib-2.0 >= 1.3.11 \
-	gtk+-2.0 >= 2.0.0 \
-	gdk-pixbuf-2.0 >= 2.0.0
-	gdk-pixbuf-xlib-2.0 >= 2.0.0)
+	gtk+-2.0 >= 2.1.0 \
+	gdk-pixbuf-2.0 >= 2.1.0
+	gdk-pixbuf-xlib-2.0 >= 2.1.0)
 AC_SUBST(TEST_LIBS)
 AC_SUBST(TEST_CFLAGS)
 
Index: magnifier/mag_image.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/mag_image.c,v
retrieving revision 1.6
diff -u -r1.6 mag_image.c
--- magnifier/mag_image.c	19 Aug 2002 08:09:34 -0000	1.6
+++ magnifier/mag_image.c	19 Aug 2002 12:56:40 -0000
@@ -22,34 +22,14 @@
 
 #include "mag_image.h"
 
-#define GDK_PIXBUF_ROOT_SUPPORT_IS_BROKEN /* undef when bug 86931 is fixed */
-
 static int get_num(char* msg);
 static void get_coord(char* msg,point *p);
 static void get_rect(char* msg, point *p1, point *p2);
 static void compute_center_coord(point p1, point p2, point *center);
 
-static void old_get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
-				   int width, int height, MagnifierData *mag_data);
-static void new_get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
-				   int width, int height, MagnifierData *mag_data);
 static void get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
 			       int width, int height, MagnifierData *mag_data);
 
-static xlib_colormap * xlib_get_colormap (Colormap id, Visual *visual, MagnifierData *data);
-static guint32 mask_table[] = {
-	0x00000000, 0x00000001, 0x00000003, 0x00000007,
-	0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
-	0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
-	0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
-	0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
-	0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
-	0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
-	0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
-	0xffffffff
-};
-
-static XImage *ximage = NULL;
 static GdkPixbuf *subimage = NULL;
 static int lastx = 0, lasty = 0;
 static int last_drawn_x, last_drawn_y, pdx, pdy;
@@ -558,1101 +538,18 @@
 		 
 }
 
-/* SpiImage grabbing and convertion routines from gdk-pixbuf-xlib */
-/*
-  convert 1 bits-pixel data
-  no alpha
-*/
-static void
-rgb1 (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-	guint8 *s;
-	register guint8 data;
-	guint8 *o;
-	guint8 *srow = image->data, *orow = pixels;
-
-	/* convert upto 8 pixels/time */
-	/* its probably not worth trying to make this run very fast, who uses
-	   1 bit displays anymore? */
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = orow;
-
-		for (xx = 0; xx < width; xx ++) {
-			data = srow[xx >> 3] >> (7 - (xx & 7)) & 1;
-			*o++ = colormap->colors[data].red;
-			*o++ = colormap->colors[data].green;
-			*o++ = colormap->colors[data].blue;
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 1 bits/pixel data
-  with alpha
-*/
-static void
-rgb1a (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-	guint8 *s;
-	register guint8 data;
-	guint8 *o;
-	guint8 *srow = image->data, *orow = pixels;
-	guint32 remap[2];
-
-	/* convert upto 8 pixels/time */
-	/* its probably not worth trying to make this run very fast, who uses
-	   1 bit displays anymore? */
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (xx = 0; xx < 2; xx++) {
-#ifdef LITTLE
-		remap[xx] = 0xff000000
-			| colormap->colors[xx].blue << 16
-			| colormap->colors[xx].green << 8
-			| colormap->colors[xx].red;
-#else
-		remap[xx] = 0xff
-			| colormap->colors[xx].red << 24
-			| colormap->colors[xx].green << 16
-			| colormap->colors[xx].blue << 8;
-#endif
-	}
-
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = orow;
-
-		for (xx = 0; xx < width; xx ++) {
-			data = srow[xx >> 3] >> (7 - (xx & 7)) & 1;
-			*o++ = remap[data];
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 8 bits/pixel data
-  no alpha
-*/
-static void
-rgb8 (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-	guint32 mask;
-	register guint32 data;
-	guint8 *srow = image->data, *orow = pixels;
-	register guint8 *s;
-	register guint8 *o;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	mask = mask_table[image->depth];
-
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = orow;
-		for (xx = 0; xx < width; xx++) {
-			data = *s++ & mask;
-			*o++ = colormap->colors[data].red;
-			*o++ = colormap->colors[data].green;
-			*o++ = colormap->colors[data].blue;
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 8 bits/pixel data
-  with alpha
-*/
-static void
-rgb8a (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-	guint32 mask;
-	register guint32 data;
-	guint32 remap[256];
-	register guint8 *s;	/* read 2 pixels at once */
-	register guint32 *o;
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	mask = mask_table[image->depth];
-
-	for (xx = 0; xx < colormap->size; xx++) {
-#ifdef LITTLE
-		remap[xx] = 0xff000000
-			| colormap->colors[xx].blue << 16
-			| colormap->colors[xx].green << 8
-			| colormap->colors[xx].red;
-#else
-		remap[xx] = 0xff
-			| colormap->colors[xx].red << 24
-			| colormap->colors[xx].green << 16
-			| colormap->colors[xx].blue << 8;
-#endif
-	}
-
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = (guint32 *) orow;
-		for (xx = 0; xx < width; xx ++) {
-			data = *s++ & mask;
-			*o++ = remap[data];
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 16 bits/pixel data
-  no alpha
-  data in lsb format
-*/
-static void
-rgb565lsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-#ifdef LITTLE
-	register guint32 *s;	/* read 2 pixels at once */
-#else
-	register guint8 *s;	/* read 2 pixels at once */
-#endif
-	register guint16 *o;
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
-		s = (guint32 *) srow;
-#else
-		s = srow;
-#endif
-		o = (guint16 *) orow;
-		for (xx = 1; xx < width; xx += 2) {
-			register guint32 data;
-#ifdef LITTLE
-			data = *s++;
-			*o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13
-				| (data & 0x7e0) << 5 | (data & 0x600) >> 1;
-			*o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2
-				| (data & 0xf8000000) >> 16 | (data & 0xe0000000) >> 21;
-			*o++ = (data & 0x7e00000) >> 19 | (data & 0x6000000) >> 25
-				| (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
-#else
-			/* swap endianness first */
-			data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
-			s += 4;
-			*o++ = (data & 0xf800) | (data & 0xe000) >> 5
-				| (data & 0x7e0) >> 3 | (data & 0x600) >> 9;
-			*o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
-				| (data & 0xf8000000) >> 24 | (data & 0xe0000000) >> 29;
-			*o++ = (data & 0x7e00000) >> 11 | (data & 0x6000000) >> 17
-				| (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
-#endif
-		}
-		/* check for last remaining pixel */
-		if (width & 1) {
-			register guint16 data;
-#ifdef LITTLE
-			data = *((short *) s);
-#else
-			data = *((short *) s);
-			data = ((data >> 8) & 0xff) | ((data & 0xff) << 8);
-#endif
-			((char *) o)[0] = ((data >> 8) & 0xf8) | ((data >> 13) & 0x7);
-			((char *) o)[1] = ((data >> 3) & 0xfc) | ((data >> 9) & 0x3);
-			((char *) o)[2] = ((data << 3) & 0xf8) | ((data >> 2) & 0x7);
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 16 bits/pixel data
-  no alpha
-  data in msb format
-*/
-static void
-rgb565msb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-#ifdef LITTLE
-	register guint8 *s;	/* need to swap data order */
-#else
-	register guint32 *s;	/* read 2 pixels at once */
-#endif
-	register guint16 *o;
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
-		s = srow;
-#else
-		s = (guint32 *) srow;
-#endif
-		o = (guint16 *) orow;
-		for (xx = 1; xx < width; xx += 2) {
-			register guint32 data;
-#ifdef LITTLE
-			/* swap endianness first */
-			data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
-			s += 4;
-			*o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13
-				| (data & 0x7e0) << 5 | (data & 0x600) >> 1;
-			*o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2
-				| (data & 0xf8000000) >> 16 | (data & 0xe0000000) >> 21;
-			*o++ = (data & 0x7e00000) >> 19 | (data & 0x6000000) >> 25
-				| (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
-#else
-			data = *s++;
-			*o++ = (data & 0xf800) | (data & 0xe000) >> 5
-				| (data & 0x7e0) >> 3 | (data & 0x600) >> 9;
-			*o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
-				| (data & 0xf8000000) >> 24 | (data & 0xe0000000) >> 29;
-			*o++ = (data & 0x7e00000) >> 11 | (data & 0x6000000) >> 17
-				| (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
-#endif
-		}
-		/* check for last remaining pixel */
-		if (width & 1) {
-			register guint16 data;
-#ifdef LITTLE
-			data = *((short *) s);
-			data = ((data >> 8) & 0xff) | ((data & 0xff) << 8);
-#else
-			data = *((short *) s);
-#endif
-			((char *) o)[0] = ((data >> 8) & 0xf8) | ((data >> 13) & 0x7);
-			((char *) o)[1] = ((data >> 3) & 0xfc) | ((data >> 9) & 0x3);
-			((char *) o)[2] = ((data << 3) & 0xf8) | ((data >> 2) & 0x7);
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 16 bits/pixel data
-  with alpha
-  data in lsb format
-*/
-static void
-rgb565alsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-#ifdef LITTLE
-	register guint16 *s;	/* read 1 pixels at once */
-#else
-	register guint8 *s;
-#endif
-	register guint32 *o;
-
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
-		s = (guint16 *) srow;
-#else
-		s = (guint8 *) srow;
-#endif
-		o = (guint32 *) orow;
-		for (xx = 0; xx < width; xx ++) {
-			register guint32 data;
-			/*  rrrrrggg gggbbbbb -> rrrrrRRR ggggggGG bbbbbBBB aaaaaaaa */
-			/*  little endian: aaaaaaaa bbbbbBBB ggggggGG rrrrrRRR */
-#ifdef LITTLE
-			data = *s++;
-			*o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13
-				| (data & 0x7e0) << 5 | (data & 0x600) >> 1
-				| (data & 0x1f) << 19 | (data & 0x1c) << 14
-				| 0xff000000;
-#else
-			/* swap endianness first */
-			data = s[0] | s[1] << 8;
-			s += 2;
-			*o++ = (data & 0xf800) << 16 | (data & 0xe000) << 11
-				| (data & 0x7e0) << 13 | (data & 0x600) << 7
-				| (data & 0x1f) << 11 | (data & 0x1c) << 6
-				| 0xff;
-#endif
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 16 bits/pixel data
-  with alpha
-  data in msb format
-*/
-static void
-rgb565amsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-#ifdef LITTLE
-	register guint8 *s;
-#else
-	register guint16 *s;	/* read 1 pixels at once */
-#endif
-	register guint32 *o;
-
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = (guint32 *) orow;
-		for (xx = 0; xx < width; xx ++) {
-			register guint32 data;
-			/*  rrrrrggg gggbbbbb -> rrrrrRRR gggggg00 bbbbbBBB aaaaaaaa */
-			/*  little endian: aaaaaaaa bbbbbBBB gggggg00 rrrrrRRR */
-#ifdef LITTLE
-			/* swap endianness first */
-			data = s[0] | s[1] << 8;
-			s += 2;
-			*o++ = (data & 0xf800) >> 8 | (data & 0xe000) >> 13
-				| (data & 0x7e0) << 5 | (data & 0x600) >> 1
-				| (data & 0x1f) << 19 | (data & 0x1c) << 14
-				| 0xff000000;
-#else
-			data = *s++;
-			*o++ = (data & 0xf800) << 16 | (data & 0xe000) << 11
-				| (data & 0x7e0) << 13 | (data & 0x600) << 7
-				| (data & 0x1f) << 11 | (data & 0x1c) << 6
-				| 0xff;
-#endif
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 15 bits/pixel data
-  no alpha
-  data in lsb format
-*/
-static void
-rgb555lsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-#ifdef LITTLE
-	register guint32 *s;	/* read 2 pixels at once */
-#else
-	register guint8 *s;	/* read 2 pixels at once */
-#endif
-	register guint16 *o;
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
-		s = (guint32 *) srow;
-#else
-		s = srow;
-#endif
-		o = (guint16 *) orow;
-		for (xx = 1; xx < width; xx += 2) {
-			register guint32 data;
-#ifdef LITTLE
-			data = *s++;
-			*o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12
-				| (data & 0x3e0) << 6 | (data & 0x380) << 1;
-			*o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2
-				| (data & 0x7c000000) >> 15 | (data & 0x70000000) >> 20;
-			*o++ = (data & 0x3e00000) >> 18 | (data & 0x3800000) >> 23
-				| (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
-#else
-			/* swap endianness first */
-			data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
-			s += 4;
-			*o++ = (data & 0x7c00) << 1 | (data & 0x7000) >> 4
-				| (data & 0x3e0) >> 2 | (data & 0x380) >> 7;
-			*o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
-				| (data & 0x7c000000) >> 23 | (data & 0x70000000) >> 28;
-			*o++ = (data & 0x3e00000) >> 10 | (data & 0x3800000) >> 15
-				| (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
-#endif
-		}
-		/* check for last remaining pixel */
-		if (width & 1) {
-			register guint16 data;
-#ifdef LITTLE
-			data = *((short *) s);
-#else
-			data = *((short *) s);
-			data = ((data >> 8) & 0xff) | ((data & 0xff) << 8);
-#endif
-			((char *) o)[0] = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12;
-			((char *) o)[1] = (data & 0x3e0) >> 2 | (data & 0x380) >> 7;
-			((char *) o)[2] = (data & 0x1f) << 3 | (data & 0x1c) >> 2;
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 15 bits/pixel data
-  no alpha
-  data in msb format
-*/
-static void
-rgb555msb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-#ifdef LITTLE
-	register guint8 *s;	/* read 2 pixels at once */
-#else
-	register guint32 *s;	/* read 2 pixels at once */
-#endif
-	register guint16 *o;
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = (guint16 *) orow;
-		for (xx = 1; xx < width; xx += 2) {
-			register guint32 data;
-#ifdef LITTLE
-			/* swap endianness first */
-			data = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
-			s += 4;
-			*o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12
-				| (data & 0x3e0) << 6 | (data & 0x380) << 1;
-			*o++ = (data & 0x1f) << 3 | (data & 0x1c) >> 2
-				| (data & 0x7c000000) >> 15 | (data & 0x70000000) >> 20;
-			*o++ = (data & 0x3e00000) >> 18 | (data & 0x3800000) >> 23
-				| (data & 0x1f0000) >> 5 | (data & 0x1c0000) >> 10;
-#else
-			data = *s++;
-			*o++ = (data & 0x7c00) << 1 | (data & 0x7000) >> 4
-				| (data & 0x3e0) >> 2 | (data & 0x380) >> 7;
-			*o++ = (data & 0x1f) << 11 | (data & 0x1c) << 6
-				| (data & 0x7c000000) >> 23 | (data & 0x70000000) >> 28;
-			*o++ = (data & 0x3e00000) >> 10 | (data & 0x3800000) >> 15
-				| (data & 0x1f0000) >> 13 | (data & 0x1c0000) >> 18;
-#endif
-		}
-		/* check for last remaining pixel */
-		if (width & 1) {
-			register guint16 data;
-#ifdef LITTLE
-			data = *((short *) s);
-			data = ((data >> 8) & 0xff) | ((data & 0xff) << 8);
-#else
-			data = *((short *) s);
-#endif
-			((char *) o)[0] = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12;
-			((char *) o)[1] = (data & 0x3e0) >> 2 | (data & 0x380) >> 7;
-			((char *) o)[2] = (data & 0x1f) << 3 | (data & 0x1c) >> 2;
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 15 bits/pixel data
-  with alpha
-  data in lsb format
-*/
-static void
-rgb555alsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-#ifdef LITTLE
-	register guint16 *s;	/* read 1 pixels at once */
-#else
-	register guint8 *s;
-#endif
-	register guint32 *o;
-
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
-		s = (guint16 *) srow;
-#else
-		s = srow;
-#endif
-		o = (guint32 *) orow;
-		for (xx = 0; xx < width; xx++) {
-			register guint32 data;
-			/*  rrrrrggg gggbbbbb -> rrrrrRRR gggggGGG bbbbbBBB aaaaaaaa */
-			/*  little endian: aaaaaaaa bbbbbBBB gggggGGG rrrrrRRR */
-#ifdef LITTLE
-			data = *s++;
-			*o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12
-				| (data & 0x3e0) << 6 | (data & 0x380) << 1
-				| (data & 0x1f) << 19 | (data & 0x1c) << 14
-				| 0xff000000;
-#else
-			/* swap endianness first */
-			data = s[0] | s[1] << 8;
-			s += 2;
-			*o++ = (data & 0x7c00) << 17 | (data & 0x7000) << 12
-				| (data & 0x3e0) << 14 | (data & 0x380) << 9
-				| (data & 0x1f) << 11 | (data & 0x1c) << 6
-				| 0xff;
-#endif
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-/*
-  convert 15 bits/pixel data
-  with alpha
-  data in msb format
-*/
-static void
-rgb555amsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-#ifdef LITTLE
-	register guint16 *s;	/* read 1 pixels at once */
-#else
-	register guint8 *s;
-#endif
-	register guint32 *o;
-
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
-		s = (guint16 *) srow;
-#else
-		s = srow;
-#endif
-		o = (guint32 *) orow;
-		for (xx = 0; xx < width; xx++) {
-			register guint32 data;
-			/*  rrrrrggg gggbbbbb -> rrrrrRRR gggggGGG bbbbbBBB aaaaaaaa */
-			/*  little endian: aaaaaaaa bbbbbBBB gggggGGG rrrrrRRR */
-#ifdef LITTLE
-			/* swap endianness first */
-			data = s[0] | s[1] << 8;
-			s += 2;
-			*o++ = (data & 0x7c00) >> 7 | (data & 0x7000) >> 12
-				| (data & 0x3e0) << 6 | (data & 0x380) << 1
-				| (data & 0x1f) << 19 | (data & 0x1c) << 14
-				| 0xff000000;
-#else
-			data = *s++;
-			*o++ = (data & 0x7c00) << 17 | (data & 0x7000) << 12
-				| (data & 0x3e0) << 14 | (data & 0x380) << 9
-				| (data & 0x1f) << 11 | (data & 0x1c) << 6
-				| 0xff;
-#endif
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-
-static void
-rgb888alsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-	guint8 *s;	/* for byte order swapping */
-	guint8 *o;
-	guint8 *srow = image->data, *orow = pixels;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	/* lsb data */
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = orow;
-		for (xx = 0; xx < width; xx++) {
-			*o++ = s[2];
-			*o++ = s[1];
-			*o++ = s[0];
-			*o++ = 0xff;
-			s += 4;
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-static void
-rgb888lsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-	guint8 *srow = image->data, *orow = pixels;
-	guint8 *o, *s;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = orow;
-		for (xx = 0; xx < width; xx++) {
-			*o++ = s[2];
-			*o++ = s[1];
-			*o++ = s[0];
-			s += 4;
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-static void
-rgb888amsb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-	guint8 *srow = image->data, *orow = pixels;
-#ifdef LITTLE
-	guint32 *o;
-	guint32 *s;
-#else
-	guint8 *s;	/* for byte order swapping */
-	guint8 *o;
-#endif
-
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	/* msb data */
-	for (yy = 0; yy < height; yy++) {
-#ifdef LITTLE
-		s = (guint32 *) srow;
-		o = (guint32 *) orow;
-#else
-		s = srow;
-		o = orow;
-#endif
-		for (xx = 0; xx < width; xx++) {
-#ifdef LITTLE
-			*o++ = s[1];
-			*o++ = s[2];
-			*o++ = s[3];
-			*o++ = 0xff;
-			s += 4;
-#else
-			*o++ = (*s << 8) | 0xff; /* untested */
-			s++;
-#endif
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-static void
-rgb888msb (XImage *image, guchar *pixels, int rowstride, xlib_colormap *colormap)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-
-	guint8 *srow = image->data, *orow = pixels;
-	guint8 *s;
-	guint8 *o;
-
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = orow;
-		for (xx = 0; xx < width; xx++) {
-			*o++ = s[1];
-			*o++ = s[2];
-			*o++ = s[3];
-			s += 4;
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-static void
-visual_decompose_mask (gulong  mask,
-		       gint   *shift,
-		       gint   *prec)
-{
-	*shift = 0;
-	*prec = 0;
-
-	while (!(mask & 0x1)) {
-		(*shift)++;
-		mask >>= 1;
-	}
-	
-	while (mask & 0x1) {
-		(*prec)++;
-		mask >>= 1;
-	}
-}
-
-
-/*
-  This should work correctly with any display/any endianness, but will probably
-  run quite slow
-*/
-static void
-convert_real_slow (XImage *image, guchar *pixels, int rowstride, xlib_colormap *cmap, int alpha)
-{
-	int xx, yy;
-	int width, height;
-	int bpl;
-	guint8 *srow = image->data, *orow = pixels;
-	guint8 *s;
-	guint8 *o;
-	guint32 pixel;
-	Visual *v;
-	guint8 component;
-	int i;
-	int red_shift, red_prec, green_shift, green_prec, blue_shift, blue_prec;
-
-	width = image->width;
-	height = image->height;
-	bpl = image->bytes_per_line;
-	v = cmap->visual;
-
-#ifdef DEBUG_VERBOSE  
-	fprintf (stderr, "using slow conversion func\n"); 
-#endif
-	if (v->red_mask)
-	  visual_decompose_mask (v->red_mask, &red_shift, &red_prec);
-	if (v->green_mask)
-	  visual_decompose_mask (v->green_mask, &green_shift, &green_prec);
-	if (v->blue_mask)
-  	  visual_decompose_mask (v->blue_mask, &blue_shift, &blue_prec);
-
-#ifdef DEBUG_VERBOSE  
-	fprintf (stderr, "image %d x %d\n", width, height);
-#endif	
-	for (yy = 0; yy < height; yy++) {
-		s = srow;
-		o = orow;
-		for (xx = 0; xx < width; xx++) {
-			pixel = XGetPixel (image, xx, yy);
-			switch (v->class) {
-				/* I assume this is right for static & greyscale's too? */
-			case StaticGray:
-			case GrayScale:
-			case StaticColor:
-			case PseudoColor:
-				*o++ = cmap->colors[pixel].red;
-				*o++ = cmap->colors[pixel].green;
-				*o++ = cmap->colors[pixel].blue;
-				break;
-			case TrueColor:
-				/* This is odd because it must sometimes shift left (otherwise
-				   I'd just shift >> (*_shift - 8 + *_prec + <0-7>). This logic
-				   should work for all bit sizes/shifts/etc. */
-				component = 0;
-				for (i = 24; i < 32; i += red_prec)
-					component |= ((pixel & v->red_mask) << (32 - red_shift - red_prec)) >> i;
-				*o++ = component;
-				component = 0;
-				for (i = 24; i < 32; i += green_prec)
-					component |= ((pixel & v->green_mask) << (32 - green_shift - green_prec)) >> i;
-				*o++ = component;
-				component = 0;
-				for (i = 24; i < 32; i += blue_prec)
-					component |= ((pixel & v->blue_mask) << (32 - blue_shift - blue_prec)) >> i;
-				*o++ = component;
-				break;
-			case DirectColor:
-				*o++ = cmap->colors[((pixel & v->red_mask) << (32 - red_shift - red_prec)) >> 24].red;
-				*o++ = cmap->colors[((pixel & v->green_mask) << (32 - green_shift - green_prec)) >> 24].green;
-				*o++ = cmap->colors[((pixel & v->blue_mask) << (32 - blue_shift - blue_prec)) >> 24].blue;
-				break;
-			}
-			if (alpha)
-				*o++ = 0xff;
-		}
-		srow += bpl;
-		orow += rowstride;
-	}
-}
-
-static xlib_colormap *
-xlib_get_colormap (Colormap id, Visual *visual, MagnifierData *mag_data)
-{
-	int i;
-	xlib_colormap *xc = g_new (xlib_colormap, 1);
-
-	xc->size = visual->map_entries;
-	xc->colors = g_new (XColor, xc->size);
-	xc->visual = visual;
-	xc->colormap = id;
-
-	for (i = 0; i < xc->size; i++) {
-		xc->colors[i].pixel = i;
-		xc->colors[i].flags = DoRed | DoGreen | DoBlue;
-	}
-
-	XQueryColors (mag_data->source_display, xc->colormap,
-		      xc->colors, xc->size);
-
-	return xc;
-}
-
-typedef void (* cfunc) (XImage *image, guchar *pixels, int rowstride, xlib_colormap *cmap);
-static cfunc convert_map[] = {
-	rgb1,rgb1,rgb1a,rgb1a,
-	rgb8,rgb8,rgb8a,rgb8a,
-	rgb555lsb,rgb555msb,rgb555alsb,rgb555amsb,
-	rgb565lsb,rgb565msb,rgb565alsb,rgb565amsb,
-	rgb888lsb,rgb888msb,rgb888alsb,rgb888amsb
-};
-
-static void
-rgbconvert (XImage *image, guchar *pixels, int rowstride, int alpha, xlib_colormap *cmap,
-	    MagnifierData *mag_data)
-{
-  int index;
-  int bank=5;		/* default fallback converter */
-  Visual *v;
-
-  g_return_if_fail (cmap != NULL);
-  g_return_if_fail (image != NULL);
-
-  index = (image->byte_order == MSBFirst) | (alpha != 0) << 1;
-  v = cmap->visual;
-  if (mag_data->fast_rgb_convert)
-    {	  
-	switch (v->class) {
-				/* I assume this is right for static & greyscale's too? */
-	case StaticGray:
-	case GrayScale:
-	case StaticColor:
-	case PseudoColor:
-		switch (image->bits_per_pixel) {
-		case 1:
-			bank = 0;
-			break;
-		case 8:
-			bank = 1;
-			break;
-		}
-		break;
-	case TrueColor:
-		switch (image->depth) {
-		case 15:
-			if (v->red_mask == 0x7c00 && v->green_mask == 0x3e0 && v->blue_mask == 0x1f
-			    && image->bits_per_pixel == 16)
-				bank = 2;
-			break;
-		case 16:
-			if (v->red_mask == 0xf800 && v->green_mask == 0x7e0 && v->blue_mask == 0x1f
-			    && image->bits_per_pixel == 16)
-				bank = 3;
-			break;
-		case 24:
-		case 32:
-			if (v->red_mask == 0xff0000 && v->green_mask == 0xff00 && v->blue_mask == 0xff
-			    && image->bits_per_pixel == 32)
-				bank = 4;
-			break;
-		}
-		break;
-	case DirectColor:
-		/* always use the slow version */
-		break;
-	}
-    }
-
-	if (bank==5) {
-		convert_real_slow(image, pixels, rowstride, cmap, alpha);
-	} else {
-		index |= bank << 2;
-#ifdef DEBUG_VERBOSE
-		fprintf (stderr, "using fast conversion func %d\n", index);
-#endif
-		(* convert_map[index]) (image, pixels, rowstride, cmap);
-	}
-}
-
-XImage *
-get_root_image (Window src, GdkPixbuf *dest, int x, int y, int width, int height,
-		MagnifierData *mag_data)
-{
-	return XGetSubImage (mag_data->source_display, src, x, y,
-			     width, height, AllPlanes, ZPixmap,
-			     ximage, x, y);
-}
-
 static void
 get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
-		       int width, int height, MagnifierData *mag_data)
-{
-#ifdef GDK_PIXBUF_ROOT_SUPPORT_IS_BROKEN
-  old_get_root_subimage (src, dest, src_x, src_y, width, height, mag_data);
-#else
-  new_get_root_subimage (src, dest, src_x, src_y, width, height, mag_data);
-#endif
-}
-
-static void
-new_get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
-		       int width, int height, MagnifierData *mag_data)
-{
-	GdkColormap *cmap = gdk_rgb_get_colormap ();
-	gdk_pixbuf_xlib_get_from_drawable (dest,
-					   gdk_x11_get_default_root_xwindow (),
-					   GDK_COLORMAP_XCOLORMAP (cmap),
-					   GDK_VISUAL_XVISUAL (gdk_visual_get_system ()),
-					   src_x, src_y,
-					   src_x, src_y,
-					   width, height);
-}
-
-static void
-old_get_root_subimage (Window src, GdkPixbuf *dest, int src_x, int src_y,
 		   int width, int height, MagnifierData *mag_data)
 {
-	if (ximage == NULL) {
-#ifdef DEBUG_VERBOSE  
-		fprintf (stderr, "creating root ximage\n");
-#endif
-		ximage = XGetImage (mag_data->source_display, src, 0, 0,
-				    DisplayWidth (mag_data->source_display,
-						  mag_data->source_screen_num),
-				    DisplayHeight (mag_data->source_display,
-						   mag_data->source_screen_num),
-				    AllPlanes, ZPixmap);
-
-        /* Get image in ZPixmap format (packed bits). */
-	} else {
-#ifdef DEBUG_VERBOSE  
-		fprintf (stderr, "Getting X subimage\n");
-#endif
-		ximage = get_root_image (src, dest, src_x, src_y, width, height, mag_data);
-	}
-	
-	g_assert(image != NULL);
+	GdkColormap *cmap = gdk_rgb_get_colormap ();
 
-	if(x_cmap == NULL) {
-	    XWindowAttributes wa;
-	    XVisualInfo vi;
-	    int xgwaret;
-	    xgwaret = XGetWindowAttributes (mag_data->source_display,
-					    src, &wa);
-	    g_assert (xgwaret);
-	    /* XGetVisualInfo (mag_data->source_display, src, &vi); */
-#ifdef DEBUG_VERBOSE  
-	    fprintf (stderr,  "colormap %d, visual cmap entries %d\n",
-		     wa.colormap, wa.visual->map_entries);
-#endif	    
-	    x_cmap = xlib_get_colormap (wa.colormap, wa.visual, mag_data);	   } 
-
-	/* we offset into the image data based on the position
-	   we are retrieving from */
-	rgbconvert (ximage, gdk_pixbuf_get_pixels(dest),
-		    gdk_pixbuf_get_rowstride(dest),
-		    gdk_pixbuf_get_has_alpha(dest),
-		    x_cmap,
-		    mag_data);
+	gdk_pixbuf_get_from_drawable (dest,
+				      spi_source_root_window,
+				      cmap,
+				      src_x, src_y,
+				      src_x, src_y,
+				      width, height);
 }
 
 
Index: magnifier/mag_image.h
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/mag_image.h,v
retrieving revision 1.4
diff -u -r1.4 mag_image.h
--- magnifier/mag_image.h	30 Jun 2002 21:36:37 -0000	1.4
+++ magnifier/mag_image.h	19 Aug 2002 12:56:40 -0000
@@ -65,7 +65,8 @@
 point	    curpos; /* Position of the magnified cursor */
 GdkPixbuf*  image;
 GdkPixbuf*  scaled_image;
-Window	    spi_image_root_window;
+GdkWindow*  spi_source_root_window;
+Window      spi_image_root_window;
 int	    screen_num;
 int         old_factor_x;
 int         old_factor_y;
Index: magnifier/magnifier.c
===================================================================
RCS file: /cvs/gnome/gnome-mag/magnifier/magnifier.c,v
retrieving revision 1.8
diff -u -r1.8 magnifier.c
--- magnifier/magnifier.c	15 Aug 2002 16:18:27 -0000	1.8
+++ magnifier/magnifier.c	19 Aug 2002 12:56:41 -0000
@@ -297,6 +297,11 @@
 
   spi_image_root_window = RootWindow(magnifier->mag_data->source_display,
 				     magnifier->mag_data->source_screen_num);
+  
+  spi_source_root_window = gdk_screen_get_root_window (
+	  gdk_display_get_screen (gdk_display_open (global_options.source_display),
+				  magnifier->mag_data->source_screen_num));
+  
   gdk_pixbuf_xlib_init (magnifier->mag_data->target_display,
 			magnifier->mag_data->target_screen_num);
   image = gdk_pixbuf_new        (GDK_COLORSPACE_RGB,FALSE, 8,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]