On Sat Oct 14 21:50:56 2023 +0000, Bartosz Kosiorek wrote:
We could optimize even more, by calculating only one `sqrt`, with:
scale_x = graphics->worldtrans.matrix[0] + graphics->worldtrans.matrix[2]; scale_y = graphics->worldtrans.matrix[1] + graphics->worldtrans.matrix[3]; pt[0].X = 0.0; pt[0].Y = 0.0; pt[1].X = scale_x; pt[1].Y = scale_y; gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceDevice, pt, 2); 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); width *= units_to_pixels(pen->width, pen->unit == UnitWorld ? graphics->unit : pen->unit, graphics->xres, graphics->printer_display); width *= graphics->scale;
I think it makes more sense to have some inline helper if needed, to avoid calling public functions internally, if that's actually a problem at all (do we have any kind of performance numbers?) rather than unrolling.