Author: greatlrd
Date: Fri May 2 13:31:21 2008
New Revision: 33242
URL:
http://svn.reactos.org/svn/reactos?rev=33242&view=rev
Log:
cleanup the startup process allot
1. Remove the hack in ddraw.c that only allown one edd_directdraw_global it been move to
dc.c for it is each drv that need alloc this space.
2. Remove we do not trying loading dxg.sys twice.
3. Remove we do not try enable the dx interface when it is already enable, better check
for it is need it later.
Modified:
trunk/reactos/subsystems/win32/win32k/include/intddraw.h
trunk/reactos/subsystems/win32/win32k/ntddraw/ddraw.c
trunk/reactos/subsystems/win32/win32k/objects/dc.c
Modified: trunk/reactos/subsystems/win32/win32k/include/intddraw.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/intddraw.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/intddraw.h [iso-8859-1] Fri May 2
13:31:21 2008
@@ -8,7 +8,8 @@
#include <reactos/drivers/directx/dxeng.h>
/* From ddraw.c */
-BOOL intEnableReactXDriver(PEDD_DIRECTDRAW_GLOBAL pEddgbl, PDC pDC);
+BOOL intEnableReactXDriver(HDC);
+NTSTATUS STDCALL DxDdStartupDxGraphics(ULONG, PDRVENABLEDATA, ULONG, PDRVENABLEDATA,
PULONG, PEPROCESS);
extern DRVFN gpDxFuncs[];
typedef BOOL (NTAPI* PGD_DDSETGAMMARAMP)(HANDLE, HDC, LPVOID);
Modified: trunk/reactos/subsystems/win32/win32k/ntddraw/ddraw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntddraw/ddraw.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntddraw/ddraw.c [iso-8859-1] Fri May 2 13:31:21
2008
@@ -10,7 +10,6 @@
#include <w32k.h>
#include <debug.h>
-#define DXDDRAWDEBUG 1
PGD_DXDDSTARTUPDXGRAPHICS gpfnStartupDxGraphics = NULL;
PGD_DXDDCLEANUPDXGRAPHICS gpfnCleanupDxGraphics = NULL;
@@ -18,58 +17,81 @@
/* export from dxeng.c */
extern DRVFN gaEngFuncs;
extern ULONG gcEngFuncs;
+extern EDD_DIRECTDRAW_GLOBAL edd_DdirectDraw_Global;
+
DRVFN gpDxFuncs[DXG_INDEX_DxDdIoctl];
HANDLE ghDxGraphics = NULL;
ULONG gdwDirectDrawContext;
-EDD_DIRECTDRAW_GLOBAL edd_DdirectDraw_Global;
-
/************************************************************************/
/* DirectX graphic/video driver enable start here */
/************************************************************************/
BOOL
-intEnableReactXDriver(PEDD_DIRECTDRAW_GLOBAL pEddgbl, PDC pDC)
-{
+intEnableReactXDriver(HDC hdc)
+{
+ NTSTATUS Status;
+ PEPROCESS Proc = NULL;
+ PDC pDC = NULL;
PGDIDEVICE pDev = (PGDIDEVICE)pDC->pPDev;
PGD_DXDDENABLEDIRECTDRAW pfnDdEnableDirectDraw =
(PGD_DXDDENABLEDIRECTDRAW)gpDxFuncs[DXG_INDEX_DxDdEnableDirectDraw].pfn;
BOOL success = FALSE;
-
- /*clean up some of the cache entry */
- RtlZeroMemory(pEddgbl,sizeof(EDD_DIRECTDRAW_GLOBAL));
-
+
+ /* FIXME get the process data */
+
+ /* Do not try load dxg.sys when it have already been load once */
+ if (gpfnStartupDxGraphics == NULL)
+ {
+ Status = DxDdStartupDxGraphics(0,NULL,0,NULL,NULL, Proc);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Warning : Failed to create the directx interface\n");
+ return FALSE;
+ }
+ }
+
+ pDC = DC_LockDc(hdc);
+ if (pDC == NULL)
+ {
+ DPRINT1("Warning : Failed to lock hdc\n");
+ return FALSE;
+ }
+
/* test see if drv got a dx interface or not */
if ( ( pDev->DriverFunctions.DisableDirectDraw == NULL) ||
( pDev->DriverFunctions.EnableDirectDraw == NULL))
{
- DPRINT1("Waring : DisableDirectDraw and EnableDirectDraw are NULL, no dx
driver \n");
- return FALSE;
- }
-
- /* setup EDD_DIRECTDRAW_GLOBAL for pDev xp */
- pDev->pEDDgpl = pEddgbl;
-
- pEddgbl->ddCallbacks.dwSize = sizeof(DD_CALLBACKS);
- pEddgbl->ddSurfaceCallbacks.dwSize = sizeof(DD_SURFACECALLBACKS);
- pEddgbl->ddPaletteCallbacks.dwSize = sizeof(DD_PALETTECALLBACKS);
-
- if (pfnDdEnableDirectDraw == NULL)
- {
- DPRINT1("Warning: no pfnDdEnableDirectDraw\n");
+ DPRINT1("Waring : DisableDirectDraw and EnableDirectDraw are NULL, no dx
driver \n");
}
else
{
- DPRINT1(" call to pfnDdEnableDirectDraw \n ");
- /* Note it is the hdev struct it want, not the drv hPDev aka pdc->PDev */
- success = pfnDdEnableDirectDraw(pDC->pPDev, TRUE);
-
- dump_edd_directdraw_global(pEddgbl);
- dump_halinfo(&pEddgbl->ddHalInfo);
- DPRINT1(" end call to pfnDdEnableDirectDraw \n ");
- }
-
+ /* FIXME : proper check see if it been disable */
+ if (pDev->pEDDgpl->dhpdev == 0)
+ {
+ pDev->pEDDgpl->ddCallbacks.dwSize = sizeof(DD_CALLBACKS);
+ pDev->pEDDgpl->ddSurfaceCallbacks.dwSize =
sizeof(DD_SURFACECALLBACKS);
+ pDev->pEDDgpl->ddPaletteCallbacks.dwSize =
sizeof(DD_PALETTECALLBACKS);
+
+ if (pfnDdEnableDirectDraw == NULL)
+ {
+ DPRINT1("Warning: no pfnDdEnableDirectDraw\n");
+ }
+ else
+ {
+ DPRINT1(" call to pfnDdEnableDirectDraw \n ");
+ /* Note it is the hdev struct it want, not the drv hPDev aka pdc->PDev
*/
+ success = pfnDdEnableDirectDraw(pDC->pPDev, TRUE);
+
+ dump_edd_directdraw_global(pDev->pEDDgpl);
+ dump_halinfo(&pDev->pEDDgpl->ddHalInfo);
+ }
+ }
+ }
+
DPRINT1("Return value : 0x%08x\n",success);
+ DC_UnlockDc(pDC);
+ DPRINT1(" end call to pfnDdEnableDirectDraw \n ");
return success;
}
@@ -189,45 +211,20 @@
NtGdiDdCreateDirectDrawObject(HDC hdc)
{
PGD_DDCREATEDIRECTDRAWOBJECT pfnDdCreateDirectDrawObject;
- NTSTATUS Status;
- PEPROCESS Proc = NULL;
- PDC pDC;
-
+
if (hdc == NULL)
{
DPRINT1("Warning : hdc is NULL\n");
return 0;
}
-
- /* FIXME this code should be add where the driver being load */
- /* FIXME get the process data */
- /* FIXME this code should be add where the driver being load */
- Status = DxDdStartupDxGraphics(0,NULL,0,NULL,NULL, Proc);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Warning : Failed to create the directx interface\n");
- return 0;
- }
-
- pDC = DC_LockDc(hdc);
- if (pDC == NULL)
- {
- DPRINT1("Warning : Failed to lock hdc\n");
- return 0;
- }
-
+
/* FIXME This should be alloc for each drv and use it from each drv, not global for
whole win32k */
- if (intEnableReactXDriver(&edd_DdirectDraw_Global, pDC) == FALSE)
- {
- DC_UnlockDc(pDC);
+ if (intEnableReactXDriver(hdc) == FALSE)
+ {
DPRINT1("Warning : Failed to start the directx interface from the graphic
driver\n");
return DDHAL_DRIVER_NOTHANDLED;
}
-
- DC_UnlockDc(pDC);
-
-
-
+
/* get the pfnDdCreateDirectDrawObject after we load the drv */
pfnDdCreateDirectDrawObject =
(PGD_DDCREATEDIRECTDRAWOBJECT)gpDxFuncs[DXG_INDEX_DxDdCreateDirectDrawObject].pfn;
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] Fri May 2 13:31:21
2008
@@ -31,7 +31,7 @@
static GDIDEVICE PrimarySurface;
static KEVENT VideoDriverNeedsPreparation;
static KEVENT VideoDriverPrepared;
-
+EDD_DIRECTDRAW_GLOBAL edd_DdirectDraw_Global;
NTSTATUS FASTCALL
InitDcImpl(VOID)
@@ -553,6 +553,8 @@
PrimarySurface.ppdevNext = NULL; // Fixme! We need to support more than display
drvs.
PrimarySurface.ppdevParent = NULL; // Always NULL if primary.
PrimarySurface.pGraphicsDev = NULL; // Fixme!
+ PrimarySurface.pEDDgpl = &edd_DdirectDraw_Global; // FIXME! We need to support
more than display drvs.
+ RtlZeroMemory(&PrimarySurface.pEDDgpl,sizeof(EDD_DIRECTDRAW_GLOBAL));
ret = TRUE;
goto cleanup;
}