gdk: optimize native RGB555 conversion
Use an aligned four-pixel integer converter for native little-endian RGB555 images. Keep the scalar implementation for narrow, unaligned and big-endian paths.
This commit is contained in:
parent
3f8b4e6ed4
commit
7dd6c04cb8
1 changed files with 68 additions and 0 deletions
68
gdk/gdkrgb.c
68
gdk/gdkrgb.c
|
|
@ -2011,6 +2011,74 @@ gdk_rgb_convert_555 (GdkRgbInfo *image_info, GdkImage *image,
|
|||
bptr = buf;
|
||||
bpl = image->bpl;
|
||||
obuf = ((guchar *)image->mem) + y0 * bpl + x0 * 2;
|
||||
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
/* GTK2_NG_WIDE_555 */
|
||||
if (width >= 32 &&
|
||||
((((guintptr) obuf |
|
||||
(guintptr) bptr |
|
||||
(guintptr) rowstride |
|
||||
(guintptr) bpl) & 3) == 0))
|
||||
{
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
guchar *obptr;
|
||||
|
||||
bp2 = bptr;
|
||||
obptr = obuf;
|
||||
|
||||
for (x = 0; x < width - 3; x += 4)
|
||||
{
|
||||
guint32 w0;
|
||||
guint32 w1;
|
||||
guint32 w2;
|
||||
|
||||
w0 = ((const guint32 *) bp2)[0];
|
||||
w1 = ((const guint32 *) bp2)[1];
|
||||
w2 = ((const guint32 *) bp2)[2];
|
||||
|
||||
((guint32 *) obptr)[0] =
|
||||
((w0 & 0x000000f8U) << 7) |
|
||||
((w0 & 0x0000f800U) >> 6) |
|
||||
((w0 & 0x00f80000U) >> 19) |
|
||||
((w0 & 0xf8000000U) >> 1) |
|
||||
((w1 & 0x000000f8U) << 18) |
|
||||
((w1 & 0x0000f800U) << 5);
|
||||
|
||||
((guint32 *) obptr)[1] =
|
||||
((w1 & 0x00f80000U) >> 9) |
|
||||
((w1 & 0xf8000000U) >> 22) |
|
||||
((w2 & 0x000000f8U) >> 3) |
|
||||
((w2 & 0x0000f800U) << 15) |
|
||||
((w2 & 0x00f80000U) << 2) |
|
||||
((w2 & 0xf8000000U) >> 11);
|
||||
|
||||
bp2 += 12;
|
||||
obptr += 8;
|
||||
}
|
||||
|
||||
for (; x < width; x++)
|
||||
{
|
||||
r = *bp2++;
|
||||
g = *bp2++;
|
||||
b = *bp2++;
|
||||
|
||||
((guint16 *) obptr)[0] =
|
||||
((r & 0xf8) << 7) |
|
||||
((g & 0xf8) << 2) |
|
||||
(b >> 3);
|
||||
|
||||
obptr += 2;
|
||||
}
|
||||
|
||||
bptr += rowstride;
|
||||
obuf += bpl;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
bp2 = bptr;
|
||||
|
|
|
|||
Loading…
Reference in a new issue