CVS: rdesktop cache.c, 1.30, 1.31 orders.c, 1.56, 1.57 proto.h, 1.114, 1.115 rdp.c, 1.107, 1.108 types.h, 1.36, 1.37 xwin.c, 1.235, 1.236

"Jay Sorg" <[email protected]> Sat, 1 Nov 2008 02:37:13 +0000
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9693

Modified Files:
	cache.c orders.c proto.h rdp.c types.h xwin.c 
Log Message:
brush cache for > 2 color brushes

Index: cache.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/cache.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** cache.c	11 Jul 2008 06:01:18 -0000	1.30
--- cache.c	1 Nov 2008 02:37:10 -0000	1.31
***************
*** 433,461 ****
  
  /* BRUSH CACHE */
! static BRUSHDATA g_brushcache[64];
  
  /* Retrieve brush from cache */
  BRUSHDATA *
! cache_get_brush_data(uint16 cache_idx)
  {
! 	if (cache_idx < NUM_ELEMENTS(g_brushcache))
  	{
! 		return &g_brushcache[cache_idx];
  	}
! 	error("get brush %d\n", cache_idx);
  	return NULL;
  }
  
  /* Store brush in cache */
  void
! cache_put_brush_data(uint16 cache_idx, BRUSHDATA * brush_data)
  {
! 	if (cache_idx < NUM_ELEMENTS(g_brushcache))
  	{
! 		memcpy(&g_brushcache[cache_idx], brush_data, sizeof(BRUSHDATA));
  	}
  	else
  	{
! 		error("put brush %d\n", cache_idx);
  	}
  }
--- 433,472 ----
  
  /* BRUSH CACHE */
! /* index 0 is 2 colour brush, index 1 is muti colour brush */
! static BRUSHDATA g_brushcache[2][64];
  
  /* Retrieve brush from cache */
  BRUSHDATA *
! cache_get_brush_data(uint8 colour_code, uint8 idx)
  {
! 	colour_code = colour_code == 1 ? 0 : 1;
! 	if (idx < NUM_ELEMENTS(g_brushcache[0]))
  	{
! 		return &g_brushcache[colour_code][idx];
  	}
! 	error("get brush %d %d\n", colour_code, idx);
  	return NULL;
  }
  
  /* Store brush in cache */
+ /* this function takes over the data pointer in struct, eg, caller gives it up */
  void
! cache_put_brush_data(uint8 colour_code, uint8 idx, BRUSHDATA * brush_data)
  {
! 	BRUSHDATA * bd;
! 
! 	colour_code = colour_code == 1 ? 0 : 1;
! 	if (idx < NUM_ELEMENTS(g_brushcache[0]))
  	{
! 		bd = &g_brushcache[colour_code][idx];
! 		if (bd->data != 0)
! 		{
! 			xfree(bd->data);
! 		}
! 		memcpy(bd, brush_data, sizeof(BRUSHDATA));
  	}
  	else
  	{
! 		error("put brush %d %d\n", colour_code, idx);
  	}
  }

