From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/graphics.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 65b33cdc960..1b319c15d26 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -270,11 +270,11 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen) else{ /* Get an estimate for the amount the pen width is affected by the world * transform. (This is similar to what some of the wine drivers do.) */ - pt[0].X = 0.0; - pt[0].Y = 0.0; - pt[1].X = 1.0; - pt[1].Y = 1.0; - GdipTransformMatrixPoints(&graphics->worldtrans, pt, 2); + pt[0].X = graphics->worldtrans.matrix[4]; + pt[0].Y = graphics->worldtrans.matrix[5]; + pt[1].X = graphics->worldtrans.matrix[4] + graphics->worldtrans.matrix[0] + graphics->worldtrans.matrix[2]; + pt[1].Y = graphics->worldtrans.matrix[5] + graphics->worldtrans.matrix[1] + graphics->worldtrans.matrix[3]; + width = sqrt((pt[1].X - pt[0].X) * (pt[1].X - pt[0].X) + (pt[1].Y - pt[0].Y) * (pt[1].Y - pt[0].Y)) / sqrt(2.0);
@@ -3215,19 +3215,16 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image if (do_resampling) { GpMatrix dst_to_src; - REAL m11, m12, m21, m22, mdx, mdy; REAL x_dx, x_dy, y_dx, y_dy; ARGB *dst_color; GpPointF src_pointf_row, src_pointf;
- m11 = (ptf[1].X - ptf[0].X) / srcwidth; - m12 = (ptf[1].Y - ptf[0].Y) / srcwidth; - m21 = (ptf[2].X - ptf[0].X) / srcheight; - m22 = (ptf[2].Y - ptf[0].Y) / srcheight; - mdx = ptf[0].X - m11 * srcx - m21 * srcy; - mdy = ptf[0].Y - m12 * srcx - m22 * srcy; - - GdipSetMatrixElements(&dst_to_src, m11, m12, m21, m22, mdx, mdy); + dst_to_src.matrix[0] = (ptf[1].X - ptf[0].X) / srcwidth; + dst_to_src.matrix[1] = (ptf[1].Y - ptf[0].Y) / srcwidth; + dst_to_src.matrix[2] = (ptf[2].X - ptf[0].X) / srcheight; + dst_to_src.matrix[3] = (ptf[2].Y - ptf[0].Y) / srcheight; + dst_to_src.matrix[4] = ptf[0].X - dst_to_src.matrix[0] * srcx - dst_to_src.matrix[2] * srcy; + dst_to_src.matrix[5] = ptf[0].Y - dst_to_src.matrix[1] * srcx - dst_to_src.matrix[3] * srcy;
stat = GdipInvertMatrix(&dst_to_src); if (stat != Ok) return stat;
Jeffrey Smith (@whydoubt) commented about dlls/gdiplus/graphics.c:
else{ /* Get an estimate for the amount the pen width is affected by the world * transform. (This is similar to what some of the wine drivers do.) */
pt[0].X = 0.0;
pt[0].Y = 0.0;
pt[1].X = 1.0;
pt[1].Y = 1.0;
GdipTransformMatrixPoints(&graphics->worldtrans, pt, 2);
pt[0].X = graphics->worldtrans.matrix[4];
pt[0].Y = graphics->worldtrans.matrix[5];
pt[1].X = graphics->worldtrans.matrix[4] + graphics->worldtrans.matrix[0] + graphics->worldtrans.matrix[2];
pt[1].Y = graphics->worldtrans.matrix[5] + graphics->worldtrans.matrix[1] + graphics->worldtrans.matrix[3];
width = sqrt((pt[1].X - pt[0].X) * (pt[1].X - pt[0].X) + (pt[1].Y - pt[0].Y) * (pt[1].Y - pt[0].Y)) / sqrt(2.0);
If going for optimization, might as well go the rest of the way cleaning this up. ```suggestion:-6+0 pt[1].X = graphics->worldtrans.matrix[0] + graphics->worldtrans.matrix[2]; pt[1].Y = graphics->worldtrans.matrix[1] + graphics->worldtrans.matrix[3];
width = sqrt(pt[1].X * pt[1].X + pt[1].Y * pt[1].Y) / sqrt(2.0); ``` Note: the compiler converts `sqrt(2.0)` to the actual value, so no need move stuff around to avoid a `sqrt` here.
Is the commit title accurate? I don't see changes that directly affect `GdipDrawImagePointsRect`.
What does this optimize for? Extra function call made once, outside of the loop?