Module: wine Branch: master Commit: 5492560cb5bdf0e66bddd395338d7dc7b01207be URL: http://source.winehq.org/git/wine.git/?a=commit;h=5492560cb5bdf0e66bddd39533...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Tue Apr 19 20:05:50 2011 +0200
ddraw: Introduce a separate function for texture creation.
---
dlls/ddraw/ddraw.c | 42 ++---------------------------------------- dlls/ddraw/ddraw_private.h | 1 + dlls/ddraw/surface.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 40 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index cf9c4c3..c2ea683 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -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; }
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 5cc09dd..4c5d4cb 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -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; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index c256819..40fd797 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -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) {