From: Florian Will florian.will@gmail.com
SetMapMode(.., MM_TEXT) is called a lot in common gdiplus use cases via gdi_transform_acquire(). Querying the size and resolution can be expensive, so skip it when its not needed.
When running the "ZusiDisplay" ET423 diagnostic display, which uses gdiplus heavily, this change increases the "indicator blinking speed" from 0.6 per second to 1 per second and probably hits the FPS limit now. Also, CPU usage of the ZusiDisplay.exe process goes down from ~75% to ~42% of one core according to "top", and wineserver CPU usage goes down from ~48% to ~3%.
Signed-off-by: Florian Will florian.will@gmail.com Signed-off-by: Huw Davies huw@codeweavers.com --- I'm not exactly overjoyed with this patch as we should strive to make GetDeviceCaps() faster. However, it does make a difference to an application and isn't too horrendous.
dlls/win32u/mapping.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/win32u/mapping.c b/dlls/win32u/mapping.c index 6c20f50a302..6e7c42fe7cc 100644 --- a/dlls/win32u/mapping.c +++ b/dlls/win32u/mapping.c @@ -117,8 +117,6 @@ BOOL set_map_mode( DC *dc, int mode ) if (mode == dc->attr->map_mode && (mode == MM_ISOTROPIC || mode == MM_ANISOTROPIC)) return TRUE;
- virtual_size = get_dc_virtual_size( dc ); - virtual_res = get_dc_virtual_res( dc ); switch (mode) { case MM_TEXT: @@ -129,30 +127,40 @@ BOOL set_map_mode( DC *dc, int mode ) break; case MM_LOMETRIC: case MM_ISOTROPIC: + virtual_size = get_dc_virtual_size( dc ); + virtual_res = get_dc_virtual_res( dc ); dc->attr->wnd_ext.cx = virtual_size.cx * 10; dc->attr->wnd_ext.cy = virtual_size.cy * 10; dc->attr->vport_ext.cx = virtual_res.cx; dc->attr->vport_ext.cy = -virtual_res.cy; break; case MM_HIMETRIC: + virtual_size = get_dc_virtual_size( dc ); + virtual_res = get_dc_virtual_res( dc ); dc->attr->wnd_ext.cx = virtual_size.cx * 100; dc->attr->wnd_ext.cy = virtual_size.cy * 100; dc->attr->vport_ext.cx = virtual_res.cx; dc->attr->vport_ext.cy = -virtual_res.cy; break; case MM_LOENGLISH: + virtual_size = get_dc_virtual_size( dc ); + virtual_res = get_dc_virtual_res( dc ); dc->attr->wnd_ext.cx = muldiv(1000, virtual_size.cx, 254); dc->attr->wnd_ext.cy = muldiv(1000, virtual_size.cy, 254); dc->attr->vport_ext.cx = virtual_res.cx; dc->attr->vport_ext.cy = -virtual_res.cy; break; case MM_HIENGLISH: + virtual_size = get_dc_virtual_size( dc ); + virtual_res = get_dc_virtual_res( dc ); dc->attr->wnd_ext.cx = muldiv(10000, virtual_size.cx, 254); dc->attr->wnd_ext.cy = muldiv(10000, virtual_size.cy, 254); dc->attr->vport_ext.cx = virtual_res.cx; dc->attr->vport_ext.cy = -virtual_res.cy; break; case MM_TWIPS: + virtual_size = get_dc_virtual_size( dc ); + virtual_res = get_dc_virtual_res( dc ); dc->attr->wnd_ext.cx = muldiv(14400, virtual_size.cx, 254); dc->attr->wnd_ext.cy = muldiv(14400, virtual_size.cy, 254); dc->attr->vport_ext.cx = virtual_res.cx;
Am Fr., 26. Nov. 2021 um 10:20 Uhr schrieb Huw Davies huw@codeweavers.com:
I'm not exactly overjoyed with this patch as we should strive to make GetDeviceCaps() faster. However, it does make a difference to an application and isn't too horrendous.
Thanks for the less fragile version!
Initially, a year ago or so, I tried to come up with a caching mechanism for device caps, but that turned out to be even more horrendous if I remember correctly (I no longer have the code). Like not knowing when/if to invalidate entries etc. So I decided to attempt that simple (previously) 4 line change.