split up CreateSurface to hal and hel interface
[reactos.git] / reactos / lib / ddraw / main / surface_main.c
index da613bf..834d4a0 100644 (file)
 
 HRESULT WINAPI Main_DDrawSurface_Initialize (LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAW pDD, LPDDSURFACEDESC2 pDDSD2)
 {
-    IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
-
-       if(sizeof(DDSURFACEDESC2) != pDDSD2->dwSize)
-               return DDERR_UNSUPPORTED;
-
-       This->owner = (IDirectDrawImpl*)pDD;    
-
-       /************ fill the discription of our primary surface ***********************/      
-       memset (&This->ddsd, 0, sizeof(DDSURFACEDESC));
-       This->ddsd.dwSize = sizeof(DDSURFACEDESC);
-
-       RtlCopyMemory(&This->ddsd.ddckCKDestBlt,&pDDSD2->ddckCKDestBlt,sizeof(This->ddsd.ddckCKDestBlt));
-       RtlCopyMemory(&This->ddsd.ddckCKDestOverlay,&pDDSD2->ddckCKDestOverlay,sizeof(This->ddsd.ddckCKDestOverlay));
-       RtlCopyMemory(&This->ddsd.ddckCKSrcBlt,&pDDSD2->ddckCKSrcBlt,sizeof(This->ddsd.ddckCKSrcBlt));
-       RtlCopyMemory(&This->ddsd.ddckCKSrcOverlay,&pDDSD2->ddckCKSrcOverlay,sizeof(This->ddsd.ddckCKSrcOverlay));
-       RtlCopyMemory(&This->ddsd.ddpfPixelFormat,&pDDSD2->ddpfPixelFormat,sizeof(This->ddsd.ddpfPixelFormat));
-       RtlCopyMemory(&This->ddsd.ddsCaps,&pDDSD2->ddsCaps,sizeof(This->ddsd.ddsCaps));
-
-       This->ddsd.dwAlphaBitDepth = pDDSD2->dwAlphaBitDepth;
-       This->ddsd.dwBackBufferCount = pDDSD2->dwBackBufferCount; 
-       This->ddsd.dwFlags = pDDSD2->dwFlags;
-       This->ddsd.dwHeight = pDDSD2->dwHeight;
-       This->ddsd.dwLinearSize = pDDSD2->dwLinearSize; 
-       This->ddsd.dwMipMapCount = pDDSD2->dwMipMapCount;
-       This->ddsd.dwRefreshRate = pDDSD2->dwRefreshRate;
-       This->ddsd.dwReserved = pDDSD2->dwReserved;
-       This->ddsd.dwWidth  = pDDSD2->dwWidth;
-       This->ddsd.lPitch = pDDSD2->lPitch; 
-       This->ddsd.lpSurface = pDDSD2->lpSurface;
-
-    /************ Test see if we can Create Surface ***********************/
-       if (This->owner->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_CANCREATESURFACE)
-       {
-               /* can the driver create the surface */
-               DDHAL_CANCREATESURFACEDATA CanCreateData;
-               memset(&CanCreateData, 0, sizeof(DDHAL_CANCREATESURFACEDATA));
-               CanCreateData.lpDD = &This->owner->DirectDrawGlobal; 
-               CanCreateData.lpDDSurfaceDesc = (LPDDSURFACEDESC)&This->ddsd;
-                       
-               if (This->owner->DirectDrawGlobal.lpDDCBtmp->HALDD.CanCreateSurface(&CanCreateData) == DDHAL_DRIVER_NOTHANDLED)
-                       return DDERR_INVALIDPARAMS;
-               
-          if(CanCreateData.ddRVal != DD_OK)
-                       return CanCreateData.ddRVal;
-       }
-
-   /************ Create Surface ***********************/
+       IDirectDrawSurfaceImpl* This = (IDirectDrawSurfaceImpl*)iface;
 
-       /* FIXME we are skipping filling in some data, I do not care for now */
-
-       LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal = &This->owner->DirectDrawGlobal;     
-       This->ddsd.dwFlags = DDSD_CAPS;
-       This->ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-        
-       /* surface global struct */     
-       memset(&This->Global, 0, sizeof(DDRAWI_DDRAWSURFACE_GBL));      
-       This->Global.lpDD = &This->owner->DirectDrawGlobal;     
-       This->Global.wHeight = This->owner->DirectDrawGlobal.vmiData.dwDisplayHeight;
-       This->Global.wWidth = This->owner->DirectDrawGlobal.vmiData.dwDisplayWidth;
-       This->Global.dwLinearSize =  This->owner->DirectDrawGlobal.vmiData.lDisplayPitch;
-    
-       
-       /* surface more struct */       
-       memset(&This->More, 0, sizeof(DDRAWI_DDRAWSURFACE_MORE));
-       This->More.dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
-       /* surface local struct */
-       
-       memset(&This->Local, 0, sizeof(DDRAWI_DDRAWSURFACE_LCL));
-       This->Local.lpGbl = &This->Global;
-       This->Local.lpSurfMore = &This->More;
-
-       /* FIXME do a memcopy */
-       This->Local.ddsCaps = *(DDSCAPS*)&This->ddsd.ddsCaps;
-       /* for the double pointer below */
-       DDRAWI_DDRAWSURFACE_LCL *pLocal[2]; 
-       pLocal[0] = &This->Local; 
-    pLocal[1] = NULL;  
-       /* the parameter struct */
-       DDHAL_CREATESURFACEDATA CreateData;
-       memset(&CreateData, 0, sizeof(DDHAL_CREATESURFACEDATA));
-       CreateData.lpDD = pDirectDrawGlobal;
-       CreateData.lpDDSurfaceDesc = (LPDDSURFACEDESC) &This->ddsd; 
-       CreateData.dwSCnt = 1;
-       CreateData.lplpSList = pLocal;  
-       CreateData.ddRVal = DD_FALSE;
-               
-       /* this is the call we were waiting for */
-       if(This->owner->DirectDrawGlobal.lpDDCBtmp->HALDD.CreateSurface(&CreateData) == DDHAL_DRIVER_NOTHANDLED)
-               return DDERR_INVALIDPARAMS;
-
-       /* FIXME remove the if and debug string*/
-       if(CreateData.ddRVal != DD_OK)
-               return CreateData.ddRVal;
-       
-       OutputDebugString(L"This does hit By Ati Readon but not for nvida :( ");
-       OutputDebugString(L"Yet ;)");
+       /* Call the Hal CreateSurface */
+       if (This->owner->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_CREATESURFACE)
+    {
+        return Hal_DDrawSurface_Initialize (iface, pDD, pDDSD2);
+    }
 
-       return DD_OK;
+       /* Call Hel if Hal of CreateSurface is not supported */
+       return Hel_DDrawSurface_Initialize (iface, pDD, pDDSD2);
 }
 
 ULONG WINAPI Main_DDrawSurface_AddRef(LPDIRECTDRAWSURFACE7 iface)