diff --git a/dll/directx/wine/ddraw/ddraw.c b/dll/directx/wine/ddraw/ddraw.c index e5205c0d00..16bba4cb34 100644 --- a/dll/directx/wine/ddraw/ddraw.c +++ b/dll/directx/wine/ddraw/ddraw.c @@ -1,4 +1,4 @@ -/* +/* * Copyright 1997-2000 Marcus Meissner * Copyright 1998-2000 Lionel Ulmer * Copyright 2000-2001 TransGaming Technologies Inc. @@ -50,7 +50,6 @@ static struct enum_device_entry char interface_name[100]; char device_name[100]; const GUID *device_guid; - DWORD remove_caps; } device_list7[] = { /* T&L HAL device */ @@ -58,7 +57,6 @@ static struct enum_device_entry "WINE Direct3D7 Hardware Transform and Lighting acceleration using WineD3D", "Wine D3D7 T&L HAL", &IID_IDirect3DTnLHalDevice, - 0, }, /* HAL device */ @@ -66,7 +64,6 @@ static struct enum_device_entry "WINE Direct3D7 Hardware acceleration using WineD3D", "Direct3D HAL", &IID_IDirect3DHALDevice, - 0, }, /* RGB device */ @@ -74,7 +71,6 @@ static struct enum_device_entry "WINE Direct3D7 RGB Software Emulation using WineD3D", "Wine D3D7 RGB", &IID_IDirect3DRGBDevice, - D3DDEVCAPS_HWTRANSFORMANDLIGHT, }, }; @@ -633,7 +629,6 @@ static HRESULT ddraw_create_swapchain(struct ddraw *ddraw, HWND window, BOOL win swapchain_desc.backbuffer_width = mode.width; swapchain_desc.backbuffer_height = mode.height; swapchain_desc.backbuffer_format = mode.format_id; - swapchain_desc.backbuffer_usage = WINED3DUSAGE_RENDERTARGET; swapchain_desc.swap_effect = WINED3D_SWAP_EFFECT_COPY; swapchain_desc.device_window = window; swapchain_desc.windowed = windowed; @@ -1439,28 +1434,6 @@ HRESULT ddraw_get_d3dcaps(const struct ddraw *ddraw, D3DDEVICEDESC7 *caps) return DD_OK; } -HRESULT CALLBACK enum_zbuffer(DDPIXELFORMAT *format, void *ctx) -{ - DDCAPS *caps = ctx; - - switch (format->u1.dwZBufferBitDepth) - { - case 8: - caps->dwZBufferBitDepths |= DDBD_8; - break; - case 16: - caps->dwZBufferBitDepths |= DDBD_16; - break; - case 24: - caps->dwZBufferBitDepths |= DDBD_24; - break; - case 32: - caps->dwZBufferBitDepths |= DDBD_32; - break; - } - return D3DENUMRET_OK; -} - /***************************************************************************** * IDirectDraw7::GetCaps * @@ -1541,10 +1514,6 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD caps.dwCaps |= DDCAPS_ALIGNSTRIDE; caps.dwAlignStrideAlign = DDRAW_STRIDE_ALIGNMENT; - caps.ddsOldCaps.dwCaps = caps.ddsCaps.dwCaps; - - IDirect3D7_EnumZBufferFormats(&ddraw->IDirect3D7_iface, &IID_IDirect3DHALDevice, enum_zbuffer, &caps); - if(DriverCaps) { DD_STRUCT_COPY_BYSIZE(DriverCaps, &caps); @@ -2092,14 +2061,7 @@ static HRESULT WINAPI d3d1_Initialize(IDirect3D *iface, REFIID riid) *****************************************************************************/ static HRESULT WINAPI ddraw7_FlipToGDISurface(IDirectDraw7 *iface) { - struct ddraw *ddraw = impl_from_IDirectDraw7(iface); - - TRACE("iface %p.\n", iface); - - ddraw->flags |= DDRAW_GDI_FLIP; - - if (ddraw->primary) - ddraw_surface_update_frontbuffer(ddraw->primary, NULL, FALSE); + FIXME("iface %p stub!\n", iface); return DD_OK; } @@ -2501,7 +2463,9 @@ static HRESULT WINAPI ddraw7_EnumDisplayModes(IDirectDraw7 *iface, DWORD Flags, struct wined3d_display_mode *new_enum_modes; enum_mode_array_size *= 2; - if (!(new_enum_modes = heap_realloc(enum_modes, enum_mode_array_size * sizeof(*new_enum_modes)))) + new_enum_modes = HeapReAlloc(GetProcessHeap(), 0, enum_modes, + sizeof(*new_enum_modes) * enum_mode_array_size); + if (!new_enum_modes) { heap_free(enum_modes); wined3d_mutex_unlock(); @@ -3229,97 +3193,46 @@ static HRESULT WINAPI ddraw7_EnumSurfaces(IDirectDraw7 *iface, DWORD Flags, { struct ddraw *ddraw = impl_from_IDirectDraw7(iface); struct ddraw_surface *surf; - DWORD match_flags = Flags & (DDENUMSURFACES_ALL | DDENUMSURFACES_NOMATCH | DDENUMSURFACES_MATCH); + BOOL all, nomatch; + DDSURFACEDESC2 desc; + struct list *entry, *entry2; TRACE("iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n", iface, Flags, DDSD, Context, Callback); + all = Flags & DDENUMSURFACES_ALL; + nomatch = Flags & DDENUMSURFACES_NOMATCH; + if (!Callback) return DDERR_INVALIDPARAMS; - if (Flags & DDENUMSURFACES_CANBECREATED) - { - IDirectDrawSurface7 *surface; - DDSURFACEDESC2 testdesc; - HRESULT hr; - - if (match_flags != DDENUMSURFACES_MATCH) - return DDERR_INVALIDPARAMS; - - if (!DDSD) - return DDERR_INVALIDPARAMS; + wined3d_mutex_lock(); - memcpy(&testdesc, DDSD, sizeof(testdesc)); - if (!(testdesc.dwFlags & DDSD_WIDTH)) - { - testdesc.dwFlags |= DDSD_WIDTH; - testdesc.dwWidth = 512; - } - if (!(testdesc.dwFlags & DDSD_HEIGHT)) - { - testdesc.dwFlags |= DDSD_HEIGHT; - testdesc.dwHeight = 512; - } + /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */ + LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list) + { + surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry); - hr = IDirectDraw7_CreateSurface(iface, &testdesc, &surface, NULL); - if (SUCCEEDED(hr)) + if (!surf->iface_count) { - surf = unsafe_impl_from_IDirectDrawSurface7(surface); - Callback(NULL, &surf->surface_desc, Context); - IDirectDrawSurface7_Release(surface); + WARN("Not enumerating surface %p because it doesn't have any references.\n", surf); + continue; } - else - ERR("Failed to create surface, hr %#x.\n", hr); - } - else if (Flags & DDENUMSURFACES_DOESEXIST) - { - BOOL all, nomatch; - DDSURFACEDESC2 desc; - struct list *entry, *entry2; - - /* a combination of match flags is not allowed */ - if (match_flags != 0 && - match_flags != DDENUMSURFACES_ALL && - match_flags != DDENUMSURFACES_MATCH && - match_flags != DDENUMSURFACES_NOMATCH) - return DDERR_INVALIDPARAMS; - - all = (Flags & DDENUMSURFACES_ALL) != 0; - nomatch = (Flags & DDENUMSURFACES_NOMATCH) != 0; - if (!all && !DDSD) - return DDERR_INVALIDPARAMS; - - wined3d_mutex_lock(); - - /* Use the _SAFE enumeration, the app may destroy enumerated surfaces */ - LIST_FOR_EACH_SAFE(entry, entry2, &ddraw->surface_list) + if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc))) { - surf = LIST_ENTRY(entry, struct ddraw_surface, surface_list_entry); - - if (!surf->iface_count) - { - WARN("Not enumerating surface %p because it doesn't have any references.\n", surf); - continue; - } - - if (all || (nomatch != ddraw_match_surface_desc(DDSD, &surf->surface_desc))) + TRACE("Enumerating surface %p.\n", surf); + desc = surf->surface_desc; + IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface); + if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK) { - TRACE("Enumerating surface %p.\n", surf); - desc = surf->surface_desc; - IDirectDrawSurface7_AddRef(&surf->IDirectDrawSurface7_iface); - if (Callback(&surf->IDirectDrawSurface7_iface, &desc, Context) != DDENUMRET_OK) - { - wined3d_mutex_unlock(); - return DD_OK; - } + wined3d_mutex_unlock(); + return DD_OK; } } - - wined3d_mutex_unlock(); } - else - return DDERR_INVALIDPARAMS; + + wined3d_mutex_unlock(); return DD_OK; } @@ -3715,7 +3628,6 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA { struct ddraw *ddraw = impl_from_IDirect3D7(iface); D3DDEVICEDESC7 device_desc7; - DWORD dev_caps; HRESULT hr; size_t i; @@ -3732,15 +3644,11 @@ static HRESULT WINAPI d3d7_EnumDevices(IDirect3D7 *iface, LPD3DENUMDEVICESCALLBA return hr; } - dev_caps = device_desc7.dwDevCaps; - - for (i = 0; i < ARRAY_SIZE(device_list7); i++) + for (i = 0; i < sizeof(device_list7)/sizeof(device_list7[0]); i++) { HRESULT ret; device_desc7.deviceGUID = *device_list7[i].device_guid; - device_desc7.dwDevCaps = dev_caps & ~device_list7[i].remove_caps; - ret = callback(device_list7[i].interface_name, device_list7[i].device_name, &device_desc7, context); if (ret != DDENUMRET_OK) { @@ -4137,8 +4045,8 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd if (!fds || !fdr) return DDERR_INVALIDPARAMS; - if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH) || (fdr->dwSize != sizeof(D3DFINDDEVICERESULT1) && - fdr->dwSize != sizeof(D3DFINDDEVICERESULT2) && fdr->dwSize != sizeof(D3DFINDDEVICERESULT))) + if (fds->dwSize != sizeof(D3DFINDDEVICESEARCH) + || fdr->dwSize != sizeof(D3DFINDDEVICERESULT)) return DDERR_INVALIDPARAMS; if ((fds->dwFlags & D3DFDS_COLORMODEL) @@ -4167,24 +4075,8 @@ static HRESULT WINAPI d3d3_FindDevice(IDirect3D3 *iface, D3DFINDDEVICESEARCH *fd /* Now return our own GUID */ ddraw_d3dcaps1_from_7(&desc1, &desc7); fdr->guid = IID_D3DDEVICE_WineD3D; - - if (fdr->dwSize == sizeof(D3DFINDDEVICERESULT1)) - { - D3DFINDDEVICERESULT1 *fdr1 = (D3DFINDDEVICERESULT1 *)fdr; - memcpy(&fdr1->ddHwDesc, &desc1, sizeof(fdr1->ddHwDesc)); - memcpy(&fdr1->ddSwDesc, &desc1, sizeof(fdr1->ddSwDesc)); - } - else if (fdr->dwSize == sizeof(D3DFINDDEVICERESULT2)) - { - D3DFINDDEVICERESULT2 *fdr2 = (D3DFINDDEVICERESULT2 *)fdr; - memcpy(&fdr2->ddHwDesc, &desc1, sizeof(fdr2->ddHwDesc)); - memcpy(&fdr2->ddSwDesc, &desc1, sizeof(fdr2->ddSwDesc)); - } - else - { - fdr->ddHwDesc = desc1; - fdr->ddSwDesc = desc1; - } + fdr->ddHwDesc = desc1; + fdr->ddSwDesc = desc1; TRACE("Returning Wine's wined3d device with (undumped) capabilities.\n"); @@ -4241,7 +4133,7 @@ static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid, TRACE("iface %p, riid %s, surface %p, device %p.\n", iface, debugstr_guid(riid), surface, device); wined3d_mutex_lock(); - if (SUCCEEDED(hr = d3d_device_create(ddraw, riid, target, (IUnknown *)surface, 7, &object, NULL))) + if (SUCCEEDED(hr = d3d_device_create(ddraw, target, (IUnknown *)surface, 7, &object, NULL))) { *device = &object->IDirect3DDevice7_iface; } @@ -4270,7 +4162,7 @@ static HRESULT WINAPI d3d3_CreateDevice(IDirect3D3 *iface, REFCLSID riid, return CLASS_E_NOAGGREGATION; wined3d_mutex_lock(); - if (SUCCEEDED(hr = d3d_device_create(ddraw, riid, surface_impl, (IUnknown *)surface, 3, &device_impl, NULL))) + if (SUCCEEDED(hr = d3d_device_create(ddraw, surface_impl, (IUnknown *)surface, 3, &device_impl, NULL))) { *device = &device_impl->IDirect3DDevice3_iface; } @@ -4296,7 +4188,7 @@ static HRESULT WINAPI d3d2_CreateDevice(IDirect3D2 *iface, REFCLSID riid, iface, debugstr_guid(riid), surface, device); wined3d_mutex_lock(); - if (SUCCEEDED(hr = d3d_device_create(ddraw, riid, surface_impl, (IUnknown *)surface, 2, &device_impl, NULL))) + if (SUCCEEDED(hr = d3d_device_create(ddraw, surface_impl, (IUnknown *)surface, 2, &device_impl, NULL))) { *device = &device_impl->IDirect3DDevice2_iface; } @@ -4807,12 +4699,11 @@ struct wined3d_vertex_declaration *ddraw_find_decl(struct ddraw *This, DWORD fvf fvf, This, &ddraw_null_wined3d_parent_ops, &pDecl); if (hr != S_OK) return NULL; - if (This->declArraySize == This->numConvertedDecls) - { - unsigned int grow = max(This->declArraySize / 2, 8); - - if (!(convertedDecls = heap_realloc(convertedDecls, - (This->numConvertedDecls + grow) * sizeof(*convertedDecls)))) + if(This->declArraySize == This->numConvertedDecls) { + int grow = max(This->declArraySize / 2, 8); + convertedDecls = HeapReAlloc(GetProcessHeap(), 0, convertedDecls, + sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow)); + if (!convertedDecls) { wined3d_vertex_declaration_decref(pDecl); return NULL; diff --git a/dll/directx/wine/ddraw/ddraw_private.h b/dll/directx/wine/ddraw/ddraw_private.h index cac38c57e9..99f9efdb6a 100644 --- a/dll/directx/wine/ddraw/ddraw_private.h +++ b/dll/directx/wine/ddraw/ddraw_private.h @@ -1,4 +1,4 @@ -/* +/* * Copyright 2006 Stefan Dösinger * * This library is free software; you can redistribute it and/or @@ -19,6 +19,7 @@ #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H +#include #include #include #define COBJMACROS @@ -39,6 +40,11 @@ #include "wine/list.h" #include "wine/wined3d.h" +#define WINED3D_POOL_DEFAULT 0x0 +#define WINED3D_POOL_MANAGED 0x1 +#define WINED3D_POOL_SYSTEM_MEM 0x2 +#define WINED3D_POOL_SCRATCH 0x3 + extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN; extern DWORD force_refresh_rate DECLSPEC_HIDDEN; @@ -348,8 +354,14 @@ struct d3d_device struct wined3d_vec4 user_clip_planes[D3DMAXUSERCLIPPLANES]; }; +#if 1 +HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface, + UINT version, struct d3d_device **device, IUnknown *outer_unknown) +#else HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_surface *target, IUnknown *rt_iface, - UINT version, struct d3d_device **device, IUnknown *outer_unknown) DECLSPEC_HIDDEN; + UINT version, struct d3d_device **device, IUnknown *outer_unknown) +#endif + DECLSPEC_HIDDEN; enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device *device) DECLSPEC_HIDDEN; /* The IID */ diff --git a/dll/directx/wine/ddraw/device.c b/dll/directx/wine/ddraw/device.c index 24dbd3be50..4d8eb85a41 100644 --- a/dll/directx/wine/ddraw/device.c +++ b/dll/directx/wine/ddraw/device.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 1998-2004 Lionel Ulmer * Copyright (c) 2002-2005 Christian Costa * Copyright (c) 2006-2009, 2011-2013 Stefan Dösinger @@ -6903,7 +6903,7 @@ enum wined3d_depth_buffer_type d3d_device_update_depth_stencil(struct d3d_device return WINED3D_ZB_TRUE; } -static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, BOOL hw, +static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface, UINT version, IUnknown *outer_unknown) { static const D3DMATRIX ident = @@ -6926,7 +6926,6 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, B device->IUnknown_inner.lpVtbl = &d3d_device_inner_vtbl; device->ref = 1; device->version = version; - device->hw = hw; if (outer_unknown) device->outer_unknown = outer_unknown; @@ -6977,18 +6976,19 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, B return D3D_OK; } +#if 1 +HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface, + UINT version, struct d3d_device **device, IUnknown *outer_unknown) +#else HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_surface *target, IUnknown *rt_iface, UINT version, struct d3d_device **device, IUnknown *outer_unknown) +#endif { struct d3d_device *object; - BOOL hw = TRUE; HRESULT hr; - TRACE("ddraw %p, guid %s, target %p, version %u, device %p, outer_unknown %p.\n", - ddraw, debugstr_guid(guid), target, version, device, outer_unknown); - - if (IsEqualGUID(guid, &IID_IDirect3DRGBDevice)) - hw = FALSE; + TRACE("ddraw %p, target %p, version %u, device %p, outer_unknown %p.\n", + ddraw, target, version, device, outer_unknown); if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) || (target->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER)) @@ -7003,7 +7003,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_su return DDERR_NOPALETTEATTACHED; } - if (hw && !(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) + if (!(target->surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) { WARN("Surface %p is not in video memory.\n", target); return D3DERR_SURFACENOTINVIDMEM; @@ -7029,7 +7029,7 @@ HRESULT d3d_device_create(struct ddraw *ddraw, const GUID *guid, struct ddraw_su return DDERR_OUTOFMEMORY; } - if (FAILED(hr = d3d_device_init(object, ddraw, hw, target, rt_iface, version, outer_unknown))) + if (FAILED(hr = d3d_device_init(object, ddraw, target, rt_iface, version, outer_unknown))) { WARN("Failed to initialize device, hr %#x.\n", hr); heap_free(object); diff --git a/dll/directx/wine/ddraw/surface.c b/dll/directx/wine/ddraw/surface.c index 11a0e6ba8d..cdb5a513f2 100644 --- a/dll/directx/wine/ddraw/surface.c +++ b/dll/directx/wine/ddraw/surface.c @@ -1,4 +1,4 @@ -/* DirectDraw Surface Implementation +/* DirectDraw Surface Implementation * * Copyright (c) 1997-2000 Marcus Meissner * Copyright (c) 1998-2000 Lionel Ulmer @@ -21,9 +21,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #include "ddraw_private.h" WINE_DEFAULT_DEBUG_CHANNEL(ddraw); @@ -42,7 +39,6 @@ static inline struct ddraw_surface *impl_from_IDirectDrawGammaControl(IDirectDra * to support windowless rendering first. */ HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface, const RECT *rect, BOOL read) { - struct ddraw *ddraw = surface->ddraw; HDC surface_dc, screen_dc; int x, y, w, h; HRESULT hr; @@ -63,14 +59,14 @@ HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface, const RE if (w <= 0 || h <= 0) return DD_OK; - if (ddraw->swapchain_window && !(ddraw->flags & DDRAW_GDI_FLIP)) + if (surface->ddraw->swapchain_window) { /* Nothing to do, we control the frontbuffer, or at least the parts we * care about. */ if (read) return DD_OK; - return wined3d_texture_blt(ddraw->wined3d_frontbuffer, 0, rect, + return wined3d_texture_blt(surface->ddraw->wined3d_frontbuffer, 0, rect, surface->wined3d_texture, surface->sub_resource_idx, rect, 0, NULL, WINED3D_TEXF_POINT); } @@ -209,7 +205,7 @@ static HRESULT WINAPI ddraw_surface7_QueryInterface(IDirectDrawSurface7 *iface, { HRESULT hr; - if (FAILED(hr = d3d_device_create(This->ddraw, riid, This, (IUnknown *)&This->IDirectDrawSurface_iface, + if (FAILED(hr = d3d_device_create(This->ddraw, This, (IUnknown *)&This->IDirectDrawSurface_iface, 1, &This->device1, (IUnknown *)&This->IDirectDrawSurface_iface))) { This->device1 = NULL; @@ -993,8 +989,7 @@ static HRESULT surface_lock(struct ddraw_surface *surface, hr = ddraw_surface_update_frontbuffer(surface, rect, TRUE); if (SUCCEEDED(hr)) hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture), - surface->sub_resource_idx, &map_desc, rect ? &box : NULL, - wined3dmapflags_from_ddrawmapflags(flags)); + surface->sub_resource_idx, &map_desc, rect ? &box : NULL, flags); if (FAILED(hr)) { wined3d_mutex_unlock(); @@ -1507,7 +1502,7 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons return hr; } - if (!(clip_list = heap_alloc(clip_list_size))) + if (!(clip_list = HeapAlloc(GetProcessHeap(), 0, clip_list_size))) { WARN("Failed to allocate clip list.\n"); return E_OUTOFMEMORY; @@ -1517,7 +1512,7 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons &dst_rect, clip_list, &clip_list_size))) { WARN("Failed to get clip list, hr %#x.\n", hr); - heap_free(clip_list); + HeapFree(GetProcessHeap(), 0, clip_list); return hr; } @@ -1551,7 +1546,7 @@ static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, cons } } - heap_free(clip_list); + HeapFree(GetProcessHeap(), 0, clip_list); return hr; } @@ -2070,7 +2065,7 @@ static HRESULT ddraw_surface_delete_attached_surface(struct ddraw_surface *surfa * particular, modify the QueryInterface() pointer in the surface vtbl * but don't cleanup properly after the relevant dll is unloaded. */ if (attachment->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER - && wined3d_device_get_depth_stencil_view(surface->ddraw->wined3d_device) == attachment->wined3d_rtv) + && wined3d_device_get_depth_stencil_view(surface->ddraw->wined3d_device) == surface->wined3d_rtv) wined3d_device_set_depth_stencil_view(surface->ddraw->wined3d_device, NULL); wined3d_mutex_unlock(); @@ -2311,9 +2306,7 @@ static HRESULT WINAPI ddraw_surface7_ReleaseDC(IDirectDrawSurface7 *iface, HDC h HRESULT hr; TRACE("iface %p, dc %p.\n", iface, hdc); -#ifdef __REACTOS__ - GdiFlush(); -#endif + wined3d_mutex_lock(); if (!surface->dc) { @@ -5189,46 +5182,6 @@ static struct ddraw_surface *get_sub_mimaplevel(struct ddraw_surface *surface) return impl_from_IDirectDrawSurface7(next_level); } -static BOOL compare_format(DDPIXELFORMAT *format1, DDPIXELFORMAT *format2) -{ - if ((format1->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_FOURCC)) != - (format2->dwFlags & (DDPF_RGB|DDPF_YUV|DDPF_FOURCC))) - return FALSE; - - if (format1->dwFlags & (DDPF_RGB|DDPF_YUV)) - { - if (!(format1->dwFlags & DDPF_ALPHA)) - { - /* The RGB and YUV bits are stored in the same fields */ - if (format1->u1.dwRGBBitCount != format2->u1.dwRGBBitCount) - return FALSE; - - if (format1->u2.dwRBitMask != format2->u2.dwRBitMask) - return FALSE; - - if (format1->u3.dwGBitMask != format2->u3.dwGBitMask) - return FALSE; - - if (format1->u4.dwBBitMask != format2->u4.dwBBitMask) - return FALSE; - } - - if (format1->dwFlags & (DDPF_ALPHAPIXELS | DDPF_ALPHA)) - { - if (format1->u5.dwRGBAlphaBitMask != format2->u5.dwRGBAlphaBitMask) - return FALSE; - } - } - - if (format1->dwFlags & DDPF_FOURCC) - { - if (format1->dwFourCC != format2->dwFourCC) - return FALSE; - } - - return TRUE; -} - /***************************************************************************** * IDirect3DTexture2::Load * @@ -5250,7 +5203,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu { struct ddraw_surface *dst_surface = impl_from_IDirect3DTexture2(iface); struct ddraw_surface *src_surface = unsafe_impl_from_IDirect3DTexture2(src_texture); - RECT src_rect, dst_rect; + struct wined3d_resource *dst_resource, *src_resource; HRESULT hr; TRACE("iface %p, src_texture %p.\n", iface, src_texture); @@ -5263,60 +5216,90 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu wined3d_mutex_lock(); + dst_resource = wined3d_texture_get_resource(dst_surface->wined3d_texture); + src_resource = wined3d_texture_get_resource(src_surface->wined3d_texture); + + if (((src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) + != (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)) + || (src_surface->surface_desc.u2.dwMipMapCount != dst_surface->surface_desc.u2.dwMipMapCount)) + { + ERR("Trying to load surfaces with different mip-map counts.\n"); + } + for (;;) { - DDSURFACEDESC *src_desc = (DDSURFACEDESC *)&src_surface->surface_desc; + struct ddraw_palette *dst_pal, *src_pal; + DDSURFACEDESC *src_desc, *dst_desc; TRACE("Copying surface %p to surface %p.\n", src_surface, dst_surface); - if (compare_format(&src_surface->surface_desc.u4.ddpfPixelFormat, - &dst_surface->surface_desc.u4.ddpfPixelFormat)) - { - struct ddraw_palette *dst_pal, *src_pal; + /* Suppress the ALLOCONLOAD flag */ + dst_surface->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD; - /* Get the palettes */ - dst_pal = dst_surface->palette; - src_pal = src_surface->palette; + /* Get the palettes */ + dst_pal = dst_surface->palette; + src_pal = src_surface->palette; - if (src_pal) - { - PALETTEENTRY palent[256]; + if (src_pal) + { + PALETTEENTRY palent[256]; - if (!dst_pal) - { - wined3d_mutex_unlock(); - return DDERR_NOPALETTEATTACHED; - } - IDirectDrawPalette_GetEntries(&src_pal->IDirectDrawPalette_iface, 0, 0, 256, palent); - IDirectDrawPalette_SetEntries(&dst_pal->IDirectDrawPalette_iface, 0, 0, 256, palent); + if (!dst_pal) + { + wined3d_mutex_unlock(); + return DDERR_NOPALETTEATTACHED; } + IDirectDrawPalette_GetEntries(&src_pal->IDirectDrawPalette_iface, 0, 0, 256, palent); + IDirectDrawPalette_SetEntries(&dst_pal->IDirectDrawPalette_iface, 0, 0, 256, palent); + } + + /* Copy one surface on the other */ + dst_desc = (DDSURFACEDESC *)&(dst_surface->surface_desc); + src_desc = (DDSURFACEDESC *)&(src_surface->surface_desc); + + if ((src_desc->dwWidth != dst_desc->dwWidth) || (src_desc->dwHeight != dst_desc->dwHeight)) + { + /* Should also check for same pixel format, u1.lPitch, ... */ + ERR("Error in surface sizes.\n"); + wined3d_mutex_unlock(); + return D3DERR_TEXTURE_LOAD_FAILED; + } + else + { + struct wined3d_map_desc src_map_desc, dst_map_desc; + /* Copy the src blit color key if the source has one, don't erase + * the destination's ckey if the source has none */ if (src_desc->dwFlags & DDSD_CKSRCBLT) { IDirectDrawSurface7_SetColorKey(&dst_surface->IDirectDrawSurface7_iface, DDCKEY_SRCBLT, &src_desc->ddckCKSrcBlt); } - } - else - { - if (src_desc->dwFlags & DDSD_CKSRCBLT) - return E_FAIL; - } - /* Suppress the ALLOCONLOAD flag */ - dst_surface->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD; + if (FAILED(hr = wined3d_resource_map(src_resource, + src_surface->sub_resource_idx, &src_map_desc, NULL, 0))) + { + ERR("Failed to lock source surface, hr %#x.\n", hr); + wined3d_mutex_unlock(); + return D3DERR_TEXTURE_LOAD_FAILED; + } - SetRect(&src_rect, 0, 0, src_surface->surface_desc.dwWidth, src_surface->surface_desc.dwHeight); - SetRect(&dst_rect, 0, 0, dst_surface->surface_desc.dwWidth, dst_surface->surface_desc.dwHeight); + if (FAILED(hr = wined3d_resource_map(dst_resource, + dst_surface->sub_resource_idx, &dst_map_desc, NULL, 0))) + { + ERR("Failed to lock destination surface, hr %#x.\n", hr); + wined3d_resource_unmap(src_resource, src_surface->sub_resource_idx); + wined3d_mutex_unlock(); + return D3DERR_TEXTURE_LOAD_FAILED; + } - hr = wined3d_texture_blt(dst_surface->wined3d_texture, dst_surface->sub_resource_idx, &dst_rect, - src_surface->wined3d_texture, src_surface->sub_resource_idx, &src_rect, - 0, NULL, WINED3D_TEXF_LINEAR); - if (FAILED(hr)) - { - ERR("Failed to blit surface, hr %#x.\n", hr); - wined3d_mutex_unlock(); - return hr; + if (dst_surface->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC) + memcpy(dst_map_desc.data, src_map_desc.data, src_surface->surface_desc.u1.dwLinearSize); + else + memcpy(dst_map_desc.data, src_map_desc.data, src_map_desc.row_pitch * src_desc->dwHeight); + + wined3d_resource_unmap(dst_resource, dst_surface->sub_resource_idx); + wined3d_resource_unmap(src_resource, src_surface->sub_resource_idx); } if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) @@ -5329,11 +5312,12 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu else dst_surface = NULL; - if (src_surface && !dst_surface) - return DDERR_NOTFOUND; - if (!src_surface || !dst_surface) + { + if (src_surface != dst_surface) + ERR("Loading surface with different mipmap structure.\n"); break; + } } wined3d_mutex_unlock(); @@ -5563,7 +5547,7 @@ static const struct IDirectDrawSurface2Vtbl ddraw_surface2_vtbl = ddraw_surface2_PageUnlock, }; -static struct IDirectDrawSurfaceVtbl ddraw_surface1_vtbl = +static const struct IDirectDrawSurfaceVtbl ddraw_surface1_vtbl = { /* IUnknown */ ddraw_surface1_QueryInterface, @@ -5763,7 +5747,7 @@ static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *paren wined3d_private_store_cleanup(&surface->private_store); - heap_free(surface); + HeapFree(GetProcessHeap(), 0, surface); } static const struct wined3d_parent_ops ddraw_surface_wined3d_parent_ops = @@ -5775,7 +5759,7 @@ static void STDMETHODCALLTYPE ddraw_texture_wined3d_object_destroyed(void *paren { TRACE("parent %p.\n", parent); - heap_free(parent); + HeapFree(GetProcessHeap(), 0, parent); } static const struct wined3d_parent_ops ddraw_texture_wined3d_parent_ops = @@ -5817,7 +5801,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (!surface) return E_POINTER; - if (!(texture = heap_alloc(sizeof(*texture)))) + if (!(texture = HeapAlloc(GetProcessHeap(), 0, sizeof(*texture)))) return E_OUTOFMEMORY; texture->version = version; @@ -5832,28 +5816,28 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (!(desc->dwFlags & DDSD_BACKBUFFERCOUNT) || !desc->u5.dwBackBufferCount) { WARN("Tried to create a flippable surface without any back buffers.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } if (!(desc->ddsCaps.dwCaps & DDSCAPS_COMPLEX)) { WARN("Tried to create a flippable surface without DDSCAPS_COMPLEX.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP) { WARN("Tried to create a flippable cubemap.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } if (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE) { FIXME("Flippable textures not implemented.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } } @@ -5863,7 +5847,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ { WARN("Tried to specify a back buffer count for a non-flippable surface.\n"); hr = desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP ? DDERR_INVALIDPARAMS : DDERR_INVALIDCAPS; - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return hr; } } @@ -5873,21 +5857,21 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE) { WARN("Tried to create a primary surface with DDSCAPS_TEXTURE.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } if ((desc->ddsCaps.dwCaps & DDSCAPS_COMPLEX) && !(desc->ddsCaps.dwCaps & DDSCAPS_FLIP)) { WARN("Tried to create a flippable primary surface without both DDSCAPS_FLIP and DDSCAPS_COMPLEX.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } if ((desc->ddsCaps.dwCaps & DDSCAPS_FLIP) && !(ddraw->cooperative_level & DDSCL_EXCLUSIVE)) { WARN("Tried to create a flippable primary surface without DDSCL_EXCLUSIVE.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_NOEXCLUSIVEMODE; } } @@ -5897,7 +5881,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ == (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY)) { WARN("Tried to create a surface in both system and video memory.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } @@ -5905,7 +5889,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ && !(desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)) { WARN("Caps %#x require DDSCAPS_TEXTURE.\n", desc->ddsCaps.dwCaps); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } @@ -5913,7 +5897,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ && !(desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)) { WARN("Cube map faces requested without cube map flag.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } @@ -5921,7 +5905,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ && !(desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP_ALLFACES)) { WARN("Cube map without faces requested.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } @@ -5934,14 +5918,14 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (!(desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)) { WARN("DDSCAPS2_TEXTUREMANAGE used without DDSCAPS_TEXTURE, returning DDERR_INVALIDCAPS.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } if (desc->ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY)) { WARN("DDSCAPS2_TEXTUREMANAGE used width DDSCAPS_VIDEOMEMORY " "or DDSCAPS_SYSTEMMEMORY, returning DDERR_INVALIDCAPS.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } } @@ -5949,7 +5933,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (FAILED(hr = wined3d_get_adapter_display_mode(ddraw->wined3d, WINED3DADAPTER_DEFAULT, &mode, NULL))) { ERR("Failed to get display mode, hr %#x.\n", hr); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return hr_ddraw_from_wined3d(hr); } @@ -5966,7 +5950,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (wined3d_desc.format == WINED3DFMT_UNKNOWN) { WARN("Unsupported / unknown pixelformat.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPIXELFORMAT; } @@ -5976,7 +5960,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (!(desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) { WARN("No width / height specified.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } @@ -5987,7 +5971,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (!desc->dwWidth || !desc->dwHeight) { - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } @@ -6012,7 +5996,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ &swapchain_desc, NULL, ddraw_reset_enum_callback, TRUE))) { ERR("Failed to reset device.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return hr_ddraw_from_wined3d(hr); } @@ -6024,7 +6008,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE; wined3d_desc.multisample_quality = 0; wined3d_desc.usage = 0; - wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + wined3d_desc.access = WINED3D_POOL_DEFAULT; wined3d_desc.width = desc->dwWidth; wined3d_desc.height = desc->dwHeight; wined3d_desc.depth = 1; @@ -6046,7 +6030,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ /* Mipmap count is given, should not be 0. */ if (!desc->u2.dwMipMapCount) { - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } } @@ -6107,31 +6091,13 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ == (DDSCAPS_OVERLAY | DDSCAPS_SYSTEMMEMORY)) { WARN("System memory overlays are not allowed.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_NOOVERLAYHW; } if (desc->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) { - /* - * The ddraw RGB device allows to use system memory surfaces as rendering target. - * This does not cause problems because the RGB device does software rasterization - * though it will fail with hardware accelerated ddraw. In order to be partially - * compatible with games requesting explicitly the RGB device, we ignore the - * specified location and try to create rendering targets in video memory if - * possible. - */ - if ((desc->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && - SUCCEEDED(hr = wined3d_check_device_format(ddraw->wined3d, WINED3DADAPTER_DEFAULT, - WINED3D_DEVICE_TYPE_HAL, mode.format_id, WINED3DUSAGE_RENDERTARGET, - WINED3D_RTYPE_TEXTURE_2D, wined3d_desc.format))) - { - FIXME("Application wants to create rendering target in system memory, using video memory instead\n"); - wined3d_desc.usage |= WINED3DUSAGE_RENDERTARGET; - } - else - wined3d_desc.access = WINED3D_RESOURCE_ACCESS_CPU - | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + wined3d_desc.access = WINED3D_POOL_SYSTEM_MEM; } else { @@ -6144,8 +6110,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (desc->ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE)) { - wined3d_desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU - | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + wined3d_desc.access = WINED3D_POOL_MANAGED; /* Managed textures have the system memory flag set. */ desc->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; } @@ -6160,24 +6125,24 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (desc->dwFlags & DDSD_LPSURFACE) { - if (wined3d_desc.access & WINED3D_RESOURCE_ACCESS_GPU) + if (wined3d_desc.access != WINED3D_POOL_SYSTEM_MEM) { - WARN("User memory surfaces should not be GPU accessible.\n"); - heap_free(texture); + WARN("User memory surfaces should be in the system memory pool.\n"); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDCAPS; } if (version < 4) { WARN("User memory surfaces not supported before version 4.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } if (!desc->lpSurface) { WARN("NULL surface memory pointer specified.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } @@ -6186,14 +6151,14 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (version != 4 && (desc->dwFlags & DDSD_PITCH)) { WARN("Pitch specified on a compressed user memory surface.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } if (!(desc->dwFlags & (DDSD_LINEARSIZE | DDSD_PITCH))) { WARN("Compressed user memory surfaces should explicitly specify the linear size.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } @@ -6202,7 +6167,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ wined3d_desc.format, wined3d_desc.width) * ((desc->dwHeight + 3) / 4)) { WARN("Invalid linear size %u specified.\n", desc->u1.dwLinearSize); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } } @@ -6211,7 +6176,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (!(desc->dwFlags & DDSD_PITCH)) { WARN("User memory surfaces should explicitly specify the pitch.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } @@ -6219,7 +6184,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ wined3d_desc.format, wined3d_desc.width) || desc->u1.lPitch & 3) { WARN("Invalid pitch %u specified.\n", desc->u1.lPitch); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_INVALIDPARAMS; } @@ -6237,7 +6202,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ && desc->ddckCKSrcBlt.dwColorSpaceLowValue != desc->ddckCKSrcBlt.dwColorSpaceHighValue)) { WARN("Range color keys not supported, returning DDERR_NOCOLORKEYHW.\n"); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return DDERR_NOCOLORKEYHW; } @@ -6264,7 +6229,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ &ddraw_texture_wined3d_parent_ops, &wined3d_texture))) { WARN("Failed to create wined3d texture, hr %#x.\n", hr); - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); return hr_ddraw_from_wined3d(hr); } @@ -6361,7 +6326,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ attach = &last->complex_array[0]; for (i = 0; i < count; ++i) { - if (!(texture = heap_alloc(sizeof(*texture)))) + if (!(texture = HeapAlloc(GetProcessHeap(), 0, sizeof(*texture)))) { hr = E_OUTOFMEMORY; goto fail; @@ -6383,7 +6348,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ WINED3D_TEXTURE_CREATE_GET_DC_LENIENT, NULL, texture, &ddraw_texture_wined3d_parent_ops, &wined3d_texture))) { - heap_free(texture); + HeapFree(GetProcessHeap(), 0, texture); hr = hr_ddraw_from_wined3d(hr); goto fail; }