mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
gdiplus: Improve performance of units_to_pixels by not using division.
Single float division (divss) is at least four time slower, than multiplication (mulss). More information: https://www.agner.org/optimize/instruction_tables.pdf The units_to_pixels was optimized to use only multiplication (mulss), and avoid using divisions (divss).
This commit is contained in:
parent
059094c1c1
commit
012f610675
1 changed files with 6 additions and 4 deletions
|
@ -36,7 +36,9 @@
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
|
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
|
||||||
|
|
||||||
static const REAL mm_per_inch = 25.4;
|
static const REAL mm_per_inch = 25.4;
|
||||||
|
static const REAL inch_per_mm = 1.0 / 25.4;
|
||||||
static const REAL point_per_inch = 72.0;
|
static const REAL point_per_inch = 72.0;
|
||||||
|
static const REAL inch_per_point = 1.0 / 72.0;
|
||||||
|
|
||||||
static Status WINAPI NotificationHook(ULONG_PTR *token)
|
static Status WINAPI NotificationHook(ULONG_PTR *token)
|
||||||
{
|
{
|
||||||
|
@ -333,17 +335,17 @@ REAL units_to_pixels(REAL units, GpUnit unit, REAL dpi, BOOL printer_display)
|
||||||
return units;
|
return units;
|
||||||
case UnitDisplay:
|
case UnitDisplay:
|
||||||
if (printer_display)
|
if (printer_display)
|
||||||
return units * dpi / 100.0;
|
return units * dpi * 0.01f;
|
||||||
else
|
else
|
||||||
return units;
|
return units;
|
||||||
case UnitPoint:
|
case UnitPoint:
|
||||||
return units * dpi / point_per_inch;
|
return units * dpi * inch_per_point;
|
||||||
case UnitInch:
|
case UnitInch:
|
||||||
return units * dpi;
|
return units * dpi;
|
||||||
case UnitDocument:
|
case UnitDocument:
|
||||||
return units * dpi / 300.0; /* Per MSDN */
|
return units * dpi * (1.0f / 300.0f); /* Per MSDN */
|
||||||
case UnitMillimeter:
|
case UnitMillimeter:
|
||||||
return units * dpi / mm_per_inch;
|
return units * dpi * inch_per_mm;
|
||||||
default:
|
default:
|
||||||
FIXME("Unhandled unit type: %d\n", unit);
|
FIXME("Unhandled unit type: %d\n", unit);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue