2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS DirectX
4 * FILE: dll/directx/ddraw/Surface/surface_main.c
5 * PURPOSE: IDirectDrawSurface7 Implementation
6 * PROGRAMMER: Magnus Olsen, Maarten Bosma
13 /* FIXME adding hal and hel stub
22 LPDDRAWI_DDRAWSURFACE_INT
23 internal_directdrawsurface_int_alloc(LPDDRAWI_DDRAWSURFACE_INT This
)
25 LPDDRAWI_DDRAWSURFACE_INT newThis
;
26 DxHeapMemAlloc(newThis
, sizeof(DDRAWI_DDRAWSURFACE_INT
));
29 newThis
->lpLcl
= This
->lpLcl
;
30 newThis
->lpLink
= This
;
35 HRESULT WINAPI
Main_DDrawSurface_Initialize (LPDDRAWI_DDRAWSURFACE_INT iface
, LPDIRECTDRAW pDD
, LPDDSURFACEDESC2 pDDSD2
)
37 return DDERR_ALREADYINITIALIZED
;
40 ULONG WINAPI
Main_DDrawSurface_AddRef(LPDDRAWI_DDRAWSURFACE_INT This
)
48 This
->lpLcl
->dwLocalRefCnt
++;
50 if (This
->lpLcl
->lpGbl
!= NULL
)
52 This
->lpLcl
->lpGbl
->dwRefCnt
++;
55 return This
->dwIntRefCnt
;
60 Main_DDrawSurface_QueryInterface(LPDDRAWI_DDRAWSURFACE_INT This
, REFIID riid
, LPVOID
* ppObj
)
62 HRESULT retVal
= DD_OK
;
69 if (IsEqualGUID(&IID_IDirectDrawSurface7
, riid
))
71 if (This
->lpVtbl
!= &DirectDrawSurface7_Vtable
)
73 This
= internal_directdrawsurface_int_alloc(This
);
76 retVal
= DDERR_OUTOFVIDEOMEMORY
;
80 This
->lpVtbl
= &DirectDrawSurface7_Vtable
;
82 Main_DDrawSurface_AddRef(This
);
84 else if (IsEqualGUID(&IID_IDirectDrawSurface4
, riid
))
86 if (This
->lpVtbl
!= &DirectDrawSurface4_Vtable
)
88 This
= internal_directdrawsurface_int_alloc(This
);
91 retVal
= DDERR_OUTOFVIDEOMEMORY
;
95 This
->lpVtbl
= &DirectDrawSurface4_Vtable
;
97 Main_DDrawSurface_AddRef(This
);
99 else if (IsEqualGUID(&IID_IDirectDrawSurface3
, riid
))
101 if (This
->lpVtbl
!= &DirectDrawSurface3_Vtable
)
103 This
= internal_directdrawsurface_int_alloc(This
);
106 retVal
= DDERR_OUTOFVIDEOMEMORY
;
110 This
->lpVtbl
= &DirectDrawSurface3_Vtable
;
112 Main_DDrawSurface_AddRef(This
);
114 else if (IsEqualGUID(&IID_IDirectDrawSurface2
, riid
))
116 if (This
->lpVtbl
!= &DirectDrawSurface2_Vtable
)
118 This
= internal_directdrawsurface_int_alloc(This
);
121 retVal
= DDERR_OUTOFVIDEOMEMORY
;
125 This
->lpVtbl
= &DirectDrawSurface2_Vtable
;
127 Main_DDrawSurface_AddRef(This
);
129 else if (IsEqualGUID(&IID_IDirectDrawSurface
, riid
))
131 if (This
->lpVtbl
!= &DirectDrawSurface_Vtable
)
133 This
= internal_directdrawsurface_int_alloc(This
);
136 retVal
= DDERR_OUTOFVIDEOMEMORY
;
140 This
->lpVtbl
= &DirectDrawSurface_Vtable
;
142 Main_DDrawSurface_AddRef(This
);
144 else if (IsEqualGUID(&IID_IDirectDrawColorControl
, riid
))
146 if (This
->lpVtbl
!= &DirectDrawColorControl_Vtable
)
148 This
= internal_directdrawsurface_int_alloc(This
);
151 retVal
= DDERR_OUTOFVIDEOMEMORY
;
155 This
->lpVtbl
= &DirectDrawColorControl_Vtable
;
157 Main_DDrawSurface_AddRef(This
);
159 else if (IsEqualGUID(&IID_IDirectDrawGammaControl
, riid
))
161 if (This
->lpVtbl
!= &DirectDrawGammaControl_Vtable
)
163 This
= internal_directdrawsurface_int_alloc(This
);
166 retVal
= DDERR_OUTOFVIDEOMEMORY
;
170 This
->lpVtbl
= &DirectDrawGammaControl_Vtable
;
172 Main_DDrawSurface_AddRef(This
);
174 else if (IsEqualGUID(&IID_IDirectDrawSurfaceKernel
, riid
))
176 if (This
->lpVtbl
!= &DirectDrawSurfaceKernel_Vtable
)
178 This
= internal_directdrawsurface_int_alloc(This
);
181 retVal
= DDERR_OUTOFVIDEOMEMORY
;
185 This
->lpVtbl
= &DirectDrawSurfaceKernel_Vtable
;
187 Main_DDrawSurface_AddRef(This
);
189 else if (IsEqualGUID(&IID_IDirect3D
, riid
))
191 if (This
->lpVtbl
!= &IDirect3D_Vtbl
)
193 This
= internal_directdrawsurface_int_alloc(This
);
196 retVal
= DDERR_OUTOFVIDEOMEMORY
;
200 This
->lpVtbl
= &IDirect3D_Vtbl
;
202 Main_DDrawSurface_AddRef(This
);
204 else if (IsEqualGUID(&IID_IDirect3D2
, riid
))
206 if (This
->lpVtbl
!= &IDirect3D2_Vtbl
)
208 This
= internal_directdrawsurface_int_alloc(This
);
211 retVal
= DDERR_OUTOFVIDEOMEMORY
;
215 This
->lpVtbl
= &IDirect3D2_Vtbl
;
217 Main_DDrawSurface_AddRef(This
);
219 else if (IsEqualGUID(&IID_IDirect3D3
, riid
))
221 if (This
->lpVtbl
!= &IDirect3D3_Vtbl
)
223 This
= internal_directdrawsurface_int_alloc(This
);
226 retVal
= DDERR_OUTOFVIDEOMEMORY
;
230 This
->lpVtbl
= &IDirect3D3_Vtbl
;
232 Main_DDrawSurface_AddRef(This
);
234 else if (IsEqualGUID(&IID_IDirect3D7
, riid
))
236 if (This
->lpVtbl
!= &IDirect3D7_Vtbl
)
238 This
= internal_directdrawsurface_int_alloc(This
);
241 retVal
= DDERR_OUTOFVIDEOMEMORY
;
245 This
->lpVtbl
= &IDirect3D7_Vtbl
;
247 Main_DDrawSurface_AddRef(This
);
251 DX_STUB_str("E_NOINTERFACE");
252 retVal
= E_NOINTERFACE
;
255 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
264 ULONG WINAPI
Main_DDrawSurface_Release(LPDDRAWI_DDRAWSURFACE_INT This
)
267 This is not right exiame how it should be done
269 ULONG ret
= --This
->dwIntRefCnt
;
272 DX_STUB_str("Release is a bit simplistic right now\n");
273 AcquireDDThreadLock();
275 ReleaseDDThreadLock();
280 ULONG WINAPI
Main_DDrawSurface_Release4(LPDDRAWI_DDRAWSURFACE_INT This
)
282 ULONG ref
= Main_DDrawSurface_Release(This
) ;
284 if(ref
== 0) Main_DirectDraw_Release(This
->lpLcl
->lpSurfMore
->lpDD_int
);
289 HRESULT WINAPI
Main_DDrawSurface_Blt(LPDDRAWI_DDRAWSURFACE_INT ThisDest
, LPRECT rdst
,
290 LPDDRAWI_DDRAWSURFACE_INT ThisSrc
, LPRECT rsrc
, DWORD dwFlags
, LPDDBLTFX lpbltfx
)
292 DDHAL_BLTDATA mDdBlt
;
296 if (ThisDest
== NULL
)
298 return DDERR_INVALIDPARAMS
;
301 /* Zero out members in DDHAL_BLTDATA */
302 ZeroMemory(&mDdBlt
, sizeof(DDHAL_BLTDATA
));
303 ZeroMemory(&mDdBlt
.bltFX
, sizeof(DDBLTFX
));
305 /* Check if we got HAL support for this api */
306 if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HALDDSurface
.dwFlags
&
307 DDHAL_SURFCB32_BLT
) == DDHAL_SURFCB32_BLT
)
309 mDdBlt
.Blt
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HALDDSurface
.Blt
;
311 /* Check if we got HEL support for this api */
312 else if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HELDDSurface
.dwFlags
&
313 DDHAL_SURFCB32_BLT
) == DDHAL_SURFCB32_BLT
)
315 mDdBlt
.Blt
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Blt
;
318 if (mDdBlt
.Blt
== NULL
)
320 /* This API is unsupported */
321 return DDERR_UNSUPPORTED
;
324 /* Prepare for draw, if we do not reset the DdResetVisrgn some graphics card will not draw on the screen */
325 if (!DdResetVisrgn( ThisDest
->lpLcl
->lpSurfMore
->slist
[0], NULL
))
327 DX_STUB_str("DdResetVisrgn failed");
330 mDdBlt
.lpDD
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
;
331 mDdBlt
.lpDDDestSurface
= ThisDest
->lpLcl
->lpSurfMore
->slist
[0];
332 ThisDest
->lpLcl
->lpSurfMore
->slist
[0]->hDC
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->hDC
;
335 if (( ThisSrc
!= NULL
) )
338 mDdBlt
.lpDDSrcSurface
= ThisSrc
->lpLcl
->lpSurfMore
->slist
[0];
339 ThisSrc
->lpLcl
->lpSurfMore
->slist
[0]->hDC
= ThisSrc
->lpLcl
->lpSurfMore
->lpDD_lcl
->hDC
;
343 memmove(&mDdBlt
.rSrc
, rsrc
, sizeof (RECTL
));
347 if(!GetWindowRect((HWND
)ThisSrc
->lpLcl
->lpSurfMore
->lpDD_lcl
->hWnd
,
348 (RECT
*)&mDdBlt
.rSrc
))
350 DX_STUB_str("GetWindowRect failed");
355 * compare so we do not write too far
356 * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
357 * ThisDest->lpLcl->lpGbl->wHeight <- surface max height
358 * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
366 memmove(&mDdBlt
.rDest
, rdst
, sizeof (RECTL
));
370 if (!GetWindowRect((HWND
)ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->hWnd
,
371 (RECT
*)&mDdBlt
.rDest
))
373 DX_STUB_str("GetWindowRect failed");
378 * compare so we do not write too far
379 * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
380 * ThisDest->lpLcl->lpGbl->wHeight <- surface max height
381 * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
388 memmove(&mDdBlt
.bltFX
, lpbltfx
, sizeof (DDBLTFX
));
391 /* setup value that are not config yet */
392 mDdBlt
.dwFlags
= dwFlags
;
393 mDdBlt
.IsClipped
= FALSE
;
394 mDdBlt
.bltFX
.dwSize
= sizeof(DDBLTFX
);
407 if (mDdBlt
.Blt(&mDdBlt
) != DDHAL_DRIVER_HANDLED
)
409 DX_STUB_str("mDdBlt DDHAL_DRIVER_HANDLED");
410 return DDERR_NOBLTHW
;
413 return mDdBlt
.ddRVal
;
418 Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT ThisDest
, LPRECT prect
,
419 LPDDSURFACEDESC2 pDDSD
, DWORD flags
, HANDLE events
)
421 DDHAL_LOCKDATA mdLock
;
425 DX_WINDBG_trace_res( (DWORD
)ThisDest
->lpLcl
->lpGbl
->wWidth
, (DWORD
)ThisDest
->lpLcl
->lpGbl
->wHeight
, (DWORD
)ThisDest
->lpLcl
->lpGbl
->lPitch
, (DWORD
) 0);
427 /* Zero out members in DDHAL_LOCKDATA */
428 ZeroMemory(&mdLock
, sizeof(DDHAL_LOCKDATA
));
430 /* Check if we got HAL support for this api */
431 if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HALDDSurface
.dwFlags
&
432 DDHAL_SURFCB32_LOCK
) == DDHAL_SURFCB32_LOCK
)
434 mdLock
.Lock
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HALDDSurface
.Lock
;
436 /* Check if we got HEL support for this api */
437 else if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HELDDSurface
.dwFlags
&
438 DDHAL_SURFCB32_LOCK
) == DDHAL_SURFCB32_LOCK
)
440 mdLock
.Lock
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Lock
;
443 if (mdLock
.Lock
== NULL
)
445 /* This api are unsupported */
446 return DDERR_UNSUPPORTED
;
451 return DDERR_INVALIDPARAMS
;
454 /* FIXME add a check see if lock support or not */
458 mdLock
.bHasRect
= TRUE
;
459 memcpy(&mdLock
.rArea
,prect
,sizeof(RECTL
));
463 mdLock
.bHasRect
= FALSE
;
466 //FIXME check if it primary or not and use primary or pixelformat data, at moment it is hardcode to primary
468 mdLock
.ddRVal
= DDERR_CANTLOCKSURFACE
;
469 mdLock
.dwFlags
= flags
;
470 mdLock
.lpDDSurface
= ThisDest
->lpLcl
->lpSurfMore
->slist
[0];
471 mdLock
.lpDD
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
;
472 mdLock
.lpSurfData
= NULL
;
475 if (!DdResetVisrgn(ThisDest
->lpLcl
->lpSurfMore
->slist
[0], NULL
))
477 DX_STUB_str("Here DdResetVisrgn lock");
478 // return DDERR_UNSUPPORTED;
481 if (mdLock
.Lock(&mdLock
)!= DDHAL_DRIVER_HANDLED
)
483 DX_STUB_str("Here DDHAL_DRIVER_HANDLED lock");
484 return DDERR_UNSUPPORTED
;
487 // FIXME ??? is this right ??
491 ZeroMemory(pDDSD
,sizeof(DDSURFACEDESC2
));
492 pDDSD
->dwSize
= sizeof(DDSURFACEDESC2
);
494 //if (pDDSD->dwSize == sizeof(DDSURFACEDESC2))
496 // ZeroMemory(pDDSD,sizeof(DDSURFACEDESC2));
497 // // FIXME the internal mddsdPrimary shall be DDSURFACEDESC2
498 // memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC));
499 // pDDSD->dwSize = sizeof(DDSURFACEDESC2);
501 //if (pDDSD->dwSize == sizeof(DDSURFACEDESC))
503 // RtlZeroMemory(pDDSD,sizeof(DDSURFACEDESC));
504 // memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC));
505 // pDDSD->dwSize = sizeof(DDSURFACEDESC);
509 pDDSD
->lpSurface
= (LPVOID
) mdLock
.lpSurfData
;
511 pDDSD
->dwHeight
= ThisDest
->lpLcl
->lpGbl
->wHeight
;
512 pDDSD
->dwWidth
= ThisDest
->lpLcl
->lpGbl
->wWidth
;
514 pDDSD
->ddpfPixelFormat
.dwRGBBitCount
= ThisDest
->lpLcl
->lpGbl
->lpDD
->lpModeInfo
->dwBPP
;// .lpModeInfo->dwBPP; //This->lpLcl->lpGbl->lPitch/ 8;
515 pDDSD
->lPitch
= ThisDest
->lpLcl
->lpGbl
->lPitch
;
516 pDDSD
->dwFlags
= DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
519 return mdLock
.ddRVal
;
523 HRESULT WINAPI
Main_DDrawSurface_Unlock (LPDDRAWI_DDRAWSURFACE_INT This
, LPRECT pRect
)
525 DDHAL_UNLOCKDATA mdUnLock
;
529 /* Zero out members in DDHAL_UNLOCKDATA */
530 ZeroMemory(&mdUnLock
, sizeof(DDHAL_UNLOCKDATA
));
532 /* Check if we got HAL support for this api */
533 if (( This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HALDDSurface
.dwFlags
&
534 DDHAL_SURFCB32_UNLOCK
) == DDHAL_SURFCB32_UNLOCK
)
536 mdUnLock
.Unlock
= This
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HALDDSurface
.Unlock
;
538 /* Check if we got HEL support for this api */
539 else if (( This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HELDDSurface
.dwFlags
&
540 DDHAL_SURFCB32_UNLOCK
) == DDHAL_SURFCB32_UNLOCK
)
542 mdUnLock
.Unlock
= This
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Unlock
;
545 if (mdUnLock
.Unlock
== NULL
)
547 /* This api are unsupported */
548 return DDERR_UNSUPPORTED
;
551 mdUnLock
.ddRVal
= DDERR_NOTPALETTIZED
;
552 mdUnLock
.lpDD
= This
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
;
553 mdUnLock
.lpDDSurface
= This
->lpLcl
->lpSurfMore
->slist
[0];
555 if (!DdResetVisrgn( mdUnLock
.lpDDSurface
, NULL
))
557 DX_STUB_str("DdResetVisrgn fail");
558 //return DDERR_UNSUPPORTED; /* this can fail */
561 if (mdUnLock
.Unlock(&mdUnLock
)!= DDHAL_DRIVER_HANDLED
)
563 DX_STUB_str("unLock fail");
564 return DDERR_UNSUPPORTED
;
567 return mdUnLock
.ddRVal
;
571 Main_DDrawSurface_AddAttachedSurface(LPDDRAWI_DDRAWSURFACE_INT iface
,
572 LPDDRAWI_DDRAWSURFACE_INT pAttach
)
575 // LPDDRAWI_DDRAWSURFACE_INT This = (LPDDRAWI_DDRAWSURFACE_INT)iface;
576 // LPDDRAWI_DDRAWSURFACE_INT That = (LPDDRAWI_DDRAWSURFACE_INT)pAttach;
584 Main_DDrawSurface_GetAttachedSurface(LPDDRAWI_DDRAWSURFACE_INT This
,
586 LPDDRAWI_DDRAWSURFACE_INT
* ppSurface
)
593 *ppSurface
= This
->lpLcl
->lpGbl
->lpDD
->dsList
;
600 Main_DDrawSurface_GetBltStatus(LPDDRAWI_DDRAWSURFACE_INT This
, DWORD dwFlags
)
605 if (!(This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.dwFlags
& DDHAL_SURFCB32_FLIP
))
607 return DDERR_GENERIC
;
614 Main_DDrawSurface_GetCaps(LPDDRAWI_DDRAWSURFACE_INT This
, LPDDSCAPS2 pCaps
)
621 return DDERR_INVALIDOBJECT
;
626 return DDERR_INVALIDPARAMS
;
629 RtlZeroMemory(pCaps
,sizeof(DDSCAPS2
));
631 pCaps
->dwCaps
= This
->lpLcl
->ddsCaps
.dwCaps
;
637 Main_DDrawSurface_GetClipper(LPDDRAWI_DDRAWSURFACE_INT This
,
638 LPDIRECTDRAWCLIPPER
* ppClipper
)
645 return DDERR_INVALIDOBJECT
;
648 if (ppClipper
== NULL
)
650 return DDERR_INVALIDPARAMS
;
653 if (This
->lpLcl
->lp16DDClipper
== NULL
)
655 return DDERR_NOCLIPPERATTACHED
;
658 *ppClipper
= (LPDIRECTDRAWCLIPPER
)This
->lpLcl
->lp16DDClipper
;
664 Main_DDrawSurface_SetClipper (LPDDRAWI_DDRAWSURFACE_INT This
,
665 LPDIRECTDRAWCLIPPER pDDClipper
)
672 return DDERR_INVALIDOBJECT
;
675 if(pDDClipper
== NULL
)
677 if(!This
->lpLcl
->lp16DDClipper
)
678 return DDERR_NOCLIPPERATTACHED
;
680 DirectDrawClipper_Release((LPDIRECTDRAWCLIPPER
)This
->lpLcl
->lp16DDClipper
);
681 This
->lpLcl
->lp16DDClipper
= NULL
;
685 // FIXME: Check Surface type and return DDERR_INVALIDSURFACETYPE
687 DirectDrawClipper_AddRef((LPDIRECTDRAWCLIPPER
)pDDClipper
);
688 This
->lpLcl
->lp16DDClipper
= (LPDDRAWI_DDRAWCLIPPER_INT
)pDDClipper
;
694 Main_DDrawSurface_GetDC(LPDDRAWI_DDRAWSURFACE_INT This
, HDC
*phDC
)
701 return DDERR_INVALIDOBJECT
;
706 return DDERR_INVALIDPARAMS
;
710 *phDC
= (HDC
)This
->lpLcl
->lpSurfMore
->lpDD_lcl
->hDC
;
716 Main_DDrawSurface_GetPixelFormat(LPDDRAWI_DDRAWSURFACE_INT This
,
717 LPDDPIXELFORMAT pDDPixelFormat
)
719 HRESULT retVale
= DDERR_INVALIDPARAMS
;
723 if (pDDPixelFormat
!= NULL
)
725 if (This
->lpLcl
->dwFlags
& DDRAWISURF_HASPIXELFORMAT
)
727 memcpy(pDDPixelFormat
,&This
->lpLcl
->lpGbl
->ddpfSurface
,sizeof(DDPIXELFORMAT
));
731 memcpy(pDDPixelFormat
,&This
->lpLcl
->lpSurfMore
->
732 lpDD_lcl
->lpGbl
->vmiData
.ddpfDisplay
,sizeof(DDPIXELFORMAT
));
741 Main_DDrawSurface_GetSurfaceDesc(LPDDRAWI_DDRAWSURFACE_INT This
,
742 LPDDSURFACEDESC2 pDDSD
)
748 dwSize
= pDDSD
->dwSize
;
750 if ((dwSize
!= sizeof(DDSURFACEDESC
)) &&
751 (dwSize
!= sizeof(DDSURFACEDESC2
)))
753 return DDERR_GENERIC
;
756 ZeroMemory(pDDSD
,dwSize
);
758 if (dwSize
== sizeof(DDSURFACEDESC
))
760 LPDDSURFACEDESC lpDS
= (LPDDSURFACEDESC
) pDDSD
;
761 memcpy(&lpDS
->ddckCKDestBlt
, &This
->lpLcl
->ddckCKDestBlt
, sizeof(DDCOLORKEY
));
762 memcpy(&lpDS
->ddckCKDestOverlay
, &This
->lpLcl
->ddckCKDestOverlay
, sizeof(DDCOLORKEY
));
763 memcpy(&lpDS
->ddckCKSrcBlt
, &This
->lpLcl
->ddckCKSrcBlt
, sizeof(DDCOLORKEY
));
764 memcpy(&lpDS
->ddckCKSrcOverlay
, &This
->lpLcl
->ddckCKSrcOverlay
, sizeof(DDCOLORKEY
));
765 memcpy(&lpDS
->ddpfPixelFormat
, &This
->lpLcl
->lpGbl
->ddpfSurface
, sizeof(DDPIXELFORMAT
));
766 memcpy(&lpDS
->ddsCaps
, &This
->lpLcl
->ddsCaps
, sizeof(DDSCAPS
));
768 lpDS
->dwAlphaBitDepth
= This
->lpLcl
->dwAlpha
;
769 lpDS
->dwBackBufferCount
= This
->lpLcl
->dwBackBufferCount
;
771 /* FIXME setting the flags right */
772 // lpDS->dwFlags = This->lpLcl->dwFlags;
774 lpDS
->dwHeight
= This
->lpLcl
->lpGbl
->wHeight
;
775 lpDS
->dwWidth
= This
->lpLcl
->lpGbl
->wWidth
;
777 /* This two are a union in lpDS and in This->lpLcl->lpGbl
778 so I comment out lPitch
779 lpDS->lPitch = This->lpLcl->lpGbl->lPitch;
781 lpDS
->dwLinearSize
= This
->lpLcl
->lpGbl
->dwLinearSize
;
784 /* This tree are a union */
785 //lpDS->dwMipMapCount
786 //lpDS->dwRefreshRate
787 //lpDS->dwZBufferBitDepth
795 memcpy(&pDDSD
->ddckCKDestBlt
, &This
->lpLcl
->ddckCKDestBlt
, sizeof(DDCOLORKEY
));
798 pDDSD->dwEmptyFaceColor is a union to ddckCKDestOverlay
800 memcpy(&pDDSD
->ddckCKDestOverlay
, &This
->lpLcl
->ddckCKDestOverlay
, sizeof(DDCOLORKEY
));
801 memcpy(&pDDSD
->ddckCKSrcBlt
, &This
->lpLcl
->ddckCKSrcBlt
, sizeof(DDCOLORKEY
));
802 memcpy(&pDDSD
->ddckCKSrcOverlay
, &This
->lpLcl
->ddckCKSrcOverlay
, sizeof(DDCOLORKEY
));
805 pDDSD->dwFVF is a union to ddpfPixelFormat
807 memcpy(&pDDSD
->ddpfPixelFormat
, &This
->lpLcl
->lpGbl
->ddpfSurface
, sizeof(DDPIXELFORMAT
));
808 memcpy(&pDDSD
->ddsCaps
, &This
->lpLcl
->ddsCaps
, sizeof(DDSCAPS
));
811 pDDSD
->dwAlphaBitDepth
= This
->lpLcl
->dwAlpha
;
812 pDDSD
->dwBackBufferCount
= This
->lpLcl
->dwBackBufferCount
;
814 /* FIXME setting the flags right */
815 // lpDS->dwFlags = This->lpLcl->dwFlags;
817 pDDSD
->dwHeight
= This
->lpLcl
->lpGbl
->wHeight
;
818 pDDSD
->dwWidth
= This
->lpLcl
->lpGbl
->wWidth
;
820 /* This two are a union in lpDS and in This->lpLcl->lpGbl
821 so I comment out lPitch
822 lpDS->lPitch = This->lpLcl->lpGbl->lPitch;
824 pDDSD
->dwLinearSize
= This
->lpLcl
->lpGbl
->dwLinearSize
;
826 /* This tree are a union */
827 // pDDSD->dwMipMapCount
828 // pDDSD->dwRefreshRate
829 // pDDSD->dwSrcVBHandle
834 // pDDSD->dwTextureStage
841 Main_DDrawSurface_ReleaseDC(LPDDRAWI_DDRAWSURFACE_INT This
, HDC hDC
)
847 return DDERR_INVALIDOBJECT
;
852 return DDERR_INVALIDPARAMS
;
855 /* FIXME check if surface exits or not */
858 if ((HDC
)This
->lpLcl
->hDC
== NULL
)
860 return DDERR_GENERIC
;
867 Main_DDrawSurface_SetColorKey (LPDDRAWI_DDRAWSURFACE_INT This
,
868 DWORD dwFlags
, LPDDCOLORKEY pCKey
)
871 DDHAL_SETCOLORKEYDATA ColorKeyData
;
875 ColorKeyData
.ddRVal
= DDERR_COLORKEYNOTSET
;
877 if (This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.dwFlags
& DDHAL_SURFCB32_SETCOLORKEY
)
880 ColorKeyData
.lpDD
= This
->lpLcl
->lpGbl
->lpDD
;
881 ColorKeyData
.SetColorKey
= This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.SetColorKey
;
883 //ColorKeyData.lpDDSurface = &This->lpLcl->hDDSurface;
884 ColorKeyData
.dwFlags
= dwFlags
;
886 ColorKeyData.ckNew = ?
887 add / move dwFlags to This->lpLcl->dwFlags ??
890 if (ColorKeyData
.SetColorKey(&ColorKeyData
) == DDHAL_DRIVER_HANDLED
)
892 return ColorKeyData
.ddRVal
;
895 return DDERR_COLORKEYNOTSET
;
901 Main_DDrawSurface_SetOverlayPosition (LPDDRAWI_DDRAWSURFACE_INT This
, LONG X
, LONG Y
)
904 DDHAL_SETOVERLAYPOSITIONDATA OverLayPositionData
;
908 OverLayPositionData
.ddRVal
= DDERR_COLORKEYNOTSET
;
910 if (This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.dwFlags
& DDHAL_SURFCB32_SETOVERLAYPOSITION
)
913 OverLayPositionData
.lpDD
= This
->lpLcl
->lpGbl
->lpDD
;
914 OverLayPositionData
.SetOverlayPosition
= This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.SetOverlayPosition
;
916 //OverLayPositionData.lpDDSrcSurface = This->lpLcl->lpSurfaceOverlaying->lpLcl->hDDSurface;
917 //OverLayPositionData.lpDDDestSurface = This->lpLcl->hDDSurface;
919 OverLayPositionData
.lXPos
= X
;
920 OverLayPositionData
.lYPos
= Y
;
924 Should X and Y be save ??
927 if (OverLayPositionData
.SetOverlayPosition(&OverLayPositionData
) == DDHAL_DRIVER_HANDLED
)
929 return OverLayPositionData
.ddRVal
;
933 return DDERR_GENERIC
;