The beginning of a ddraw implementation. Does not work yet for unknown reason.

svn path=/trunk/; revision=17199
This commit is contained in:
Maarten Bosma 2005-08-08 13:29:50 +00:00
parent 1a2a435f9c
commit 2cacd67bcc
16 changed files with 1126 additions and 1895 deletions

View file

@ -1,119 +0,0 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/opengl32/opengl32.c
* PURPOSE: OpenGL32 lib
* PROGRAMMER: Anich Gregor (blight), Royce Mitchell III
* UPDATE HISTORY:
* Feb 1, 2004: Created
*/
#include <windows.h>
#include "ddraw.h"
#include "rosddraw.h"
HRESULT WINAPI DirectDrawCreate(LPGUID lpGUID, LPDIRECTDRAW* lplpDD, LPUNKNOWN pUnkOuter)
{
if (pUnkOuter!=NULL) return DDERR_INVALIDPARAMS;
return DDRAW_Create(lpGUID, (LPVOID*) lplpDD, pUnkOuter, &IID_IDirectDraw, FALSE);
}
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID* lplpDD, REFIID iid, LPUNKNOWN pUnkOuter)
{
if (pUnkOuter!=NULL) return DDERR_INVALIDPARAMS;
if (!IsEqualGUID(iid, &IID_IDirectDraw7)) return DDERR_INVALIDPARAMS;
return DDRAW_Create(lpGUID, lplpDD, pUnkOuter, iid, TRUE);
}
HRESULT WINAPI DirectDrawEnumerateA(
LPDDENUMCALLBACKA lpCallback,
LPVOID lpContext
)
{
return DD_OK;
}
HRESULT WINAPI DirectDrawEnumerateW(
LPDDENUMCALLBACKW lpCallback,
LPVOID lpContext
)
{
return DD_OK;
}
HRESULT WINAPI DirectDrawEnumerateExA(
LPDDENUMCALLBACKEXA lpCallback,
LPVOID lpContext,
DWORD dwFlags
)
{
return DD_OK;
}
HRESULT WINAPI DirectDrawEnumerateExW(
LPDDENUMCALLBACKEXW lpCallback,
LPVOID lpContext,
DWORD dwFlags
)
{
return DD_OK;
}
HRESULT WINAPI DirectDrawCreateClipper(
DWORD dwFlags,
LPDIRECTDRAWCLIPPER* lplpDDClipper,
LPUNKNOWN pUnkOuter
)
{
return DD_OK;
}
HRESULT DDRAW_Create(
LPGUID lpGUID, LPVOID *lplpDD, LPUNKNOWN pUnkOuter, REFIID iid, BOOL ex)
{
HRESULT hr;
/* TODO 1:
check the GUID are right
add scanner that DirectDrawCreate / DirectDrawCreateEx select right 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());
lplpDD = OsThunkDdCreateDirectDrawObject(desktop);
if (lplpDD == NULL) return DDERR_NODIRECTDRAWHW;
*/
return hr;
}
BOOL WINAPI DllMain(HINSTANCE hInstance,DWORD fwdReason, LPVOID lpvReserved)
{
switch(fwdReason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_DETACH:
break;
}
return(TRUE);
}

View file

@ -0,0 +1,35 @@
<module name="ddraw" type="win32dll" installbase="system32" installname="ddraw.dll">
<importlibrary definition="ddraw.def" />
<include base="ddraw">.</include>
<include base="d3d8thk">.</include>
<define name="UNICODE" />
<define name="__USE_W32API" />
<define name="WINVER">0x0600</define>
<define name="_WIN32_WINNT">0x0501</define>
<library>ntdll</library>
<library>kernel32</library>
<library>gdi32</library>
<library>d3d8thk</library>
<library>dxguid</library>
<library>ole32</library>
<library>dciman32</library>
<file>main.c</file>
<file>regsvr.c</file>
<directory name="hal">
<file>ddraw.c</file>
<file>surface.c</file>
</directory>
<directory name="main">
<file>ddraw.c</file>
<file>surface.c</file>
</directory>
<directory name="soft">
<file>ddraw.c</file>
<file>surface.c</file>
</directory>
</module>

View file

