Complete the dummy of HAL.

CreateDirectDraw and CreateDirectDrawEx
will return a pointer of ddraw object.
only hardware acclration support are being add.
noting real working yet. 

svn path=/trunk/; revision=14211
This commit is contained in:
Magnus Olsen 2005-03-20 09:58:10 +00:00
parent f0e4451f31
commit a98111e50f
3 changed files with 845 additions and 818 deletions

View file

@ -76,27 +76,30 @@ HRESULT DDRAW_Create(
LPGUID lpGUID, LPVOID *lplpDD, LPUNKNOWN pUnkOuter, REFIID iid, BOOL ex) LPGUID lpGUID, LPVOID *lplpDD, LPUNKNOWN pUnkOuter, REFIID iid, BOOL ex)
{ {
HRESULT hr;
//HDC desktop; /* TODO 1:
/* BOOL ex == TRUE it is DirectDrawCreateEx call here. */
/* TODO:
check the GUID are right check the GUID are right
add scanner that DirectDrawCreate / DirectDrawCreateEx select right driver. add scanner that DirectDrawCreate / DirectDrawCreateEx select right driver.
now we will assume it is the current display driver now we will assume it is the current display driver
*/ */
/* TODO 2:
do not only use hardware mode.
*/
hr = HAL_DirectDraw_Create(lpGUID, lplpDD, pUnkOuter, iid, ex);
/* old code
//HDC desktop;
/*
desktop = GetWindowDC(GetDesktopWindow()); desktop = GetWindowDC(GetDesktopWindow());
lplpDD = OsThunkDdCreateDirectDrawObject(desktop); lplpDD = OsThunkDdCreateDirectDrawObject(desktop);
if (lplpDD == NULL) return DDERR_NODIRECTDRAWHW; if (lplpDD == NULL) return DDERR_NODIRECTDRAWHW;
*/ */
return DDERR_NODIRECTDRAWHW; return hr;
} }
BOOL WINAPI DllMain(HINSTANCE hInstance,DWORD fwdReason, LPVOID lpvReserved) BOOL WINAPI DllMain(HINSTANCE hInstance,DWORD fwdReason, LPVOID lpvReserved)

View file

@ -1,330 +1,353 @@
/* DirectDraw HAL driver /* DirectDraw HAL driver
* *
* Copyright 2001 TransGaming Technologies Inc. * Copyright 2001 TransGaming Technologies Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <windows.h> #include <windows.h>
#include "ddraw.h" #include "ddraw.h"
#include "rosddraw.h" #include "rosddraw.h"
#include "ddraw_private.h" #include "ddraw_private.h"
static IDirectDraw7Vtbl HAL_DirectDraw_VTable; static IDirectDraw7Vtbl HAL_DirectDraw_VTable;
HRESULT HAL_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex) HRESULT HAL_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex)
{ {
//This->local.lpGbl = &dd_gbl; //This->local.lpGbl = &dd_gbl;
This->final_release = HAL_DirectDraw_final_release; This->final_release = HAL_DirectDraw_final_release;
This->set_exclusive_mode = HAL_DirectDrawSet_exclusive_mode; This->set_exclusive_mode = HAL_DirectDrawSet_exclusive_mode;
// This->create_palette = HAL_DirectDrawPalette_Create; // This->create_palette = HAL_DirectDrawPalette_Create;
This->create_primary = HAL_DirectDraw_create_primary; This->create_primary = HAL_DirectDraw_create_primary;
This->create_backbuffer = HAL_DirectDraw_create_backbuffer; This->create_backbuffer = HAL_DirectDraw_create_backbuffer;
This->create_texture = HAL_DirectDraw_create_texture; This->create_texture = HAL_DirectDraw_create_texture;
ICOM_INIT_INTERFACE(This, IDirectDraw7, HAL_DirectDraw_VTable); ICOM_INIT_INTERFACE(This, IDirectDraw7, HAL_DirectDraw_VTable);
return S_OK; return S_OK;
} }
void HAL_DirectDraw_final_release(IDirectDrawImpl *This) void HAL_DirectDraw_final_release(IDirectDrawImpl *This)
{ {
} }
HRESULT HAL_DirectDrawSet_exclusive_mode(IDirectDrawImpl *This, DWORD dwEnterExcl) HRESULT HAL_DirectDrawSet_exclusive_mode(IDirectDrawImpl *This, DWORD dwEnterExcl)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT HAL_DirectDraw_create_primary(IDirectDrawImpl* This, const DDSURFACEDESC2* pDDSD, LPDIRECTDRAWSURFACE7* ppSurf, HRESULT HAL_DirectDraw_create_primary(IDirectDrawImpl* This, const DDSURFACEDESC2* pDDSD, LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter) IUnknown* pUnkOuter)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT HAL_DirectDraw_create_backbuffer(IDirectDrawImpl* This, HRESULT HAL_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD, const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter, IUnknown* pUnkOuter,
IDirectDrawSurfaceImpl* primary) IDirectDrawSurfaceImpl* primary)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT HAL_DirectDraw_create_texture(IDirectDrawImpl* This, HRESULT HAL_DirectDraw_create_texture(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD, const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter, LPUNKNOWN pOuter,
DWORD dwMipMapLevel) DWORD dwMipMapLevel)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
/* basic funtion for the com object */ /* basic funtion for the com object */
HRESULT WINAPI HAL_DirectDraw_QueryInterface(LPDIRECTDRAW7 iface,REFIID refiid,LPVOID *obj) HRESULT WINAPI HAL_DirectDraw_QueryInterface(LPDIRECTDRAW7 iface,REFIID refiid,LPVOID *obj)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
ULONG WINAPI HAL_DirectDraw_AddRef(LPDIRECTDRAW7 iface) ULONG WINAPI HAL_DirectDraw_AddRef(LPDIRECTDRAW7 iface)
{ {
IDirectDrawImpl *This = (IDirectDrawImpl *)iface; IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref); ULONG ref = InterlockedIncrement(&This->ref);
//TRACE("(%p)->() incrementing from %lu.\n", This, ref -1); //TRACE("(%p)->() incrementing from %lu.\n", This, ref -1);
return ref; return ref;
} }
ULONG WINAPI HAL_DirectDraw_Release(LPDIRECTDRAW7 iface) ULONG WINAPI HAL_DirectDraw_Release(LPDIRECTDRAW7 iface)
{ {
IDirectDrawImpl *This = (IDirectDrawImpl *)iface; IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0)
{ {
if (This->final_release != NULL) if (This->final_release != NULL)
This->final_release(This); This->final_release(This);
/* We free the private. This is an artifact of the fact that I don't /* We free the private. This is an artifact of the fact that I don't
* have the destructors set up correctly. */ * have the destructors set up correctly. */
if (This->private != (This+1)) if (This->private != (This+1))
HeapFree(GetProcessHeap(), 0, This->private); HeapFree(GetProcessHeap(), 0, This->private);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
} }
HRESULT WINAPI HAL_DirectDraw_Compact(LPDIRECTDRAW7 iface) HRESULT WINAPI HAL_DirectDraw_Compact(LPDIRECTDRAW7 iface)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface, DWORD dwFlags, HRESULT WINAPI HAL_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper, IUnknown *pUnkOuter) LPDIRECTDRAWCLIPPER *ppClipper, IUnknown *pUnkOuter)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags, HRESULT WINAPI HAL_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE* ppPalette,LPUNKNOWN pUnknown) LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE* ppPalette,LPUNKNOWN pUnknown)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_CreateSurface(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD, HRESULT WINAPI HAL_DirectDraw_CreateSurface(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,IUnknown *pUnkOuter) LPDIRECTDRAWSURFACE7 *ppSurf,IUnknown *pUnkOuter)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src, HRESULT WINAPI HAL_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src,
LPDIRECTDRAWSURFACE7* dst) LPDIRECTDRAWSURFACE7* dst)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags, HRESULT WINAPI HAL_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback) LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags, HRESULT WINAPI HAL_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 lpDDSD2, LPVOID context, LPDDSURFACEDESC2 lpDDSD2, LPVOID context,
LPDDENUMSURFACESCALLBACK7 callback) LPDDENUMSURFACESCALLBACK7 callback)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface) HRESULT WINAPI HAL_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps, HRESULT WINAPI HAL_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
LPDDCAPS pHELCaps) LPDDCAPS pHELCaps)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD) HRESULT WINAPI HAL_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes) HRESULT WINAPI HAL_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetGDISurface(LPDIRECTDRAW7 iface, HRESULT WINAPI HAL_DirectDraw_GetGDISurface(LPDIRECTDRAW7 iface,
LPDIRECTDRAWSURFACE7 *lplpGDIDDSSurface) LPDIRECTDRAWSURFACE7 *lplpGDIDDSSurface)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq) HRESULT WINAPI HAL_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine) HRESULT WINAPI HAL_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL status) HRESULT WINAPI HAL_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL status)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_Initialize(LPDIRECTDRAW7 iface, LPGUID lpGuid) HRESULT WINAPI HAL_DirectDraw_Initialize(LPDIRECTDRAW7 iface, LPGUID lpGuid)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface) HRESULT WINAPI HAL_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_SetCooperativeLevel(LPDIRECTDRAW7 iface, HWND hwnd, HRESULT WINAPI HAL_DirectDraw_SetCooperativeLevel(LPDIRECTDRAW7 iface, HWND hwnd,
DWORD cooplevel) DWORD cooplevel)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth, HRESULT WINAPI HAL_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags, HRESULT WINAPI HAL_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,
HANDLE h) HANDLE h)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps, HRESULT WINAPI HAL_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps,
LPDWORD total, LPDWORD free) LPDWORD total, LPDWORD free)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetSurfaceFromDC(LPDIRECTDRAW7 iface, HDC hdc, HRESULT WINAPI HAL_DirectDraw_GetSurfaceFromDC(LPDIRECTDRAW7 iface, HDC hdc,
LPDIRECTDRAWSURFACE7 *lpDDS) LPDIRECTDRAWSURFACE7 *lpDDS)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_RestoreAllSurfaces(LPDIRECTDRAW7 iface) HRESULT WINAPI HAL_DirectDraw_RestoreAllSurfaces(LPDIRECTDRAW7 iface)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_TestCooperativeLevel(LPDIRECTDRAW7 iface) HRESULT WINAPI HAL_DirectDraw_TestCooperativeLevel(LPDIRECTDRAW7 iface)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface, HRESULT WINAPI HAL_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI, DWORD dwFlags) LPDDDEVICEIDENTIFIER2 pDDDI, DWORD dwFlags)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_StartModeTest(LPDIRECTDRAW7 iface, LPSIZE pModes, HRESULT WINAPI HAL_DirectDraw_StartModeTest(LPDIRECTDRAW7 iface, LPSIZE pModes,
DWORD dwNumModes, DWORD dwFlags) DWORD dwNumModes, DWORD dwFlags)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
HRESULT WINAPI HAL_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b) HRESULT WINAPI HAL_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b)
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
/* End com interface */ /* End com interface */
HRESULT WINAPI HAL_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface, HRESULT WINAPI HAL_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex) IUnknown* pUnkOuter, BOOL ex)
{ {
IDirectDrawImpl* This; HRESULT hr;
*pIface = ICOM_INTERFACE(This, IDirectDraw7); IDirectDrawImpl* This;
return DD_OK; /*
} This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IDirectDrawImpl)
static IDirectDraw7Vtbl HAL_DirectDraw_VTable = + sizeof(HAL_DirectDrawImpl));
{ */
HAL_DirectDraw_QueryInterface, This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
HAL_DirectDraw_AddRef, sizeof(IDirectDrawImpl));
HAL_DirectDraw_Release,
HAL_DirectDraw_Compact, if (This == NULL) return E_OUTOFMEMORY;
HAL_DirectDraw_CreateClipper,
HAL_DirectDraw_CreatePalette, /* Note that this relation does *not* hold true if the DD object was
HAL_DirectDraw_CreateSurface, * CoCreateInstanced then Initialized. */
HAL_DirectDraw_DuplicateSurface, //This->private = (HAL_DirectDrawImpl *)(This+1);
HAL_DirectDraw_EnumDisplayModes,
HAL_DirectDraw_EnumSurfaces, /* Initialize the DDCAPS structure */
HAL_DirectDraw_FlipToGDISurface, This->caps.dwSize = sizeof(This->caps);
HAL_DirectDraw_GetCaps,
HAL_DirectDraw_GetDisplayMode, hr = HAL_DirectDraw_Construct(This, ex);
HAL_DirectDraw_GetFourCCCodes, if (FAILED(hr))
HAL_DirectDraw_GetGDISurface, HeapFree(GetProcessHeap(), 0, This);
HAL_DirectDraw_GetMonitorFrequency, else
HAL_DirectDraw_GetScanLine, *pIface = ICOM_INTERFACE(This, IDirectDraw7);
HAL_DirectDraw_GetVerticalBlankStatus,
HAL_DirectDraw_Initialize, return hr;
HAL_DirectDraw_RestoreDisplayMode, }
HAL_DirectDraw_SetCooperativeLevel,
HAL_DirectDraw_SetDisplayMode, static IDirectDraw7Vtbl HAL_DirectDraw_VTable =
HAL_DirectDraw_WaitForVerticalBlank, {
HAL_DirectDraw_GetAvailableVidMem, HAL_DirectDraw_QueryInterface,
HAL_DirectDraw_GetSurfaceFromDC, HAL_DirectDraw_AddRef,
HAL_DirectDraw_RestoreAllSurfaces, HAL_DirectDraw_Release,
HAL_DirectDraw_TestCooperativeLevel, HAL_DirectDraw_Compact,
HAL_DirectDraw_GetDeviceIdentifier, HAL_DirectDraw_CreateClipper,
HAL_DirectDraw_StartModeTest, HAL_DirectDraw_CreatePalette,
HAL_DirectDraw_EvaluateMode HAL_DirectDraw_CreateSurface,
}; HAL_DirectDraw_DuplicateSurface,
HAL_DirectDraw_EnumDisplayModes,
HAL_DirectDraw_EnumSurfaces,
HAL_DirectDraw_FlipToGDISurface,
HAL_DirectDraw_GetCaps,
HAL_DirectDraw_GetDisplayMode,
HAL_DirectDraw_GetFourCCCodes,
HAL_DirectDraw_GetGDISurface,
HAL_DirectDraw_GetMonitorFrequency,
HAL_DirectDraw_GetScanLine,
HAL_DirectDraw_GetVerticalBlankStatus,
HAL_DirectDraw_Initialize,
HAL_DirectDraw_RestoreDisplayMode,
HAL_DirectDraw_SetCooperativeLevel,
HAL_DirectDraw_SetDisplayMode,
HAL_DirectDraw_WaitForVerticalBlank,
HAL_DirectDraw_GetAvailableVidMem,
HAL_DirectDraw_GetSurfaceFromDC,
HAL_DirectDraw_RestoreAllSurfaces,
HAL_DirectDraw_TestCooperativeLevel,
HAL_DirectDraw_GetDeviceIdentifier,
HAL_DirectDraw_StartModeTest,
HAL_DirectDraw_EvaluateMode
};

View file

@ -1,481 +1,482 @@
/* /*
* Copyright 2000-2001 TransGaming Technologies Inc. * Copyright 2000-2001 TransGaming Technologies Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef _DDCOMIMPL_H_ #ifndef _DDCOMIMPL_H_
#define _DDCOMIMPL_H_ #define _DDCOMIMPL_H_
#include <stddef.h> #include <stddef.h>
/* Generates the name for a vtable pointer for a given interface. */ /* Generates the name for a vtable pointer for a given interface. */
/* The canonical name for a single interface is "lpVtbl". */ /* The canonical name for a single interface is "lpVtbl". */
#define ICOM_VFIELD_MULTI_NAME2(iface) ITF_##iface #define ICOM_VFIELD_MULTI_NAME2(iface) ITF_##iface
#define ICOM_VFIELD_MULTI_NAME(iface) ICOM_VFIELD_MULTI_NAME2(iface) #define ICOM_VFIELD_MULTI_NAME(iface) ICOM_VFIELD_MULTI_NAME2(iface)
/* Declares a vtable pointer field in an implementation. */ /* Declares a vtable pointer field in an implementation. */
#define ICOM_VFIELD_MULTI(iface) \ #define ICOM_VFIELD_MULTI(iface) \
iface ICOM_VFIELD_MULTI_NAME(iface) iface ICOM_VFIELD_MULTI_NAME(iface)
/* Returns the offset of a vtable pointer within an implementation object. */ /* Returns the offset of a vtable pointer within an implementation object. */
#define ICOM_VFIELD_OFFSET(impltype, iface) \ #define ICOM_VFIELD_OFFSET(impltype, iface) \
offsetof(impltype, ICOM_VFIELD_MULTI_NAME(iface)) offsetof(impltype, ICOM_VFIELD_MULTI_NAME(iface))
/* Given an interface pointer, returns the implementation pointer. */ /* Given an interface pointer, returns the implementation pointer. */
#define ICOM_OBJECT(impltype, ifacename, ifaceptr) \ #define ICOM_OBJECT(impltype, ifacename, ifaceptr) \
(impltype*)((ifaceptr) == NULL ? NULL \ (impltype*)((ifaceptr) == NULL ? NULL \
: (char*)(ifaceptr) - ICOM_VFIELD_OFFSET(impltype,ifacename)) : (char*)(ifaceptr) - ICOM_VFIELD_OFFSET(impltype,ifacename))
#define ICOM_THIS_FROM(impltype, ifacename, ifaceptr) \ #define ICOM_THIS_FROM(impltype, ifacename, ifaceptr) \
impltype* This = ICOM_OBJECT(impltype, ifacename, ifaceptr) impltype* This = ICOM_OBJECT(impltype, ifacename, ifaceptr)
/* Given an object and interface name, returns a pointer to that interface. */ /* Given an object and interface name, returns a pointer to that interface. */
#define ICOM_INTERFACE(implobj, iface) \ #define ICOM_INTERFACE(implobj, iface) \
(&((implobj)->ICOM_VFIELD_MULTI_NAME(iface))) (&((implobj)->ICOM_VFIELD_MULTI_NAME(iface)))
#define ICOM_INIT_INTERFACE(implobj, ifacename, vtblname) \ #define ICOM_INIT_INTERFACE(implobj, ifacename, vtblname) \
do { \ do { \
(implobj)->ICOM_VFIELD_MULTI_NAME(ifacename).lpVtbl = &(vtblname); \ (implobj)->ICOM_VFIELD_MULTI_NAME(ifacename).lpVtbl = &(vtblname); \
} while (0) } while (0)
#define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \ #define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \
ICOM_INTERFACE(ICOM_OBJECT(impltype, ifnamefrom, ifaceptr), ifnameto) ICOM_INTERFACE(ICOM_OBJECT(impltype, ifnamefrom, ifaceptr), ifnameto)
#endif /* _DDCOMIMPL_H_ */ #endif /* _DDCOMIMPL_H_ */
#ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
#define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
/* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */ /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wtypes.h" #include "wtypes.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "ddraw.h" #include "ddraw.h"
#include "d3d.h" #include "d3d.h"
#include "ddrawi.h" #include "ddrawi.h"
/* XXX Put this somewhere proper. */ /* XXX Put this somewhere proper. */
#define DD_STRUCT_INIT(x) \ #define DD_STRUCT_INIT(x) \
do { \ do { \
memset((x), 0, sizeof(*(x))); \ memset((x), 0, sizeof(*(x))); \
(x)->dwSize = sizeof(*x); \ (x)->dwSize = sizeof(*x); \
} while (0) } while (0)
#define DD_STRUCT_COPY_BYSIZE(to,from) \ #define DD_STRUCT_COPY_BYSIZE(to,from) \
do { \ do { \
DWORD __size = (to)->dwSize; \ DWORD __size = (to)->dwSize; \
DWORD __copysize = __size; \ DWORD __copysize = __size; \
DWORD __resetsize = __size; \ DWORD __resetsize = __size; \
if (__resetsize > sizeof(*to)) \ if (__resetsize > sizeof(*to)) \
__resetsize = sizeof(*to); \ __resetsize = sizeof(*to); \
memset(to,0,__resetsize); \ memset(to,0,__resetsize); \
if ((from)->dwSize < __size) \ if ((from)->dwSize < __size) \
__copysize = (from)->dwSize; \ __copysize = (from)->dwSize; \
memcpy(to,from,__copysize); \ memcpy(to,from,__copysize); \
(to)->dwSize = __size;/*restore size*/ \ (to)->dwSize = __size;/*restore size*/ \
} while (0) } while (0)
#define MAKE_FOURCC(a,b,c,d) ((a << 0) | (b << 8) | (c << 16) | (d << 24)) #define MAKE_FOURCC(a,b,c,d) ((a << 0) | (b << 8) | (c << 16) | (d << 24))
/***************************************************************************** /*****************************************************************************
* IDirectDraw implementation structure * IDirectDraw implementation structure
*/ */
typedef struct IDirectDrawImpl IDirectDrawImpl; typedef struct IDirectDrawImpl IDirectDrawImpl;
typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl; typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl; typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl; typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl; typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
typedef void (*pixel_convert_func)(void *src, void *dst, DWORD width, typedef void (*pixel_convert_func)(void *src, void *dst, DWORD width,
DWORD height, LONG pitch, DWORD height, LONG pitch,
IDirectDrawPaletteImpl *palette); IDirectDrawPaletteImpl *palette);
typedef void (*palette_convert_func)(LPPALETTEENTRY palent, typedef void (*palette_convert_func)(LPPALETTEENTRY palent,
void *screen_palette, DWORD start, void *screen_palette, DWORD start,
DWORD count); DWORD count);
struct IDirectDrawImpl struct IDirectDrawImpl
{ {
ICOM_VFIELD_MULTI(IDirectDraw7); ICOM_VFIELD_MULTI(IDirectDraw7);
ICOM_VFIELD_MULTI(IDirectDraw4); ICOM_VFIELD_MULTI(IDirectDraw4);
ICOM_VFIELD_MULTI(IDirectDraw2); ICOM_VFIELD_MULTI(IDirectDraw2);
ICOM_VFIELD_MULTI(IDirectDraw); ICOM_VFIELD_MULTI(IDirectDraw);
// ICOM_VFIELD_MULTI(IDirect3D7); ICOM_VFIELD_MULTI(IDirect3D7);
// ICOM_VFIELD_MULTI(IDirect3D3); ICOM_VFIELD_MULTI(IDirect3D3);
// ICOM_VFIELD_MULTI(IDirect3D2); ICOM_VFIELD_MULTI(IDirect3D2);
// ICOM_VFIELD_MULTI(IDirect3D); ICOM_VFIELD_MULTI(IDirect3D);
DWORD ref; DWORD ref;
/* TRUE if created via DirectDrawCreateEx or CoCreateInstance, /* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
* FALSE if created via DirectDrawCreate. */ * FALSE if created via DirectDrawCreate. */
BOOL ex; BOOL ex;
/* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */ /* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
IDirectDrawSurfaceImpl* surfaces; IDirectDrawSurfaceImpl* surfaces;
/* Linked list of palettes, joined by next_ddraw. */ /* Linked list of palettes, joined by next_ddraw. */
IDirectDrawPaletteImpl* palettes; IDirectDrawPaletteImpl* palettes;
/* Linked list of clippers, joined by next_ddraw. */ /* Linked list of clippers, joined by next_ddraw. */
IDirectDrawClipperImpl* clippers; IDirectDrawClipperImpl* clippers;
IDirectDrawSurfaceImpl* primary_surface; IDirectDrawSurfaceImpl* primary_surface;
DDRAWI_DIRECTDRAW_LCL local; DDRAWI_DIRECTDRAW_LCL local;
DDCAPS caps; DDCAPS caps;
HWND window; HWND window;
DWORD cooperative_level; DWORD cooperative_level;
WNDPROC original_wndproc; WNDPROC original_wndproc;
DWORD width, height; DWORD width, height;
LONG pitch; LONG pitch;
DDPIXELFORMAT pixelformat; DDPIXELFORMAT pixelformat;
DWORD cur_scanline; DWORD cur_scanline;
/* Should each of these go into some structure? */ /* Should each of these go into some structure? */
DWORD orig_width, orig_height; DWORD orig_width, orig_height;
LONG orig_pitch; LONG orig_pitch;
DDPIXELFORMAT orig_pixelformat; DDPIXELFORMAT orig_pixelformat;
/* Called when the refcount goes to 0. */ /* Called when the refcount goes to 0. */
void (*final_release)(IDirectDrawImpl *This); void (*final_release)(IDirectDrawImpl *This);
HRESULT (*set_exclusive_mode)(IDirectDrawImpl *This, DWORD dwExcl); HRESULT (*set_exclusive_mode)(IDirectDrawImpl *This, DWORD dwExcl);
HRESULT (*create_palette)(IDirectDrawImpl* This, DWORD dwFlags, HRESULT (*create_palette)(IDirectDrawImpl* This, DWORD dwFlags,
LPDIRECTDRAWPALETTE* ppPalette, LPDIRECTDRAWPALETTE* ppPalette,
LPUNKNOWN pUnkOuter); LPUNKNOWN pUnkOuter);
/* Surface creation functions. For all of these, pOuter == NULL. */ /* Surface creation functions. For all of these, pOuter == NULL. */
/* Do not create any backbuffers or the flipping chain. */ /* Do not create any backbuffers or the flipping chain. */
HRESULT (*create_primary)(IDirectDrawImpl* This, HRESULT (*create_primary)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD, const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter); LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
/* Primary may be NULL if we are creating an unattached backbuffer. */ /* Primary may be NULL if we are creating an unattached backbuffer. */
HRESULT (*create_backbuffer)(IDirectDrawImpl* This, HRESULT (*create_backbuffer)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD, const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter, LPUNKNOWN pOuter,
IDirectDrawSurfaceImpl* primary); IDirectDrawSurfaceImpl* primary);
/* shiny happy offscreenplain surfaces */ /* shiny happy offscreenplain surfaces */
HRESULT (*create_offscreen)(IDirectDrawImpl* This, HRESULT (*create_offscreen)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD, const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter); LPUNKNOWN pOuter);
/* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */ /* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
HRESULT (*create_texture)(IDirectDrawImpl* This, HRESULT (*create_texture)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD, const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter, LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter,
DWORD dwMipMapLevel); DWORD dwMipMapLevel);
HRESULT (*create_zbuffer)(IDirectDrawImpl* This, HRESULT (*create_zbuffer)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD, const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter); LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
LPVOID private; LPVOID private;
/* Everything below here is still questionable. */ /* Everything below here is still questionable. */
DDPIXELFORMAT screen_pixelformat; DDPIXELFORMAT screen_pixelformat;
int pixmap_depth; int pixmap_depth;
// pixel_convert_func pixel_convert; // pixel_convert_func pixel_convert;
// palette_convert_func palette_convert; // palette_convert_func palette_convert;
/* Use to fool some too strict games */ /* Use to fool some too strict games */
INT32 (*allocate_memory)(IDirectDrawImpl *This, DWORD mem); INT32 (*allocate_memory)(IDirectDrawImpl *This, DWORD mem);
void (*free_memory)(IDirectDrawImpl *This, DWORD mem); void (*free_memory)(IDirectDrawImpl *This, DWORD mem);
DWORD total_vidmem, available_vidmem; DWORD total_vidmem, available_vidmem;
/* IDirect3D fields */ /* IDirect3D fields */
LPVOID d3d_private; LPVOID d3d_private;
/* Used as a callback function to create a texture */ /* Used as a callback function to create a texture */
HRESULT (*d3d_create_texture)(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main); HRESULT (*d3d_create_texture)(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main);
/* Used as a callback for Devices to tell to the D3D object it's been created */ /* Used as a callback for Devices to tell to the D3D object it's been created */
HRESULT (*d3d_added_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device); HRESULT (*d3d_added_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device);
HRESULT (*d3d_removed_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device); HRESULT (*d3d_removed_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device);
/* This is needed for delayed texture creation and Z buffer blits */ /* This is needed for delayed texture creation and Z buffer blits */
IDirect3DDeviceImpl *current_device; IDirect3DDeviceImpl *current_device;
/* This is for the fake mainWindow */ /* This is for the fake mainWindow */
ATOM winclass; ATOM winclass;
PAINTSTRUCT ps; PAINTSTRUCT ps;
BOOL paintable; BOOL paintable;
}; };
/***************************************************************************** /*****************************************************************************
* IDirectDrawPalette implementation structure * IDirectDrawPalette implementation structure
*/ */
struct IDirectDrawPaletteImpl struct IDirectDrawPaletteImpl
{ {
/* IUnknown fields */ /* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDrawPalette); ICOM_VFIELD_MULTI(IDirectDrawPalette);
DWORD ref; DWORD ref;
DDRAWI_DDRAWPALETTE_LCL local; DDRAWI_DDRAWPALETTE_LCL local;
DDRAWI_DDRAWPALETTE_GBL global; DDRAWI_DDRAWPALETTE_GBL global;
/* IDirectDrawPalette fields */ /* IDirectDrawPalette fields */
HPALETTE hpal; HPALETTE hpal;
WORD palVersion, palNumEntries; /* LOGPALETTE */ WORD palVersion, palNumEntries; /* LOGPALETTE */
PALETTEENTRY palents[256]; PALETTEENTRY palents[256];
/* This is to store the palette in 'screen format' */ /* This is to store the palette in 'screen format' */
int screen_palents[256]; int screen_palents[256];
VOID (*final_release)(IDirectDrawPaletteImpl* This); VOID (*final_release)(IDirectDrawPaletteImpl* This);
IDirectDrawImpl* ddraw_owner; IDirectDrawImpl* ddraw_owner;
IDirectDrawPaletteImpl* prev_ddraw; IDirectDrawPaletteImpl* prev_ddraw;
IDirectDrawPaletteImpl* next_ddraw; IDirectDrawPaletteImpl* next_ddraw;
LPVOID private; LPVOID private;
}; };
/***************************************************************************** /*****************************************************************************
* IDirectDrawClipper implementation structure * IDirectDrawClipper implementation structure
*/ */
struct IDirectDrawClipperImpl struct IDirectDrawClipperImpl
{ {
/* IUnknown fields */ /* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDrawClipper); ICOM_VFIELD_MULTI(IDirectDrawClipper);
DWORD ref; DWORD ref;
/* IDirectDrawClipper fields */ /* IDirectDrawClipper fields */
HWND hWnd; HWND hWnd;
IDirectDrawImpl* ddraw_owner; IDirectDrawImpl* ddraw_owner;
IDirectDrawClipperImpl* prev_ddraw; IDirectDrawClipperImpl* prev_ddraw;
IDirectDrawClipperImpl* next_ddraw; IDirectDrawClipperImpl* next_ddraw;
}; };
/***************************************************************************** /*****************************************************************************
* IDirectDrawSurface implementation structure * IDirectDrawSurface implementation structure
*/ */
struct IDirectDrawSurfaceImpl struct IDirectDrawSurfaceImpl
{ {
/* IUnknown fields */ /* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDrawSurface7); ICOM_VFIELD_MULTI(IDirectDrawSurface7);
ICOM_VFIELD_MULTI(IDirectDrawSurface3); ICOM_VFIELD_MULTI(IDirectDrawSurface3);
ICOM_VFIELD_MULTI(IDirectDrawGammaControl); ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
//ICOM_VFIELD_MULTI(IDirect3DTexture2); ICOM_VFIELD_MULTI(IDirect3DTexture2);
//ICOM_VFIELD_MULTI(IDirect3DTexture); ICOM_VFIELD_MULTI(IDirect3DTexture);
DWORD ref; DWORD ref;
struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */ struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */
struct IDirectDrawSurfaceImpl* next_ddraw; /* ddraw surface chain */ struct IDirectDrawSurfaceImpl* next_ddraw; /* ddraw surface chain */
struct IDirectDrawSurfaceImpl* prev_ddraw; struct IDirectDrawSurfaceImpl* prev_ddraw;
struct IDirectDrawSurfaceImpl* next_attached; /* attached surface chain */ struct IDirectDrawSurfaceImpl* next_attached; /* attached surface chain */
struct IDirectDrawSurfaceImpl* prev_attached; struct IDirectDrawSurfaceImpl* prev_attached;
IDirectDrawImpl* ddraw_owner; IDirectDrawImpl* ddraw_owner;
IDirectDrawSurfaceImpl* surface_owner; IDirectDrawSurfaceImpl* surface_owner;
IDirectDrawPaletteImpl* palette; /* strong ref */ IDirectDrawPaletteImpl* palette; /* strong ref */
IDirectDrawClipperImpl* clipper; /* strong ref */ IDirectDrawClipperImpl* clipper; /* strong ref */
DDRAWI_DDRAWSURFACE_LCL local; DDRAWI_DDRAWSURFACE_LCL local;
DDRAWI_DDRAWSURFACE_MORE more; DDRAWI_DDRAWSURFACE_MORE more;
/* FIXME: since Flip should swap the GBL structures, they should /* FIXME: since Flip should swap the GBL structures, they should
* probably not be embedded into the IDirectDrawSurfaceImpl structure... */ * probably not be embedded into the IDirectDrawSurfaceImpl structure... */
LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore; LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore;
DDRAWI_DDRAWSURFACE_GBL global; DDRAWI_DDRAWSURFACE_GBL global;
DDRAWI_DDRAWSURFACE_GBL_MORE global_more; DDRAWI_DDRAWSURFACE_GBL_MORE global_more;
DDSURFACEDESC2 surface_desc; DDSURFACEDESC2 surface_desc;
HDC hDC; HDC hDC;
RECT lastlockrect; RECT lastlockrect;
DWORD lastlocktype; DWORD lastlocktype;
BOOL dc_in_use; BOOL dc_in_use;
BOOL locked; BOOL locked;
HRESULT (*duplicate_surface)(IDirectDrawSurfaceImpl* src, HRESULT (*duplicate_surface)(IDirectDrawSurfaceImpl* src,
LPDIRECTDRAWSURFACE7* dst); LPDIRECTDRAWSURFACE7* dst);
void (*final_release)(IDirectDrawSurfaceImpl *This); void (*final_release)(IDirectDrawSurfaceImpl *This);
HRESULT (*late_allocate)(IDirectDrawSurfaceImpl *This); HRESULT (*late_allocate)(IDirectDrawSurfaceImpl *This);
BOOL (*attach)(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *to); BOOL (*attach)(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *to);
BOOL (*detach)(IDirectDrawSurfaceImpl *This); BOOL (*detach)(IDirectDrawSurfaceImpl *This);
void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags); void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect); void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
void (*lose_surface)(IDirectDrawSurfaceImpl* This); void (*lose_surface)(IDirectDrawSurfaceImpl* This);
BOOL (*flip_data)(IDirectDrawSurfaceImpl* front, BOOL (*flip_data)(IDirectDrawSurfaceImpl* front,
IDirectDrawSurfaceImpl* back, IDirectDrawSurfaceImpl* back,
DWORD dwFlags); DWORD dwFlags);
void (*flip_update)(IDirectDrawSurfaceImpl* front, DWORD dwFlags); void (*flip_update)(IDirectDrawSurfaceImpl* front, DWORD dwFlags);
HRESULT (*get_dc)(IDirectDrawSurfaceImpl* This, HDC* phDC); HRESULT (*get_dc)(IDirectDrawSurfaceImpl* This, HDC* phDC);
HRESULT (*release_dc)(IDirectDrawSurfaceImpl* This, HDC hDC); HRESULT (*release_dc)(IDirectDrawSurfaceImpl* This, HDC hDC);
void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal); void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
void (*update_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal, void (*update_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal,
DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent); DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent);
HWND (*get_display_window)(IDirectDrawSurfaceImpl *This); HWND (*get_display_window)(IDirectDrawSurfaceImpl *This);
HRESULT (*get_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp); HRESULT (*get_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
HRESULT (*set_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp); HRESULT (*set_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
struct PrivateData* private_data; struct PrivateData* private_data;
DWORD max_lod; DWORD max_lod;
DWORD priority; DWORD priority;
BOOL lost; BOOL lost;
DWORD uniqueness_value; DWORD uniqueness_value;
LPVOID private; LPVOID private;
/* Everything below here is dodgy. */ /* Everything below here is dodgy. */
/* For Direct3D use */ /* For Direct3D use */
LPVOID aux_ctx, aux_data; LPVOID aux_ctx, aux_data;
void (*aux_release)(LPVOID ctx, LPVOID data); void (*aux_release)(LPVOID ctx, LPVOID data);
BOOL (*aux_flip)(LPVOID ctx, LPVOID data); BOOL (*aux_flip)(LPVOID ctx, LPVOID data);
void (*aux_unlock)(LPVOID ctx, LPVOID data, LPRECT lpRect); void (*aux_unlock)(LPVOID ctx, LPVOID data, LPRECT lpRect);
HRESULT (*aux_blt)(struct IDirectDrawSurfaceImpl *This, LPRECT rdst, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx); HRESULT (*aux_blt)(struct IDirectDrawSurfaceImpl *This, LPRECT rdst, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx);
HRESULT (*aux_bltfast)(struct IDirectDrawSurfaceImpl *This, DWORD dstx, DWORD dsty, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD trans); HRESULT (*aux_bltfast)(struct IDirectDrawSurfaceImpl *This, DWORD dstx, DWORD dsty, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD trans);
HRESULT (*aux_setcolorkey_cb)(struct IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey ); HRESULT (*aux_setcolorkey_cb)(struct IDirectDrawSurfaceImpl *texture, DWORD dwFlags, LPDDCOLORKEY ckey );
/* This is to get the D3DDevice object associated to this surface */ /* This is to get the D3DDevice object associated to this surface */
struct IDirect3DDeviceImpl *d3ddevice; struct IDirect3DDeviceImpl *d3ddevice;
/* This is for texture */ /* This is for texture */
IDirectDrawSurfaceImpl *mip_main; IDirectDrawSurfaceImpl *mip_main;
int mipmap_level; int mipmap_level;
LPVOID tex_private; LPVOID tex_private;
void (*lock_update_prev)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags); void (*lock_update_prev)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
void (*unlock_update_prev)(IDirectDrawSurfaceImpl* This, LPCRECT pRect); void (*unlock_update_prev)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
BOOLEAN (*get_dirty_status)(IDirectDrawSurfaceImpl* This, LPCRECT pRect); BOOLEAN (*get_dirty_status)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
}; };
/***************************************************************************** /*****************************************************************************
* Driver initialisation functions. * Driver initialisation functions.
*/ */
BOOL DDRAW_HAL_Init(HINSTANCE, DWORD, LPVOID); BOOL DDRAW_HAL_Init(HINSTANCE, DWORD, LPVOID);
BOOL DDRAW_User_Init(HINSTANCE, DWORD, LPVOID); BOOL DDRAW_User_Init(HINSTANCE, DWORD, LPVOID);
typedef struct { typedef struct {
const DDDEVICEIDENTIFIER2* info; const DDDEVICEIDENTIFIER2* info;
int preference; /* how good we are. dga might get 100, xlib 50*/ int preference; /* how good we are. dga might get 100, xlib 50*/
HRESULT (*create)(const GUID*, LPDIRECTDRAW7*, LPUNKNOWN, BOOL ex); HRESULT (*create)(const GUID*, LPDIRECTDRAW7*, LPUNKNOWN, BOOL ex);
/* For IDirectDraw7::Initialize. */ /* For IDirectDraw7::Initialize. */
HRESULT (*init)(IDirectDrawImpl *, const GUID*); HRESULT (*init)(IDirectDrawImpl *, const GUID*);
} ddraw_driver; } ddraw_driver;
void DDRAW_register_driver(const ddraw_driver*); void DDRAW_register_driver(const ddraw_driver*);
const ddraw_driver* DDRAW_FindDriver(const GUID* guid); const ddraw_driver* DDRAW_FindDriver(const GUID* guid);
/****************************************************************************** /******************************************************************************
* Random utilities * Random utilities
*/ */
/* Get DDSCAPS of surface (shortcutmacro) */ /* Get DDSCAPS of surface (shortcutmacro) */
#define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps) #define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
/* Get the number of bytes per pixel for a given surface */ /* Get the number of bytes per pixel for a given surface */
#define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8)) #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.u1.dwRGBBitCount+7)/8))
#define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat) #define GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
LONG DDRAW_width_bpp_to_pitch(DWORD width, DWORD bpp); LONG DDRAW_width_bpp_to_pitch(DWORD width, DWORD bpp);
typedef struct { typedef struct {
unsigned short bpp,depth; unsigned short bpp,depth;
unsigned int rmask,gmask,bmask; unsigned int rmask,gmask,bmask;
} ConvertMode; } ConvertMode;
typedef struct { typedef struct {
void (*pixel_convert)(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette); void (*pixel_convert)(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette);
void (*palette_convert)(LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count); void (*palette_convert)(LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count);
} ConvertFuncs; } ConvertFuncs;
typedef struct { typedef struct {
ConvertMode screen, dest; ConvertMode screen, dest;
ConvertFuncs funcs; ConvertFuncs funcs;
} Convert; } Convert;
extern Convert ModeEmulations[8]; extern Convert ModeEmulations[8];
extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw); extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw);
extern BOOL opengl_initialized; extern BOOL opengl_initialized;
extern BOOL s3tc_initialized; extern BOOL s3tc_initialized;
typedef void (*FUNC_FETCH_2D_TEXEL_RGBA_DXT1)(int srcRowStride, const BYTE *pixdata, int i, int j, void *texel); typedef void (*FUNC_FETCH_2D_TEXEL_RGBA_DXT1)(int srcRowStride, const BYTE *pixdata, int i, int j, void *texel);
typedef void (*FUNC_FETCH_2D_TEXEL_RGBA_DXT3)(int srcRowStride, const BYTE *pixdata, int i, int j, void *texel); typedef void (*FUNC_FETCH_2D_TEXEL_RGBA_DXT3)(int srcRowStride, const BYTE *pixdata, int i, int j, void *texel);
typedef void (*FUNC_FETCH_2D_TEXEL_RGBA_DXT5)(int srcRowStride, const BYTE *pixdata, int i, int j, void *texel); typedef void (*FUNC_FETCH_2D_TEXEL_RGBA_DXT5)(int srcRowStride, const BYTE *pixdata, int i, int j, void *texel);
extern FUNC_FETCH_2D_TEXEL_RGBA_DXT1 fetch_2d_texel_rgba_dxt1; extern FUNC_FETCH_2D_TEXEL_RGBA_DXT1 fetch_2d_texel_rgba_dxt1;
extern FUNC_FETCH_2D_TEXEL_RGBA_DXT3 fetch_2d_texel_rgba_dxt3; extern FUNC_FETCH_2D_TEXEL_RGBA_DXT3 fetch_2d_texel_rgba_dxt3;
extern FUNC_FETCH_2D_TEXEL_RGBA_DXT5 fetch_2d_texel_rgba_dxt5; extern FUNC_FETCH_2D_TEXEL_RGBA_DXT5 fetch_2d_texel_rgba_dxt5;
/****************************************************************************** /******************************************************************************
* Structure conversion (for thunks) * Structure conversion (for thunks)
*/ */
void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut); void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut);
void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn, void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
DDDEVICEIDENTIFIER* pOut); DDDEVICEIDENTIFIER* pOut);
/****************************************************************************** /******************************************************************************
* Debugging / Flags output functions * Debugging / Flags output functions
*/ */
extern void DDRAW_dump_DDBLTFX(DWORD flagmask); extern void DDRAW_dump_DDBLTFX(DWORD flagmask);
extern void DDRAW_dump_DDBLTFAST(DWORD flagmask); extern void DDRAW_dump_DDBLTFAST(DWORD flagmask);
extern void DDRAW_dump_DDBLT(DWORD flagmask); extern void DDRAW_dump_DDBLT(DWORD flagmask);
extern void DDRAW_dump_DDSCAPS(const DDSCAPS *in); extern void DDRAW_dump_DDSCAPS(const DDSCAPS *in);
extern void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in); extern void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
extern void DDRAW_dump_pixelformat_flag(DWORD flagmask); extern void DDRAW_dump_pixelformat_flag(DWORD flagmask);
extern void DDRAW_dump_paletteformat(DWORD dwFlags); extern void DDRAW_dump_paletteformat(DWORD dwFlags);
extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT *in); extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT *in);
extern void DDRAW_dump_colorkeyflag(DWORD ck); extern void DDRAW_dump_colorkeyflag(DWORD ck);
extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd); extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
extern void DDRAW_dump_cooperativelevel(DWORD cooplevel); extern void DDRAW_dump_cooperativelevel(DWORD cooplevel);
extern void DDRAW_dump_lockflag(DWORD lockflag); extern void DDRAW_dump_lockflag(DWORD lockflag);
extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *in); extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *in);
extern void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps); extern void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
extern void DDRAW_dump_surface_to_disk(IDirectDrawSurfaceImpl *surface, FILE *f, int scale) ; extern void DDRAW_dump_surface_to_disk(IDirectDrawSurfaceImpl *surface, FILE *f, int scale) ;
/* Used for generic dumping */ /* Used for generic dumping */
typedef struct typedef struct
{ {
DWORD val; DWORD val;
const char* name; const char* name;
} flag_info; } flag_info;
#define FE(x) { x, #x } #define FE(x) { x, #x }
typedef struct typedef struct
{ {
DWORD val; DWORD val;
const char* name; const char* name;
void (*func)(const void *); void (*func)(const void *);
ptrdiff_t offset; ptrdiff_t offset;
} member_info; } member_info;
#define DDRAW_dump_flags(flags,names,num_names) DDRAW_dump_flags_(flags, names, num_names, 1) #define DDRAW_dump_flags(flags,names,num_names) DDRAW_dump_flags_(flags, names, num_names, 1)
#define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) } #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
extern void DDRAW_dump_flags_(DWORD flags, const flag_info* names, size_t num_names, int newline); extern void DDRAW_dump_flags_(DWORD flags, const flag_info* names, size_t num_names, int newline);
extern void DDRAW_dump_members(DWORD flags, const void* data, const member_info* mems, size_t num_mems); extern void DDRAW_dump_members(DWORD flags, const void* data, const member_info* mems, size_t num_mems);
#endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */
#endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */