From 8273be221830fb165b1420b2f7e1be64cf886226 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Mon, 12 Jun 2023 18:18:51 +0300 Subject: [PATCH] Updated gdiplus-Performance-Improvements patchset. --- ...the-order-of-x-y-loops-in-the-scaler.patch | 29 --------- ...ultiplications-by-additions-in-the-x.patch | 65 ------------------- ...eilf-floorf-calls-from-bilinear-scal.patch | 14 ++-- ...sing-pre-multiplied-ARGB-data-in-the.patch | 30 +++++---- .../definition | 2 +- 5 files changed, 25 insertions(+), 115 deletions(-) delete mode 100644 patches/gdiplus-Performance-Improvements/0001-gdiplus-Change-the-order-of-x-y-loops-in-the-scaler.patch delete mode 100644 patches/gdiplus-Performance-Improvements/0002-gdiplus-Change-multiplications-by-additions-in-the-x.patch diff --git a/patches/gdiplus-Performance-Improvements/0001-gdiplus-Change-the-order-of-x-y-loops-in-the-scaler.patch b/patches/gdiplus-Performance-Improvements/0001-gdiplus-Change-the-order-of-x-y-loops-in-the-scaler.patch deleted file mode 100644 index a2b9a139..00000000 --- a/patches/gdiplus-Performance-Improvements/0001-gdiplus-Change-the-order-of-x-y-loops-in-the-scaler.patch +++ /dev/null @@ -1,29 +0,0 @@ -From f7c317dac3581075e75168ce50c4523973422384 Mon Sep 17 00:00:00 2001 -From: Dmitry Timoshkov -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 -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 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 --- 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 diff --git a/patches/gdiplus-Performance-Improvements/0004-gdiplus-Prefer-using-pre-multiplied-ARGB-data-in-the.patch b/patches/gdiplus-Performance-Improvements/0004-gdiplus-Prefer-using-pre-multiplied-ARGB-data-in-the.patch index 2ede68a1..23e212f3 100644 --- a/patches/gdiplus-Performance-Improvements/0004-gdiplus-Prefer-using-pre-multiplied-ARGB-data-in-the.patch +++ b/patches/gdiplus-Performance-Improvements/0004-gdiplus-Prefer-using-pre-multiplied-ARGB-data-in-the.patch @@ -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 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 --- - 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 diff --git a/patches/gdiplus-Performance-Improvements/definition b/patches/gdiplus-Performance-Improvements/definition index d8a6dbf3..18120cfd 100644 --- a/patches/gdiplus-Performance-Improvements/definition +++ b/patches/gdiplus-Performance-Improvements/definition @@ -1,2 +1,2 @@ Fixes: Improve performance of bilinear bitmap scaling -Disabled: True +