@ -1,342 +0,0 @@
#include <windows.h>
#include "ddraw.h"
#include "rosddraw.h"
#include "ddraw_private.h"
static IDirectDraw7Vtbl HAL_DirectDraw_VTable;
HRESULT HAL_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex)
{
//This->local.lpGbl = &dd_gbl;
This->final_release = HAL_DirectDraw_final_release;
This->set_exclusive_mode = HAL_DirectDrawSet_exclusive_mode;
// This->create_palette = HAL_DirectDrawPalette_Create;
This->create_primary = HAL_DirectDraw_create_primary;
This->create_backbuffer = HAL_DirectDraw_create_backbuffer;
This->create_texture = HAL_DirectDraw_create_texture;
// ICOM_INIT_INTERFACE(This, IDirectDraw7, HAL_DirectDraw_VTable);
return S_OK;
}
void HAL_DirectDraw_final_release(IDirectDrawImpl *This)
{
}
HRESULT HAL_DirectDrawSet_exclusive_mode(IDirectDrawImpl *This, DWORD dwEnterExcl)
{
return DDERR_UNSUPPORTED;
}
HRESULT HAL_DirectDraw_create_primary(IDirectDrawImpl* This, const DDSURFACEDESC2* pDDSD, LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter)
{
return DDERR_UNSUPPORTED;
}
HRESULT HAL_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter,
IDirectDrawSurfaceImpl* primary)
{
return DDERR_UNSUPPORTED;
}
HRESULT HAL_DirectDraw_create_texture(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter,
DWORD dwMipMapLevel)
{
return DDERR_UNSUPPORTED;
}
/* basic funtion for the com object */
HRESULT WINAPI HAL_DirectDraw_QueryInterface(LPDIRECTDRAW7 iface,REFIID refiid,LPVOID *obj)
{
return DDERR_UNSUPPORTED;
}
ULONG WINAPI HAL_DirectDraw_AddRef(LPDIRECTDRAW7 iface)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
//TRACE("(%p)->() incrementing from %lu.\n", This, ref -1);
return ref;
}
ULONG WINAPI HAL_DirectDraw_Release(LPDIRECTDRAW7 iface)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
{
if (This->final_release != NULL)
This->final_release(This);
/* We free the private. This is an artifact of the fact that I don't
* have the destructors set up correctly. */
if (This->private != (This+1))
HeapFree(GetProcessHeap(), 0, This->private);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
HRESULT WINAPI HAL_DirectDraw_Compact(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper, IUnknown *pUnkOuter)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE* ppPalette,LPUNKNOWN pUnknown)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_CreateSurface(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,IUnknown *pUnkOuter)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src,
LPDIRECTDRAWSURFACE7* dst)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 lpDDSD2, LPVOID context,
LPDDENUMSURFACESCALLBACK7 callback)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
LPDDCAPS pHELCaps)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetGDISurface(LPDIRECTDRAW7 iface,
LPDIRECTDRAWSURFACE7 *lplpGDIDDSSurface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL status)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_Initialize(LPDIRECTDRAW7 iface, LPGUID lpGuid)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_SetCooperativeLevel(LPDIRECTDRAW7 iface, HWND hwnd,
DWORD cooplevel)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,
HANDLE h)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps,
LPDWORD total, LPDWORD free)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetSurfaceFromDC(LPDIRECTDRAW7 iface, HDC hdc,
LPDIRECTDRAWSURFACE7 *lpDDS)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_RestoreAllSurfaces(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_TestCooperativeLevel(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_StartModeTest(LPDIRECTDRAW7 iface, LPSIZE pModes,
DWORD dwNumModes, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI HAL_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b)
{
return DDERR_UNSUPPORTED;
}
/* End com interface */
HRESULT WINAPI HAL_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex)
{
HRESULT hr;
IDirectDrawImpl* This;
HDC desktop;
/*
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IDirectDrawImpl)
+ sizeof(HAL_DirectDrawImpl));
*/
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IDirectDrawImpl));
if (This == NULL) return E_OUTOFMEMORY;
/* Note that this relation does *not* hold true if the DD object was
* CoCreateInstanced then Initialized. */
//This->private = (HAL_DirectDrawImpl *)(This+1);
/* Initialize the DDCAPS structure */
This->caps.dwSize = sizeof(This->caps);
hr = HAL_DirectDraw_Construct(This, ex);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else *pIface = ICOM_INTERFACE(This, IDirectDraw7);
/* create a scaner that check which driver we should get the HDC from */
/* for now we always asume it is the active dirver that should be use. */
desktop = GetWindowDC(GetDesktopWindow());
*pIface = OsThunkDdCreateDirectDrawObject(desktop);
if (pIface == NULL) hr == DDERR_NODIRECTDRAWHW;
return DDERR_UNSUPPORTED;
}
static IDirectDraw7Vtbl HAL_DirectDraw_VTable =
{
HAL_DirectDraw_QueryInterface,
HAL_DirectDraw_AddRef,
HAL_DirectDraw_Release,
HAL_DirectDraw_Compact,
HAL_DirectDraw_CreateClipper,
HAL_DirectDraw_CreatePalette,
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,482 +0,0 @@
/*
* Copyright 2000-2001 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* 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,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _DDCOMIMPL_H_
#define _DDCOMIMPL_H_
#include <stddef.h>
/* Generates the name for a vtable pointer for a given interface. */
/* The canonical name for a single interface is "lpVtbl". */
#define ICOM_VFIELD_MULTI_NAME2(iface) ITF_##iface
#define ICOM_VFIELD_MULTI_NAME(iface) ICOM_VFIELD_MULTI_NAME2(iface)
/* Declares a vtable pointer field in an implementation. */
#define ICOM_VFIELD_MULTI(iface) \
iface ICOM_VFIELD_MULTI_NAME(iface)
/* Returns the offset of a vtable pointer within an implementation object. */
#define ICOM_VFIELD_OFFSET(impltype, iface) \
offsetof(impltype, ICOM_VFIELD_MULTI_NAME(iface))
/* Given an interface pointer, returns the implementation pointer. */
#define ICOM_OBJECT(impltype, ifacename, ifaceptr) \
(impltype*)((ifaceptr) == NULL ? NULL \
: (char*)(ifaceptr) - ICOM_VFIELD_OFFSET(impltype,ifacename))
#define ICOM_THIS_FROM(impltype, ifacename, ifaceptr) \
impltype* This = ICOM_OBJECT(impltype, ifacename, ifaceptr)
/* Given an object and interface name, returns a pointer to that interface. */
#define ICOM_INTERFACE(implobj, iface) \
(&((implobj)->ICOM_VFIELD_MULTI_NAME(iface)))
#define ICOM_INIT_INTERFACE(implobj, ifacename, vtblname) \
do { \
(implobj)->ICOM_VFIELD_MULTI_NAME(ifacename).lpVtbl = &(vtblname); \
} while (0)
#define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \
ICOM_INTERFACE(ICOM_OBJECT(impltype, ifnamefrom, ifaceptr), ifnameto)
#endif /* _DDCOMIMPL_H_ */
#ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
#define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
/* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wtypes.h"
#include "wingdi.h"
#include "winuser.h"
#include "ddraw.h"
#include "d3d.h"
#include "ddrawi.h"
/* XXX Put this somewhere proper. */
#define DD_STRUCT_INIT(x) \
do { \
memset((x), 0, sizeof(*(x))); \
(x)->dwSize = sizeof(*x); \
} while (0)
#define DD_STRUCT_COPY_BYSIZE(to,from) \
do { \
DWORD __size = (to)->dwSize; \
DWORD __copysize = __size; \
DWORD __resetsize = __size; \
if (__resetsize > sizeof(*to)) \
__resetsize = sizeof(*to); \
memset(to,0,__resetsize); \
if ((from)->dwSize < __size) \
__copysize = (from)->dwSize; \
memcpy(to,from,__copysize); \
(to)->dwSize = __size;/*restore size*/ \
} while (0)
#define MAKE_FOURCC(a,b,c,d) ((a << 0) | (b << 8) | (c << 16) | (d << 24))
/*****************************************************************************
* IDirectDraw implementation structure
*/
typedef struct IDirectDrawImpl IDirectDrawImpl;
typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
typedef void (*pixel_convert_func)(void *src, void *dst, DWORD width,
DWORD height, LONG pitch,
IDirectDrawPaletteImpl *palette);
typedef void (*palette_convert_func)(LPPALETTEENTRY palent,
void *screen_palette, DWORD start,
DWORD count);
struct IDirectDrawImpl
{
ICOM_VFIELD_MULTI(IDirectDraw7);
ICOM_VFIELD_MULTI(IDirectDraw4);
ICOM_VFIELD_MULTI(IDirectDraw2);
ICOM_VFIELD_MULTI(IDirectDraw);
ICOM_VFIELD_MULTI(IDirect3D7);
ICOM_VFIELD_MULTI(IDirect3D3);
ICOM_VFIELD_MULTI(IDirect3D2);
ICOM_VFIELD_MULTI(IDirect3D);
DWORD ref;
/* TRUE if created via DirectDrawCreateEx or CoCreateInstance,
* FALSE if created via DirectDrawCreate. */
BOOL ex;
/* Linked list of surfaces, joined by next_ddraw in IDirectSurfaceImpl. */
IDirectDrawSurfaceImpl* surfaces;
/* Linked list of palettes, joined by next_ddraw. */
IDirectDrawPaletteImpl* palettes;
/* Linked list of clippers, joined by next_ddraw. */
IDirectDrawClipperImpl* clippers;
IDirectDrawSurfaceImpl* primary_surface;
DDRAWI_DIRECTDRAW_LCL local;
DDCAPS caps;
HWND window;
DWORD cooperative_level;
WNDPROC original_wndproc;
DWORD width, height;
LONG pitch;
DDPIXELFORMAT pixelformat;
DWORD cur_scanline;
/* Should each of these go into some structure? */
DWORD orig_width, orig_height;
LONG orig_pitch;
DDPIXELFORMAT orig_pixelformat;
/* Called when the refcount goes to 0. */
void (*final_release)(IDirectDrawImpl *This);
HRESULT (*set_exclusive_mode)(IDirectDrawImpl *This, DWORD dwExcl);
HRESULT (*create_palette)(IDirectDrawImpl* This, DWORD dwFlags,
LPDIRECTDRAWPALETTE* ppPalette,
LPUNKNOWN pUnkOuter);
/* Surface creation functions. For all of these, pOuter == NULL. */
/* Do not create any backbuffers or the flipping chain. */
HRESULT (*create_primary)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
/* Primary may be NULL if we are creating an unattached backbuffer. */
HRESULT (*create_backbuffer)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter,
IDirectDrawSurfaceImpl* primary);
/* shiny happy offscreenplain surfaces */
HRESULT (*create_offscreen)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter);
/* dwMipMapLevel is specified as per OpenGL. (i.e. 0 is base) */
HRESULT (*create_texture)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter,
DWORD dwMipMapLevel);
HRESULT (*create_zbuffer)(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf, LPUNKNOWN pOuter);
LPVOID private;
/* Everything below here is still questionable. */
DDPIXELFORMAT screen_pixelformat;
int pixmap_depth;
// pixel_convert_func pixel_convert;
// palette_convert_func palette_convert;
/* Use to fool some too strict games */
INT32 (*allocate_memory)(IDirectDrawImpl *This, DWORD mem);
void (*free_memory)(IDirectDrawImpl *This, DWORD mem);
DWORD total_vidmem, available_vidmem;
/* IDirect3D fields */
LPVOID d3d_private;
/* Used as a callback function to create a texture */
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 */
HRESULT (*d3d_added_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device);
HRESULT (*d3d_removed_device)(IDirectDrawImpl *d3d, IDirect3DDeviceImpl *device);
/* This is needed for delayed texture creation and Z buffer blits */
IDirect3DDeviceImpl *current_device;
/* This is for the fake mainWindow */
ATOM winclass;
PAINTSTRUCT ps;
BOOL paintable;
};
/*****************************************************************************
* IDirectDrawPalette implementation structure
*/
struct IDirectDrawPaletteImpl
{
/* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDrawPalette);
DWORD ref;
DDRAWI_DDRAWPALETTE_LCL local;
DDRAWI_DDRAWPALETTE_GBL global;
/* IDirectDrawPalette fields */
HPALETTE hpal;
WORD palVersion, palNumEntries; /* LOGPALETTE */
PALETTEENTRY palents[256];
/* This is to store the palette in 'screen format' */
int screen_palents[256];
VOID (*final_release)(IDirectDrawPaletteImpl* This);
IDirectDrawImpl* ddraw_owner;
IDirectDrawPaletteImpl* prev_ddraw;
IDirectDrawPaletteImpl* next_ddraw;
LPVOID private;
};
/*****************************************************************************
* IDirectDrawClipper implementation structure
*/
struct IDirectDrawClipperImpl
{
/* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDrawClipper);
DWORD ref;
/* IDirectDrawClipper fields */
HWND hWnd;
IDirectDrawImpl* ddraw_owner;
IDirectDrawClipperImpl* prev_ddraw;
IDirectDrawClipperImpl* next_ddraw;
};
/*****************************************************************************
* IDirectDrawSurface implementation structure
*/
struct IDirectDrawSurfaceImpl
{
/* IUnknown fields */
ICOM_VFIELD_MULTI(IDirectDrawSurface7);
ICOM_VFIELD_MULTI(IDirectDrawSurface3);
ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
ICOM_VFIELD_MULTI(IDirect3DTexture2);
ICOM_VFIELD_MULTI(IDirect3DTexture);
DWORD ref;
struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */
struct IDirectDrawSurfaceImpl* next_ddraw; /* ddraw surface chain */
struct IDirectDrawSurfaceImpl* prev_ddraw;
struct IDirectDrawSurfaceImpl* next_attached; /* attached surface chain */
struct IDirectDrawSurfaceImpl* prev_attached;
IDirectDrawImpl* ddraw_owner;
IDirectDrawSurfaceImpl* surface_owner;
IDirectDrawPaletteImpl* palette; /* strong ref */
IDirectDrawClipperImpl* clipper; /* strong ref */
DDRAWI_DDRAWSURFACE_LCL local;
DDRAWI_DDRAWSURFACE_MORE more;
/* FIXME: since Flip should swap the GBL structures, they should
* probably not be embedded into the IDirectDrawSurfaceImpl structure... */
LPDDRAWI_DDRAWSURFACE_GBL_MORE gmore;
DDRAWI_DDRAWSURFACE_GBL global;
DDRAWI_DDRAWSURFACE_GBL_MORE global_more;
DDSURFACEDESC2 surface_desc;
HDC hDC;
RECT lastlockrect;
DWORD lastlocktype;
BOOL dc_in_use;
BOOL locked;
HRESULT (*duplicate_surface)(IDirectDrawSurfaceImpl* src,
LPDIRECTDRAWSURFACE7* dst);
void (*final_release)(IDirectDrawSurfaceImpl *This);
HRESULT (*late_allocate)(IDirectDrawSurfaceImpl *This);
BOOL (*attach)(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *to);
BOOL (*detach)(IDirectDrawSurfaceImpl *This);
void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
void (*lose_surface)(IDirectDrawSurfaceImpl* This);
BOOL (*flip_data)(IDirectDrawSurfaceImpl* front,
IDirectDrawSurfaceImpl* back,
DWORD dwFlags);
void (*flip_update)(IDirectDrawSurfaceImpl* front, DWORD dwFlags);
HRESULT (*get_dc)(IDirectDrawSurfaceImpl* This, HDC* phDC);
HRESULT (*release_dc)(IDirectDrawSurfaceImpl* This, HDC hDC);
void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
void (*update_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal,
DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent);
HWND (*get_display_window)(IDirectDrawSurfaceImpl *This);
HRESULT (*get_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
HRESULT (*set_gamma_ramp)(IDirectDrawSurfaceImpl *This, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp);
struct PrivateData* private_data;
DWORD max_lod;
DWORD priority;
BOOL lost;
DWORD uniqueness_value;
LPVOID private;
/* Everything below here is dodgy. */
/* For Direct3D use */
LPVOID aux_ctx, aux_data;
void (*aux_release)(LPVOID ctx, LPVOID data);
BOOL (*aux_flip)(LPVOID ctx, LPVOID data);
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_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 );
/* This is to get the D3DDevice object associated to this surface */
struct IDirect3DDeviceImpl *d3ddevice;
/* This is for texture */
IDirectDrawSurfaceImpl *mip_main;
int mipmap_level;
LPVOID tex_private;
void (*lock_update_prev)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
void (*unlock_update_prev)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
BOOLEAN (*get_dirty_status)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
};
/*****************************************************************************
* Driver initialisation functions.
*/
BOOL DDRAW_HAL_Init(HINSTANCE, DWORD, LPVOID);
BOOL DDRAW_User_Init(HINSTANCE, DWORD, LPVOID);
typedef struct {
const DDDEVICEIDENTIFIER2* info;
int preference; /* how good we are. dga might get 100, xlib 50*/
HRESULT (*create)(const GUID*, LPDIRECTDRAW7*, LPUNKNOWN, BOOL ex);
/* For IDirectDraw7::Initialize. */
HRESULT (*init)(IDirectDrawImpl *, const GUID*);
} ddraw_driver;
void DDRAW_register_driver(const ddraw_driver*);
const ddraw_driver* DDRAW_FindDriver(const GUID* guid);
/******************************************************************************
* Random utilities
*/
/* Get DDSCAPS of surface (shortcutmacro) */
#define SDDSCAPS(iface) ((iface)->s.surface_desc.ddsCaps.dwCaps)
/* 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 GET_BPP(desc) PFGET_BPP(desc.u4.ddpfPixelFormat)
LONG DDRAW_width_bpp_to_pitch(DWORD width, DWORD bpp);
typedef struct {
unsigned short bpp,depth;
unsigned int rmask,gmask,bmask;
} ConvertMode;
typedef struct {
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);
} ConvertFuncs;
typedef struct {
ConvertMode screen, dest;
ConvertFuncs funcs;
} Convert;
extern Convert ModeEmulations[8];
extern int _common_depth_to_pixelformat(DWORD depth,LPDIRECTDRAW ddraw);
extern BOOL opengl_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_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);
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_DXT5 fetch_2d_texel_rgba_dxt5;
/******************************************************************************
* Structure conversion (for thunks)
*/
void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut);
void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
DDDEVICEIDENTIFIER* pOut);
/******************************************************************************
* Debugging / Flags output functions
*/
extern void DDRAW_dump_DDBLTFX(DWORD flagmask);
extern void DDRAW_dump_DDBLTFAST(DWORD flagmask);
extern void DDRAW_dump_DDBLT(DWORD flagmask);
extern void DDRAW_dump_DDSCAPS(const DDSCAPS *in);
extern void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
extern void DDRAW_dump_pixelformat_flag(DWORD flagmask);
extern void DDRAW_dump_paletteformat(DWORD dwFlags);
extern void DDRAW_dump_pixelformat(const DDPIXELFORMAT *in);
extern void DDRAW_dump_colorkeyflag(DWORD ck);
extern void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
extern void DDRAW_dump_cooperativelevel(DWORD cooplevel);
extern void DDRAW_dump_lockflag(DWORD lockflag);
extern void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *in);
extern void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
extern void DDRAW_dump_surface_to_disk(IDirectDrawSurfaceImpl *surface, FILE *f, int scale) ;
/* Used for generic dumping */
typedef struct
{
DWORD val;
const char* name;
} flag_info;
#define FE(x) { x, #x }
typedef struct
{
DWORD val;
const char* name;
void (*func)(const void *);
ptrdiff_t offset;
} member_info;
#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) }
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);
#endif /* __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H */

