clean up and comment the repeat macros

git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@708 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
Jay Sorg 2004-06-11 22:37:05 +00:00
parent 312035fd20
commit d33f94f744

109
xwin.c
View File

@ -230,8 +230,25 @@ translate_colour(uint32 colour)
return make_colour(pc); 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 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) \ while (out <= end - 8 * 4) \
UNROLL8(stm) \ UNROLL8(stm) \
@ -252,28 +269,32 @@ translate8to16(uint8 * data, uint8 * out, uint8 * end)
uint16 value; uint16 value;
if (g_arch_match) 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)
{
value = (uint16) g_colmap[*(data++)];
*(out++) = value >> 8;
*(out++) = value;
}
}
else else
if (g_xserver_be)
{
while (out < end)
{ {
value = (uint16) g_colmap[*(data++)]; while (out < end)
*(out++) = value >> 8; {
*(out++) = value; value = (uint16) g_colmap[*(data++)];
*(out++) = value;
*(out++) = value >> 8;
}
} }
} }
else
{
while (out < end)
{
value = (uint16) g_colmap[*(data++)];
*(out++) = value;
*(out++) = value >> 8;
}
}
}
/* little endian - conversion happens when colourmap is built */ /* little endian - conversion happens when colourmap is built */
static void static void
@ -309,32 +330,38 @@ translate8to32(uint8 * data, uint8 * out, uint8 * end)
uint32 value; uint32 value;
if (g_arch_match) 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)
{
value = g_colmap[*(data++)];
*(out++) = value >> 24;
*(out++) = value >> 16;
*(out++) = value >> 8;
*(out++) = value;
}
}
else else
if (g_xserver_be)
{
while (out < end)
{ {
value = g_colmap[*(data++)]; while (out < end)
*(out++) = value >> 24; {
*(out++) = value >> 16; value = g_colmap[*(data++)];
*(out++) = value >> 8; *(out++) = value;
*(out++) = value; *(out++) = value >> 8;
*(out++) = value >> 16;
*(out++) = value >> 24;
}
} }
} }
else
{ /* *INDENT-ON* */
while (out < end)
{
value = g_colmap[*(data++)];
*(out++) = value;
*(out++) = value >> 8;
*(out++) = value >> 16;
*(out++) = value >> 24;
}
}
}
static void static void
translate15to16(uint16 * data, uint8 * out, uint8 * end) translate15to16(uint16 * data, uint8 * out, uint8 * end)