[PATCH] win32u: Get DC size in set_map_mode() only if needed.

Huw Davies huw at codeweavers.com
Fri Nov 26 03:22:41 CST 2021


On Tue, Nov 23, 2021 at 12:57:11PM +0100, Florian Will wrote:
> SetMapMode(.., MM_TEXT) is called a lot in common gdiplus use cases via
> gdi_transform_acquire(). Querying the size and resolution can be
> expensive, and is not needed in the MM_TEXT case, so skip it in that
> case.
> 
> 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 at gmail.com>
> ---
>  dlls/win32u/mapping.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/dlls/win32u/mapping.c b/dlls/win32u/mapping.c
> index 6c20f50a302..b4122644dfe 100644
> --- a/dlls/win32u/mapping.c
> +++ b/dlls/win32u/mapping.c
> @@ -117,8 +117,12 @@ 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 );
> +    if (mode != MM_TEXT)
> +    {
> +        virtual_size = get_dc_virtual_size( dc );
> +        virtual_res = get_dc_virtual_res( dc );
> +    }
> +

I've sent in something slightly less fragile as v2.

Thanks,
Huw.



More information about the wine-devel mailing list