Index: orders.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/orders.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** orders.c	11 Jul 2008 03:55:52 -0000	1.56
--- orders.c	1 Nov 2008 02:37:10 -0000	1.57
***************
*** 153,180 ****
  {
  	BRUSHDATA *brush_data;
! 	uint16 cache_idx;
! 	uint8 brush_bpp;
  
  	memcpy(out_brush, in_brush, sizeof(BRUSH));
  	if (out_brush->style & 0x80)
  	{
! 		brush_bpp = out_brush->style & 0x0f;
! 		if (brush_bpp == 1)	/* 1 bpp */
  		{
! 			cache_idx = out_brush->pattern[0];
! 			brush_data = cache_get_brush_data(cache_idx);
! 			if (brush_data == NULL)
! 			{
! 				error("error getting brush data, style %x\n", out_brush->style);
! 			}
! 			else
! 			{
! 				memcpy(out_brush->pattern, brush_data->pattern,
! 				       sizeof(out_brush->pattern));
! 			}
  		}
  		else
  		{
! 			error("bad brush bpp %d\n", brush_bpp);
  		}
  		out_brush->style = 3;
--- 153,174 ----
  {
  	BRUSHDATA *brush_data;
! 	uint8 cache_idx;
! 	uint8 colour_code;
  
  	memcpy(out_brush, in_brush, sizeof(BRUSH));
  	if (out_brush->style & 0x80)
  	{
! 		colour_code = out_brush->style & 0x0f;
! 		cache_idx = out_brush->pattern[0];
! 		brush_data = cache_get_brush_data(colour_code, cache_idx);
! 		if ((brush_data == NULL) || (brush_data->data == NULL))
  		{
! 			error("error getting brush data, style %x\n", out_brush->style);
! 			out_brush->bd = NULL;
! 			memset(out_brush->pattern, 0, 8);
  		}
  		else
  		{
! 			out_brush->bd = brush_data;
  		}
  		out_brush->style = 3;
***************
*** 1155,1158 ****
--- 1149,1185 ----
  }
  
+ static void
+ process_compressed_8x8_brush_data(uint8 * in, uint8 * out, int Bpp)
+ {
+ 	int x, y, pal_index, in_index, shift, do2, i;
+ 	uint8 * pal;
+ 
+ 	in_index = 0;
+ 	pal = in + 16;
+ 	/* read it bottom up */
+ 	for (y = 7; y >= 0; y--)
+ 	{
+ 		/* 2 bytes per row */
+ 		x = 0;
+ 		for (do2 = 0; do2 < 2; do2++)
+ 		{
+ 			/* 4 pixels per byte */
+ 			shift = 6;
+ 			while (shift >= 0)
+ 			{
+ 				pal_index = (in[in_index] >> shift) & 3;
+ 				/* size of palette entries depends on Bpp */
+ 				for (i = 0; i < Bpp; i++)
+ 				{
+ 					out[(y * 8 + x) * Bpp + i] = pal[pal_index * Bpp + i];
+ 				}
+ 				x++;
+ 				shift -= 2;
+ 			}
+ 			in_index++;
+ 		}
+ 	}
+ }
+ 
  /* Process a brush cache order */
  static void
***************
*** 1160,1170 ****
  {
  	BRUSHDATA brush_data;
! 	uint8 cache_idx, depth, width, height, size;
  
  	in_uint8(s, cache_idx);
! 	in_uint8(s, depth);
  	in_uint8(s, width);
  	in_uint8(s, height);
! 	in_uint8s(s, 1);	/* type, 0x80 = cached */
  	in_uint8(s, size);
  
--- 1187,1200 ----
  {
  	BRUSHDATA brush_data;
! 	uint8 cache_idx, colour_code, width, height, size, type;
! 	uint8 * comp_brush;
! 	int index;
! 	int Bpp;
  
  	in_uint8(s, cache_idx);
! 	in_uint8(s, colour_code);
  	in_uint8(s, width);
  	in_uint8(s, height);
! 	in_uint8(s, type);	/* type, 0x8x = cached */
  	in_uint8(s, size);
  
***************
*** 1172,1183 ****
  	       width, height, size));
  
! 	if ((depth == 1) && (width == 8) && (height == 8) && (size == 8))
  	{
! 		in_uint8a(s, brush_data.pattern, sizeof(brush_data.pattern));
! 		cache_put_brush_data(cache_idx, &brush_data);
  	}
  	else
  	{
! 		warning("ignoring incompatible brush type. display may be incorrect\n");
  	}
  }
--- 1202,1251 ----
  	       width, height, size));
  
! 	if ((width == 8) && (height == 8))
  	{
! 		if (colour_code == 1)
! 		{
! 			brush_data.colour_code = 1;
! 			brush_data.data_size = 8;
! 			brush_data.data = xmalloc(8);
! 			if (size == 8)
! 			{
! 				/* read it bottom up */
! 				for (index = 7; index >= 0; index--)
! 				{
! 					in_uint8(s, brush_data.data[index]);
! 				}
! 			}
! 			else
! 			{
! 				warning("incompatible brush, colour_code %d size %d\n", colour_code, size);
! 			}			
! 			cache_put_brush_data(1, cache_idx, &brush_data);
! 		}
! 		else if ((colour_code >= 3) && (colour_code <= 6))
! 		{
! 			Bpp = colour_code - 2;
! 			brush_data.colour_code = colour_code;
! 			brush_data.data_size = 8 * 8 * Bpp;
! 			brush_data.data = xmalloc(8 * 8 * Bpp);
! 			if (size == 16 + 4 * Bpp)
! 			{
! 				in_uint8p(s, comp_brush, 16 + 4 * Bpp);
! 				process_compressed_8x8_brush_data(comp_brush, brush_data.data, Bpp);
! 			}
! 			else
! 			{
! 				in_uint8a(s, brush_data.data, 8 * 8 * Bpp);
! 			}
! 			cache_put_brush_data(colour_code, cache_idx, &brush_data);
! 		}
! 		else
! 		{
! 			warning("incompatible brush, colour_code %d size %d\n", colour_code, size);
! 		}
  	}
  	else
  	{
! 		warning("incompatible brush, width height %d %d\n", width, height);
  	}
  }

Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.114
retrieving revision 1.115
diff -C2 -d -r1.114 -r1.115
*** proto.h	11 Jul 2008 03:55:52 -0000	1.114
--- proto.h	1 Nov 2008 02:37:10 -0000	1.115
***************
*** 45,50 ****
  RD_HCURSOR cache_get_cursor(uint16 cache_idx);
  void cache_put_cursor(uint16 cache_idx, RD_HCURSOR cursor);
! BRUSHDATA *cache_get_brush_data(uint16 cache_idx);
! void cache_put_brush_data(uint16 cache_idx, BRUSHDATA * brush_data);
  /* channels.c */
  VCHANNEL *channel_register(char *name, uint32 flags, void (*callback) (STREAM));
--- 45,50 ----
  RD_HCURSOR cache_get_cursor(uint16 cache_idx);
  void cache_put_cursor(uint16 cache_idx, RD_HCURSOR cursor);
! BRUSHDATA *cache_get_brush_data(uint8 colour_code, uint8 idx);
! void cache_put_brush_data(uint8 colour_code, uint8 idx, BRUSHDATA * brush_data);
  /* channels.c */
  VCHANNEL *channel_register(char *name, uint32 flags, void (*callback) (STREAM));

Index: rdp.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdp.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -C2 -d -r1.107 -r1.108
*** rdp.c	20 Oct 2008 07:16:43 -0000	1.107
--- rdp.c	1 Nov 2008 02:37:10 -0000	1.108
***************
*** 859,862 ****
--- 859,863 ----
  		RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL +
  		RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE +
+ 		RDP_CAPLEN_BRUSHCACHE +
  		0x58 + 0x08 + 0x08 + 0x34 /* unknown caps */  +
  		4 /* w2k fix, why? */ ;
***************
*** 886,893 ****
  	rdp_out_pointer_caps(s);
  	rdp_out_share_caps(s);
- #if 0
- 	/* Temporarily disabled due to bug 2167833. When re-enabling, add RDP_CAPLEN_BRUSHCACHE to caplen.  */
  	rdp_out_brushcache_caps(s);
- #endif
  
  	rdp_out_unknown_caps(s, 0x0d, 0x58, caps_0x0d);	/* international? */
--- 887,891 ----

Index: types.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/types.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** types.h	11 Jul 2008 03:51:23 -0000	1.36
--- types.h	1 Nov 2008 02:37:10 -0000	1.37
***************
*** 83,87 ****
  typedef struct _BRUSHDATA
  {
! 	uint8 pattern[8];
  }
  BRUSHDATA;
--- 83,89 ----
  typedef struct _BRUSHDATA
  {
! 	uint32 colour_code;
! 	uint32 data_size;
! 	uint8 * data;
  }
  BRUSHDATA;
***************
*** 93,97 ****
  	uint8 style;
  	uint8 pattern[8];
! 
  }
  BRUSH;
--- 95,99 ----
  	uint8 style;
  	uint8 pattern[8];
! 	BRUSHDATA * bd;
  }
  BRUSH;

