Skip to content

Commit

Permalink
Revert "[WIN32SS][NTDDRAW] Don't startup DirectX graphics each time o…
Browse files Browse the repository at this point in the history
…n DirectDraw object creation (reactos#5329)"

This reverts commit e7ccb36.
  • Loading branch information
DarkFire01 committed Sep 22, 2023
1 parent 1aff572 commit 4e0ae90
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
89 changes: 89 additions & 0 deletions win32ss/reactx/ntddraw/ddraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,88 @@ ULONG gdwDirectDrawContext = 0;

#define DXDBG 1

/************************************************************************/
/* DirectX graphic/video driver enable start here */
/************************************************************************/
BOOL
intEnableReactXDriver(HDC hdc)
{
NTSTATUS Status;
PEPROCESS Proc = NULL;
PDC pDC = NULL;
PPDEVOBJ pDev = NULL;
PGD_DXDDENABLEDIRECTDRAW pfnDdEnableDirectDraw = NULL;
BOOL success = FALSE;

/* 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;
}

pDev = pDC->ppdev;

/* Test and see if drv got a DX interface or not */
if ( ( pDev->DriverFunctions.DisableDirectDraw == NULL) ||
( pDev->DriverFunctions.EnableDirectDraw == NULL))
{
DPRINT1("Warning : DisableDirectDraw and EnableDirectDraw are NULL, no dx driver \n");
}
else
{

/* Check and see if DX has been enabled or not */
if ( pDev->pEDDgpl->pvmList == NULL)
{
pDev->pEDDgpl->ddCallbacks.dwSize = sizeof(DD_CALLBACKS);
pDev->pEDDgpl->ddSurfaceCallbacks.dwSize = sizeof(DD_SURFACECALLBACKS);
pDev->pEDDgpl->ddPaletteCallbacks.dwSize = sizeof(DD_PALETTECALLBACKS);

pfnDdEnableDirectDraw = (PGD_DXDDENABLEDIRECTDRAW)gpDxFuncs[DXG_INDEX_DxDdEnableDirectDraw].pfn;
if (pfnDdEnableDirectDraw == NULL)
{
DPRINT1("Warning: no pfnDdEnableDirectDraw\n");
}
else
{
DPRINT1(" call to pfnDdEnableDirectDraw \n ");

/* Note: it is the hdev struct it wants, not the drv hPDev aka pdc->PDev */
success = pfnDdEnableDirectDraw(pDC->ppdev, TRUE);
}
}
else
{
DPRINT1(" The dxg.sys and graphic card driver interface is enabled \n ");
success = TRUE;
}
}


DPRINT1("Return value : 0x%08x\n",success);
DC_UnlockDc(pDC);
DPRINT1(" end call to pfnDdEnableDirectDraw \n ");
return success;
}

/************************************************************************/
/* DirectX graphic/video driver enable ends here */
/************************************************************************/

/************************************************************************/
/* DirectX graphic/video driver loading and cleanup starts here */
/************************************************************************/
Expand Down Expand Up @@ -137,6 +219,13 @@ NtGdiDdCreateDirectDrawObject(HDC hdc)
return 0;
}

/* FIXME: This should be alloc for each drv and use it from each drv, not global for whole win32k */
if (intEnableReactXDriver(hdc) == FALSE)
{
DPRINT1("Warning: Failed to start the DirectX interface from the graphic driver\n");
return DDHAL_DRIVER_NOTHANDLED;
}

/* Get the pfnDdCreateDirectDrawObject after we load the drv */
pfnDdCreateDirectDrawObject = (PGD_DDCREATEDIRECTDRAWOBJECT)gpDxFuncs[DXG_INDEX_DxDdCreateDirectDrawObject].pfn;

Expand Down
1 change: 1 addition & 0 deletions win32ss/reactx/ntddraw/intddraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <reactos/drivers/directx/dxeng.h>

/* From ddraw.c */
BOOL intEnableReactXDriver(HDC);
NTSTATUS APIENTRY DxDdStartupDxGraphics(ULONG, PDRVENABLEDATA, ULONG, PDRVENABLEDATA, PULONG, PEPROCESS);
extern DRVFN gpDxFuncs[];

Expand Down

0 comments on commit 4e0ae90

Please sign in to comment.