From: Stefan Dösinger Subject: Re: [PATCH] wined3d: Always try to create a hardware cursor. Message-Id: <450250F0-B6D2-4215-B629-8DC21FF9E18A@gmail.com> Date: Sun, 30 Jun 2019 12:04:57 +0200 In-Reply-To: <20190628234633.7139-1-zfigura@codeweavers.com> References: <20190628234633.7139-1-zfigura@codeweavers.com> If my memory of my own experiments are right then what your patch does is correct for windowed mode. In Windowed mode native d3d9 never renders an SW cursor and instead creates a scaled HW cursor. In fullscreen mode I do get a (non-moving by default) SW cursor for a 64x64 texture, or at least used to when I tested it on Windows 7 years ago. The behavior might have changed. Since comment 7 on bug 47386 indicates that the game calls SetCursorProperties over and over it might be the correct thing to update the cursor position to the current user32 cursor pos in SetCursorProperties. How does the cursor appear on Windows? Does it look like a 32x32 or 64x64 cursor? Also keep in mind the possibility that the cursor is a 64x64 one where only a 32x32 part of the texture contains non-transparent data. > Am 29.06.2019 um 01:46 schrieb Zebediah Figura : > > From: Zebediah Figura > > Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47386 > Signed-off-by: Zebediah Figura > --- > dlls/wined3d/device.c | 65 +++++++++++++++++++++---------------------- > 1 file changed, 31 insertions(+), 34 deletions(-) > > diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c > index d35a0648c9c..39dd93e11b7 100644 > --- a/dlls/wined3d/device.c > +++ b/dlls/wined3d/device.c > @@ -5216,9 +5216,12 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device > UINT x_hotspot, UINT y_hotspot, struct wined3d_texture *texture, unsigned int sub_resource_idx) > { > unsigned int texture_level = sub_resource_idx % texture->level_count; > - unsigned int cursor_width, cursor_height; > + unsigned int cursor_width, cursor_height, mask_size; > struct wined3d_display_mode mode; > struct wined3d_map_desc map_desc; > + ICONINFO cursor_info; > + DWORD *mask_bits; > + HCURSOR cursor; > HRESULT hr; > > TRACE("device %p, x_hotspot %u, y_hotspot %u, texture %p, sub_resource_idx %u.\n", > @@ -5268,43 +5271,37 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device > return WINED3DERR_INVALIDCALL; > } > > - if (cursor_width == 32 && cursor_height == 32) > - { > - UINT mask_size = cursor_width * cursor_height / 8; > - ICONINFO cursor_info; > - DWORD *mask_bits; > - HCURSOR cursor; > + mask_size = cursor_width * cursor_height / 8; > > - /* 32-bit user32 cursors ignore the alpha channel if it's all > - * zeroes, and use the mask instead. Fill the mask with all ones > - * to ensure we still get a fully transparent cursor. */ > - if (!(mask_bits = heap_alloc(mask_size))) > - return E_OUTOFMEMORY; > - memset(mask_bits, 0xff, mask_size); > + /* 32-bit user32 cursors ignore the alpha channel if it's all > + * zeroes, and use the mask instead. Fill the mask with all ones > + * to ensure we still get a fully transparent cursor. */ > + if (!(mask_bits = heap_alloc(mask_size))) > + return E_OUTOFMEMORY; > + memset(mask_bits, 0xff, mask_size); > > - wined3d_resource_map(&texture->resource, sub_resource_idx, &map_desc, NULL, > - WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READ); > - cursor_info.fIcon = FALSE; > - cursor_info.xHotspot = x_hotspot; > - cursor_info.yHotspot = y_hotspot; > - cursor_info.hbmMask = CreateBitmap(cursor_width, cursor_height, 1, 1, mask_bits); > - cursor_info.hbmColor = CreateBitmap(cursor_width, cursor_height, 1, 32, map_desc.data); > - wined3d_resource_unmap(&texture->resource, sub_resource_idx); > + wined3d_resource_map(&texture->resource, sub_resource_idx, &map_desc, NULL, > + WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READ); > + cursor_info.fIcon = FALSE; > + cursor_info.xHotspot = x_hotspot; > + cursor_info.yHotspot = y_hotspot; > + cursor_info.hbmMask = CreateBitmap(cursor_width, cursor_height, 1, 1, mask_bits); > + cursor_info.hbmColor = CreateBitmap(cursor_width, cursor_height, 1, 32, map_desc.data); > + wined3d_resource_unmap(&texture->resource, sub_resource_idx); > > - /* Create our cursor and clean up. */ > - cursor = CreateIconIndirect(&cursor_info); > - if (cursor_info.hbmMask) > - DeleteObject(cursor_info.hbmMask); > - if (cursor_info.hbmColor) > - DeleteObject(cursor_info.hbmColor); > - if (device->hardwareCursor) > - DestroyCursor(device->hardwareCursor); > - device->hardwareCursor = cursor; > - if (device->bCursorVisible) > - SetCursor(cursor); > + /* Create our cursor and clean up. */ > + cursor = CreateIconIndirect(&cursor_info); > + if (cursor_info.hbmMask) > + DeleteObject(cursor_info.hbmMask); > + if (cursor_info.hbmColor) > + DeleteObject(cursor_info.hbmColor); > + if (device->hardwareCursor) > + DestroyCursor(device->hardwareCursor); > + device->hardwareCursor = cursor; > + if (device->bCursorVisible) > + SetCursor(cursor); > > - heap_free(mask_bits); > - } > + heap_free(mask_bits); > > TRACE("New cursor dimensions are %ux%u.\n", cursor_width, cursor_height); > device->cursorWidth = cursor_width; > -- > 2.20.1 > > > -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEQxb0tqoFWyeVMl1sPRO8yFRPGiIFAl0YiUkACgkQPRO8yFRP GiKCPw//Z69Ve+yFSiUUlvrGOlwjh9O3GLppw3Tsb24lkWRpNaqwOyKJy8zfj9v1 X4AtFQD6QVnU8cCss4CNHFbMj7yGzleCDfwUXs8XOXcPGXBm0CcjAwIMwPyVAHQk uJbGl/v881XOQ1ogxVUx7VLoratugamdYMdogCFVTw3vPsvf4eNmzCoWho/+ZrVd 7gX5iXc9x+fwBwVg6nZnvB8OiP1i9JskJm+Cf6BvML0pfOzIuM5yuhEdgXYaXcAo WVmoYNfdPokei0qpvWwLH1saTtW25LAj8/rIiKHv7xD4gT2MIsed+eLLs3sZf/wk 812JRHnr0MoJ88NLk56+sOjOnU2i6HFXqXBD2SvJVmFQgvnqkken5CFpyIDkKHID nc0eJbLf954rBTbAuhU33AsUpwlR71w2m3XMkstgI7inLkzdEqNAifpuyNkqyNto IR/4hdlV7OdFe9KoTPmV54OMqjCK2lBh/OFBEkD6XBAtmB7oonzxz7LpMS2gOA2o Kqycz/+ZocI2FX7HlX1oJf2MLhB5J3BXN59GmfzaYXQqKCaSDde9XBQ1ZX3/D0ex QIEN0dqVZAVkSMse2XjdrfggUqsTXWHSxrg7Gp2Gr+KU0T3sBgcppmDLulpedZTR vTaSvwsvmwBSc21wkJ85u8Hq1FncpRyKjgpotEbxMOnXay7KZeg= =a8wb -----END PGP SIGNATURE-----