--- sourceforge.net/trunk/rdesktop/xwin.c 2004/06/04 15:01:36 708 +++ sourceforge.net/trunk/rdesktop/xwin.c 2004/06/11 22:37:05 709 @@ -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,27 +269,31 @@ uint16 value; if (g_arch_match) - REPEAT(*((uint16 *) out) = g_colmap[*(data++)]; - out += 2;) - else -if (g_xserver_be) -{ - while (out < end) { - value = (uint16) g_colmap[*(data++)]; - *(out++) = value >> 8; - *(out++) = value; + REPEAT2 + ( + *((uint16 *) out) = g_colmap[*(data++)]; + out += 2; + ) } -} -else -{ - while (out < end) + else if (g_xserver_be) { - value = (uint16) g_colmap[*(data++)]; - *(out++) = value; - *(out++) = value >> 8; + while (out < end) + { + value = (uint16) g_colmap[*(data++)]; + *(out++) = value >> 8; + *(out++) = value; + } + } + else + { + while (out < end) + { + value = (uint16) g_colmap[*(data++)]; + *(out++) = value; + *(out++) = value >> 8; + } } -} } /* little endian - conversion happens when colourmap is built */ @@ -309,32 +330,38 @@ uint32 value; if (g_arch_match) - REPEAT(*((uint32 *) out) = g_colmap[*(data++)]; - out += 4;) - else -if (g_xserver_be) -{ - while (out < end) { - value = g_colmap[*(data++)]; - *(out++) = value >> 24; - *(out++) = value >> 16; - *(out++) = value >> 8; - *(out++) = value; + REPEAT4 + ( + *((uint32 *) out) = g_colmap[*(data++)]; + out += 4; + ) } -} -else -{ - while (out < end) + else if (g_xserver_be) + { + while (out < end) + { + value = g_colmap[*(data++)]; + *(out++) = value >> 24; + *(out++) = value >> 16; + *(out++) = value >> 8; + *(out++) = value; + } + } + 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)