From fc29d1edf07c6cebb748e5f43e10939e0beab7b6 Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Sun, 16 Jul 2006 12:03:41 +0000 Subject: [PATCH] Clean up NtGdiDdCreateDirectDrawObject and confirm it working. 1. Fix create hdc when it is NULL that is need to get ms windows xp d3dx.dll working in ReactOS, if some want try it. svn path=/trunk/; revision=23073 --- .../subsystems/win32/win32k/ntddraw/ddraw.c | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntddraw/ddraw.c b/reactos/subsystems/win32/win32k/ntddraw/ddraw.c index 6bc3aca6f7d..b44198c9725 100644 --- a/reactos/subsystems/win32/win32k/ntddraw/ddraw.c +++ b/reactos/subsystems/win32/win32k/ntddraw/ddraw.c @@ -12,6 +12,7 @@ #define NDEBUG #include +GDIDEVICE IntGetPrimarySurface(VOID); /* swtich this off to get rid of all dx debug msg */ #define DX_DEBUG @@ -19,6 +20,8 @@ #define DdHandleTable GdiHandleTable + + /************************************************************************/ /* DIRECT DRAW OBJECT */ /************************************************************************/ @@ -55,9 +58,8 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject( BOOL success; HANDLE hDirectDraw; PDD_DIRECTDRAW pDirectDraw; -#ifdef DX_DEBUG + DPRINT1("NtGdiDdCreateDirectDrawObject\n"); -#endif RtlZeroMemory(&callbacks, sizeof(DD_CALLBACKS)); callbacks.dwSize = sizeof(DD_CALLBACKS); @@ -70,29 +72,30 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject( /* we need create it, if in that case */ if (hdc == NULL) { + DPRINT1("FIXME hdc is NULL \n"); return NULL; } pDC = DC_LockDc(hdc); if (!pDC) - return NULL; - - if (!pDC->DriverFunctions.EnableDirectDraw) { - // Driver doesn't support DirectDraw + return NULL; + } + + if (pDC->DriverFunctions.EnableDirectDraw == NULL) + { + /* Driver doesn't support DirectDraw */ DC_UnlockDc(pDC); return NULL; } success = pDC->DriverFunctions.EnableDirectDraw( - pDC->PDev, &callbacks, &surface_callbacks, &palette_callbacks); + pDC->PDev, &callbacks, &surface_callbacks, &palette_callbacks); if (!success) { -#ifdef DX_DEBUG DPRINT1("DirectDraw creation failed\n"); -#endif - // DirectDraw creation failed + /* DirectDraw creation failed */ DC_UnlockDc(pDC); return NULL; } @@ -101,9 +104,6 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject( if (!hDirectDraw) { /* No more memmory */ -#ifdef DX_DEBUG - DPRINT1("No more memmory\n"); -#endif DC_UnlockDc(pDC); return NULL; } @@ -112,14 +112,10 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject( if (!pDirectDraw) { /* invalid handle */ -#ifdef DX_DEBUG - DPRINT1("invalid handle\n"); -#endif DC_UnlockDc(pDC); return NULL; } - pDirectDraw->Global.dhpdev = pDC->PDev; pDirectDraw->Local.lpGbl = &pDirectDraw->Global; @@ -128,16 +124,17 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject( /* DD_CALLBACKS setup */ RtlMoveMemory(&pDirectDraw->DD, &callbacks, sizeof(DD_CALLBACKS)); - - /* DD_SURFACECALLBACKS setup*/ + + /* DD_SURFACECALLBACKS setup*/ RtlMoveMemory(&pDirectDraw->Surf, &surface_callbacks, sizeof(DD_SURFACECALLBACKS)); - + /* DD_PALETTECALLBACKS setup*/ - RtlMoveMemory(&pDirectDraw->Pal, &surface_callbacks, sizeof(DD_PALETTECALLBACKS)); - + RtlMoveMemory(&pDirectDraw->Pal, &palette_callbacks, sizeof(DD_PALETTECALLBACKS)); + GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw); DC_UnlockDc(pDC); + DPRINT1("DirectDraw return handler\n"); return hDirectDraw; }