Author: greatlrd
Date: Mon Dec 4 00:11:40 2006
New Revision: 25051
URL:
http://svn.reactos.org/svn/reactos?rev=25051&view=rev
Log:
started hacked SetCooperativeLevel and ReCreateDirectDraw code. we need it if hwnd are not
null we need recreate the HAL and HEL interface for we already inistate it early.
Modified:
trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
trunk/reactos/dll/directx/ddraw/rosdraw.h
trunk/reactos/dll/directx/ddraw/startup.c
Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddr…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Mon Dec 4 00:11:40 2006
@@ -713,14 +713,23 @@
HRESULT WINAPI
Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD cooplevel)
{
+ LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
+
+ DX_WINDBG_trace();
+
+ /* This code should be a callback */
+ This->lpLcl->hWnd = hwnd;
+ This->lpLcl->hFocusWnd = hwnd;
+ ReCreateDirectDraw(iface);
+
// 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
-
-
- // LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
+
+
+ //
// DDHAL_SETEXCLUSIVEMODEDATA SetExclusiveMode;
//DX_WINDBG_trace();
Modified: trunk/reactos/dll/directx/ddraw/rosdraw.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/rosdraw.…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/rosdraw.h (original)
+++ trunk/reactos/dll/directx/ddraw/rosdraw.h Mon Dec 4 00:11:40 2006
@@ -21,10 +21,12 @@
extern DDRAWI_DIRECTDRAW_GBL ddgbl;
extern DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
-HRESULT WINAPI StartDirectDraw(LPDIRECTDRAW* iface, LPGUID pGUID);
-HRESULT WINAPI StartDirectDrawHal(LPDIRECTDRAW* iface);
-HRESULT WINAPI StartDirectDrawHel(LPDIRECTDRAW* iface);
+HRESULT WINAPI StartDirectDraw(LPDIRECTDRAW* iface, LPGUID pGUID, BOOL reenable);
+HRESULT WINAPI StartDirectDrawHal(LPDIRECTDRAW* iface, BOOL reenable);
+HRESULT WINAPI StartDirectDrawHel(LPDIRECTDRAW* iface, BOOL reenable);
HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface, REFIID id, BOOL
ex);
+
+HRESULT WINAPI ReCreateDirectDraw(LPDIRECTDRAW* iface);
/* DirectDraw Cleanup code only internal use */
VOID Cleanup(LPDIRECTDRAW7 iface);
Modified: trunk/reactos/dll/directx/ddraw/startup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/startup.…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/startup.c (original)
+++ trunk/reactos/dll/directx/ddraw/startup.c Mon Dec 4 00:11:40 2006
@@ -18,7 +18,7 @@
HRESULT WINAPI
-StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid)
+StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid, BOOL reenable)
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DWORD hal_ret = DD_FALSE;
@@ -34,26 +34,25 @@
DX_WINDBG_trace();
-
- if (This->lpLink == NULL)
- {
-
- RtlZeroMemory(&ddgbl, sizeof(DDRAWI_DIRECTDRAW_GBL));
- This->lpLcl->lpGbl->dwRefCnt++;
+ if (reenable == FALSE)
+ {
+ if (This->lpLink == NULL)
+ {
+ RtlZeroMemory(&ddgbl, sizeof(DDRAWI_DIRECTDRAW_GBL));
+ This->lpLcl->lpGbl->dwRefCnt++;
- if (ddgbl.lpDDCBtmp == NULL)
- {
- ddgbl.lpDDCBtmp = (LPDDHAL_CALLBACKS) DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS));
if (ddgbl.lpDDCBtmp == NULL)
{
- DX_STUB_str("Out of memmory");
- return DD_FALSE;
- }
+ ddgbl.lpDDCBtmp = (LPDDHAL_CALLBACKS) DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS));
+ if (ddgbl.lpDDCBtmp == NULL)
+ {
+ DX_STUB_str("Out of memmory");
+ return DD_FALSE;
+ }
+ }
}
-
-
- }
-
+ }
+
/*
Visual studio think this code is a break point if we call
second time to this function, press on continue in visual
@@ -84,61 +83,64 @@
This->lpLcl->lpGbl->lpModeInfo[0].wRefreshRate =
(WORD)devmode.dmDisplayFrequency;
- if (lpGuid == NULL)
- {
- devicetypes = 1;
-
- /* Create HDC for default, hal and hel driver */
- This->lpLcl->hDC = (ULONG_PTR)
CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL);
-
- /* cObsolete is undoc in msdn it being use in CreateDCA */
- RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
- RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
-
- dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
- }
-
- else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY)
- {
- devicetypes = 2;
-
- /* Create HDC for default, hal and hel driver */
- This->lpLcl->hDC =
(ULONG_PTR)CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL);
-
- /* cObsolete is undoc in msdn it being use in CreateDCA */
- RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
- RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
-
- dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
- }
-
- else if (lpGuid == (LPGUID) DDCREATE_EMULATIONONLY)
- {
- devicetypes = 3;
-
- /* Create HDC for default, hal and hel driver */
- This->lpLcl->hDC = (ULONG_PTR)
CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL);
-
- /* cObsolete is undoc in msdn it being use in CreateDCA */
- RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
- RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
-
- dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
- }
- else
- {
- /* FIXME : need getting driver from the GUID that have been pass in from
+ if (reenable == FALSE)
+ {
+ if (lpGuid == NULL)
+ {
+ devicetypes = 1;
+
+ /* Create HDC for default, hal and hel driver */
+ This->lpLcl->hDC = (ULONG_PTR)
CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL);
+
+ /* cObsolete is undoc in msdn it being use in CreateDCA */
+ RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
+ RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
+
+ dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
+ }
+
+ else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY)
+ {
+ devicetypes = 2;
+
+ /* Create HDC for default, hal and hel driver */
+ This->lpLcl->hDC =
(ULONG_PTR)CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL);
+
+ /* cObsolete is undoc in msdn it being use in CreateDCA */
+ RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
+ RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
+
+ dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
+ }
+
+ else if (lpGuid == (LPGUID) DDCREATE_EMULATIONONLY)
+ {
+ devicetypes = 3;
+
+ /* Create HDC for default, hal and hel driver */
+ This->lpLcl->hDC = (ULONG_PTR)
CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL);
+
+ /* cObsolete is undoc in msdn it being use in CreateDCA */
+ RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
+ RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
+
+ dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
+ }
+ else
+ {
+ /* FIXME : need getting driver from the GUID that have been pass in from
the register. we do not support that yet
- */
- devicetypes = 4;
- This->lpLcl->hDC = (ULONG_PTR) NULL ;
- }
-
- if ( (HDC)This->lpLcl->hDC == NULL)
- {
- DX_STUB_str("DDERR_OUTOFMEMORY");
- return DDERR_OUTOFMEMORY ;
- }
+ */
+ devicetypes = 4;
+ This->lpLcl->hDC = (ULONG_PTR) NULL ;
+ }
+
+ if ( (HDC)This->lpLcl->hDC == NULL)
+ {
+ DX_STUB_str("DDERR_OUTOFMEMORY");
+ return DDERR_OUTOFMEMORY ;
+ }
+ }
hbmp = CreateCompatibleBitmap((HDC) This->lpLcl->hDC, 1, 1);
if (hbmp==NULL)
@@ -187,18 +189,18 @@
switch (devicetypes)
{
case 2:
- hal_ret = StartDirectDrawHal(iface);
+ hal_ret = StartDirectDrawHal(iface, reenable);
This->lpLcl->lpDDCB->HELDD.dwFlags = 0;
break;
case 3:
- hel_ret = StartDirectDrawHel(iface);
+ hel_ret = StartDirectDrawHel(iface, reenable);
This->lpLcl->lpDDCB->HALDD.dwFlags = 0;
break;
default:
- hal_ret = StartDirectDrawHal(iface);
- hel_ret = StartDirectDrawHel(iface);
+ hal_ret = StartDirectDrawHal(iface, reenable);
+ hel_ret = StartDirectDrawHel(iface, reenable);
}
@@ -658,12 +660,14 @@
This->lpLcl->lpDDCB->cbDDVideoPortCallbacks
*/
+ This->lpLcl->hDD = ddgbl.hDD;
+
return DD_OK;
}
HRESULT WINAPI
-StartDirectDrawHal(LPDIRECTDRAW* iface)
+StartDirectDrawHal(LPDIRECTDRAW* iface, BOOL reenable)
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DDHAL_GETDRIVERINFODATA DriverInfo;
@@ -685,10 +689,17 @@
RtlZeroMemory(&mHALInfo, sizeof(DDHALINFO));
- ddgbl.lpDDCBtmp = DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS));
- if ( ddgbl.lpDDCBtmp == NULL)
- {
- return DD_FALSE;
+ if (reenable == FALSE)
+ {
+ ddgbl.lpDDCBtmp = DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS));
+ if ( ddgbl.lpDDCBtmp == NULL)
+ {
+ return DD_FALSE;
+ }
+ }
+ else
+ {
+ RtlZeroMemory(ddgbl.lpDDCBtmp,sizeof(DDHAL_CALLBACKS));
}
/*
@@ -848,7 +859,7 @@
}
HRESULT WINAPI
-StartDirectDrawHel(LPDIRECTDRAW* iface)
+StartDirectDrawHel(LPDIRECTDRAW* iface, BOOL reenable)
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
@@ -1028,10 +1039,8 @@
return DDERR_INVALIDPARAMS;
}
- if (StartDirectDraw((LPDIRECTDRAW*)This, pGUID) == DD_OK);
- {
-
- This->lpLcl->hDD = ddgbl.hDD;
+ if (StartDirectDraw((LPDIRECTDRAW*)This, pGUID, FALSE) == DD_OK);
+ {
return DD_OK;
}
@@ -1040,3 +1049,30 @@
+HRESULT WINAPI
+ReCreateDirectDraw(LPDIRECTDRAW* iface)
+{
+ LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
+
+ DdDeleteDirectDrawObject(This->lpLcl->lpGbl);
+
+ if ((This->lpLcl->lpGbl->dwFlags & DDRAWI_NOHARDWARE) !=
DDRAWI_NOHARDWARE)
+ {
+ if (This->lpLcl->lpGbl->dwFlags & DDRAWI_EMULATIONINITIALIZED)
+ {
+ return StartDirectDraw(iface,NULL, TRUE);
+ }
+ else
+ {
+ return StartDirectDraw(iface,(LPGUID)DDCREATE_HARDWAREONLY, TRUE);
+ }
+ }
+ else
+ {
+ return StartDirectDraw(iface,(LPGUID)DDCREATE_EMULATIONONLY, TRUE);
+ }
+
+ return DD_FALSE;
+}
+
+