Add a fallback for unaligned source data for FORMAT_ARGB_MASK. (#117217)

Mon Aug 18 11:48:51 2003  Owen Taylor  <otaylor@redhat.com>

        * gdk/x11/gdkdrawable-x11.c (convert_to_format):
        Add a fallback for unaligned source data for
        FORMAT_ARGB_MASK. (#117217)
This commit is contained in:
Owen Taylor 2003-08-18 16:02:46 +00:00 committed by Owen Taylor
parent 7a3ce1dbf9
commit df58bb7f8a
6 changed files with 94 additions and 47 deletions

View File

@ -1,3 +1,9 @@
Mon Aug 18 11:48:51 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.c (convert_to_format):
Add a fallback for unaligned source data for
FORMAT_ARGB_MASK. (#117217)
Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com>
* configure.in: Rework handling of REBUILD_PNGS, * configure.in: Rework handling of REBUILD_PNGS,

View File

@ -1,3 +1,9 @@
Mon Aug 18 11:48:51 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.c (convert_to_format):
Add a fallback for unaligned source data for
FORMAT_ARGB_MASK. (#117217)
Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com>
* configure.in: Rework handling of REBUILD_PNGS, * configure.in: Rework handling of REBUILD_PNGS,

View File

@ -1,3 +1,9 @@
Mon Aug 18 11:48:51 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.c (convert_to_format):
Add a fallback for unaligned source data for
FORMAT_ARGB_MASK. (#117217)
Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com>
* configure.in: Rework handling of REBUILD_PNGS, * configure.in: Rework handling of REBUILD_PNGS,

View File

@ -1,3 +1,9 @@
Mon Aug 18 11:48:51 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.c (convert_to_format):
Add a fallback for unaligned source data for
FORMAT_ARGB_MASK. (#117217)
Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com>
* configure.in: Rework handling of REBUILD_PNGS, * configure.in: Rework handling of REBUILD_PNGS,

View File

@ -1,3 +1,9 @@
Mon Aug 18 11:48:51 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.c (convert_to_format):
Add a fallback for unaligned source data for
FORMAT_ARGB_MASK. (#117217)
Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com> Mon Aug 18 10:51:57 2003 Owen Taylor <otaylor@redhat.com>
* configure.in: Rework handling of REBUILD_PNGS, * configure.in: Rework handling of REBUILD_PNGS,

View File

@ -1079,63 +1079,80 @@ convert_to_format (guchar *src_buf,
} }
case FORMAT_ARGB_MASK: case FORMAT_ARGB_MASK:
{ {
guint *p = (guint *)(src_buf + i * src_rowstride); guchar *row = src_buf + i * src_rowstride;
guint *q = (guint *)(dest_buf + i * dest_rowstride); if (((gsize)row & 3) != 0)
guint *end = p + width; {
guchar *p = row;
guint32 *q = (guint32 *)(dest_buf + i * dest_rowstride);
guchar *end = p + 4 * width;
while (p < end)
{
*q = (p[3] << 24) | (p[0] << 16) | (p[1] << 8) | p[2];
p += 4;
q++;
}
}
else
{
guint32 *p = (guint32 *)row;
guint32 *q = (guint32 *)(dest_buf + i * dest_rowstride);
guint32 *end = p + width;
#if G_BYTE_ORDER == G_LITTLE_ENDIAN #if G_BYTE_ORDER == G_LITTLE_ENDIAN
if (dest_byteorder == GDK_LSB_FIRST) if (dest_byteorder == GDK_LSB_FIRST)
{
/* ABGR => ARGB */
while (p < end)
{ {
*q = ( (*p & 0xff00ff00) | /* ABGR => ARGB */
((*p & 0x000000ff) << 16) |
((*p & 0x00ff0000) >> 16));
q++;
p++;
}
}
else
{
/* ABGR => BGRA */
while (p < end) while (p < end)
{ {
*q = (((*p & 0xff000000) >> 24) | *q = ( (*p & 0xff00ff00) |
((*p & 0x00ffffff) << 8)); ((*p & 0x000000ff) << 16) |
q++; ((*p & 0x00ff0000) >> 16));
p++; q++;
p++;
}
}
else
{
/* ABGR => BGRA */
while (p < end)
{
*q = (((*p & 0xff000000) >> 24) |
((*p & 0x00ffffff) << 8));
q++;
p++;
}
} }
}
#else /* G_BYTE_ORDER == G_BIG_ENDIAN */ #else /* G_BYTE_ORDER == G_BIG_ENDIAN */
if (dest_byteorder == GDK_LSB_FIRST) if (dest_byteorder == GDK_LSB_FIRST)
{
/* RGBA => BGRA */
while (p < end)
{ {
*q = ( (*p & 0x00ff00ff) | /* RGBA => BGRA */
((*p & 0x0000ff00) << 16) |
((*p & 0xff000000) >> 16));
q++;
p++;
}
}
else
{
/* RGBA => ARGB */
while (p < end) while (p < end)
{ {
*q = (((*p & 0xffffff00) >> 8) | *q = ( (*p & 0x00ff00ff) |
((*p & 0x000000ff) << 24)); ((*p & 0x0000ff00) << 16) |
q++; ((*p & 0xff000000) >> 16));
p++; q++;
p++;
}
}
else
{
/* RGBA => ARGB */
while (p < end)
{
*q = (((*p & 0xffffff00) >> 8) |
((*p & 0x000000ff) << 24));
q++;
p++;
}
} }
}
#endif /* G_BYTE_ORDER*/ #endif /* G_BYTE_ORDER*/
}
break; break;
} }
case FORMAT_ARGB: case FORMAT_ARGB: