Updated gdiplus-Performance-Improvements patchset.

This commit is contained in:
Dmitry Timoshkov 2023-06-12 18:18:51 +03:00 committed by Alistair Leslie-Hughes
parent adda594159
commit 8273be2218
5 changed files with 25 additions and 115 deletions

View File

@ -1,29 +0,0 @@
From f7c317dac3581075e75168ce50c4523973422384 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 5 Mar 2017 12:55:51 +0800
Subject: gdiplus: Change the order of x/y loops in the scaler.
This improves performance by about 5%.
---
dlls/gdiplus/graphics.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 142b68115e..02d699b00b 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -3043,9 +3043,9 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
y_dx = dst_to_src_points[2].X - dst_to_src_points[0].X;
y_dy = dst_to_src_points[2].Y - dst_to_src_points[0].Y;
- for (x=dst_area.left; x<dst_area.right; x++)
+ for (y=dst_area.top; y<dst_area.bottom; y++)
{
- for (y=dst_area.top; y<dst_area.bottom; y++)
+ for (x=dst_area.left; x<dst_area.right; x++)
{
GpPointF src_pointf;
ARGB *dst_color;
--
2.11.0

View File

@ -1,65 +0,0 @@
From 04aee185cec481587e66fd410cf6ed2b6b6e2f90 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 5 Mar 2017 13:07:43 +0800
Subject: gdiplus: Change multiplications by additions in the x/y scaler loops.
This should imrove performance when floating point math will be replaced
by fixed point calculations.
---
dlls/gdiplus/graphics.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 02d699b00b..ef26887d14 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -3026,6 +3026,8 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
if (do_resampling)
{
+ REAL delta_xx, delta_xy, delta_yx, delta_yy;
+
/* Transform the bits as needed to the destination. */
dst_data = dst_dyn_data = heap_alloc_zero(sizeof(ARGB) * (dst_area.right - dst_area.left) * (dst_area.bottom - dst_area.top));
if (!dst_data)
@@ -3043,15 +3045,21 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
y_dx = dst_to_src_points[2].X - dst_to_src_points[0].X;
y_dy = dst_to_src_points[2].Y - dst_to_src_points[0].Y;
+ delta_yy = dst_area.top * y_dy;
+ delta_yx = dst_area.top * y_dx;
+
for (y=dst_area.top; y<dst_area.bottom; y++)
{
+ delta_xx = dst_area.left * x_dx;
+ delta_xy = dst_area.left * x_dy;
+
for (x=dst_area.left; x<dst_area.right; x++)
{
GpPointF src_pointf;
ARGB *dst_color;
- src_pointf.X = dst_to_src_points[0].X + x * x_dx + y * y_dx;
- src_pointf.Y = dst_to_src_points[0].Y + x * x_dy + y * y_dy;
+ src_pointf.X = dst_to_src_points[0].X + delta_xx + delta_yx;
+ src_pointf.Y = dst_to_src_points[0].Y + delta_xy + delta_yy;
dst_color = (ARGB*)(dst_data + dst_stride * (y - dst_area.top) + sizeof(ARGB) * (x - dst_area.left));
@@ -3060,7 +3068,13 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
imageAttributes, interpolation, offset_mode);
else
*dst_color = 0;
+
+ delta_xx += x_dx;
+ delta_yx += y_dx;
}
+
+ delta_xy += x_dy;
+ delta_yy += y_dy;
}
}
else
--
2.11.0

View File

@ -1,18 +1,20 @@
From f1b82c151d064eeafe234cdd95a4b29d7000232a Mon Sep 17 00:00:00 2001
From bfd7f078bd023915fb857e37fedf2e557df48c9b Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 5 Mar 2017 13:18:21 +0800
Subject: gdiplus: Remove ceilf/floorf calls from bilinear scaler. (v2)
This improves performance by about 55%.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
---
dlls/gdiplus/graphics.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index ef26887d14..58cfebb923 100644
index 835c2889bd1..4e286f959e5 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -526,7 +526,7 @@ static ARGB blend_colors(ARGB start, ARGB end, REAL position)
@@ -603,7 +603,7 @@ static ARGB blend_colors(ARGB start, ARGB end, REAL position)
INT start_a, end_a, final_a;
INT pos;
@ -21,7 +23,7 @@ index ef26887d14..58cfebb923 100644
start_a = ((start >> 24) & 0xff) * (pos ^ 0xff);
end_a = ((end >> 24) & 0xff) * pos;
@@ -928,6 +928,11 @@ static ARGB sample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT wi
@@ -1009,6 +1009,11 @@ static ARGB sample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT wi
return ((DWORD*)(bits))[(x - src_rect->X) + (y - src_rect->Y) * src_rect->Width];
}
@ -33,7 +35,7 @@ index ef26887d14..58cfebb923 100644
static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT width,
UINT height, GpPointF *point, GDIPCONST GpImageAttributes *attributes,
InterpolationMode interpolation, PixelOffsetMode offset_mode)
@@ -948,12 +953,12 @@ static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT
@@ -1029,12 +1034,12 @@ static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT
ARGB top, bottom;
float x_offset;
@ -53,5 +55,5 @@ index ef26887d14..58cfebb923 100644
if (leftx == rightx && topy == bottomy)
return sample_bitmap_pixel(src_rect, bits, width, height,
--
2.11.0
2.38.1

View File

@ -1,18 +1,20 @@
From 37b9499d8da295cd8819d85e9a563629ef13f22e Mon Sep 17 00:00:00 2001
From ae562535926a6c2524c6d227f9ebf45a0d477c65 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 5 Mar 2017 14:34:51 +0800
Subject: gdiplus: Prefer using pre-multiplied ARGB data in the scaler.
This further improves performance by about 20%.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
---
dlls/gdiplus/graphics.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++--
dlls/gdiplus/graphics.c | 94 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 91 insertions(+), 3 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 58cfebb923..bdee2e8318 100644
index 4e286f959e5..0233f5c6429 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -521,6 +521,17 @@ static GpStatus alpha_blend_pixels(GpGraphics *graphics, INT dst_x, INT dst_y,
@@ -598,6 +598,17 @@ static GpStatus alpha_blend_pixels(GpGraphics *graphics, INT dst_x, INT dst_y,
return alpha_blend_pixels_hrgn(graphics, dst_x, dst_y, src, src_width, src_height, src_stride, NULL, fmt);
}
@ -30,7 +32,7 @@ index 58cfebb923..bdee2e8318 100644
static ARGB blend_colors(ARGB start, ARGB end, REAL position)
{
INT start_a, end_a, final_a;
@@ -1002,6 +1013,75 @@ static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT
@@ -1083,6 +1094,75 @@ static ARGB resample_bitmap_pixel(GDIPCONST GpRect *src_rect, LPBYTE bits, UINT
}
}
@ -106,7 +108,7 @@ index 58cfebb923..bdee2e8318 100644
static REAL intersect_line_scanline(const GpPointF *p1, const GpPointF *p2, REAL y)
{
return (p1->X - p2->X) * (p2->Y - y) / (p2->Y - p1->Y) + p2->X;
@@ -3010,8 +3090,10 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
@@ -3216,8 +3296,10 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
lockeddata.Scan0 = src_data;
if (!do_resampling && bitmap->format == PixelFormat32bppPARGB)
lockeddata.PixelFormat = apply_image_attributes(imageAttributes, NULL, 0, 0, 0, ColorAdjustTypeBitmap, bitmap->format);
@ -118,10 +120,10 @@ index 58cfebb923..bdee2e8318 100644
stat = GdipBitmapLockBits(bitmap, &src_area, ImageLockModeRead|ImageLockModeUserInputBuf,
lockeddata.PixelFormat, &lockeddata);
@@ -3069,8 +3151,14 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
dst_color = (ARGB*)(dst_data + dst_stride * (y - dst_area.top) + sizeof(ARGB) * (x - dst_area.left));
if (src_pointf.X >= srcx && src_pointf.X < srcx + srcwidth && src_pointf.Y >= srcy && src_pointf.Y < srcy+srcheight)
@@ -3285,8 +3367,14 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
{
if (src_pointf.X >= srcx && src_pointf.X < srcx + srcwidth &&
src_pointf.Y >= srcy && src_pointf.Y < srcy + srcheight)
- *dst_color = resample_bitmap_pixel(&src_area, src_data, bitmap->width, bitmap->height, &src_pointf,
- imageAttributes, interpolation, offset_mode);
+ {
@ -132,9 +134,9 @@ index 58cfebb923..bdee2e8318 100644
+ *dst_color = resample_bitmap_pixel_premult(&src_area, src_data, bitmap->width, bitmap->height, &src_pointf,
+ imageAttributes, interpolation, offset_mode);
+ }
else
*dst_color = 0;
dst_color++;
}
}
--
2.11.0
2.38.1

View File

@ -1,2 +1,2 @@
Fixes: Improve performance of bilinear bitmap scaling
Disabled: True