[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

svgalib fix for unified patch 19-8-3



Hi all!

   Here is a patch to fix the ui_draw_text bugs in svga.c.

Frank
diff -ur rdesktop-1.1.0/gl/svga.c rdesktop-1.1.0-new/gl/svga.c
--- rdesktop-1.1.0/gl/svga.c	Thu Jan 17 16:56:13 2002
+++ rdesktop-1.1.0-new/gl/svga.c	Thu Jan 17 17:09:16 2002
@@ -80,9 +80,6 @@
 static BOOL host_be;
 static BOOL xserver_be;
 
-/* software backing store */
-static BOOL ownbackstore;
-
 typedef struct {
 	int width;
 	int height;
@@ -564,11 +561,10 @@
 void
 svga_draw_cursor (int x, int y, rect * old)
 {
-	int i, j, c;
+	int i, j;
 	uint8 *and;
 	uint8 *xor;
 	uint8 *img;
-	rect r, scr;
 	int x1, y1, x2, y2;
 
 	x -= mcursor.x;
@@ -813,7 +809,7 @@
 void
 svga_process_keyboard (int tick)
 {
-	int i, j, l;
+	int i, l;
 	char *k = keyboard_getstate ();
 
 	keyboard_update ();
@@ -894,12 +890,11 @@
 HGLYPH
 ui_create_glyph (int width, int height, uint8 * data)
 {
-	int bwidth = (width + 7) / 8;
-	int x, y, i, j;
+	int x, y;
 	bitmap *b = xmalloc (sizeof (bitmap));
 	uint8 *d = xmalloc (width * height);
 	uint8 *c = data;
-	int a;
+	int a = 0;
 	b->data = d;
 	b->width = width;
 	b->height = height;
@@ -968,10 +963,6 @@
 void
 ui_set_cursor (HCURSOR c_)
 {
-
-	bitmap *b;
-	uint8 *d;
-	int s;
 	cursor *c = (cursor *) c_;
 
 	svga_hide_mouse ();
@@ -1108,7 +1099,6 @@
 	rect r;
 	rect d;
 	bitmap *fill;
-	int i, j;
 
 	svga_buildrect (&r, x, y, cx, cy);
 	if (!svga_intersect (&r, &curclip, &d))
@@ -1121,9 +1111,10 @@
 		break;
 
 	case 3:		/* Pattern */
+        
 		fill = (bitmap *) ui_create_glyph (8, 8, brush->pattern);
 
-		svga_fill_glyph (opcode, 0, fgcolour, bgcolour, fill, x, y, cx,
+		svga_fill_glyph (opcode, 0, bgcolour, fgcolour, fill, x, y, cx,
 				 cy);
 
 		ui_destroy_glyph ((HGLYPH) fill);
@@ -1332,50 +1323,101 @@
 
 }
 
+
+#define DO_GLYPH(ttext,idx) \
+{\
+  glyph = cache_get_font (font, ttext[idx]);\
+  if (!(flags & TEXT2_IMPLICIT_X))\
+    {\
+      xyoffset = ttext[++idx];\
+      if ((xyoffset & 0x80))\
+        {\
+          if (flags & TEXT2_VERTICAL) \
+            y += ttext[++idx] | (ttext[++idx] << 8);\
+          else\
+            x += ttext[++idx] | (ttext[++idx] << 8);\
+        }\
+      else\
+        {\
+          if (flags & TEXT2_VERTICAL) \
+            y += xyoffset;\
+          else\
+            x += xyoffset;\
+        }\
+    }\
+  if (glyph != NULL)\
+    {\
+      ui_draw_glyph (mixmode, x + (short) glyph->offset,\
+                     y + (short) glyph->baseline,\
+                     glyph->width, glyph->height,\
+                     glyph->pixmap, 0, 0, bgcolour, fgcolour,\
+                     0);\
+      if (flags & TEXT2_IMPLICIT_X)\
+        x += glyph->width;\
+    }\
+}
+
 void
-ui_draw_text (uint8 font, uint8 flags, int mixmode, int x, int y,
-	      int clipx, int clipy, int clipcx, int clipcy,
-	      int boxx, int boxy, int boxcx, int boxcy,
-	      int bgcolour, int fgcolour, uint8 * text, uint8 length)
+ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y,
+	     int clipx, int clipy, int clipcx, int clipcy, int boxx,
+	     int boxy, int boxcx, int boxcy, int bgcolour,
+	     int fgcolour, uint8 * text, uint8 length)
 {
-
 	FONTGLYPH *glyph;
-	int i, offset;
+	int i, j, xyoffset;
 
-	if (boxcx > 1) {
+	DATABLOB *entry;
 
+	if (boxcx > 1)
 		ui_rect (boxx, boxy, boxcx, boxcy, bgcolour);
-	} else if (mixmode == MIX_OPAQUE) {
+	else if (mixmode == MIX_OPAQUE)
 		ui_rect (clipx, clipy, clipcx, clipcy, bgcolour);
-	}
 
 	/* Paint text, character by character */
-	for (i = 0; i < length; i++) {
-		glyph = cache_get_font (font, text[i]);
-
-		if (!(flags & TEXT2_IMPLICIT_X)) {
-			offset = text[++i];
-			if (offset & 0x80)
-				offset = ((offset & 0x7f) << 8) | text[++i];
-
-			if (flags & TEXT2_VERTICAL)
-				y += offset;
-			else
-				x += offset;
-		}
-
-		if (glyph != NULL) {
-			ui_draw_glyph (mixmode, x + (short) glyph->offset,
-				       y + (short) glyph->baseline,
-				       glyph->width, glyph->height,
-				       glyph->pixmap, 0, 0, bgcolour, fgcolour,
-				       0);
+	for (i = 0; i < length;) {
+		switch (text[i]) {
+		case 0xff:
+			if (i + 2 < length)
+				cache_put_text(text[i + 1], text, text[i + 2]);
+			else {
+				error("this shouldn't be happening\n");
+				break;
+			}
+			/* this will move pointer from start to first character after FF command */
+			length -= i + 3;
+			text = &(text[i + 3]);
+			i = 0;
+			break;
+
+		case 0xfe:
+			entry = cache_get_text(text[i + 1]);
+			if (entry != NULL) {
+				if ((((uint8 *) (entry->data))[1] == 0)
+				    && (!(flags & TEXT2_IMPLICIT_X))) {
+					if (flags & 0x04)	/* vertical text */
+						y += text[i + 2];
+					else
+						x += text[i + 2];
+				}
+				if (i + 2 < length)
+					i += 3;
+				else
+					i += 2;
+				length -= i;
+				/* this will move pointer from start to first character after FE command */
+				text = &(text[i]);
+				i = 0;
+				for (j = 0; j < entry->size; j++)
+					DO_GLYPH(((uint8 *) (entry->data)), j);
+			}
+			break;
 
-			if (flags & TEXT2_IMPLICIT_X)
-				x += glyph->width;
+		default:
+			DO_GLYPH(text, i);
+			i++;
+			break;
 		}
 	}
-
 }
 
 void