--- sourceforge.net/trunk/rdesktop/xwin.c 2004/05/11 13:45:57 697 +++ sourceforge.net/trunk/rdesktop/xwin.c 2004/06/11 22:37:05 709 @@ -172,9 +172,9 @@ split_colour15(uint32 colour) { PixelColour rv; - rv.red = (colour & 0x7c00) >> 7; - rv.green = (colour & 0x03e0) >> 2; - rv.blue = (colour & 0x001f) << 3; + rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7); + rv.green = ((colour >> 2) & 0xf8) | ((colour >> 8) & 0x7); + rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); return rv; } @@ -182,9 +182,9 @@ split_colour16(uint32 colour) { PixelColour rv; - rv.red = (colour & 0xf800) >> 8; - rv.green = (colour & 0x07e0) >> 3; - rv.blue = (colour & 0x001f) << 3; + rv.red = ((colour >> 8) & 0xf8) | ((colour >> 13) & 0x7); + rv.green = ((colour >> 3) & 0xfc) | ((colour >> 9) & 0x3); + rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7); return rv; } @@ -230,8 +230,25 @@ return make_colour(pc); } +/* indent is confused by UNROLL8 */ +/* *INDENT-OFF* */ + +/* repeat and unroll, similar to bitmap.c */ +/* potentialy any of the following translate */ +/* functions can use repeat but just doing */ +/* the most common ones */ + #define UNROLL8(stm) { stm stm stm stm stm stm stm stm } -#define REPEAT(stm) \ +/* 2 byte output repeat */ +#define REPEAT2(stm) \ +{ \ + while (out <= end - 8 * 2) \ + UNROLL8(stm) \ + while (out < end) \ + { stm } \ +} +/* 4 byte output repeat */ +#define REPEAT4(stm) \ { \ while (out <= end - 8 * 4) \ UNROLL8(stm) \ @@ -252,28 +269,32 @@ uint16 value; if (g_arch_match) - REPEAT(*((uint16 *) out) = g_colmap[*(data++)]; out += 2; + { + REPEAT2 + ( + *((uint16 *) out) = g_colmap[*(data++)]; + out += 2; ) - else -if (g_xserver_be) -{ - while (out < end) + } + else if (g_xserver_be) { - value = (uint16) g_colmap[*(data++)]; - *(out++) = value >> 8; - *(out++) = value; + while (out < end) + { + value = (uint16) g_colmap[*(data++)]; + *(out++) = value >> 8; + *(out++) = value; + } } -} -else -{ - while (out < end) + else { - value = (uint16) g_colmap[*(data++)]; - *(out++) = value; - *(out++) = value >> 8; + while (out < end) + { + value = (uint16) g_colmap[*(data++)]; + *(out++) = value; + *(out++) = value >> 8; + } } } -} /* little endian - conversion happens when colourmap is built */ static void @@ -309,32 +330,38 @@ uint32 value; if (g_arch_match) - REPEAT(*((uint32 *) out) = g_colmap[*(data++)]; out += 4; + { + REPEAT4 + ( + *((uint32 *) out) = g_colmap[*(data++)]; + out += 4; ) - else -if (g_xserver_be) -{ - while (out < end) + } + else if (g_xserver_be) { - value = g_colmap[*(data++)]; - *(out++) = value >> 24; - *(out++) = value >> 16; - *(out++) = value >> 8; - *(out++) = value; + while (out < end) + { + value = g_colmap[*(data++)]; + *(out++) = value >> 24; + *(out++) = value >> 16; + *(out++) = value >> 8; + *(out++) = value; + } } -} -else -{ - while (out < end) + else { - value = g_colmap[*(data++)]; - *(out++) = value; - *(out++) = value >> 8; - *(out++) = value >> 16; - *(out++) = value >> 24; + while (out < end) + { + value = g_colmap[*(data++)]; + *(out++) = value; + *(out++) = value >> 8; + *(out++) = value >> 16; + *(out++) = value >> 24; + } } } -} + +/* *INDENT-ON* */ static void translate15to16(uint16 * data, uint8 * out, uint8 * end) @@ -1031,6 +1058,7 @@ ui_resize_window() { XSizeHints *sizehints; + Pixmap bs; sizehints = XAllocSizeHints(); if (sizehints) @@ -1046,6 +1074,17 @@ { XResizeWindow(g_display, g_wnd, g_width, g_height); } + + /* create new backstore pixmap */ + if (g_backstore != 0) + { + bs = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth); + XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen)); + XFillRectangle(g_display, bs, g_gc, 0, 0, g_width, g_height); + XCopyArea(g_display, g_backstore, bs, g_gc, 0, 0, g_width, g_height, 0, 0); + XFreePixmap(g_display, g_backstore); + g_backstore = bs; + } } void