View file

@ -1,330 +0,0 @@
/* DirectDraw HAL driver
*
* Copyright 2001 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* 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,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include "ddraw.h"
#include "rosddraw.h"
#include "ddraw_private.h"
static IDirectDraw7Vtbl MAIN_DirectDraw_VTable;
HRESULT MAIN_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex)
{
//This->local.lpGbl = &dd_gbl;
This->final_release = MAIN_DirectDraw_final_release;
This->set_exclusive_mode = MAIN_DirectDrawSet_exclusive_mode;
// This->create_palette = MAIN_DirectDrawPalette_Create;
This->create_primary = MAIN_DirectDraw_create_primary;
This->create_backbuffer = MAIN_DirectDraw_create_backbuffer;
This->create_texture = MAIN_DirectDraw_create_texture;
ICOM_INIT_INTERFACE(This, IDirectDraw7, MAIN_DirectDraw_VTable);
return S_OK;
}
void MAIN_DirectDraw_final_release(IDirectDrawImpl *This)
{
}
HRESULT MAIN_DirectDrawSet_exclusive_mode(IDirectDrawImpl *This, DWORD dwEnterExcl)
{
return DDERR_UNSUPPORTED;
}
HRESULT MAIN_DirectDraw_create_primary(IDirectDrawImpl* This, const DDSURFACEDESC2* pDDSD, LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter)
{
return DDERR_UNSUPPORTED;
}
HRESULT MAIN_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter,
IDirectDrawSurfaceImpl* primary)
{
return DDERR_UNSUPPORTED;
}
HRESULT MAIN_DirectDraw_create_texture(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter,
DWORD dwMipMapLevel)
{
return DDERR_UNSUPPORTED;
}
/* basic funtion for the com object */
HRESULT WINAPI MAIN_DirectDraw_QueryInterface(LPDIRECTDRAW7 iface,REFIID refiid,LPVOID *obj)
{
return DDERR_UNSUPPORTED;
}
ULONG WINAPI MAIN_DirectDraw_AddRef(LPDIRECTDRAW7 iface)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
//TRACE("(%p)->() incrementing from %lu.\n", This, ref -1);
return ref;
}
ULONG WINAPI MAIN_DirectDraw_Release(LPDIRECTDRAW7 iface)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
{
if (This->final_release != NULL)
This->final_release(This);
/* We free the private. This is an artifact of the fact that I don't
* have the destructors set up correctly. */
if (This->private != (This+1))
HeapFree(GetProcessHeap(), 0, This->private);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
HRESULT WINAPI MAIN_DirectDraw_Compact(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper, IUnknown *pUnkOuter)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE* ppPalette,LPUNKNOWN pUnknown)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_CreateSurface(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,IUnknown *pUnkOuter)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src,
LPDIRECTDRAWSURFACE7* dst)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 lpDDSD2, LPVOID context,
LPDDENUMSURFACESCALLBACK7 callback)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
LPDDCAPS pHELCaps)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetGDISurface(LPDIRECTDRAW7 iface,
LPDIRECTDRAWSURFACE7 *lplpGDIDDSSurface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL status)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_Initialize(LPDIRECTDRAW7 iface, LPGUID lpGuid)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_SetCooperativeLevel(LPDIRECTDRAW7 iface, HWND hwnd,
DWORD cooplevel)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,
HANDLE h)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps,
LPDWORD total, LPDWORD free)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetSurfaceFromDC(LPDIRECTDRAW7 iface, HDC hdc,
LPDIRECTDRAWSURFACE7 *lpDDS)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_RestoreAllSurfaces(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_TestCooperativeLevel(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_StartModeTest(LPDIRECTDRAW7 iface, LPSIZE pModes,
DWORD dwNumModes, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI MAIN_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b)
{
return DDERR_UNSUPPORTED;
}
/* End com interface */
HRESULT WINAPI MAIN_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex)
{
IDirectDrawImpl* This;
*pIface = ICOM_INTERFACE(This, IDirectDraw7);
return DD_OK;
}
static IDirectDraw7Vtbl MAIN_DirectDraw_VTable =
{
MAIN_DirectDraw_QueryInterface,
MAIN_DirectDraw_AddRef,
MAIN_DirectDraw_Release,
MAIN_DirectDraw_Compact,
MAIN_DirectDraw_CreateClipper,
MAIN_DirectDraw_CreatePalette,
MAIN_DirectDraw_CreateSurface,
MAIN_DirectDraw_DuplicateSurface,
MAIN_DirectDraw_EnumDisplayModes,
MAIN_DirectDraw_EnumSurfaces,
MAIN_DirectDraw_FlipToGDISurface,
MAIN_DirectDraw_GetCaps,
MAIN_DirectDraw_GetDisplayMode,
MAIN_DirectDraw_GetFourCCCodes,
MAIN_DirectDraw_GetGDISurface,
MAIN_DirectDraw_GetMonitorFrequency,
MAIN_DirectDraw_GetScanLine,
MAIN_DirectDraw_GetVerticalBlankStatus,
MAIN_DirectDraw_Initialize,
MAIN_DirectDraw_RestoreDisplayMode,
MAIN_DirectDraw_SetCooperativeLevel,
MAIN_DirectDraw_SetDisplayMode,
MAIN_DirectDraw_WaitForVerticalBlank,
MAIN_DirectDraw_GetAvailableVidMem,
MAIN_DirectDraw_GetSurfaceFromDC,
MAIN_DirectDraw_RestoreAllSurfaces,
MAIN_DirectDraw_TestCooperativeLevel,
MAIN_DirectDraw_GetDeviceIdentifier,
MAIN_DirectDraw_StartModeTest,
MAIN_DirectDraw_EvaluateMode
};

View file

@ -0,0 +1,62 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS
* FILE: lib/ddraw/hal/ddraw.c
* PURPOSE: DirectDraw HAL Implementation
* PROGRAMMER: Magnus Olsen, Maarten Bosma
*
*/
#include "rosdraw.h"
HRESULT Hal_DirectDraw_Initialize (LPDIRECTDRAW7 iface)
{
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
if(!DdCreateDirectDrawObject (&This->DirectDrawGlobal, This->hdc))
return DDERR_INVALIDPARAMS;
This->HalInfo.dwSize = sizeof(DDHALINFO);
This->DriverCallbacks.DdMain.dwSize = sizeof(DDHAL_DDCALLBACKS);
This->DriverCallbacks.DdSurface.dwSize = sizeof(DDHAL_DDSURFACECALLBACKS);
This->DriverCallbacks.DdPalette.dwSize = sizeof(DDHAL_DDPALETTECALLBACKS);
This->DriverCallbacks.D3dMain.dwSize = sizeof(D3DHAL_CALLBACKS);
This->DriverCallbacks.D3dDriverData.dwSize = sizeof(D3DHAL_GLOBALDRIVERDATA);
This->DriverCallbacks.D3dBufferCallbacks.dwSize = sizeof(DDHAL_DDEXEBUFCALLBACKS);
if(!DdQueryDirectDrawObject (
&This->DirectDrawGlobal,
&This->HalInfo,
&This->DriverCallbacks.DdMain,
&This->DriverCallbacks.DdSurface,
&This->DriverCallbacks.DdPalette,
&This->DriverCallbacks.D3dMain,
&This->DriverCallbacks.D3dDriverData,
&This->DriverCallbacks.D3dBufferCallbacks,
NULL,
NULL,
NULL ))
return DDERR_INVALIDPARAMS;
// ToDo: Second DdQueryDirectDrawObject without the three NULLs
return DD_OK;
}
HRESULT Hal_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface)
{
return DD_OK;
}
VOID Hal_DirectDraw_Release (LPDIRECTDRAW7 iface)
{
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
DdDeleteDirectDrawObject (&This->DirectDrawGlobal);
}

