From: Vincent Povirk Subject: [3/3] gdiplus: Add a more optimized loop for composing onto PARGB. Message-Id: Date: Fri, 19 Sep 2014 11:28:13 -0500 From a911e1082056586225b1a94bf769b722f2fa4e0f Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Thu, 18 Sep 2014 14:03:26 -0500 Subject: [PATCH 3/3] gdiplus: Add a more optimized loop for composing onto PARGB. --- dlls/gdiplus/image.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 8511e3e..683a53d 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -1027,6 +1027,42 @@ GpStatus convert_pixels(INT width, INT height, return NotImplemented; } +static void compose_32bppARGB_on_32bppPARGB(INT dst_x, INT dst_y, INT width, INT height, + INT dst_stride, BYTE *dst_bits, INT src_stride, const BYTE *src_bits) +{ + INT x, y; + dst_bits = dst_bits + dst_x * 4 + dst_y * dst_stride; + for (y=0; y>24) & 0xff; + bg_alpha = 0xff-fg_alpha; + + a = ((bg>>24)&0xff) * bg_alpha / 0xff + fg_alpha; + b = ((bg&0xff) * bg_alpha + (fg&0xff)*fg_alpha) / 0xff; + g = (((bg>>8)&0xff) * bg_alpha + ((fg>>8)&0xff)*fg_alpha) / 0xff; + r = (((bg>>16)&0xff) * bg_alpha + ((fg>>16)&0xff)*fg_alpha) / 0xff; + + dst[x] = (a<<24)|(r<<16)|(g<<8)|b; + } + } +} + GpStatus compose_pixels(INT dst_x, INT dst_y, INT width, INT height, INT dst_stride, BYTE *dst_bits, PixelFormat dst_format, ColorPalette *dst_palette, INT src_stride, const BYTE *src_bits) @@ -1112,7 +1148,8 @@ GpStatus compose_pixels(INT dst_x, INT dst_y, INT width, INT height, case PixelFormat32bppARGB: compose_rgb(getpixel_32bppARGB, setpixel_32bppARGB); case PixelFormat32bppPARGB: - compose_rgb(getpixel_32bppPARGB, setpixel_32bppPARGB); + compose_32bppARGB_on_32bppPARGB(dst_x, dst_y, width, height, dst_stride, dst_bits, src_stride, src_bits); + return Ok; case PixelFormat48bppRGB: compose_rgb(getpixel_48bppRGB, setpixel_48bppRGB); case PixelFormat64bppARGB: -- 1.9.1