gdiplus: Call GdiAlphaBlend only once per GdipFillRegion call.

This commit is contained in:
Vincent Povirk 2011-03-10 15:58:22 -06:00 committed by Alexandre Julliard
parent 77f5a07c1b
commit 833316f91d
1 changed files with 73 additions and 22 deletions

View File

@ -3855,6 +3855,56 @@ static GpStatus SOFTWARE_GdipFillRegion(GpGraphics *graphics, GpBrush *brush,
return Ok;
if (stat == Ok)
{
if (!graphics->image)
{
/* If we have to go through gdi32, use as few alpha blends as possible. */
INT min_x, min_y, max_x, max_y;
UINT data_width, data_height;
min_x = scans[0].X;
min_y = scans[0].Y;
max_x = scans[0].X+scans[0].Width;
max_y = scans[0].Y+scans[0].Height;
for (i=1; i<scans_count; i++)
{
min_x = min(min_x, scans[i].X);
min_y = min(min_y, scans[i].Y);
max_x = max(max_x, scans[i].X+scans[i].Width);
max_y = max(max_y, scans[i].Y+scans[i].Height);
}
data_width = max_x - min_x;
data_height = max_y - min_y;
pixel_data = GdipAlloc(sizeof(*pixel_data) * data_width * data_height);
if (!pixel_data)
stat = OutOfMemory;
if (stat == Ok)
{
for (i=0; i<scans_count; i++)
{
stat = brush_fill_pixels(graphics, brush,
pixel_data + (scans[i].X - min_x) + (scans[i].Y - min_y) * data_width,
&scans[i], data_width);
if (stat != Ok)
break;
}
if (stat == Ok)
{
stat = alpha_blend_pixels(graphics, min_x, min_y,
(BYTE*)pixel_data, data_width, data_height,
data_width * 4);
}
GdipFree(pixel_data);
}
}
else
{
UINT max_size=0;
@ -3890,6 +3940,7 @@ static GpStatus SOFTWARE_GdipFillRegion(GpGraphics *graphics, GpBrush *brush,
GdipFree(pixel_data);
}
}
GdipFree(scans);
}