Index: xwin.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xwin.c,v
retrieving revision 1.235
retrieving revision 1.236
diff -C2 -d -r1.235 -r1.236
*** xwin.c	11 Jul 2008 03:51:23 -0000	1.235
--- xwin.c	1 Nov 2008 02:37:10 -0000	1.236
***************
*** 3071,3086 ****
  
  		case 3:	/* Pattern */
! 			for (i = 0; i != 8; i++)
! 				ipattern[7 - i] = brush->pattern[i];
! 			fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
! 			SET_FOREGROUND(bgcolour);
! 			SET_BACKGROUND(fgcolour);
! 			XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
! 			XSetStipple(g_display, g_gc, fill);
! 			XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 			FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
! 			XSetFillStyle(g_display, g_gc, FillSolid);
! 			XSetTSOrigin(g_display, g_gc, 0, 0);
! 			ui_destroy_glyph((RD_HGLYPH) fill);
  			break;
  
--- 3071,3113 ----
  
  		case 3:	/* Pattern */
! 			if (brush->bd == 0) /* rdp4 brush */
! 			{
! 				for (i = 0; i != 8; i++)
! 					ipattern[7 - i] = brush->pattern[i];
! 				fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
! 				SET_FOREGROUND(bgcolour);
! 				SET_BACKGROUND(fgcolour);
! 				XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
! 				XSetStipple(g_display, g_gc, fill);
! 				XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 				FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
! 				XSetFillStyle(g_display, g_gc, FillSolid);
! 				XSetTSOrigin(g_display, g_gc, 0, 0);
! 				ui_destroy_glyph((RD_HGLYPH) fill);
! 			}
! 			else if (brush->bd->colour_code > 1) /* > 1 bpp */
! 			{
! 				fill = (Pixmap) ui_create_bitmap(8, 8, brush->bd->data);
! 				XSetFillStyle(g_display, g_gc, FillTiled);
! 				XSetTile(g_display, g_gc, fill);
! 				XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 				FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
! 				XSetFillStyle(g_display, g_gc, FillSolid);
! 				XSetTSOrigin(g_display, g_gc, 0, 0);
! 				ui_destroy_bitmap((RD_HBITMAP) fill);
! 			}
! 			else
! 			{
! 				fill = (Pixmap) ui_create_glyph(8, 8, brush->bd->data);
! 				SET_FOREGROUND(bgcolour);
! 				SET_BACKGROUND(fgcolour);
! 				XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
! 				XSetStipple(g_display, g_gc, fill);
! 				XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 				FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
! 				XSetFillStyle(g_display, g_gc, FillSolid);
! 				XSetTSOrigin(g_display, g_gc, 0, 0);
! 				ui_destroy_glyph((RD_HGLYPH) fill);
! 			}
  			break;
  
***************
*** 3245,3260 ****
  
  		case 3:	/* Pattern */
! 			for (i = 0; i != 8; i++)
! 				ipattern[7 - i] = brush->pattern[i];
! 			fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
! 			SET_FOREGROUND(bgcolour);
! 			SET_BACKGROUND(fgcolour);
! 			XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
! 			XSetStipple(g_display, g_gc, fill);
! 			XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 			FILL_POLYGON((XPoint *) point, npoints);
! 			XSetFillStyle(g_display, g_gc, FillSolid);
! 			XSetTSOrigin(g_display, g_gc, 0, 0);
! 			ui_destroy_glyph((RD_HGLYPH) fill);
  			break;
  
--- 3272,3314 ----
  
  		case 3:	/* Pattern */
! 			if (brush->bd == 0) /* rdp4 brush */
! 			{
! 				for (i = 0; i != 8; i++)
! 					ipattern[7 - i] = brush->pattern[i];
! 				fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
! 				SET_FOREGROUND(bgcolour);
! 				SET_BACKGROUND(fgcolour);
! 				XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
! 				XSetStipple(g_display, g_gc, fill);
! 				XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 				FILL_POLYGON((XPoint *) point, npoints);
! 				XSetFillStyle(g_display, g_gc, FillSolid);
! 				XSetTSOrigin(g_display, g_gc, 0, 0);
! 				ui_destroy_glyph((RD_HGLYPH) fill);
! 			}
! 			else if (brush->bd->colour_code > 1) /* > 1 bpp */
! 			{
! 				fill = (Pixmap) ui_create_bitmap(8, 8, brush->bd->data);
! 				XSetFillStyle(g_display, g_gc, FillTiled);
! 				XSetTile(g_display, g_gc, fill);
! 				XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 				FILL_POLYGON((XPoint *) point, npoints);
! 				XSetFillStyle(g_display, g_gc, FillSolid);
! 				XSetTSOrigin(g_display, g_gc, 0, 0);
! 				ui_destroy_bitmap((RD_HBITMAP) fill);
! 			}
! 			else
! 			{
! 				fill = (Pixmap) ui_create_glyph(8, 8, brush->bd->data);
! 				SET_FOREGROUND(bgcolour);
! 				SET_BACKGROUND(fgcolour);
! 				XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
! 				XSetStipple(g_display, g_gc, fill);
! 				XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 				FILL_POLYGON((XPoint *) point, npoints);
! 				XSetFillStyle(g_display, g_gc, FillSolid);
! 				XSetTSOrigin(g_display, g_gc, 0, 0);
! 				ui_destroy_glyph((RD_HGLYPH) fill);
! 			}
  			break;
  
***************
*** 3323,3338 ****
  
  		case 3:	/* Pattern */
! 			for (i = 0; i != 8; i++)
! 				ipattern[7 - i] = brush->pattern[i];
! 			fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
! 			SET_FOREGROUND(bgcolour);
! 			SET_BACKGROUND(fgcolour);
! 			XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
! 			XSetStipple(g_display, g_gc, fill);
! 			XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 			DRAW_ELLIPSE(x, y, cx, cy, fillmode);
! 			XSetFillStyle(g_display, g_gc, FillSolid);
! 			XSetTSOrigin(g_display, g_gc, 0, 0);
! 			ui_destroy_glyph((RD_HGLYPH) fill);
  			break;
  
--- 3377,3419 ----
  
  		case 3:	/* Pattern */
! 			if (brush->bd == 0) /* rdp4 brush */
! 			{
! 				for (i = 0; i != 8; i++)
! 					ipattern[7 - i] = brush->pattern[i];
! 				fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
! 				SET_FOREGROUND(bgcolour);
! 				SET_BACKGROUND(fgcolour);
! 				XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
! 				XSetStipple(g_display, g_gc, fill);
! 				XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 				DRAW_ELLIPSE(x, y, cx, cy, fillmode);
! 				XSetFillStyle(g_display, g_gc, FillSolid);
! 				XSetTSOrigin(g_display, g_gc, 0, 0);
! 				ui_destroy_glyph((RD_HGLYPH) fill);
! 			}
! 			else if (brush->bd->colour_code > 1) /* > 1 bpp */
! 			{
! 				fill = (Pixmap) ui_create_bitmap(8, 8, brush->bd->data);
! 				XSetFillStyle(g_display, g_gc, FillTiled);
! 				XSetTile(g_display, g_gc, fill);
! 				XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 				DRAW_ELLIPSE(x, y, cx, cy, fillmode);
! 				XSetFillStyle(g_display, g_gc, FillSolid);
! 				XSetTSOrigin(g_display, g_gc, 0, 0);
! 				ui_destroy_bitmap((RD_HBITMAP) fill);
! 			}
! 			else
! 			{
! 				fill = (Pixmap) ui_create_glyph(8, 8, brush->bd->data);
! 				SET_FOREGROUND(bgcolour);
! 				SET_BACKGROUND(fgcolour);
! 				XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
! 				XSetStipple(g_display, g_gc, fill);
! 				XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
! 				DRAW_ELLIPSE(x, y, cx, cy, fillmode);
! 				XSetFillStyle(g_display, g_gc, FillSolid);
! 				XSetTSOrigin(g_display, g_gc, 0, 0);
! 				ui_destroy_glyph((RD_HGLYPH) fill);
! 			}
  			break;
  


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/