View file

@ -0,0 +1,11 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS
* FILE: lib/ddraw/hal/surface.c
* PURPOSE: DirectDraw HAL Implementation
* PROGRAMMER: Magnus Olsen, Maarten Bosma
*
*/
#include "rosdraw.h"

90
reactos/lib/ddraw/main.c Normal file
View file

@ -0,0 +1,90 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ddraw/ddraw.c
* PURPOSE: DirectDraw Library
* PROGRAMMER: Magnus Olsen (greatlrd)
*
*/
#include <windows.h>
#include "rosdraw.h"
HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
IUnknown* pUnkOuter, BOOL ex)
{
if (pUnkOuter!=NULL)
return DDERR_INVALIDPARAMS;
IDirectDrawImpl* This = (IDirectDrawImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawImpl));
if (This == NULL)
return E_OUTOFMEMORY;
This->lpVtbl = &DirectDraw_VTable;
This->ref = 1;
*pIface = (LPDIRECTDRAW)This;
return This->lpVtbl->Initialize ((LPDIRECTDRAW7)This, pGUID);
}
HRESULT WINAPI DirectDrawCreate (LPGUID lpGUID, LPDIRECTDRAW* lplpDD, LPUNKNOWN pUnkOuter)
{
return Create_DirectDraw (lpGUID, lplpDD, pUnkOuter, FALSE);
}
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID* lplpDD, REFIID iid, LPUNKNOWN pUnkOuter)
{
if (!IsEqualGUID(iid, &IID_IDirectDraw7))
return DDERR_INVALIDPARAMS;
return Create_DirectDraw (lpGUID, (LPDIRECTDRAW*)lplpDD, pUnkOuter, TRUE);
}
HRESULT WINAPI DirectDrawEnumerateA(
LPDDENUMCALLBACKA lpCallback,
LPVOID lpContext
)
{
return DD_OK;
}
HRESULT WINAPI DirectDrawEnumerateW(
LPDDENUMCALLBACKW lpCallback,
LPVOID lpContext
)
{
return DD_OK;
}
HRESULT WINAPI DirectDrawEnumerateExA(
LPDDENUMCALLBACKEXA lpCallback,
LPVOID lpContext,
DWORD dwFlags
)
{
return DD_OK;
}
HRESULT WINAPI DirectDrawEnumerateExW(
LPDDENUMCALLBACKEXW lpCallback,
LPVOID lpContext,
DWORD dwFlags
)
{
return DD_OK;
}
HRESULT WINAPI DirectDrawCreateClipper(
DWORD dwFlags,
LPDIRECTDRAWCLIPPER* lplpDDClipper,
LPUNKNOWN pUnkOuter
)
{
return DD_OK;
}

View file

@ -0,0 +1,345 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS
* FILE: lib/ddraw/main/ddraw.c
* PURPOSE: DirectDraw Implementation
* PROGRAMMER: Magnus Olsen, Maarten Bosma
*
*/
#include "rosdraw.h"
HRESULT WINAPI Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
{
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
HRESULT ret;
// this if it is not called by DirectDrawCreate
if(FALSE)
return DDERR_ALREADYINITIALIZED;
// save the parameter
This->lpGUID = lpGUID;
// get the HDC
This->hdc = CreateDC (L"Display", NULL, NULL, NULL);
This->Height = GetDeviceCaps(This->hdc, HORZRES);
This->Width = GetDeviceCaps(This->hdc, VERTRES);
This->Bpp = GetDeviceCaps(This->hdc, BITSPIXEL);
// call software first
if((ret = Hal_DirectDraw_Initialize (iface)) != DD_OK)
return ret;
// ... then overwrite with hal
if((ret = Hel_DirectDraw_Initialize (iface)) != DD_OK)
return ret;
return DD_OK;
}
HRESULT WINAPI Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD cooplevel)
{
// TODO:
// - create a scaner that check which driver we should get the HDC from
// for now we always asume it is the active dirver that should be use.
// - allow more Flags
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
HRESULT ret;
// check the parameters
if (This->cooperative_level == cooplevel && This->window == hwnd)
return DD_OK;
if (This->window)
return DDERR_HWNDALREADYSET;
if (This->cooperative_level)
return DDERR_EXCLUSIVEMODEALREADYSET;
if ((cooplevel&DDSCL_EXCLUSIVE) && !(cooplevel&DDSCL_FULLSCREEN))
return DDERR_INVALIDPARAMS;
if (cooplevel&DDSCL_NORMAL && cooplevel&DDSCL_FULLSCREEN)
return DDERR_INVALIDPARAMS;
// set the data
This->window = hwnd;
This->hdc = GetDC(hwnd);
This->cooperative_level = cooplevel;
if((ret = Hel_DirectDraw_SetCooperativeLevel (iface)) != DD_OK)
return ret;
if((ret = Hal_DirectDraw_SetCooperativeLevel (iface)) != DD_OK)
return ret;
return DD_OK;
}
HRESULT WINAPI Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight,
DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
{
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
// this only for exclusive mode
if(!This->cooperative_level & DDSCL_EXCLUSIVE)
return DDERR_NOEXCLUSIVEMODE;
// change the resolution using normal WinAPI function
DEVMODE mode;
mode.dmSize = sizeof(mode);
mode.dmPelsWidth = dwWidth;
mode.dmPelsHeight = dwHeight;
mode.dmBitsPerPel = dwBPP;
mode.dmDisplayFrequency = dwRefreshRate;
mode.dmFields = 0;
if(dwWidth)
mode.dmFields |= DM_PELSWIDTH;
if(dwHeight)
mode.dmFields |= DM_PELSHEIGHT;
if(dwBPP)
mode.dmFields |= DM_BITSPERPEL;
if(dwRefreshRate)
mode.dmFields |= DM_DISPLAYFREQUENCY;
if (ChangeDisplaySettings(&mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
return DDERR_UNSUPPORTEDMODE;
// TODO: reactivate ddraw object, maximize window, set it in foreground
// and set excluive mode (if implemented by the driver)
if(dwWidth)
This->Height = dwWidth;
if(dwHeight)
This->Width = dwHeight;
if(dwBPP)
This->Bpp = dwBPP;
return DD_OK;
}
HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter)
{
if (pUnkOuter!=NULL)
return DDERR_INVALIDPARAMS;
if(sizeof(DDSURFACEDESC2)!=pDDSD->dwSize)
return DDERR_UNSUPPORTED;
// the nasty com stuff
IDirectDrawSurfaceImpl* That;
That = (IDirectDrawSurfaceImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawSurfaceImpl));
if (That == NULL)
return E_OUTOFMEMORY;
That->lpVtbl = &DDrawSurface_VTable;
That->ref = 1;
*ppSurf = (LPDIRECTDRAWSURFACE7)That;
// the real surface object creation
return That->lpVtbl->Initialize (*ppSurf, (LPDIRECTDRAW)iface, pDDSD);
}
ULONG WINAPI Main_DirectDraw_AddRef (LPDIRECTDRAW7 iface)
{
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
ULONG ref = InterlockedIncrement(&This->ref);
return ref;
}
ULONG WINAPI Main_DirectDraw_Release (LPDIRECTDRAW7 iface)
{
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
{
// set resoltion back to the one in registry
if(This->cooperative_level & DDSCL_EXCLUSIVE)
ChangeDisplaySettings(NULL, 0);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/**** Stubs ****/
HRESULT WINAPI Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,REFIID refiid,LPVOID *obj)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_Compact(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper, IUnknown *pUnkOuter)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE* ppPalette,LPUNKNOWN pUnknown)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src,
LPDIRECTDRAWSURFACE7* dst)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 lpDDSD2, LPVOID context,
LPDDENUMSURFACESCALLBACK7 callback)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
LPDDCAPS pHELCaps)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetGDISurface(LPDIRECTDRAW7 iface,
LPDIRECTDRAWSURFACE7 *lplpGDIDDSSurface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL status)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,
HANDLE h)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps,
LPDWORD total, LPDWORD free)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetSurfaceFromDC(LPDIRECTDRAW7 iface, HDC hdc,
LPDIRECTDRAWSURFACE7 *lpDDS)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_RestoreAllSurfaces(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_TestCooperativeLevel(LPDIRECTDRAW7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_StartModeTest(LPDIRECTDRAW7 iface, LPSIZE pModes,
DWORD dwNumModes, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b)
{
return DDERR_UNSUPPORTED;
}
IDirectDraw7Vtbl DirectDraw_VTable =
{
Main_DirectDraw_QueryInterface,
Main_DirectDraw_AddRef,
Main_DirectDraw_Release,
Main_DirectDraw_Compact,
Main_DirectDraw_CreateClipper,
Main_DirectDraw_CreatePalette,
Main_DirectDraw_CreateSurface,
Main_DirectDraw_DuplicateSurface,
Main_DirectDraw_EnumDisplayModes,
Main_DirectDraw_EnumSurfaces,
Main_DirectDraw_FlipToGDISurface,
Main_DirectDraw_GetCaps,
Main_DirectDraw_GetDisplayMode,
Main_DirectDraw_GetFourCCCodes,
Main_DirectDraw_GetGDISurface,
Main_DirectDraw_GetMonitorFrequency,
Main_DirectDraw_GetScanLine,
Main_DirectDraw_GetVerticalBlankStatus,
Main_DirectDraw_Initialize,
Main_DirectDraw_RestoreDisplayMode,
Main_DirectDraw_SetCooperativeLevel,
Main_DirectDraw_SetDisplayMode,
Main_DirectDraw_WaitForVerticalBlank,
Main_DirectDraw_GetAvailableVidMem,
Main_DirectDraw_GetSurfaceFromDC,
Main_DirectDraw_RestoreAllSurfaces,
Main_DirectDraw_TestCooperativeLevel,
Main_DirectDraw_GetDeviceIdentifier,
Main_DirectDraw_StartModeTest,
Main_DirectDraw_EvaluateMode
};

View file

@ -0,0 +1,445 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS
* FILE: lib/ddraw/main/surface.c
* PURPOSE: DirectDraw Implementation
* PROGRAMMER: Magnus Olsen, Maarten Bosma
*
*/
#include "rosdraw.h"
HRESULT WINAPI Main_DDrawSurface_Initialize (LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAW pDD, LPDDSURFACEDESC2 pDDSD)
{
IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
if (This->owner)
return DDERR_ALREADYINITIALIZED;
if(sizeof(DDSURFACEDESC2) != pDDSD->dwSize)
return DDERR_UNSUPPORTED;
if(!pDDSD->dwFlags & DDSD_CAPS)
return DDERR_INVALIDPARAMS;
This->owner = (IDirectDrawImpl*)pDD;
// Surface Global Struct
DDRAWI_DDRAWSURFACE_GBL Global;
memset(&Global, 0, sizeof(DDRAWI_DDRAWSURFACE_GBL));
if(pDDSD->ddsCaps.dwCaps == DDSCAPS_PRIMARYSURFACE)
Global.dwGlobalFlags |= DDRAWISURFGBL_ISGDISURFACE;
Global.lpDD = &This->owner->DirectDrawGlobal;
Global.wHeight = This->owner->Width;
Global.wWidth = This->owner->Height;
Global.dwLinearSize = Global.wWidth * This->owner->Bpp/8;
// Surface More Struct
DDRAWI_DDRAWSURFACE_MORE More;
memset(&More, 0, sizeof(DDRAWI_DDRAWSURFACE_MORE));
More.dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
// Surface Local Struct
DDRAWI_DDRAWSURFACE_LCL Local;
memset(&Local, 0, sizeof(DDRAWI_DDRAWSURFACE_LCL));
Local.lpGbl = &Global;
Local.lpSurfMore = &More;
Local.ddsCaps = *(DDSCAPS*)&pDDSD->ddsCaps;
if(pDDSD->ddsCaps.dwCaps == DDSCAPS_PRIMARYSURFACE)
Local.dwFlags |= DDRAWISURF_FRONTBUFFER;
DDRAWI_DDRAWSURFACE_LCL* pLocal = &Local; // for stupid double pointer below
// The Parameter Struct
DDHAL_CREATESURFACEDATA CreateData;
memset(&CreateData, 0, sizeof(DDHAL_CREATESURFACEDATA));
CreateData.lpDD = &This->owner->DirectDrawGlobal;
CreateData.lpDDSurfaceDesc = (DDSURFACEDESC*)pDDSD;
CreateData.dwSCnt = 1;
CreateData.lplpSList = &pLocal;
if(!This->owner->DriverCallbacks.DdMain.CreateSurface (&CreateData) != DDHAL_DRIVER_HANDLED)
return DDERR_INVALIDPARAMS;
OutputDebugString(L"This does not get hit.");
if(CreateData.ddRVal != DD_OK)
return CreateData.ddRVal;
return DD_OK;
}
HRESULT WINAPI Main_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst,
LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx)
{
return DD_OK;
}
HRESULT WINAPI Main_DDrawSurface_Lock (LPDIRECTDRAWSURFACE7 iface, LPRECT prect,
LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE event)
{
return DD_OK;
}
HRESULT WINAPI Main_DDrawSurface_Unlock (LPDIRECTDRAWSURFACE7 iface, LPRECT pRect)
{
return DD_OK;
}
ULONG WINAPI Main_DDrawSurface_AddRef(LPDIRECTDRAWSURFACE7 iface)
{
IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
return InterlockedIncrement(&This->ref);
}
ULONG WINAPI Main_DDrawSurface_Release(LPDIRECTDRAWSURFACE7 iface)
{
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
return ref;
}
/**** Stubs ****/
HRESULT WINAPI
Main_DDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid,
LPVOID* ppObj)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_AddAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWSURFACE7 pAttach)
{
return DDERR_UNSUPPORTED;
}
/* MSDN: "not currently implemented." */
HRESULT WINAPI
Main_DDrawSurface_AddOverlayDirtyRect(LPDIRECTDRAWSURFACE7 iface,
LPRECT pRect)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
DWORD dsty, LPDIRECTDRAWSURFACE7 src,
LPRECT rsrc, DWORD trans)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_Restore(LPDIRECTDRAWSURFACE7 iface)
{
return DDERR_UNSUPPORTED;
}
/* MSDN: "not currently implemented." */
HRESULT WINAPI
Main_DDrawSurface_BltBatch(LPDIRECTDRAWSURFACE7 iface,
LPDDBLTBATCH pBatch, DWORD dwCount,
DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_ChangeUniquenessValue(LPDIRECTDRAWSURFACE7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_DeleteAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags,
LPDIRECTDRAWSURFACE7 pAttach)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_EnumAttachedSurfaces(LPDIRECTDRAWSURFACE7 iface,
LPVOID context,
LPDDENUMSURFACESCALLBACK7 cb)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_EnumOverlayZOrders(LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags, LPVOID context,
LPDDENUMSURFACESCALLBACK7 cb)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_Flip(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWSURFACE7 override, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_FreePrivateData(LPDIRECTDRAWSURFACE7 iface, REFGUID tag)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
LPDDSCAPS2 pCaps,
LPDIRECTDRAWSURFACE7* ppSurface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetBltStatus(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetCaps(LPDIRECTDRAWSURFACE7 iface, LPDDSCAPS2 pCaps)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetClipper(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWCLIPPER* ppClipper)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetColorKey(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags,
LPDDCOLORKEY pCKey)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetDDInterface(LPDIRECTDRAWSURFACE7 iface, LPVOID* pDD)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetFlipStatus(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetLOD(LPDIRECTDRAWSURFACE7 iface, LPDWORD pdwMaxLOD)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetOverlayPosition(LPDIRECTDRAWSURFACE7 iface,
LPLONG pX, LPLONG pY)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetPalette(LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWPALETTE* ppPalette)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetPixelFormat(LPDIRECTDRAWSURFACE7 iface,
LPDDPIXELFORMAT pDDPixelFormat)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetPriority(LPDIRECTDRAWSURFACE7 iface,
LPDWORD pdwPriority)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetPrivateData(LPDIRECTDRAWSURFACE7 iface,
REFGUID tag, LPVOID pBuffer,
LPDWORD pcbBufferSize)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
LPDDSURFACEDESC2 pDDSD)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_GetUniquenessValue(LPDIRECTDRAWSURFACE7 iface,
LPDWORD pValue)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_IsLost(LPDIRECTDRAWSURFACE7 iface)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_PageLock(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_PageUnlock(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface, HDC hDC)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_SetClipper (LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWCLIPPER pDDClipper)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_SetColorKey (LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags, LPDDCOLORKEY pCKey)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_SetLOD (LPDIRECTDRAWSURFACE7 iface, DWORD dwMaxLOD)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_SetOverlayPosition (LPDIRECTDRAWSURFACE7 iface,
LONG X, LONG Y)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_SetPalette (LPDIRECTDRAWSURFACE7 iface,
LPDIRECTDRAWPALETTE pPalette)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_SetPriority (LPDIRECTDRAWSURFACE7 iface,
DWORD dwPriority)
{
return DDERR_UNSUPPORTED;
}
/* Be careful when locking this: it is risky to call the object's AddRef
* or Release holding a lock. */
HRESULT WINAPI
Main_DDrawSurface_SetPrivateData (LPDIRECTDRAWSURFACE7 iface,
REFGUID tag, LPVOID pData,
DWORD cbSize, DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_DDrawSurface_UpdateOverlay (LPDIRECTDRAWSURFACE7 iface,
LPRECT pSrcRect,
LPDIRECTDRAWSURFACE7 pDstSurface,
LPRECT pDstRect, DWORD dwFlags,
LPDDOVERLAYFX pFX)
{
return DDERR_UNSUPPORTED;
}
/* MSDN: "not currently implemented." */
HRESULT WINAPI
Main_DDrawSurface_UpdateOverlayDisplay (LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags)
{
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI Main_DDrawSurface_UpdateOverlayZOrder (LPDIRECTDRAWSURFACE7 iface,
DWORD dwFlags, LPDIRECTDRAWSURFACE7 pDDSRef)
{
return DDERR_NOTAOVERLAYSURFACE;
}
IDirectDrawSurface7Vtbl DDrawSurface_VTable =
{
Main_DDrawSurface_QueryInterface,
Main_DDrawSurface_AddRef,
Main_DDrawSurface_Release,
Main_DDrawSurface_AddAttachedSurface,
Main_DDrawSurface_AddOverlayDirtyRect,
Main_DDrawSurface_Blt,
Main_DDrawSurface_BltBatch,
Main_DDrawSurface_BltFast,
Main_DDrawSurface_DeleteAttachedSurface,
Main_DDrawSurface_EnumAttachedSurfaces,
Main_DDrawSurface_EnumOverlayZOrders,
Main_DDrawSurface_Flip,
Main_DDrawSurface_GetAttachedSurface,
Main_DDrawSurface_GetBltStatus,
Main_DDrawSurface_GetCaps,
Main_DDrawSurface_GetClipper,
Main_DDrawSurface_GetColorKey,
Main_DDrawSurface_GetDC,
Main_DDrawSurface_GetFlipStatus,
Main_DDrawSurface_GetOverlayPosition,
Main_DDrawSurface_GetPalette,
Main_DDrawSurface_GetPixelFormat,
Main_DDrawSurface_GetSurfaceDesc,
Main_DDrawSurface_Initialize,
Main_DDrawSurface_IsLost,
Main_DDrawSurface_Lock,
Main_DDrawSurface_ReleaseDC,
Main_DDrawSurface_Restore,
Main_DDrawSurface_SetClipper,
Main_DDrawSurface_SetColorKey,
Main_DDrawSurface_SetOverlayPosition,
Main_DDrawSurface_SetPalette,
Main_DDrawSurface_Unlock,
Main_DDrawSurface_UpdateOverlay,
Main_DDrawSurface_UpdateOverlayDisplay,
Main_DDrawSurface_UpdateOverlayZOrder
};

View file

@ -1,497 +0,0 @@
/*
* self-registerable dll functions for ddraw.dll
*
* Copyright (C) 2003 John K. Hohm
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* 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,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* this file are from wine ddraw with some modification
*/
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "ddraw.h"
//#include "wine/debug.h"
//WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/*
* Near the bottom of this file are the exported DllRegisterServer and
* DllUnregisterServer, which make all this worthwhile.
*/
/***********************************************************************
* interface for self-registering
*/
struct regsvr_interface
{
IID const *iid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
IID const *base_iid; /* can be NULL to omit */
int num_methods; /* can be <0 to omit */
CLSID const *ps_clsid; /* can be NULL to omit */
CLSID const *ps_clsid32; /* can be NULL to omit */
};
static HRESULT register_interfaces(struct regsvr_interface const *list);
static HRESULT unregister_interfaces(struct regsvr_interface const *list);
struct regsvr_coclass
{
CLSID const *clsid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
LPCSTR ips; /* can be NULL to omit */
LPCSTR ips32; /* can be NULL to omit */
LPCSTR ips32_tmodel; /* can be NULL to omit */
LPCSTR clsid_str; /* can be NULL to omit */
LPCSTR progid; /* can be NULL to omit */
};
static HRESULT register_coclasses(struct regsvr_coclass const *list);
static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
/***********************************************************************
* static string constants
*/
static WCHAR const interface_keyname[10] = {
'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
static WCHAR const base_ifa_keyname[14] = {
'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
'e', 0 };
static WCHAR const num_methods_keyname[11] = {
'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
static WCHAR const ps_clsid_keyname[15] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', 0 };
static WCHAR const ps_clsid32_keyname[17] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', '3', '2', 0 };
static WCHAR const clsid_keyname[6] = {
'C', 'L', 'S', 'I', 'D', 0 };
static WCHAR const ips_keyname[13] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
0 };
static WCHAR const ips32_keyname[15] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
'3', '2', 0 };
static WCHAR const progid_keyname[7] = {
'P', 'r', 'o', 'g', 'I', 'D', 0 };
static char const tmodel_valuename[] = "ThreadingModel";
/***********************************************************************
* static helper functions
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
WCHAR const *value);
static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
char const *value);
static LONG recursive_delete_key(HKEY key);
static LONG recursive_delete_keyA(HKEY base, char const *name);
static LONG recursive_delete_keyW(HKEY base, WCHAR const *name);
/***********************************************************************
* register_interfaces
*/
static HRESULT register_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
HKEY iid_key;
StringFromGUID2(list->iid, buf, 39);
res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_interface_key;
if (list->name) {
res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->base_iid) {
register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (0 <= list->num_methods) {
static WCHAR const fmt[3] = { '%', 'd', 0 };
HKEY key;
res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
wsprintfW(buf, fmt, list->num_methods);
res = RegSetValueExW(key, NULL, 0, REG_SZ,
(CONST BYTE*)buf,
(lstrlenW(buf) + 1) * sizeof(WCHAR));
RegCloseKey(key);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid) {
register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid32) {
register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
error_close_iid_key:
RegCloseKey(iid_key);
}
error_close_interface_key:
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_interfaces
*/
static HRESULT unregister_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
KEY_READ | KEY_WRITE, &interface_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->iid, buf, 39);
res = recursive_delete_keyW(interface_key, buf);
}
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* register_coclasses
*/
static HRESULT register_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
HKEY clsid_key;
StringFromGUID2(list->clsid, buf, 39);
res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->name) {
res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips) {
res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips32) {
HKEY ips32_key;
res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&ips32_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
(CONST BYTE*)list->ips32,
lstrlenA(list->ips32) + 1);
if (res == ERROR_SUCCESS && list->ips32_tmodel)
res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
(CONST BYTE*)list->ips32_tmodel,
strlen(list->ips32_tmodel) + 1);
RegCloseKey(ips32_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->clsid_str) {
res = register_key_defvalueA(clsid_key, clsid_keyname,
list->clsid_str);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->progid) {
HKEY progid_key;
res = register_key_defvalueA(clsid_key, progid_keyname,
list->progid);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegCreateKeyExA(HKEY_CLASSES_ROOT, list->progid, 0,
NULL, 0, KEY_READ | KEY_WRITE, NULL,
&progid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = register_key_defvalueW(progid_key, clsid_keyname, buf);
RegCloseKey(progid_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
error_close_clsid_key:
RegCloseKey(clsid_key);
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_coclasses
*/
static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
KEY_READ | KEY_WRITE, &coclass_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->clsid, buf, 39);
res = recursive_delete_keyW(coclass_key, buf);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->progid) {
res = recursive_delete_keyA(HKEY_CLASSES_ROOT, list->progid);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
}
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* regsvr_key_guid
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
{
WCHAR buf[39];
StringFromGUID2(guid, buf, 39);
return register_key_defvalueW(base, name, buf);
}
/***********************************************************************
* regsvr_key_defvalueW
*/
static LONG register_key_defvalueW(
HKEY base,
WCHAR const *name,
WCHAR const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
(lstrlenW(value) + 1) * sizeof(WCHAR));
RegCloseKey(key);
return res;
}
/***********************************************************************
* regsvr_key_defvalueA
*/
static LONG register_key_defvalueA(
HKEY base,
WCHAR const *name,
char const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
lstrlenA(value) + 1);
RegCloseKey(key);
return res;
}
/***********************************************************************
* recursive_delete_key
*/
static LONG recursive_delete_key(HKEY key)
{
LONG res;
WCHAR subkey_name[MAX_PATH];
DWORD cName;
HKEY subkey;
for (;;) {
cName = sizeof(subkey_name) / sizeof(WCHAR);
res = RegEnumKeyExW(key, 0, subkey_name, &cName,
NULL, NULL, NULL, NULL);
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) {
res = ERROR_SUCCESS; /* presumably we're done enumerating */
break;
}
res = RegOpenKeyExW(key, subkey_name, 0,
KEY_READ | KEY_WRITE, &subkey);
if (res == ERROR_FILE_NOT_FOUND) continue;
if (res != ERROR_SUCCESS) break;
res = recursive_delete_key(subkey);
RegCloseKey(subkey);
if (res != ERROR_SUCCESS) break;
}
if (res == ERROR_SUCCESS) res = RegDeleteKeyW(key, 0);
return res;
}
/***********************************************************************
* recursive_delete_keyA
*/
static LONG recursive_delete_keyA(HKEY base, char const *name)
{
LONG res;
HKEY key;
res = RegOpenKeyExA(base, name, 0, KEY_READ | KEY_WRITE, &key);
if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
if (res != ERROR_SUCCESS) return res;
res = recursive_delete_key(key);
RegCloseKey(key);
return res;
}
/***********************************************************************
* recursive_delete_keyW
*/
static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
{
LONG res;
HKEY key;
res = RegOpenKeyExW(base, name, 0, KEY_READ | KEY_WRITE, &key);
if (res == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS;
if (res != ERROR_SUCCESS) return res;
res = recursive_delete_key(key);
RegCloseKey(key);
return res;
}
/***********************************************************************
* coclass list
*/
static struct regsvr_coclass const coclass_list[] = {
{ &CLSID_DirectDraw,
"DirectDraw Object",
NULL,
"ddraw.dll",
"Both"
},
{ &CLSID_DirectDrawClipper,
"DirectDraw Clipper Object",
NULL,
"ddraw.dll",
"Both"
},
{ NULL } /* list terminator */
};
/***********************************************************************
* interface list
*/
static struct regsvr_interface const interface_list[] = {
{ NULL } /* list terminator */
};
/***********************************************************************
* DllRegisterServer (DDRAW.@)
*/
HRESULT WINAPI DDRAW_DllRegisterServer()
{
HRESULT hr;
//TRACE("\n");
hr = register_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = register_interfaces(interface_list);
return hr;
}
/***********************************************************************
* DllUnregisterServer (DDRAW.@)
*/
HRESULT WINAPI DDRAW_DllUnregisterServer()
{
HRESULT hr;
//TRACE("\n");
hr = unregister_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = unregister_interfaces(interface_list);
return hr;
}

View file

@ -1,125 +0,0 @@
/*
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ddraw/ddraw.c
* PURPOSE: ddraw lib
* PROGRAMMER: Magnus Olsen
* UPDATE HISTORY:
*/
#include "ddraw_private.h"
HANDLE STDCALL OsThunkDdCreateDirectDrawObject(HDC hdc);
void HAL_DirectDraw_final_release(IDirectDrawImpl *This);
HRESULT HAL_DirectDrawSet_exclusive_mode(IDirectDrawImpl *This, DWORD dwEnterExcl);
HRESULT HAL_DirectDraw_create_primary(IDirectDrawImpl* This, const DDSURFACEDESC2* pDDSD, LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter);
HRESULT HAL_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter,
IDirectDrawSurfaceImpl* primary);
HRESULT HAL_DirectDraw_create_texture(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter,
DWORD dwMipMapLevel);
HRESULT DDRAW_Create(LPGUID lpGUID, LPVOID *lplpDD, LPUNKNOWN pUnkOuter, REFIID iid, BOOL ex);
HRESULT WINAPI HAL7_DirectDraw_CreateClipper(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDIRECTDRAWCLIPPER *ppClipper, IUnknown *pUnkOuter);
HRESULT WINAPI HAL7_DirectDraw_QueryInterface(LPDIRECTDRAW7 iface,REFIID refiid,LPVOID *obj) ;
ULONG WINAPI HAL7_DirectDraw_AddRef(LPDIRECTDRAW7 iface) ;
ULONG WINAPI HAL7_DirectDraw_Release(LPDIRECTDRAW7 iface) ;
HRESULT WINAPI HAL7_DirectDraw_Compact(LPDIRECTDRAW7 iface) ;
HRESULT WINAPI HAL7_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPPALETTEENTRY palent,LPDIRECTDRAWPALETTE* ppPalette,LPUNKNOWN pUnknown) ;
HRESULT WINAPI HAL7_DirectDraw_CreateSurface(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
LPDIRECTDRAWSURFACE7 *ppSurf,IUnknown *pUnkOuter) ;
HRESULT WINAPI HAL7_DirectDraw_DuplicateSurface(LPDIRECTDRAW7 iface, LPDIRECTDRAWSURFACE7 src,
LPDIRECTDRAWSURFACE7* dst) ;
HRESULT WINAPI HAL7_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback) ;
HRESULT WINAPI HAL7_DirectDraw_EnumSurfaces(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 lpDDSD2, LPVOID context,
LPDDENUMSURFACESCALLBACK7 callback) ;
HRESULT WINAPI HAL7_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface) ;
HRESULT WINAPI HAL7_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
LPDDCAPS pHELCaps) ;
HRESULT WINAPI HAL7_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD) ;
HRESULT WINAPI HAL7_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes);
HRESULT WINAPI HAL7_DirectDraw_GetGDISurface(LPDIRECTDRAW7 iface,
LPDIRECTDRAWSURFACE7 *lplpGDIDDSSurface);
HRESULT WINAPI HAL7_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq);
HRESULT WINAPI HAL7_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine);
HRESULT WINAPI HAL7_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL status);
HRESULT WINAPI HAL7_DirectDraw_Initialize(LPDIRECTDRAW7 iface, LPGUID lpGuid);
HRESULT WINAPI HAL7_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface);
HRESULT WINAPI HAL7_DirectDraw_SetCooperativeLevel(LPDIRECTDRAW7 iface, HWND hwnd,
DWORD cooplevel);
HRESULT WINAPI HAL7_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags);
HRESULT WINAPI HAL7_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,
HANDLE h);
HRESULT WINAPI HAL7_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps,
LPDWORD total, LPDWORD free);
HRESULT WINAPI HAL7_DirectDraw_GetSurfaceFromDC(LPDIRECTDRAW7 iface, HDC hdc,
LPDIRECTDRAWSURFACE7 *lpDDS);
HRESULT WINAPI HAL7_DirectDraw_RestoreAllSurfaces(LPDIRECTDRAW7 iface);
HRESULT WINAPI HAL7_DirectDraw_TestCooperativeLevel(LPDIRECTDRAW7 iface) ;
HRESULT WINAPI HAL7_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI, DWORD dwFlags);
HRESULT WINAPI HAL7_DirectDraw_StartModeTest(LPDIRECTDRAW7 iface, LPSIZE pModes,
DWORD dwNumModes, DWORD dwFlags);
HRESULT WINAPI HAL7_DirectDraw_EvaluateMode(LPDIRECTDRAW7 iface,DWORD a,DWORD* b);
HRESULT WINAPI HAL7_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex);

101
reactos/lib/ddraw/rosdraw.h Normal file
View file

@ -0,0 +1,101 @@
#ifndef __DDRAW_PRIVATE
#define __DDRAW_PRIVATE
/********* Includes *********/
#include <windows.h>
#include <stdio.h>
#include <ddraw.h>
#include <ddk/ddrawint.h>
#include <ddk/d3dnthal.h>
#include <ddk/d3dhal.h>
#include <ddrawgdi.h>
#include <d3d8thk.h>
/******** Main Object ********/
typedef struct
{
DDHAL_DDCALLBACKS DdMain;
DDHAL_DDSURFACECALLBACKS DdSurface;
DDHAL_DDPALETTECALLBACKS DdPalette;
D3DHAL_CALLBACKS D3dMain;
D3DHAL_GLOBALDRIVERDATA D3dDriverData;
DDHAL_DDEXEBUFCALLBACKS D3dBufferCallbacks;
} DRIVERCALLBACKS;
typedef struct
{
IDirectDraw7Vtbl* lpVtbl;
DRIVERCALLBACKS DriverCallbacks;
DWORD ref;
DDHALINFO HalInfo;
HWND window;
DWORD cooperative_level;
HDC hdc;
int Height, Width, Bpp;
GUID* lpGUID;
DDRAWI_DIRECTDRAW_GBL DirectDrawGlobal;
} IDirectDrawImpl;
/******** Surface Object ********/
typedef struct
{
IDirectDrawSurface7Vtbl* lpVtbl;
DWORD ref;
IDirectDrawImpl* owner;
} IDirectDrawSurfaceImpl;
/******** Clipper Object ********/
typedef struct
{
IDirectDrawClipperVtbl* lpVtbl;
DWORD ref;
IDirectDrawImpl* owner;
} IDirectDrawClipperImpl;
/******** Palette Object ********/
typedef struct
{
IDirectDrawPaletteVtbl* lpVtbl;
DWORD ref;
IDirectDrawImpl* owner;
} IDirect3DDeviceImpl;
/*********** VTables ************/
extern IDirectDraw7Vtbl DirectDraw_VTable;
extern IDirectDrawSurface7Vtbl DDrawSurface_VTable;
/********* Prototypes **********/
HRESULT Hal_DirectDraw_Initialize (LPDIRECTDRAW7 iface);
HRESULT Hal_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface);
VOID Hal_DirectDraw_Release (LPDIRECTDRAW7 iface);
HRESULT Hel_DirectDraw_Initialize (LPDIRECTDRAW7 iface);
HRESULT Hel_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface);
VOID Hel_DirectDraw_Release (LPDIRECTDRAW7 iface);
#endif /* __DDRAW_PRIVATE */

View file

@ -0,0 +1,26 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS
* FILE: lib/ddraw/soft/ddraw.c
* PURPOSE: DirectDraw Software Implementation
* PROGRAMMER: Magnus Olsen, Maarten Bosma
*
*/
#include "rosdraw.h"
HRESULT Hel_DirectDraw_Initialize (LPDIRECTDRAW7 iface)
{
return DD_OK;
}
HRESULT Hel_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface)
{
return DD_OK;
}
VOID Hel_DirectDraw_Release (LPDIRECTDRAW7 iface)
{
}

View file

@ -0,0 +1,11 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS
* FILE: lib/ddraw/soft/surface.c
* PURPOSE: DirectDraw Software Implementation
* PROGRAMMER: Magnus Olsen, Maarten Bosma
*
*/
#include "rosdraw.h"

0
reactos/lib/ddraw/thunks/.gitignore vendored Normal file
View file