ddraw: Use unsafe_impl_from_IDirectDrawSurface7() for application provided interfaces.

This commit is contained in:
Ričardas Barkauskas 2011-06-06 12:30:23 +03:00 committed by Alexandre Julliard
parent 39b15066b0
commit 28ce1c00a7
4 changed files with 30 additions and 22 deletions

View File

@ -4163,7 +4163,7 @@ static HRESULT WINAPI ddraw1_CreatePalette(IDirectDraw *iface, DWORD flags,
static HRESULT WINAPI ddraw7_DuplicateSurface(IDirectDraw7 *iface,
IDirectDrawSurface7 *Src, IDirectDrawSurface7 **Dest)
{
IDirectDrawSurfaceImpl *Surf = (IDirectDrawSurfaceImpl *)Src;
IDirectDrawSurfaceImpl *Surf = unsafe_impl_from_IDirectDrawSurface7(Src);
FIXME("iface %p, src %p, dst %p partial stub!\n", iface, Src, Dest);
@ -4733,7 +4733,7 @@ static HRESULT WINAPI d3d1_FindDevice(IDirect3D *iface, D3DFINDDEVICESEARCH *fds
static HRESULT WINAPI d3d7_CreateDevice(IDirect3D7 *iface, REFCLSID riid,
IDirectDrawSurface7 *surface, IDirect3DDevice7 **device)
{
IDirectDrawSurfaceImpl *target = (IDirectDrawSurfaceImpl *)surface;
IDirectDrawSurfaceImpl *target = unsafe_impl_from_IDirectDrawSurface7(surface);
IDirectDrawImpl *This = impl_from_IDirect3D7(iface);
IDirect3DDeviceImpl *object;
HRESULT hr;
@ -5714,7 +5714,7 @@ static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *
{
IDirectDrawSurface7 *attached;
IDirectDrawSurface7_GetAttachedSurface((IDirectDrawSurface7 *)ddraw->tex_root, &searchcaps, &attached);
surf = (IDirectDrawSurfaceImpl *)attached;
surf = unsafe_impl_from_IDirectDrawSurface7(attached);
IDirectDrawSurface7_Release(attached);
}
if (!surf) ERR("root search surface not found\n");

View File

@ -226,6 +226,7 @@ static inline IDirectDrawSurfaceImpl *impl_from_IDirectDrawSurface3(IDirectDrawS
}
IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface3(IDirectDrawSurface3 *iface) DECLSPEC_HIDDEN;
IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface) DECLSPEC_HIDDEN;
/* Get the number of bytes per pixel for a given surface */
#define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))

View File

@ -1832,7 +1832,7 @@ IDirect3DDeviceImpl_7_SetRenderTarget(IDirect3DDevice7 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewTarget;
IDirectDrawSurfaceImpl *Target = unsafe_impl_from_IDirectDrawSurface7(NewTarget);
HRESULT hr;
TRACE("iface %p, target %p, flags %#x.\n", iface, NewTarget, Flags);
@ -1900,7 +1900,7 @@ static HRESULT WINAPI IDirect3DDeviceImpl_2_SetRenderTarget(IDirect3DDevice2 *if
IDirectDrawSurface *NewRenderTarget, DWORD Flags)
{
IDirect3DDeviceImpl *This = device_from_device2(iface);
IDirectDrawSurfaceImpl *Target = (IDirectDrawSurfaceImpl *)NewRenderTarget;
IDirectDrawSurfaceImpl *Target = unsafe_impl_from_IDirectDrawSurface3((IDirectDrawSurface3 *)NewRenderTarget);
TRACE("iface %p, target %p, flags %#x.\n", iface, NewRenderTarget, Flags);
@ -4517,7 +4517,7 @@ IDirect3DDeviceImpl_7_SetTexture(IDirect3DDevice7 *iface,
IDirectDrawSurface7 *Texture)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *)Texture;
IDirectDrawSurfaceImpl *surf = unsafe_impl_from_IDirectDrawSurface7(Texture);
HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, Stage, Texture);
@ -5526,7 +5526,7 @@ static HRESULT
IDirect3DDeviceImpl_7_PreLoad(IDirect3DDevice7 *iface,
IDirectDrawSurface7 *Texture)
{
IDirectDrawSurfaceImpl *surf = (IDirectDrawSurfaceImpl *)Texture;
IDirectDrawSurfaceImpl *surf = unsafe_impl_from_IDirectDrawSurface7(Texture);
TRACE("iface %p, texture %p.\n", iface, Texture);
@ -5866,7 +5866,7 @@ static BOOL is_mip_level_subset(IDirectDrawSurfaceImpl *dest,
if (dest_level != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_level);
dest_level = (IDirectDrawSurfaceImpl *)temp;
dest_level = unsafe_impl_from_IDirectDrawSurface7(temp);
}
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
@ -5875,7 +5875,7 @@ static BOOL is_mip_level_subset(IDirectDrawSurfaceImpl *dest,
if (src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
src_level = (IDirectDrawSurfaceImpl *)temp;
src_level = unsafe_impl_from_IDirectDrawSurface7(temp);
}
if (src_level && src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
@ -5967,7 +5967,7 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
if (dest_level != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_level);
dest_level = (IDirectDrawSurfaceImpl *)temp;
dest_level = unsafe_impl_from_IDirectDrawSurface7(temp);
}
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
@ -5976,7 +5976,7 @@ static void copy_mipmap_chain(IDirect3DDeviceImpl *device,
if (src_level != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_level);
src_level = (IDirectDrawSurfaceImpl *)temp;
src_level = unsafe_impl_from_IDirectDrawSurface7(temp);
point.x /= 2;
point.y /= 2;
@ -6025,8 +6025,8 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
DWORD Flags)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IDirectDrawSurfaceImpl *dest = (IDirectDrawSurfaceImpl *)DestTex;
IDirectDrawSurfaceImpl *src = (IDirectDrawSurfaceImpl *)SrcTex;
IDirectDrawSurfaceImpl *dest = unsafe_impl_from_IDirectDrawSurface7(DestTex);
IDirectDrawSurfaceImpl *src = unsafe_impl_from_IDirectDrawSurface7(SrcTex);
POINT destpoint;
RECT srcrect;
@ -6126,7 +6126,7 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
if (src_face != src) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)src_face);
src_face = (IDirectDrawSurfaceImpl *)temp;
src_face = unsafe_impl_from_IDirectDrawSurface7(temp);
}
else
{
@ -6144,7 +6144,7 @@ IDirect3DDeviceImpl_7_Load(IDirect3DDevice7 *iface,
if (dest_face != dest) IDirectDrawSurface7_Release((IDirectDrawSurface7 *)dest_face);
dest_face = (IDirectDrawSurfaceImpl *)temp;
dest_face = unsafe_impl_from_IDirectDrawSurface7(temp);
}
else
{

View File

@ -740,7 +740,7 @@ static HRESULT WINAPI ddraw_surface3_Unlock(IDirectDrawSurface3 *iface, void *da
static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDrawSurface7 *DestOverride, DWORD Flags)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Override = (IDirectDrawSurfaceImpl *)DestOverride;
IDirectDrawSurfaceImpl *Override = unsafe_impl_from_IDirectDrawSurface7(DestOverride);
IDirectDrawSurface7 *Override7;
HRESULT hr;
@ -810,7 +810,7 @@ static HRESULT WINAPI ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *DestR
IDirectDrawSurface7 *SrcSurface, RECT *SrcRect, DWORD Flags, DDBLTFX *DDBltFx)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Src = (IDirectDrawSurfaceImpl *)SrcSurface;
IDirectDrawSurfaceImpl *Src = unsafe_impl_from_IDirectDrawSurface7(SrcSurface);
HRESULT hr;
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
@ -973,7 +973,7 @@ static HRESULT ddraw_surface_attach_surface(IDirectDrawSurfaceImpl *This, IDirec
static HRESULT WINAPI ddraw_surface7_AddAttachedSurface(IDirectDrawSurface7 *iface, IDirectDrawSurface7 *Attach)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Surf = (IDirectDrawSurfaceImpl *)Attach;
IDirectDrawSurfaceImpl *Surf = unsafe_impl_from_IDirectDrawSurface7(Attach);
TRACE("iface %p, attachment %p.\n", iface, Attach);
@ -1046,7 +1046,7 @@ static HRESULT WINAPI ddraw_surface7_DeleteAttachedSurface(IDirectDrawSurface7 *
DWORD Flags, IDirectDrawSurface7 *Attach)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Surf = (IDirectDrawSurfaceImpl *)Attach;
IDirectDrawSurfaceImpl *Surf = unsafe_impl_from_IDirectDrawSurface7(Attach);
IDirectDrawSurfaceImpl *Prev = This;
TRACE("iface %p, flags %#x, attachment %p.\n", iface, Flags, Attach);
@ -2100,7 +2100,7 @@ static HRESULT WINAPI ddraw_surface7_UpdateOverlay(IDirectDrawSurface7 *iface, R
IDirectDrawSurface7 *DstSurface, RECT *DstRect, DWORD Flags, DDOVERLAYFX *FX)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Dst = (IDirectDrawSurfaceImpl *)DstSurface;
IDirectDrawSurfaceImpl *Dst = unsafe_impl_from_IDirectDrawSurface7(DstSurface);
HRESULT hr;
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
@ -2174,7 +2174,7 @@ static HRESULT WINAPI ddraw_surface7_UpdateOverlayZOrder(IDirectDrawSurface7 *if
DWORD Flags, IDirectDrawSurface7 *DDSRef)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *Ref = (IDirectDrawSurfaceImpl *)DDSRef;
IDirectDrawSurfaceImpl *Ref = unsafe_impl_from_IDirectDrawSurface7(DDSRef);
HRESULT hr;
TRACE("iface %p, flags %#x, reference %p.\n", iface, Flags, DDSRef);
@ -2390,7 +2390,7 @@ static HRESULT WINAPI ddraw_surface7_BltFast(IDirectDrawSurface7 *iface, DWORD d
IDirectDrawSurface7 *Source, RECT *rsrc, DWORD trans)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)iface;
IDirectDrawSurfaceImpl *src = (IDirectDrawSurfaceImpl *)Source;
IDirectDrawSurfaceImpl *src = unsafe_impl_from_IDirectDrawSurface7(Source);
DWORD src_w, src_h, dst_w, dst_h;
HRESULT hr;
@ -3443,6 +3443,13 @@ static const struct IDirect3DTextureVtbl d3d_texture1_vtbl =
d3d_texture1_Unload,
};
IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface)
{
if (!iface) return NULL;
assert(iface->lpVtbl == &ddraw_surface7_vtbl);
return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, lpVtbl);
}
IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface3(IDirectDrawSurface3 *iface)
{
if (!iface) return NULL;