3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS GDI32
21 * PURPOSE: Gdi DirectX inteface
22 * FILE: lib/gdi32/misc/gdientry.c
23 * PROGRAMER: Magnus Olsen (magnus@greatlord.com)
34 static LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobalInternal
;
35 static ULONG RemberDdQueryDisplaySettingsUniquenessID
= 0;
38 intDDCreateSurface ( LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
48 DdCreateDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal
,
52 /* check see if HDC is NULL or not
53 if it null we need create the DC */
57 pDirectDrawGlobal
->hDD
= (ULONG_PTR
)NtGdiDdCreateDirectDrawObject(hdc
);
60 if (!pDirectDrawGlobal
->hDD
)
67 /* The hdc was not null we need check see if we alread
68 have create a directdraw handler */
71 if (pDirectDrawGlobalInternal
->hDD
)
73 /* we have create a directdraw handler already */
75 pDirectDrawGlobal
->hDD
= pDirectDrawGlobalInternal
->hDD
;
79 /* Now we create the DC */
80 newHdc
= CreateDC(L
"DISPLAY\0", NULL
, NULL
, NULL
);
82 /* we are checking if we got a hdc or not */
83 if ((ULONG_PTR
)newHdc
!= pDirectDrawGlobalInternal
->hDD
)
85 pDirectDrawGlobalInternal
->hDD
= (ULONG_PTR
) NtGdiDdCreateDirectDrawObject(newHdc
);
86 NtGdiDeleteObjectApp(newHdc
);
89 /* pDirectDrawGlobal->hDD = pDirectDrawGlobalInternal->hDD; ? */
90 pDirectDrawGlobal
->hDD
= 0; /* ? */
92 /* test see if we got a handler */
93 if (!pDirectDrawGlobalInternal
->hDD
)
106 DdQueryDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal
,
107 LPDDHALINFO pHalInfo
,
108 LPDDHAL_DDCALLBACKS pDDCallbacks
,
109 LPDDHAL_DDSURFACECALLBACKS pDDSurfaceCallbacks
,
110 LPDDHAL_DDPALETTECALLBACKS pDDPaletteCallbacks
,
111 LPD3DHAL_CALLBACKS pD3dCallbacks
,
112 LPD3DHAL_GLOBALDRIVERDATA pD3dDriverData
,
113 LPDDHAL_DDEXEBUFCALLBACKS pD3dBufferCallbacks
,
114 LPDDSURFACEDESC pD3dTextureFormats
,
118 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
127 DdCreateDIBSection(HDC hdc
,
128 CONST BITMAPINFO
*pbmi
,
134 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
145 DdDeleteDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal
)
147 /* if pDirectDrawGlobal->hDD == NULL and pDirectDrawGlobalInternal->hDD == NULL
150 if (!pDirectDrawGlobal
->hDD
)
152 if (!pDirectDrawGlobalInternal
->hDD
)
156 return NtGdiDdDeleteDirectDrawObject((HANDLE
)pDirectDrawGlobalInternal
->hDD
);
159 return NtGdiDdDeleteDirectDrawObject((HANDLE
)pDirectDrawGlobal
->hDD
);
169 DdCreateSurfaceObject( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
,
170 BOOL bPrimarySurface
)
172 return intDDCreateSurface(pSurfaceLocal
,1);
182 DdDeleteSurfaceObject(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
)
184 if (!pSurfaceLocal
->hDDSurface
)
189 return NtGdiDdDeleteSurfaceObject((HANDLE
)pSurfaceLocal
->hDDSurface
);
199 DdResetVisrgn(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
,
202 return NtGdiDdResetVisrgn((HANDLE
) pSurfaceLocal
->hDDSurface
, hWnd
);
211 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
,
212 LPPALETTEENTRY pColorTable
215 return NtGdiDdGetDC(pColorTable
, (HANDLE
) pSurfaceLocal
->hDDSurface
);
223 BOOL STDCALL
DdReleaseDC(
224 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
227 return NtGdiDdReleaseDC((HANDLE
) pSurfaceLocal
->hDDSurface
);
239 DdReenableDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal
,
242 if (!pDirectDrawGlobal
->hDD
)
244 if (!pDirectDrawGlobalInternal
->hDD
)
248 return NtGdiDdReenableDirectDrawObject((HANDLE
)pDirectDrawGlobalInternal
->hDD
, pbNewMode
);
251 return NtGdiDdReenableDirectDrawObject((HANDLE
)pDirectDrawGlobal
->hDD
, pbNewMode
);
261 DdAttachSurface( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceFrom
,
262 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceTo
)
265 /* Create Surface if it does not exits one */
266 if (pSurfaceFrom
->hDDSurface
)
268 if (!intDDCreateSurface(pSurfaceFrom
,FALSE
))
274 /* Create Surface if it does not exits one */
275 if (pSurfaceTo
->hDDSurface
)
277 if (!intDDCreateSurface(pSurfaceTo
,FALSE
))
283 return NtGdiDdAttachSurface( (HANDLE
) pSurfaceFrom
->hDDSurface
, (HANDLE
) pSurfaceTo
->hDDSurface
);
293 DdUnattachSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
294 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceAttached
)
296 NtGdiDdUnattachSurface((HANDLE
) pSurface
->hDDSurface
, (HANDLE
) pSurfaceAttached
->hDDSurface
);
306 DdQueryDisplaySettingsUniqueness()
308 return RemberDdQueryDisplaySettingsUniquenessID
;
318 DdGetDxHandle(LPDDRAWI_DIRECTDRAW_LCL pDDraw
,
319 LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
324 return ((HANDLE
) NtGdiDdGetDxHandle(NULL
, (HANDLE
)pSurface
->hDDSurface
, bRelease
));
328 if (!pDDraw
->lpGbl
->hDD
)
330 if (!pDirectDrawGlobalInternal
->hDD
)
334 return ((HANDLE
) NtGdiDdGetDxHandle( (HANDLE
) pDirectDrawGlobalInternal
->hDD
, (HANDLE
) pSurface
->hDDSurface
, bRelease
));
337 return ((HANDLE
) NtGdiDdGetDxHandle((HANDLE
)pDDraw
->lpGbl
->hDD
, (HANDLE
) pSurface
->hDDSurface
, bRelease
));
345 BOOL STDCALL
DdSetGammaRamp(
346 LPDDRAWI_DIRECTDRAW_LCL pDDraw
,
351 if (!pDDraw
->lpGbl
->hDD
)
353 if (!pDirectDrawGlobalInternal
->hDD
)
357 return NtGdiDdSetGammaRamp((HANDLE
)pDirectDrawGlobalInternal
->hDD
,hdc
,lpGammaRamp
);
360 return NtGdiDdSetGammaRamp((HANDLE
)pDDraw
->lpGbl
->hDD
,hdc
,lpGammaRamp
);
368 DWORD STDCALL
DdSwapTextureHandles(
369 LPDDRAWI_DIRECTDRAW_LCL pDDraw
,
370 LPDDRAWI_DDRAWSURFACE_LCL pDDSLcl1
,
371 LPDDRAWI_DDRAWSURFACE_LCL pDDSLcl2
378 /* interal create surface */
380 intDDCreateSurface ( LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
383 DD_SURFACE_LOCAL SurfaceLocal
;
384 DD_SURFACE_GLOBAL SurfaceGlobal
;
385 DD_SURFACE_MORE SurfaceMore
;
388 RtlZeroMemory(&SurfaceLocal
, sizeof(DD_SURFACE_LOCAL
));
389 RtlZeroMemory(&SurfaceGlobal
, sizeof(DD_SURFACE_GLOBAL
));
390 RtlZeroMemory(&SurfaceMore
, sizeof(DD_SURFACE_MORE
));
392 /* Set up SurfaceLocal struct */
393 SurfaceLocal
.ddsCaps
.dwCaps
= pSurface
->ddsCaps
.dwCaps
;
394 SurfaceLocal
.dwFlags
= pSurface
->dwFlags
;
396 /* Set up SurfaceMore struct */
397 /* copy pSurface->ddckCKDestBlt and pSurface->ddckCKSrcBlt to SurfaceMore.ddsCapsEx */
398 memcpy(&SurfaceMore
.ddsCapsEx
, &pSurface
->ddckCKDestBlt
, sizeof(DDSCAPSEX
));
399 SurfaceMore
.dwSurfaceHandle
= (DWORD
) pSurface
->dbnOverlayNode
.object_int
->lpVtbl
;
402 /* Set up SurfaceGlobal struct */
403 SurfaceGlobal
.fpVidMem
= pSurface
->lpGbl
->fpVidMem
;
404 SurfaceGlobal
.dwLinearSize
= pSurface
->lpGbl
->dwLinearSize
;
405 SurfaceGlobal
.wHeight
= pSurface
->lpGbl
->wHeight
;
406 SurfaceGlobal
.wWidth
= pSurface
->lpGbl
->wWidth
;
408 /* check which memory type should be use */
409 if ((pSurface
->dwFlags
& DDRAWISURFGBL_LOCKVRAMSTYLE
) == DDRAWISURFGBL_LOCKVRAMSTYLE
)
411 memcpy(&SurfaceGlobal
.ddpfSurface
,&pSurface
->lpGbl
->lpDD
->vmiData
.ddpfDisplay
, sizeof(DDPIXELFORMAT
));
415 memcpy(&SurfaceGlobal
.ddpfSurface
,&pSurface
->lpGbl
->ddpfSurface
, sizeof(DDPIXELFORMAT
));
418 /* Determer if Gdi32 chace of directdraw handler or not */
419 if (pSurface
->lpGbl
->lpDD
->hDD
)
421 pSurface
->hDDSurface
= ((DWORD
) NtGdiDdCreateSurfaceObject( (HANDLE
) pSurface
->lpGbl
->lpDD
->hDD
,
422 (HANDLE
) pSurface
->hDDSurface
, &SurfaceLocal
,
423 &SurfaceMore
, &SurfaceGlobal
, bComplete
));
427 pSurface
->hDDSurface
= ((DWORD
) NtGdiDdCreateSurfaceObject( (HANDLE
) pDirectDrawGlobalInternal
->hDD
,
428 (HANDLE
) pSurface
->hDDSurface
, &SurfaceLocal
,
435 if (pSurface
->hDDSurface
)