ddraw: Introduce a separate function for texture creation.

This commit is contained in:
Henri Verbeet 2011-04-19 20:05:50 +02:00 committed by Alexandre Julliard
parent 2b1b5dba43
commit 5492560cb5
3 changed files with 31 additions and 40 deletions

View File

@ -3395,48 +3395,10 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
object->ifaceToRelease = (IUnknown *)&ddraw->IDirectDraw7_iface;
/* Create a WineD3DTexture if a texture was requested */
if(desc2.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
if (desc2.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
{
enum wined3d_format_id Format;
UINT levels;
WINED3DPOOL Pool = WINED3DPOOL_DEFAULT;
ddraw->tex_root = object;
if(desc2.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
{
/* a mipmap is created, create enough levels */
levels = desc2.u2.dwMipMapCount;
}
else
{
/* No mipmap is created, create one level */
levels = 1;
}
/* DDSCAPS_SYSTEMMEMORY textures are in WINED3DPOOL_SYSTEMMEM */
if(DDSD->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
{
Pool = WINED3DPOOL_SYSTEMMEM;
}
/* Should I forward the MANAGED cap to the managed pool ? */
/* Get the format. It's set already by CreateNewSurface */
Format = PixelFormat_DD2WineD3D(&object->surface_desc.u4.ddpfPixelFormat);
/* The surfaces are already created, the callback only
* passes the IWineD3DSurface to WineD3D
*/
if(desc2.ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
{
hr = IWineD3DDevice_CreateCubeTexture(ddraw->wineD3DDevice, DDSD->dwWidth, levels, 0,
Format, Pool, object, &ddraw_null_wined3d_parent_ops, &object->wined3d_texture);
}
else
{
hr = IWineD3DDevice_CreateTexture(ddraw->wineD3DDevice, DDSD->dwWidth, DDSD->dwHeight,
levels, 0, Format, Pool, object, &ddraw_null_wined3d_parent_ops, &object->wined3d_texture);
}
ddraw_surface_create_texture(object);
ddraw->tex_root = NULL;
}

View File

@ -219,6 +219,7 @@ struct IDirectDrawSurfaceImpl
DWORD Handle;
};
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;

View File

@ -3490,6 +3490,34 @@ static const struct IDirect3DTextureVtbl d3d_texture1_vtbl =
d3d_texture1_Unload,
};
HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface)
{
const DDSURFACEDESC2 *desc = &surface->surface_desc;
enum wined3d_format_id format;
WINED3DPOOL pool;
UINT levels;
if (desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
levels = desc->u2.dwMipMapCount;
else
levels = 1;
/* DDSCAPS_SYSTEMMEMORY textures are in WINED3DPOOL_SYSTEMMEM.
* Should I forward the MANAGED cap to the managed pool? */
if (desc->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
pool = WINED3DPOOL_SYSTEMMEM;
else
pool = WINED3DPOOL_DEFAULT;
format = PixelFormat_DD2WineD3D(&surface->surface_desc.u4.ddpfPixelFormat);
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
return IWineD3DDevice_CreateCubeTexture(surface->ddraw->wineD3DDevice, desc->dwWidth,
levels, 0, format, pool, surface, &ddraw_null_wined3d_parent_ops, &surface->wined3d_texture);
else
return IWineD3DDevice_CreateTexture(surface->ddraw->wineD3DDevice, desc->dwWidth, desc->dwHeight,
levels, 0, format, pool, surface, &ddraw_null_wined3d_parent_ops, &surface->wined3d_texture);
}
HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddraw,
DDSURFACEDESC2 *desc, UINT mip_level, WINED3DSURFTYPE surface_type)
{