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

