Commit 8959a139 authored by Ričardas Barkauskas's avatar Ričardas Barkauskas Committed by Alexandre Julliard

ddraw: Remove ddraw_set_surface_version and set surface version when initialising it.

parent b5e04640
......@@ -2711,7 +2711,7 @@ static HRESULT ddraw_recreate_surfaces(IDirectDrawImpl *This)
*
*****************************************************************************/
static HRESULT ddraw_create_surface(IDirectDrawImpl *This, DDSURFACEDESC2 *pDDSD,
IDirectDrawSurfaceImpl **ppSurf, UINT level)
IDirectDrawSurfaceImpl **ppSurf, UINT level, UINT version)
{
WINED3DSURFTYPE ImplType = This->ImplType;
HRESULT hr;
......@@ -2788,7 +2788,7 @@ static HRESULT ddraw_create_surface(IDirectDrawImpl *This, DDSURFACEDESC2 *pDDSD
return DDERR_OUTOFVIDEOMEMORY;
}
hr = ddraw_surface_init(*ppSurf, This, pDDSD, level, ImplType);
hr = ddraw_surface_init(*ppSurf, This, pDDSD, level, ImplType, version);
if (FAILED(hr))
{
WARN("Failed to initialize surface, hr %#x.\n", hr);
......@@ -2823,7 +2823,7 @@ CreateAdditionalSurfaces(IDirectDrawImpl *This,
IDirectDrawSurfaceImpl *root,
UINT count,
DDSURFACEDESC2 DDSD,
BOOL CubeFaceRoot)
BOOL CubeFaceRoot, UINT version)
{
UINT i, j, level = 0;
HRESULT hr;
......@@ -2850,7 +2850,7 @@ CreateAdditionalSurfaces(IDirectDrawImpl *This,
}
CubeFaceRoot = FALSE;
hr = ddraw_create_surface(This, &DDSD, &object2, level);
hr = ddraw_create_surface(This, &DDSD, &object2, level, version);
if(hr != DD_OK)
{
return hr;
......@@ -2874,25 +2874,6 @@ CreateAdditionalSurfaces(IDirectDrawImpl *This,
return DD_OK;
}
/* Must set all attached surfaces (e.g. mipmaps) versions as well */
static void ddraw_set_surface_version(IDirectDrawSurfaceImpl *surface, UINT version)
{
unsigned int i;
TRACE("surface %p, version %u -> %u.\n", surface, surface->version, version);
surface->version = version;
for (i = 0; i < MAX_COMPLEX_ATTACHED; ++i)
{
if (!surface->complex_array[i]) break;
ddraw_set_surface_version(surface->complex_array[i], version);
}
while ((surface = surface->next_attached))
{
ddraw_set_surface_version(surface, version);
}
}
/*****************************************************************************
* ddraw_attach_d3d_device
*
......@@ -3101,7 +3082,7 @@ static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSur
*
*****************************************************************************/
static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
IDirectDrawSurfaceImpl **Surf, IUnknown *UnkOuter)
IDirectDrawSurfaceImpl **Surf, IUnknown *UnkOuter, UINT version)
{
IDirectDrawSurfaceImpl *object = NULL;
HRESULT hr;
......@@ -3357,7 +3338,7 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
}
/* Create the first surface */
hr = ddraw_create_surface(ddraw, &desc2, &object, 0);
hr = ddraw_create_surface(ddraw, &desc2, &object, 0, version);
if (FAILED(hr))
{
WARN("ddraw_create_surface failed, hr %#x.\n", hr);
......@@ -3386,28 +3367,39 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
{
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_ALLFACES;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEZ;
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE, version);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_NEGATIVEZ;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEZ;
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE, version);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_POSITIVEZ;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEY;
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE, version);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_NEGATIVEY;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEY;
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE, version);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_POSITIVEY;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_NEGATIVEX;
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE);
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces + 1, desc2, TRUE, version);
desc2.ddsCaps.dwCaps2 &= ~DDSCAPS2_CUBEMAP_NEGATIVEX;
desc2.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP_POSITIVEX;
}
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces, desc2, FALSE);
hr |= CreateAdditionalSurfaces(ddraw, object, extra_surfaces, desc2, FALSE, version);
if(hr != DD_OK)
{
/* This destroys and possibly created surfaces too */
IDirectDrawSurface7_Release(&object->IDirectDrawSurface7_iface);
if (version == 7)
{
IDirectDrawSurface7_Release(&object->IDirectDrawSurface7_iface);
}
else if (version == 4)
{
IDirectDrawSurface4_Release(&object->IDirectDrawSurface4_iface);
}
else
{
IDirectDrawSurface_Release(&object->IDirectDrawSurface_iface);
}
LeaveCriticalSection(&ddraw_cs);
return hr;
}
......@@ -3514,7 +3506,7 @@ static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface, DDSURFACEDESC2 *
return DDERR_INVALIDCAPS;
}
hr = CreateSurface(This, surface_desc, &impl, outer_unknown);
hr = CreateSurface(This, surface_desc, &impl, outer_unknown, 7);
if (FAILED(hr))
{
*surface = NULL;
......@@ -3554,7 +3546,7 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
return DDERR_INVALIDCAPS;
}
hr = CreateSurface(This, surface_desc, &impl, outer_unknown);
hr = CreateSurface(This, surface_desc, &impl, outer_unknown, 4);
if (FAILED(hr))
{
*surface = NULL;
......@@ -3562,7 +3554,6 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
}
*surface = &impl->IDirectDrawSurface4_iface;
ddraw_set_surface_version(impl, 4);
IDirectDraw7_Release(&This->IDirectDraw7_iface);
IDirectDraw4_AddRef(iface);
impl->ifaceToRelease = (IUnknown *)iface;
......@@ -3598,7 +3589,7 @@ static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface, DDSURFACEDESC *s
return DDERR_INVALIDCAPS;
}
hr = CreateSurface(This, (DDSURFACEDESC2 *)surface_desc, &impl, outer_unknown);
hr = CreateSurface(This, (DDSURFACEDESC2 *)surface_desc, &impl, outer_unknown, 3);
if (FAILED(hr))
{
*surface = NULL;
......@@ -3606,7 +3597,6 @@ static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface, DDSURFACEDESC *s
}
*surface = &impl->IDirectDrawSurface_iface;
ddraw_set_surface_version(impl, 3);
IDirectDraw7_Release(&This->IDirectDraw7_iface);
IDirectDraw3_AddRef(iface);
impl->ifaceToRelease = (IUnknown *)iface;
......@@ -3642,7 +3632,7 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
return DDERR_INVALIDCAPS;
}
hr = CreateSurface(This, (DDSURFACEDESC2 *)surface_desc, &impl, outer_unknown);
hr = CreateSurface(This, (DDSURFACEDESC2 *)surface_desc, &impl, outer_unknown, 2);
if (FAILED(hr))
{
*surface = NULL;
......@@ -3650,7 +3640,6 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
}
*surface = &impl->IDirectDrawSurface_iface;
ddraw_set_surface_version(impl, 2);
IDirectDraw7_Release(&This->IDirectDraw7_iface);
impl->ifaceToRelease = NULL;
......@@ -3676,7 +3665,7 @@ static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
/* Remove front buffer flag, this causes failure in v7, and its added to normal
* primaries anyway. */
surface_desc->ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
hr = CreateSurface(This, (DDSURFACEDESC2 *)surface_desc, &impl, outer_unknown);
hr = CreateSurface(This, (DDSURFACEDESC2 *)surface_desc, &impl, outer_unknown, 1);
if (FAILED(hr))
{
*surface = NULL;
......@@ -3684,7 +3673,6 @@ static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
}
*surface = &impl->IDirectDrawSurface_iface;
ddraw_set_surface_version(impl, 1);
IDirectDraw7_Release(&This->IDirectDraw7_iface);
impl->ifaceToRelease = NULL;
......
......@@ -211,7 +211,7 @@ struct IDirectDrawSurfaceImpl
HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface) DECLSPEC_HIDDEN;
void ddraw_surface_destroy(IDirectDrawSurfaceImpl *surface) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddraw,
DDSURFACEDESC2 *desc, UINT mip_level, WINED3DSURFTYPE surface_type) DECLSPEC_HIDDEN;
DDSURFACEDESC2 *desc, UINT mip_level, WINED3DSURFTYPE surface_type, UINT version) DECLSPEC_HIDDEN;
static inline IDirectDrawSurfaceImpl *surface_from_texture1(IDirect3DTexture *iface)
{
......
......@@ -4931,7 +4931,7 @@ HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface)
}
HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddraw,
DDSURFACEDESC2 *desc, UINT mip_level, WINED3DSURFTYPE surface_type)
DDSURFACEDESC2 *desc, UINT mip_level, WINED3DSURFTYPE surface_type, UINT version)
{
struct wined3d_resource_desc wined3d_desc;
struct wined3d_resource *wined3d_resource;
......@@ -5005,7 +5005,7 @@ HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddr
surface->IDirect3DTexture2_vtbl = &d3d_texture2_vtbl;
surface->IDirect3DTexture_vtbl = &d3d_texture1_vtbl;
surface->ref = 1;
surface->version = 7;
surface->version = version;
surface->ddraw = ddraw;
copy_to_surfacedesc2(&surface->surface_desc, desc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment