You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Window Maker Development
This patch is improving the alpha combine function by using int instead of float. That function is used for example in the switch panel to merge the transparency mask. The change is practically indistinguishable to the human eye for a single-pass blend but the performance gained is huge.
I've been doing some benchmark of wrlib and even implemented AVX2 support. But the gain compared to the complexity of AVX2 is not worth, while having int usage in that specific function is a really good trade-off.
By using int, the alpha blending in that use case is 28% faster. --- wrlib/alpha_combine.c | 76 +++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 38 deletions(-)
void RCombineAlpha(unsigned char *d, unsigned char *s, int s_has_alpha, - int width, int height, int dwi, int swi, int opacity) { -int x, y; -int t, sa; -int alpha; -float ratio, cratio; + int width, int height, int dwi, int swi, int opacity) { + int x, y; + unsigned char *dst = d; + unsigned char *src = s;
-for (y=0; y<height; y++) { -for (x=0; x<width; x++) { -sa=s_has_alpha?*(s+3):255; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + int sa = s_has_alpha ? src[3] : 255; + int t, alpha;
-if (opacity!=255) { -t = sa * opacity + 0x80; -sa = ((t>>8)+t)>>8; -} + if (opacity != 255) { + t = sa * opacity + 0x80; + sa = ((t >> 8) + t) >> 8; + }