Henri Verbeet : ddraw: Get rid of CreateSurface().
Alexandre Julliard
julliard at winehq.org
Fri Nov 29 13:24:27 CST 2013
Module: wine
Branch: master
Commit: 69ebf9de540a71acc8bb4c1e83ca7a5071d88371
URL: http://source.winehq.org/git/wine.git/?a=commit;h=69ebf9de540a71acc8bb4c1e83ca7a5071d88371
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Thu Nov 28 09:55:42 2013 +0100
ddraw: Get rid of CreateSurface().
---
dlls/ddraw/ddraw.c | 120 ++------------------------------------------
dlls/ddraw/ddraw_private.h | 4 +-
dlls/ddraw/surface.c | 15 +++++-
3 files changed, 19 insertions(+), 120 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 9645c2d..d2d762d 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -2731,118 +2731,6 @@ static HRESULT WINAPI ddraw7_StartModeTest(IDirectDraw7 *iface, SIZE *Modes, DWO
return DD_OK;
}
-/*****************************************************************************
- * IDirectDraw7::CreateSurface
- *
- * Creates a new IDirectDrawSurface object and returns its interface.
- *
- * The surface connections with wined3d are a bit tricky. Basically it works
- * like this:
- *
- * |------------------------| |-----------------|
- * | DDraw surface | | WineD3DSurface |
- * | | | |
- * | WineD3DSurface |-------------->| |
- * | Child |<------------->| Parent |
- * |------------------------| |-----------------|
- *
- * The DDraw surface is the parent of the wined3d surface, and it releases
- * the WineD3DSurface when the ddraw surface is destroyed.
- *
- * However, for all surfaces which can be in a container in WineD3D,
- * we have to do this. These surfaces are usually complex surfaces,
- * so this concerns primary surfaces with a front and a back buffer,
- * and textures.
- *
- * |------------------------| |-----------------|
- * | DDraw surface | | Container |
- * | | | |
- * | Child |<------------->| Parent |
- * | Texture |<------------->| |
- * | WineD3DSurface |<----| | Levels |<--|
- * | Complex connection | | | | |
- * |------------------------| | |-----------------| |
- * ^ | |
- * | | |
- * | | |
- * | |------------------| | |-----------------| |
- * | | IParent | |-------->| WineD3DSurface | |
- * | | | | | |
- * | | Child |<------------->| Parent | |
- * | | | | Container |<--|
- * | |------------------| |-----------------| |
- * | |
- * | |----------------------| |
- * | | DDraw surface 2 | |
- * | | | |
- * |<->| Complex root Child | |
- * | | Texture | |
- * | | WineD3DSurface |<----| |
- * | |----------------------| | |
- * | | |
- * | |---------------------| | |-----------------| |
- * | | IParent | |----->| WineD3DSurface | |
- * | | | | | |
- * | | Child |<---------->| Parent | |
- * | |---------------------| | Container |<--|
- * | |-----------------| |
- * | |
- * | ---More surfaces can follow--- |
- *
- * The reason is that the IWineD3DSwapchain(render target container)
- * and the IWineD3DTexure(Texture container) release the parents
- * of their surface's children, but by releasing the complex root
- * the surfaces which are complexly attached to it are destroyed
- * too. See IDirectDrawSurface::Release for a more detailed
- * explanation.
- *
- * Params:
- * DDSD: Description of the surface to create
- * Surf: Address to store the interface pointer at
- * UnkOuter: Basically for aggregation support, but ddraw doesn't support
- * aggregation, so it has to be NULL
- *
- * Returns:
- * DD_OK on success
- * CLASS_E_NOAGGREGATION if UnkOuter != NULL
- * DDERR_* if an error occurs
- *
- *****************************************************************************/
-static HRESULT CreateSurface(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
- struct ddraw_surface **surface, IUnknown *UnkOuter, UINT version)
-{
- struct ddraw_surface *object = NULL;
- HRESULT hr;
-
- TRACE("ddraw %p, surface_desc %p, surface %p, outer_unknown %p.\n", ddraw, surface_desc, surface, UnkOuter);
-
- if (UnkOuter != NULL)
- {
- FIXME("(%p) : outer != NULL?\n", ddraw);
- return CLASS_E_NOAGGREGATION; /* unchecked */
- }
-
- if (!surface)
- {
- FIXME("(%p) You want to get back a surface? Don't give NULL ptrs!\n", ddraw);
- return E_POINTER; /* unchecked */
- }
-
- if (FAILED(hr = ddraw_surface_create_texture(ddraw, surface_desc, version, &object)))
- {
- WARN("Failed to create texture, hr %#x.\n", hr);
- return hr;
- }
- object->is_complex_root = TRUE;
-
- *surface = object;
-
- if (surface_desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
- ddraw->primary = object;
-
- return hr;
-}
-
static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface, DDSURFACEDESC2 *surface_desc,
IDirectDrawSurface7 **surface, IUnknown *outer_unknown)
{
@@ -2882,7 +2770,7 @@ static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface, DDSURFACEDESC2 *
return DDERR_INVALIDCAPS;
}
- hr = CreateSurface(ddraw, surface_desc, &impl, outer_unknown, 7);
+ hr = ddraw_surface_create(ddraw, surface_desc, &impl, outer_unknown, 7);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@@ -2936,7 +2824,7 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
return DDERR_INVALIDCAPS;
}
- hr = CreateSurface(ddraw, surface_desc, &impl, outer_unknown, 4);
+ hr = ddraw_surface_create(ddraw, surface_desc, &impl, outer_unknown, 4);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@@ -2992,7 +2880,7 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
return DDERR_INVALIDCAPS;
}
- hr = CreateSurface(ddraw, &surface_desc2, &impl, outer_unknown, 2);
+ hr = ddraw_surface_create(ddraw, &surface_desc2, &impl, outer_unknown, 2);
wined3d_mutex_unlock();
if (FAILED(hr))
{
@@ -3037,7 +2925,7 @@ static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
* primaries anyway. */
surface_desc->ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
DDSD_to_DDSD2(surface_desc, &surface_desc2);
- hr = CreateSurface(ddraw, &surface_desc2, &impl, outer_unknown, 1);
+ hr = ddraw_surface_create(ddraw, &surface_desc2, &impl, outer_unknown, 1);
wined3d_mutex_unlock();
if (FAILED(hr))
{
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 94f5453..b6f5170 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -193,8 +193,8 @@ struct ddraw_texture
struct ddraw_surface *root;
};
-HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, const DDSURFACEDESC2 *desc,
- unsigned int version, struct ddraw_surface **surface) DECLSPEC_HIDDEN;
+HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
+ struct ddraw_surface **surface, IUnknown *outer_unknown, unsigned int version) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index ee5f2eb..d6a948d 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -5589,8 +5589,8 @@ static HRESULT CDECL ddraw_reset_enum_callback(struct wined3d_resource *resource
return DD_OK;
}
-HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
- unsigned int version, struct ddraw_surface **surface)
+HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
+ struct ddraw_surface **surface, IUnknown *outer_unknown, unsigned int version)
{
struct ddraw_surface *root, *mip, **attach;
struct wined3d_resource_desc wined3d_desc;
@@ -5602,12 +5602,20 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, const DDSURFACEDESC2 *
UINT layers, levels, i, j;
HRESULT hr;
+ TRACE("ddraw %p, surface_desc %p, surface %p, outer_unknown %p, version %u.\n",
+ ddraw, surface_desc, surface, outer_unknown, version);
if (TRACE_ON(ddraw))
{
TRACE("Requesting surface desc:\n");
DDRAW_dump_surface_desc(surface_desc);
}
+ if (outer_unknown)
+ return CLASS_E_NOAGGREGATION;
+
+ if (!surface)
+ return E_POINTER;
+
if (!(texture = HeapAlloc(GetProcessHeap(), 0, sizeof(*texture))))
return E_OUTOFMEMORY;
@@ -5915,6 +5923,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, const DDSURFACEDESC2 *
resource = wined3d_texture_get_sub_resource(wined3d_texture, 0);
root = wined3d_resource_get_parent(resource);
root->wined3d_texture = wined3d_texture;
+ root->is_complex_root = TRUE;
texture->root = root;
for (i = 0; i < layers; ++i)
@@ -6010,6 +6019,8 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, const DDSURFACEDESC2 *
}
}
+ if (surface_desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+ ddraw->primary = root;
*surface = root;
return DD_OK;
More information about the wine-cvs
mailing list