forked from old/legacy-imlib2
Eliminate WRITE_RGBA()
Potentially causing way more memory access than needed.
This commit is contained in:
parent
7c426928e9
commit
581e6baed8
|
@ -5470,7 +5470,7 @@ imlib_image_clear_color(int r, int g, int b, int a)
|
|||
return;
|
||||
__imlib_DirtyImage(im);
|
||||
max = im->w * im->h;
|
||||
WRITE_RGBA(&col, r, g, b, a);
|
||||
col = PIXEL_ARGB(a, r, g, b);
|
||||
for (i = 0; i < max; i++)
|
||||
im->data[i] = col;
|
||||
}
|
||||
|
|
|
@ -34,20 +34,6 @@
|
|||
(b) = B_VAL(p); \
|
||||
(a) = A_VAL(p);
|
||||
|
||||
#define WRITE_RGB(p, r, g, b) \
|
||||
R_VAL(p) = (r); \
|
||||
G_VAL(p) = (g); \
|
||||
B_VAL(p) = (b);
|
||||
|
||||
#define WRITE_RGB_PRESERVE_ALPHA(p, r, g, b) \
|
||||
WRITE_RGB(p, r, g, b)
|
||||
|
||||
#define WRITE_RGBA(p, r, g, b, a) \
|
||||
R_VAL(p) = (r); \
|
||||
G_VAL(p) = (g); \
|
||||
B_VAL(p) = (b); \
|
||||
A_VAL(p) = (a);
|
||||
|
||||
#define INTERSECTS(x, y, w, h, xx, yy, ww, hh) \
|
||||
((x < (xx + ww)) && \
|
||||
(y < (yy + hh)) && \
|
||||
|
|
|
@ -338,34 +338,22 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
|
||||
switch (bpp)
|
||||
{
|
||||
|
||||
/* 32-bit BGRA pixels */
|
||||
case 32:
|
||||
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
||||
*(bufptr + 1), /* G */
|
||||
*(bufptr + 0), /* B */
|
||||
*(bufptr + 3) /* A */
|
||||
);
|
||||
dataptr++;
|
||||
case 32: /* 32-bit BGRA pixels */
|
||||
*dataptr++ =
|
||||
PIXEL_ARGB(bufptr[3], bufptr[2], bufptr[1],
|
||||
bufptr[0]);
|
||||
bufptr += 4;
|
||||
break;
|
||||
|
||||
/* 24-bit BGR pixels */
|
||||
case 24:
|
||||
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
||||
*(bufptr + 1), /* G */
|
||||
*(bufptr + 0), /* B */
|
||||
(char)0xff /* A */
|
||||
);
|
||||
dataptr++;
|
||||
case 24: /* 24-bit BGR pixels */
|
||||
*dataptr++ =
|
||||
PIXEL_ARGB(0xff, bufptr[2], bufptr[1], bufptr[0]);
|
||||
bufptr += 3;
|
||||
break;
|
||||
|
||||
/* 8-bit grayscale */
|
||||
case 8:
|
||||
WRITE_RGBA(dataptr, /* grayscale */
|
||||
*bufptr, *bufptr, *bufptr, (char)0xff);
|
||||
dataptr++;
|
||||
case 8: /* 8-bit grayscale */
|
||||
*dataptr++ =
|
||||
PIXEL_ARGB(0xff, bufptr[0], bufptr[0], bufptr[0]);
|
||||
bufptr += 1;
|
||||
break;
|
||||
}
|
||||
|
@ -400,31 +388,23 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
red = *bufptr++;
|
||||
alpha = *bufptr++;
|
||||
for (i = 0; (i < count) && (dataptr < final_pixel); i++)
|
||||
{
|
||||
WRITE_RGBA(dataptr, red, green, blue, alpha);
|
||||
dataptr++;
|
||||
}
|
||||
*dataptr++ = PIXEL_ARGB(alpha, red, green, blue);
|
||||
break;
|
||||
|
||||
case 24:
|
||||
blue = *bufptr++;
|
||||
green = *bufptr++;
|
||||
red = *bufptr++;
|
||||
alpha = 0xff;
|
||||
for (i = 0; (i < count) && (dataptr < final_pixel); i++)
|
||||
{
|
||||
WRITE_RGBA(dataptr, red, green, blue, (char)0xff);
|
||||
dataptr++;
|
||||
}
|
||||
*dataptr++ = PIXEL_ARGB(alpha, red, green, blue);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
alpha = *bufptr++;
|
||||
red = *bufptr++;
|
||||
alpha = 0xff;
|
||||
for (i = 0; (i < count) && (dataptr < final_pixel); i++)
|
||||
{
|
||||
WRITE_RGBA(dataptr, alpha, alpha, alpha,
|
||||
(char)0xff);
|
||||
dataptr++;
|
||||
}
|
||||
*dataptr++ = PIXEL_ARGB(alpha, red, red, red);
|
||||
break;
|
||||
}
|
||||
} /* end if (RLE packet) */
|
||||
|
@ -437,34 +417,24 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
|
||||
switch (bpp)
|
||||
{
|
||||
|
||||
/* 32-bit BGRA pixels */
|
||||
case 32:
|
||||
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
||||
*(bufptr + 1), /* G */
|
||||
*(bufptr + 0), /* B */
|
||||
*(bufptr + 3) /* A */
|
||||
);
|
||||
dataptr++;
|
||||
case 32: /* 32-bit BGRA pixels */
|
||||
*dataptr++ =
|
||||
PIXEL_ARGB(bufptr[3], bufptr[2], bufptr[1],
|
||||
bufptr[0]);
|
||||
bufptr += 4;
|
||||
break;
|
||||
|
||||
/* 24-bit BGR pixels */
|
||||
case 24:
|
||||
WRITE_RGBA(dataptr, *(bufptr + 2), /* R */
|
||||
*(bufptr + 1), /* G */
|
||||
*(bufptr + 0), /* B */
|
||||
(char)0xff /* A */
|
||||
);
|
||||
dataptr++;
|
||||
case 24: /* 24-bit BGR pixels */
|
||||
*dataptr++ =
|
||||
PIXEL_ARGB(0xff, bufptr[2], bufptr[1],
|
||||
bufptr[0]);
|
||||
bufptr += 3;
|
||||
break;
|
||||
|
||||
/* 8-bit grayscale */
|
||||
case 8:
|
||||
WRITE_RGBA(dataptr, *bufptr, /* pseudo-grayscale */
|
||||
*bufptr, *bufptr, (char)0xff);
|
||||
dataptr++;
|
||||
case 8: /* 8-bit grayscale */
|
||||
*dataptr++ =
|
||||
PIXEL_ARGB(0xff, bufptr[0], bufptr[0],
|
||||
bufptr[0]);
|
||||
bufptr += 1;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue