[PATCH 6/6] wined3d: Get rid of wined3d_device_get_surface_from_dc().
Henri Verbeet
hverbeet at codeweavers.com
Mon Feb 8 11:32:06 CST 2016
From: Riccardo Bortolato <rikyz619 at gmail.com>
Signed-off-by: Riccardo Bortolato <rikyz619 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/ddraw/ddraw.c | 37 +++++++++++++++++++------------
dlls/ddraw/ddraw_private.h | 1 +
dlls/ddraw/surface.c | 55 +++++++++++++++++++++++++++-------------------
dlls/wined3d/device.c | 26 ----------------------
dlls/wined3d/surface.c | 7 ------
dlls/wined3d/wined3d.spec | 2 --
include/wine/wined3d.h | 2 --
7 files changed, 56 insertions(+), 74 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 89ce07a..5ffc951 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -2621,29 +2621,38 @@ static HRESULT WINAPI ddraw4_GetDeviceIdentifier(IDirectDraw4 *iface,
* Always returns DD_OK because it's a stub
*
*****************************************************************************/
-static HRESULT WINAPI ddraw7_GetSurfaceFromDC(IDirectDraw7 *iface, HDC hdc,
- IDirectDrawSurface7 **Surface)
+static HRESULT WINAPI ddraw7_GetSurfaceFromDC(IDirectDraw7 *iface,
+ HDC dc, IDirectDrawSurface7 **surface)
{
struct ddraw *ddraw = impl_from_IDirectDraw7(iface);
- struct wined3d_surface *wined3d_surface;
struct ddraw_surface *surface_impl;
- TRACE("iface %p, dc %p, surface %p.\n", iface, hdc, Surface);
+ TRACE("iface %p, dc %p, surface %p.\n", iface, dc, surface);
+
+ if (!surface)
+ return E_INVALIDARG;
- if (!Surface) return E_INVALIDARG;
+ if (!dc)
+ goto done;
- if (!(wined3d_surface = wined3d_device_get_surface_from_dc(ddraw->wined3d_device, hdc)))
+ wined3d_mutex_lock();
+ LIST_FOR_EACH_ENTRY(surface_impl, &ddraw->surface_list, struct ddraw_surface, surface_list_entry)
{
- TRACE("No surface found for dc %p.\n", hdc);
- *Surface = NULL;
- return DDERR_NOTFOUND;
+ if (surface_impl->dc != dc)
+ continue;
+
+ TRACE("Found surface %p for dc %p.\n", surface_impl, dc);
+ *surface = &surface_impl->IDirectDrawSurface7_iface;
+ IDirectDrawSurface7_AddRef(*surface);
+ wined3d_mutex_unlock();
+ return DD_OK;
}
+ wined3d_mutex_unlock();
- surface_impl = wined3d_surface_get_parent(wined3d_surface);
- *Surface = &surface_impl->IDirectDrawSurface7_iface;
- IDirectDrawSurface7_AddRef(*Surface);
- TRACE("Returning surface %p.\n", Surface);
- return DD_OK;
+done:
+ TRACE("No surface found for dc %p.\n", dc);
+ *surface = NULL;
+ return DDERR_NOTFOUND;
}
static HRESULT WINAPI ddraw4_GetSurfaceFromDC(IDirectDraw4 *iface, HDC dc,
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index d73d87b..e6d8f3a 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -197,6 +197,7 @@ struct ddraw_surface
struct list surface_list_entry;
DWORD Handle;
+ HDC dc;
};
struct ddraw_texture
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index d5ebe31..3286b97 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -2103,48 +2103,53 @@ static HRESULT WINAPI ddraw_surface1_AddOverlayDirtyRect(IDirectDrawSurface *ifa
* For details, see IWineD3DSurface::GetDC
*
*****************************************************************************/
-static HRESULT WINAPI ddraw_surface7_GetDC(IDirectDrawSurface7 *iface, HDC *hdc)
+static HRESULT WINAPI ddraw_surface7_GetDC(IDirectDrawSurface7 *iface, HDC *dc)
{
struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface);
HRESULT hr = DD_OK;
- TRACE("iface %p, dc %p.\n", iface, hdc);
+ TRACE("iface %p, dc %p.\n", iface, dc);
- if(!hdc)
+ if (!dc)
return DDERR_INVALIDPARAMS;
wined3d_mutex_lock();
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(surface, NULL, TRUE);
if (SUCCEEDED(hr))
- hr = wined3d_texture_get_dc(surface->wined3d_texture, surface->sub_resource_idx, hdc);
+ hr = wined3d_texture_get_dc(surface->wined3d_texture, surface->sub_resource_idx, dc);
- if (SUCCEEDED(hr) && format_is_paletteindexed(&surface->surface_desc.u4.ddpfPixelFormat))
+ if (SUCCEEDED(hr))
{
- const struct ddraw_palette *palette;
+ surface->dc = *dc;
- if (surface->palette)
- palette = surface->palette;
- else if (surface->ddraw->primary)
- palette = surface->ddraw->primary->palette;
- else
- palette = NULL;
+ if (format_is_paletteindexed(&surface->surface_desc.u4.ddpfPixelFormat))
+ {
+ const struct ddraw_palette *palette;
+
+ if (surface->palette)
+ palette = surface->palette;
+ else if (surface->ddraw->primary)
+ palette = surface->ddraw->primary->palette;
+ else
+ palette = NULL;
- if (palette)
- wined3d_palette_apply_to_dc(palette->wineD3DPalette, *hdc);
+ if (palette)
+ wined3d_palette_apply_to_dc(palette->wineD3DPalette, *dc);
+ }
}
wined3d_mutex_unlock();
- switch(hr)
+ switch (hr)
{
- /* Some, but not all errors set *hdc to NULL. E.g. DCALREADYCREATED does not
- * touch *hdc
- */
+ /* Some, but not all errors set *dc to NULL. E.g. DCALREADYCREATED
+ * does not touch *dc. */
case WINED3DERR_INVALIDCALL:
- if(hdc) *hdc = NULL;
+ *dc = NULL;
return DDERR_INVALIDPARAMS;
- default: return hr;
+ default:
+ return hr;
}
}
@@ -2205,11 +2210,15 @@ static HRESULT WINAPI ddraw_surface7_ReleaseDC(IDirectDrawSurface7 *iface, HDC h
TRACE("iface %p, dc %p.\n", iface, hdc);
wined3d_mutex_lock();
- hr = wined3d_texture_release_dc(surface->wined3d_texture, surface->sub_resource_idx, hdc);
- if (SUCCEEDED(hr) && (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
- hr = ddraw_surface_update_frontbuffer(surface, NULL, FALSE);
+ if (SUCCEEDED(hr = wined3d_texture_release_dc(surface->wined3d_texture, surface->sub_resource_idx, hdc)))
+ {
+ surface->dc = NULL;
+ if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+ hr = ddraw_surface_update_frontbuffer(surface, NULL, FALSE);
+ }
wined3d_mutex_unlock();
+
return hr;
}
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 14e1f51..2d45135 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5040,32 +5040,6 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso
TRACE("Resource released.\n");
}
-struct wined3d_surface * CDECL wined3d_device_get_surface_from_dc(const struct wined3d_device *device, HDC dc)
-{
- struct wined3d_resource *resource;
-
- TRACE("device %p, dc %p.\n", device, dc);
-
- if (!dc)
- return NULL;
-
- LIST_FOR_EACH_ENTRY(resource, &device->resources, struct wined3d_resource, resource_list_entry)
- {
- if (resource->type == WINED3D_RTYPE_SURFACE)
- {
- struct wined3d_surface *s = surface_from_resource(resource);
-
- if (s->hDC == dc)
- {
- TRACE("Found surface %p for dc %p.\n", s, dc);
- return s;
- }
- }
- }
-
- return NULL;
-}
-
static int wined3d_sampler_compare(const void *key, const struct wine_rb_entry *entry)
{
const struct wined3d_sampler *sampler = WINE_RB_ENTRY_VALUE(entry, struct wined3d_sampler, entry);
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index d5ba3ac..8597404 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1883,13 +1883,6 @@ static inline unsigned short float_32_to_16(const float *in)
return ret;
}
-void * CDECL wined3d_surface_get_parent(const struct wined3d_surface *surface)
-{
- TRACE("surface %p.\n", surface);
-
- return surface->resource.parent;
-}
-
DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
{
unsigned int alignment;
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 532702e..5933b48 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -84,7 +84,6 @@
@ cdecl wined3d_device_get_stream_output(ptr long ptr)
@ cdecl wined3d_device_get_stream_source(ptr long ptr ptr ptr)
@ cdecl wined3d_device_get_stream_source_freq(ptr long ptr)
-@ cdecl wined3d_device_get_surface_from_dc(ptr ptr)
@ cdecl wined3d_device_get_swapchain(ptr long)
@ cdecl wined3d_device_get_swapchain_count(ptr)
@ cdecl wined3d_device_get_texture(ptr long)
@@ -221,7 +220,6 @@
@ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_incref(ptr)
-@ cdecl wined3d_surface_get_parent(ptr)
@ cdecl wined3d_surface_get_pitch(ptr)
@ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 420a55b..df95da9 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2202,7 +2202,6 @@ HRESULT __cdecl wined3d_device_get_stream_source(const struct wined3d_device *de
UINT stream_idx, struct wined3d_buffer **buffer, UINT *offset, UINT *stride);
HRESULT __cdecl wined3d_device_get_stream_source_freq(const struct wined3d_device *device,
UINT stream_idx, UINT *divider);
-struct wined3d_surface * __cdecl wined3d_device_get_surface_from_dc(const struct wined3d_device *device, HDC dc);
struct wined3d_swapchain * __cdecl wined3d_device_get_swapchain(const struct wined3d_device *device,
UINT swapchain_idx);
UINT __cdecl wined3d_device_get_swapchain_count(const struct wined3d_device *device);
@@ -2473,7 +2472,6 @@ HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device,
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
-void * __cdecl wined3d_surface_get_parent(const struct wined3d_surface *surface);
DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface);
HRESULT __cdecl wined3d_swapchain_create(struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
--
2.1.4
More information about the wine-patches
mailing list