[PATCH] wined3d: Always try to create a hardware cursor.
Zebediah Figura
z.figura12 at gmail.com
Sun Jun 30 08:48:53 CDT 2019
I guess the behaviour may have changed. I tested on Windows 10, and in
both windowed and fullscreen mode I got a scaled 32x32 HW cursor. I also
tested with a reduced testcase [essentially adapting test_cursor()] and
I was never able to get a SW cursor. Or at least, it was always scaled
to 32x32, and it always moved without me making any calls to d3d9.
I'd test with Windows 7 or something earlier, but I don't have immediate
access to any such machine myself.
On 6/30/19 5:04 AM, Stefan Dösinger wrote:
> 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 <zfigura at codeweavers.com>:
>>
>> From: Zebediah Figura <z.figura12 at gmail.com>
>>
>> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47386
>> Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
>> ---
>> 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
>>
>>
>>
>
More information about the wine-devel
mailing list