From 649e5b815399a26eb4f3ace31d604310771a9eac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Thu, 3 Oct 2013 19:23:24 +0200
Subject: wined3d: Remove software cursor support.

This has been broken since quite some time and only serves to crash fglrx by acquiring a context
in the main thread.

FIXME: Make sure wined3d_device_show_cursor returns the correct value if a software cursor is set.
---
 dlls/wined3d/device.c          | 64 ------------------------------------------
 dlls/wined3d/swapchain.c       | 29 -------------------
 dlls/wined3d/wined3d_private.h |  1 -
 3 files changed, 94 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 70fb2cb..e9ef79f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1073,8 +1073,6 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
 
     if (device->logo_texture)
         wined3d_texture_decref(device->logo_texture);
-    if (device->cursor_texture)
-        wined3d_texture_decref(device->cursor_texture);
 
     /* Release the buffers (with sanity checks).
      * FIXME: Move this move into a separate patch. I think the idea
@@ -4181,48 +4179,6 @@ void CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *device,
         wined3d_rendertarget_view_decref(prev);
 }
 
-static struct wined3d_texture *wined3d_device_create_cursor_texture(struct wined3d_device *device,
-        struct wined3d_surface *cursor_image)
-{
-    struct wined3d_sub_resource_data data;
-    struct wined3d_resource_desc desc;
-    struct wined3d_map_desc map_desc;
-    struct wined3d_texture *texture;
-    HRESULT hr;
-
-    if (FAILED(wined3d_surface_map(cursor_image, &map_desc, NULL, WINED3D_MAP_READONLY)))
-    {
-        ERR("Failed to map source surface.\n");
-        return NULL;
-    }
-
-    data.data = map_desc.data;
-    data.row_pitch = map_desc.row_pitch;
-    data.slice_pitch = map_desc.slice_pitch;
-
-    desc.resource_type = WINED3D_RTYPE_TEXTURE;
-    desc.format = WINED3DFMT_B8G8R8A8_UNORM;
-    desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
-    desc.multisample_quality = 0;
-    desc.usage = WINED3DUSAGE_DYNAMIC;
-    desc.pool = WINED3D_POOL_DEFAULT;
-    desc.width = cursor_image->resource.width;
-    desc.height = cursor_image->resource.height;
-    desc.depth = 1;
-    desc.size = 0;
-
-    hr = wined3d_texture_create(device, &desc, 1, WINED3D_SURFACE_MAPPABLE,
-            &data, NULL, &wined3d_null_parent_ops, &texture);
-    wined3d_surface_unmap(cursor_image);
-    if (FAILED(hr))
-    {
-        ERR("Failed to create cursor texture.\n");
-        return NULL;
-    }
-
-    return texture;
-}
-
 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)
 {
@@ -4241,12 +4197,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
 
     cursor_image = surface_from_resource(sub_resource);
 
-    if (device->cursor_texture)
-    {
-        wined3d_texture_decref(device->cursor_texture);
-        device->cursor_texture = NULL;
-    }
-
     if (cursor_image->resource.format->id != WINED3DFMT_B8G8R8A8_UNORM)
     {
         WARN("Surface %p has an invalid format %s.\n",
@@ -4274,11 +4224,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
      * release it after setting the cursor image. Windows doesn't
      * addref the set surface, so we can't do this either without
      * creating circular refcount dependencies. */
-    if (!(device->cursor_texture = wined3d_device_create_cursor_texture(device, cursor_image)))
-    {
-        ERR("Failed to create cursor texture.\n");
-        return WINED3DERR_INVALIDCALL;
-    }
 
     if (cursor_image->resource.width == 32 && cursor_image->resource.height == 32)
     {
@@ -4383,10 +4328,6 @@ BOOL CDECL wined3d_device_show_cursor(struct wined3d_device *device, BOOL show)
         else
             SetCursor(NULL);
     }
-    else if (device->cursor_texture)
-    {
-        device->bCursorVisible = show;
-    }
 
     return oldVisible;
 }
@@ -4541,11 +4482,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
             wined3d_texture_decref(device->logo_texture);
             device->logo_texture = NULL;
         }
-        if (device->cursor_texture)
-        {
-            wined3d_texture_decref(device->cursor_texture);
-            device->cursor_texture = NULL;
-        }
     }
 
     if (device->state.fb.render_targets)
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 77eb532..d0c7c54 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -455,35 +455,6 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT
                 NULL, WINED3D_TEXF_POINT);
     }
 
-    if (swapchain->device->bCursorVisible && swapchain->device->cursor_texture
-            && !swapchain->device->hardwareCursor)
-    {
-        struct wined3d_surface *cursor = surface_from_resource(
-                wined3d_texture_get_sub_resource(swapchain->device->cursor_texture, 0));
-        RECT destRect =
-        {
-            swapchain->device->xScreenSpace - swapchain->device->xHotSpot,
-            swapchain->device->yScreenSpace - swapchain->device->yHotSpot,
-            swapchain->device->xScreenSpace + swapchain->device->cursorWidth - swapchain->device->xHotSpot,
-            swapchain->device->yScreenSpace + swapchain->device->cursorHeight - swapchain->device->yHotSpot,
-        };
-        RECT src_rect =
-        {
-            0, 0,
-            swapchain->device->cursor_texture->resource.width,
-            swapchain->device->cursor_texture->resource.height
-        };
-        const RECT clip_rect = {0, 0, back_buffer->resource.width, back_buffer->resource.height};
-
-        TRACE("Rendering the software cursor.\n");
-
-        if (swapchain->desc.windowed)
-            MapWindowPoints(NULL, swapchain->win_handle, (POINT *)&destRect, 2);
-        if (wined3d_clip_blit(&clip_rect, &destRect, &src_rect))
-            wined3d_surface_blt(back_buffer, &destRect, cursor, &src_rect, WINEDDBLT_ALPHATEST,
-                    NULL, WINED3D_TEXF_POINT);
-    }
-
     TRACE("Presenting HDC %p.\n", context->hdc);
 
     render_to_fbo = swapchain->render_to_fbo;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9450bdc..27a4a87 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2151,7 +2151,6 @@ struct wined3d_device
     UINT                    xScreenSpace;
     UINT                    yScreenSpace;
     UINT                    cursorWidth, cursorHeight;
-    struct wined3d_texture *cursor_texture;
     HCURSOR                 hardwareCursor;
 
     /* The Wine logo texture */
-- 
2.6.2

