* Made it possible to include both d3d9types.h and ddrawgdi.h at the same time
[reactos.git] / reactos / dll / win32 / gdi32 / misc / gdientry.c
index 7471470..84e7c19 100644 (file)
@@ -15,6 +15,7 @@
 #include <ddrawint.h>
 #include <ddrawgdi.h>
 #include <ntgdi.h>
+#include <d3dhal.h>
 
 /* DATA **********************************************************************/
 
@@ -72,7 +73,7 @@ DdDestroySurface(LPDDHAL_DESTROYSURFACEDATA pDestroySurface)
         {
             RealDestroy = FALSE;
         }
-        
+
         /* Call win32k */
         Return = NtGdiDdDestroySurface((HANDLE)pSurfaceLocal->hDDSurface,
                                        RealDestroy);
@@ -86,10 +87,10 @@ WINAPI
 DdFlip(LPDDHAL_FLIPDATA Flip)
 {
     /* Call win32k */
-       
+
     return NtGdiDdFlip( (HANDLE)Flip->lpSurfCurr->hDDSurface,
                         (HANDLE)Flip->lpSurfTarg->hDDSurface,
-   /* FIXME  the two last should be current left handler */ 
+   /* FIXME  the two last should be current left handler */
                                                (HANDLE)Flip->lpSurfCurr->hDDSurface,
                         (HANDLE)Flip->lpSurfTarg->hDDSurface,
                         (PDD_FLIPDATA)Flip);
@@ -99,7 +100,7 @@ DWORD
 WINAPI
 DdLock(LPDDHAL_LOCKDATA Lock)
 {
-    /* Call win32k */  
+    /* Call win32k */
     return NtGdiDdLock((HANDLE)Lock->lpDDSurface->hDDSurface,
                         (PDD_LOCKDATA)Lock,
                                                (HANDLE)Lock->lpDDSurface->hDC);
@@ -238,11 +239,11 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface)
         pDdSurfaceGlobal = &DdSurfaceGlobal;
         phSurface = &hPrevSurface;
         puhSurface = &hSurface;
-        
+
         /* Clear the structures */
         RtlZeroMemory(&DdSurfaceLocal, sizeof(DdSurfaceLocal));
         RtlZeroMemory(&DdSurfaceGlobal, sizeof(DdSurfaceGlobal));
-        RtlZeroMemory(&DdSurfaceMore, sizeof(DdSurfaceMore));  
+        RtlZeroMemory(&DdSurfaceMore, sizeof(DdSurfaceMore));
     }
 
     /* check if we got a surface or not */
@@ -262,7 +263,7 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface)
             phSurface[i] = (HANDLE)lcl->hDDSurface;
             ptmpDdSurfaceLocal->ddsCaps.dwCaps = lcl->ddsCaps.dwCaps;
 
-            ptmpDdSurfaceLocal->dwFlags = (ptmpDdSurfaceLocal->dwFlags & 
+            ptmpDdSurfaceLocal->dwFlags = (ptmpDdSurfaceLocal->dwFlags &
                                           (0xB0000000 | DDRAWISURF_INMASTERSPRITELIST |
                                            DDRAWISURF_HELCB | DDRAWISURF_FRONTBUFFER |
                                            DDRAWISURF_BACKBUFFER | DDRAWISURF_INVALID |
@@ -271,7 +272,7 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface)
 
             ptmpDdSurfaceGlobal->wWidth = gpl->wWidth;
             ptmpDdSurfaceGlobal->wHeight = gpl->wHeight;
-            ptmpDdSurfaceGlobal->lPitch = gpl->fpVidMem;
+            ptmpDdSurfaceGlobal->lPitch = gpl->lPitch;
             ptmpDdSurfaceGlobal->fpVidMem = gpl->fpVidMem;
             ptmpDdSurfaceGlobal->dwBlockSizeX = gpl->dwBlockSizeX;
             ptmpDdSurfaceGlobal->dwBlockSizeY = gpl->dwBlockSizeY;
@@ -279,7 +280,7 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface)
             if (lcl->dwFlags & DDRAWISURF_HASPIXELFORMAT)
             {
                 RtlCopyMemory( &ptmpDdSurfaceGlobal->ddpfSurface ,
-                               &gpl->ddpfSurface, 
+                               &gpl->ddpfSurface,
                                sizeof(DDPIXELFORMAT));
 
                 ptmpDdSurfaceGlobal->ddpfSurface.dwSize = sizeof(DDPIXELFORMAT);
@@ -299,7 +300,7 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface)
                 ptmpDdSurfaceMore->dwSurfaceHandle = (DWORD) pCreateSurface->lplpSList[i]->dbnOverlayNode.object_int;
             }
 
-            /* FIXME count to next SurfaceCount for 
+            /* FIXME count to next SurfaceCount for
                ptmpDdSurfaceGlobal = pDdSurfaceGlobal;
                ptmpDdSurfaceLocal = pDdSurfaceLocal;
                ptmpDdSurfaceMore = pDdSurfaceMore;
@@ -368,7 +369,7 @@ DdCreateSurface(LPDDHAL_CREATESURFACEDATA pCreateSurface)
                 lcl->lpSurfMore->ddsCapsEx.dwCaps3 = ptmpDdSurfaceMore->ddsCapsEx.dwCaps3;
                 lcl->lpSurfMore->ddsCapsEx.dwCaps4 = ptmpDdSurfaceMore->ddsCapsEx.dwCaps4;
             }
-            /* FIXME count to next SurfaceCount for 
+            /* FIXME count to next SurfaceCount for
                ptmpDdSurfaceGlobal = pDdSurfaceGlobal;
                ptmpDdSurfaceLocal = pDdSurfaceLocal;
                ptmpDdSurfaceMore = pDdSurfaceMore;
@@ -406,11 +407,10 @@ DdGetScanLine(LPDDHAL_GETSCANLINEDATA pGetScanLine)
 }
 
 /* PRIVATE FUNCTIONS *********************************************************/
-static ULONG RemberDdQueryDisplaySettingsUniquenessID = 0;
 
 BOOL
 WINAPI
-bDDCreateSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface, 
+bDDCreateSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface,
                  BOOL bComplete)
 {
     DD_SURFACE_LOCAL SurfaceLocal;
@@ -440,7 +440,7 @@ bDDCreateSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface,
 
     /* Check if we have a pixel format */
     if (pSurface->dwFlags & DDSD_PIXELFORMAT)
-    {  
+    {
         /* Use global one */
         SurfaceGlobal.ddpfSurface = pSurface->lpGbl->lpDD->vmiData.ddpfDisplay;
         SurfaceGlobal.ddpfSurface.dwSize = sizeof(DDPIXELFORMAT);
@@ -469,13 +469,13 @@ bDDCreateSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface,
 /*
  * @implemented
  *
- * GDIEntry 1 
+ * GDIEntry 1
  */
-BOOL 
-WINAPI 
+BOOL
+WINAPI
 DdCreateDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
                          HDC hdc)
-{  
+{
     BOOL Return = FALSE;
 
     /* Check if the global hDC (hdc == 0) is being used */
@@ -485,12 +485,12 @@ DdCreateDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
         if (!ghDirectDraw)
         {
             /* Create the DC */
-            if ((hdc = CreateDC(L"Display", NULL, NULL, NULL)))
+            if ((hdc = CreateDCW(L"Display", NULL, NULL, NULL)))
             {
                 /* Create the DDraw Object */
                 ghDirectDraw = NtGdiDdCreateDirectDrawObject(hdc);
 
-                /* Delete our DC */                
+                /* Delete our DC */
                 NtGdiDeleteObjectApp(hdc);
             }
         }
@@ -509,8 +509,8 @@ DdCreateDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
     else
     {
         /* Using the per-process object, so create it */
-    pDirectDrawGlobal->hDD = (ULONG_PTR)NtGdiDdCreateDirectDrawObject(hdc); 
-    
+         pDirectDrawGlobal->hDD = (ULONG_PTR)NtGdiDdCreateDirectDrawObject(hdc);
+
         /* Set the return value */
         Return = pDirectDrawGlobal->hDD ? TRUE : FALSE;
     }
@@ -554,14 +554,7 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
     RtlZeroMemory(&D3dBufferCallbacks, sizeof(DD_D3DBUFCALLBACKS));
     RtlZeroMemory(CallbackFlags, sizeof(DWORD)*3);
 
-    /* Check if we got a list pointer */
-    if (pvmList)
-    {
-        /* Allocate memory for it */
-        VidMemList = LocalAlloc(LMEM_ZEROINIT,
-                                sizeof(VIDEOMEMORY) *
-                                pHalInfo->vmiData.dwNumHeaps);
-    }
+    pvmList = NULL;
 
     /* Do the query */
     if (!NtGdiDdQueryDirectDrawObject(GetDdHandle(pDirectDrawGlobal->hDD),
@@ -577,7 +570,6 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
                                       pdwFourCC))
     {
         /* We failed, free the memory and return */
-        if (VidMemList) LocalFree(VidMemList);
         return FALSE;
     }
 
@@ -621,7 +613,7 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
     pHalInfo->vmiData.dwTextureAlign = HalInfo.vmiData.dwTextureAlign;
     pHalInfo->vmiData.dwZBufferAlign = HalInfo.vmiData.dwZBufferAlign;
     pHalInfo->vmiData.dwAlphaAlign = HalInfo.vmiData.dwAlphaAlign;
-    pHalInfo->vmiData.dwNumHeaps = dwNumHeaps;
+    pHalInfo->vmiData.dwNumHeaps = 0;
     pHalInfo->vmiData.pvmList = pvmList;
 
     RtlCopyMemory( &pHalInfo->ddCaps, &HalInfo.ddCaps,sizeof(DDCORECAPS ));
@@ -753,7 +745,7 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
             if (D3dCallbacks.ContextCreate)
             {
                 /* FIXME
-                 pD3dCallbacks->ContextCreate = D3dContextCreate; 
+                 pD3dCallbacks->ContextCreate = D3dContextCreate;
                  */
             }
             if (D3dCallbacks.ContextDestroy)
@@ -762,7 +754,7 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
             }
             if (D3dCallbacks.ContextDestroyAll)
             {
-                /* FIXME 
+                /* FIXME
                 pD3dCallbacks->ContextDestroyAll = (LPD3DHAL_CONTEXTDESTROYALLCB) NtGdiD3dContextDestroyAll;
                 */
             }
@@ -783,33 +775,6 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
 
     /* FIXME: Check for D3D Buffer Callbacks */
 
-    /* Check if we have a video memory list */
-    if (VidMemList)
-    {
-        /* Start a loop here */
-        PVIDEOMEMORY VidMem = VidMemList;
-
-        /* Loop all the heaps we have */
-        while (dwNumHeaps--)
-        {
-            /* Copy from one format to the other */
-            pvmList->dwFlags = VidMem->dwFlags;
-            pvmList->fpStart = VidMem->fpStart;
-            pvmList->fpEnd = VidMem->fpEnd;
-            pvmList->ddsCaps = VidMem->ddsCaps;
-            pvmList->ddsCapsAlt = VidMem->ddsCapsAlt;
-            pvmList->dwHeight = VidMem->dwHeight;
-
-            /* Advance in both structures */
-            pvmList++;
-            VidMem++;
-        }
-
-        /* Free our structure */
-        LocalFree(VidMemList);
-    }
-
-  
   return TRUE;
 }
 
@@ -818,7 +783,7 @@ DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
  *
  * GDIEntry 3
  */
-BOOL 
+BOOL
 WINAPI
 DdDeleteDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal)
 {
@@ -860,13 +825,12 @@ DdDeleteDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal)
  *
  * GDIEntry 4
  */
-BOOL 
-WINAPI 
+BOOL
+WINAPI
 DdCreateSurfaceObject( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal,
                        BOOL bPrimarySurface)
 {
-       return bDDCreateSurface(pSurfaceLocal, TRUE);
-    //return bDdCreateSurfaceObject(pSurfaceLocal, TRUE);
+    return bDDCreateSurface(pSurfaceLocal, TRUE);
 }
 
 
@@ -875,8 +839,8 @@ DdCreateSurfaceObject( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal,
  *
  * GDIEntry 5
  */
-BOOL 
-WINAPI 
+BOOL
+WINAPI
 DdDeleteSurfaceObject(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal)
 {
     BOOL Return = FALSE;
@@ -897,9 +861,9 @@ DdDeleteSurfaceObject(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal)
  *
  * GDIEntry 6
  */
-BOOL 
-WINAPI 
-DdResetVisrgn(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal, 
+BOOL
+WINAPI
+DdResetVisrgn(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal,
               HWND hWnd)
 {
     /* Call win32k directly */
@@ -946,8 +910,8 @@ DdCreateDIBSection(HDC hdc,
                    HANDLE hSectionApp,
                    DWORD dwOffset)
 {
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
+    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+    return 0;
 }
 
 /*
@@ -955,15 +919,15 @@ DdCreateDIBSection(HDC hdc,
  *
  * GDIEntry 10
  */
-BOOL 
-WINAPI 
+BOOL
+WINAPI
 DdReenableDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
                            BOOL *pbNewMode)
 {
     /* Call win32k directly */
     return NtGdiDdReenableDirectDrawObject(GetDdHandle(pDirectDrawGlobal->hDD),
                                            pbNewMode);
-} 
+}
 
 
 /*
@@ -971,13 +935,13 @@ DdReenableDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal,
  *
  * GDIEntry 11
  */
-BOOL 
-STDCALL 
+BOOL
+STDCALL
 DdAttachSurface( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceFrom,
                  LPDDRAWI_DDRAWSURFACE_LCL pSurfaceTo)
 {
     /* Create Surface if it does not exits one */
-    if (pSurfaceFrom->hDDSurface)
+    if (!pSurfaceFrom->hDDSurface)
     {
         if (!bDDCreateSurface(pSurfaceFrom, FALSE))
         {
@@ -986,7 +950,7 @@ DdAttachSurface( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceFrom,
     }
 
     /* Create Surface if it does not exits one */
-    if (pSurfaceTo->hDDSurface)
+    if (!pSurfaceTo->hDDSurface)
     {
         if (!bDDCreateSurface(pSurfaceTo, FALSE))
         {
@@ -1020,10 +984,10 @@ DdUnattachSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface,
  * GDIEntry 13
  */
 ULONG
-STDCALL 
+STDCALL
 DdQueryDisplaySettingsUniqueness()
 {
- return RemberDdQueryDisplaySettingsUniquenessID;
+ return GdiSharedHandleTable->flDeviceUniq;
 }
 
 /*
@@ -1031,8 +995,8 @@ DdQueryDisplaySettingsUniqueness()
  *
  * GDIEntry 14
  */
-HANDLE 
-WINAPI 
+HANDLE
+WINAPI
 DdGetDxHandle(LPDDRAWI_DIRECTDRAW_LCL pDDraw,
               LPDDRAWI_DDRAWSURFACE_LCL pSurface,
               BOOL bRelease)
@@ -1068,20 +1032,7 @@ DdSetGammaRamp(LPDDRAWI_DIRECTDRAW_LCL pDDraw,
                                hdc,
                                lpGammaRamp);
 }
-/*
- * @implemented
- *
- * GDIEntry 16
- */
-DWORD
-WINAPI
-DdSwapTextureHandles(LPDDRAWI_DIRECTDRAW_LCL pDDraw,
-                     LPDDRAWI_DDRAWSURFACE_LCL pDDSLcl1,
-                     LPDDRAWI_DDRAWSURFACE_LCL pDDSLcl2)
-{
-    /* Always returns success */
-    return TRUE;
-}
+