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
)
148 /* if pDirectDrawGlobal->hDD == NULL and pDirectDrawGlobalInternal->hDD == NULL
151 if (!pDirectDrawGlobal
->hDD
)
153 if (!pDirectDrawGlobalInternal
->hDD
)
157 return NtGdiDdDeleteDirectDrawObject((HANDLE
)pDirectDrawGlobalInternal
->hDD
);
160 status
= NtGdiDdDeleteDirectDrawObject((HANDLE
)pDirectDrawGlobal
->hDD
);
161 if ((status
== TRUE
) && (pDirectDrawGlobalInternal
->hDD
!= 0))
163 pDirectDrawGlobalInternal
->hDD
= 0;
176 DdCreateSurfaceObject( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
,
177 BOOL bPrimarySurface
)
179 return intDDCreateSurface(pSurfaceLocal
,1);
189 DdDeleteSurfaceObject(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
)
191 if (!pSurfaceLocal
->hDDSurface
)
196 return NtGdiDdDeleteSurfaceObject((HANDLE
)pSurfaceLocal
->hDDSurface
);
206 DdResetVisrgn(LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
,
209 return NtGdiDdResetVisrgn((HANDLE
) pSurfaceLocal
->hDDSurface
, hWnd
);
218 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
,
219 LPPALETTEENTRY pColorTable
222 return NtGdiDdGetDC(pColorTable
, (HANDLE
) pSurfaceLocal
->hDDSurface
);
230 BOOL STDCALL
DdReleaseDC(
231 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceLocal
234 return NtGdiDdReleaseDC((HANDLE
) pSurfaceLocal
->hDDSurface
);
246 DdReenableDirectDrawObject(LPDDRAWI_DIRECTDRAW_GBL pDirectDrawGlobal
,
249 if (!pDirectDrawGlobal
->hDD
)
251 if (!pDirectDrawGlobalInternal
->hDD
)
255 return NtGdiDdReenableDirectDrawObject((HANDLE
)pDirectDrawGlobalInternal
->hDD
, pbNewMode
);
258 return NtGdiDdReenableDirectDrawObject((HANDLE
)pDirectDrawGlobal
->hDD
, pbNewMode
);
268 DdAttachSurface( LPDDRAWI_DDRAWSURFACE_LCL pSurfaceFrom
,
269 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceTo
)
272 /* Create Surface if it does not exits one */
273 if (pSurfaceFrom
->hDDSurface
)
275 if (!intDDCreateSurface(pSurfaceFrom
,FALSE
))
281 /* Create Surface if it does not exits one */
282 if (pSurfaceTo
->hDDSurface
)
284 if (!intDDCreateSurface(pSurfaceTo
,FALSE
))
290 return NtGdiDdAttachSurface( (HANDLE
) pSurfaceFrom
->hDDSurface
, (HANDLE
) pSurfaceTo
->hDDSurface
);
300 DdUnattachSurface(LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
301 LPDDRAWI_DDRAWSURFACE_LCL pSurfaceAttached
)
303 NtGdiDdUnattachSurface((HANDLE
) pSurface
->hDDSurface
, (HANDLE
) pSurfaceAttached
->hDDSurface
);
313 DdQueryDisplaySettingsUniqueness()
315 return RemberDdQueryDisplaySettingsUniquenessID
;
325 DdGetDxHandle(LPDDRAWI_DIRECTDRAW_LCL pDDraw
,
326 LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
331 return ((HANDLE
) NtGdiDdGetDxHandle(NULL
, (HANDLE
)pSurface
->hDDSurface
, bRelease
));
335 if (!pDDraw
->lpGbl
->hDD
)
337 if (!pDirectDrawGlobalInternal
->hDD
)
341 return ((HANDLE
) NtGdiDdGetDxHandle( (HANDLE
) pDirectDrawGlobalInternal
->hDD
, (HANDLE
) pSurface
->hDDSurface
, bRelease
));
344 return ((HANDLE
) NtGdiDdGetDxHandle((HANDLE
)pDDraw
->lpGbl
->hDD
, (HANDLE
) pSurface
->hDDSurface
, bRelease
));
352 BOOL STDCALL
DdSetGammaRamp(
353 LPDDRAWI_DIRECTDRAW_LCL pDDraw
,
358 if (!pDDraw
->lpGbl
->hDD
)
360 if (!pDirectDrawGlobalInternal
->hDD
)
364 return NtGdiDdSetGammaRamp((HANDLE
)pDirectDrawGlobalInternal
->hDD
,hdc
,lpGammaRamp
);
367 return NtGdiDdSetGammaRamp((HANDLE
)pDDraw
->lpGbl
->hDD
,hdc
,lpGammaRamp
);
375 DWORD STDCALL
DdSwapTextureHandles(
376 LPDDRAWI_DIRECTDRAW_LCL pDDraw
,
377 LPDDRAWI_DDRAWSURFACE_LCL pDDSLcl1
,
378 LPDDRAWI_DDRAWSURFACE_LCL pDDSLcl2
385 /* interal create surface */
387 intDDCreateSurface ( LPDDRAWI_DDRAWSURFACE_LCL pSurface
,
390 DD_SURFACE_LOCAL SurfaceLocal
;
391 DD_SURFACE_GLOBAL SurfaceGlobal
;
392 DD_SURFACE_MORE SurfaceMore
;
395 RtlZeroMemory(&SurfaceLocal
, sizeof(DD_SURFACE_LOCAL
));
396 RtlZeroMemory(&SurfaceGlobal
, sizeof(DD_SURFACE_GLOBAL
));
397 RtlZeroMemory(&SurfaceMore
, sizeof(DD_SURFACE_MORE
));
399 /* Set up SurfaceLocal struct */
400 SurfaceLocal
.ddsCaps
.dwCaps
= pSurface
->ddsCaps
.dwCaps
;
401 SurfaceLocal
.dwFlags
= pSurface
->dwFlags
;
403 /* Set up SurfaceMore struct */
404 /* copy pSurface->ddckCKDestBlt and pSurface->ddckCKSrcBlt to SurfaceMore.ddsCapsEx */
405 memcpy(&SurfaceMore
.ddsCapsEx
, &pSurface
->ddckCKDestBlt
, sizeof(DDSCAPSEX
));
406 SurfaceMore
.dwSurfaceHandle
= (DWORD
) pSurface
->dbnOverlayNode
.object_int
->lpVtbl
;
409 /* Set up SurfaceGlobal struct */
410 SurfaceGlobal
.fpVidMem
= pSurface
->lpGbl
->fpVidMem
;
411 SurfaceGlobal
.dwLinearSize
= pSurface
->lpGbl
->dwLinearSize
;
412 SurfaceGlobal
.wHeight
= pSurface
->lpGbl
->wHeight
;
413 SurfaceGlobal
.wWidth
= pSurface
->lpGbl
->wWidth
;
415 /* check which memory type should be use */
416 if ((pSurface
->dwFlags
& DDRAWISURFGBL_LOCKVRAMSTYLE
) == DDRAWISURFGBL_LOCKVRAMSTYLE
)
418 memcpy(&SurfaceGlobal
.ddpfSurface
,&pSurface
->lpGbl
->lpDD
->vmiData
.ddpfDisplay
, sizeof(DDPIXELFORMAT
));
422 memcpy(&SurfaceGlobal
.ddpfSurface
,&pSurface
->lpGbl
->ddpfSurface
, sizeof(DDPIXELFORMAT
));
425 /* Determer if Gdi32 chace of directdraw handler or not */
426 if (pSurface
->lpGbl
->lpDD
->hDD
)
428 pSurface
->hDDSurface
= ((DWORD
) NtGdiDdCreateSurfaceObject( (HANDLE
) pSurface
->lpGbl
->lpDD
->hDD
,
429 (HANDLE
) pSurface
->hDDSurface
, &SurfaceLocal
,
430 &SurfaceMore
, &SurfaceGlobal
, bComplete
));
434 pSurface
->hDDSurface
= ((DWORD
) NtGdiDdCreateSurfaceObject( (HANDLE
) pDirectDrawGlobalInternal
->hDD
,
435 (HANDLE
) pSurface
->hDDSurface
, &SurfaceLocal
,
442 if (pSurface
->hDDSurface
)