From: Zebediah Figura z.figura12@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47386 Signed-off-by: Zebediah Figura z.figura12@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;