3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS DirectX
5 * FILE: ddraw/surface/surface_main.c
6 * PURPOSE: IDirectDrawSurface7 Implementation
7 * PROGRAMMER: Magnus Olsen, Maarten Bosma
14 /* FIXME adding hal and hel stub
23 LPDDRAWI_DDRAWSURFACE_INT
24 internal_directdrawsurface_int_alloc(LPDDRAWI_DDRAWSURFACE_INT This
)
26 LPDDRAWI_DDRAWSURFACE_INT newThis
;
27 DxHeapMemAlloc(newThis
, sizeof(DDRAWI_DDRAWSURFACE_INT
));
30 newThis
->lpLcl
= This
->lpLcl
;
31 newThis
->lpLink
= This
;
36 HRESULT WINAPI
Main_DDrawSurface_Initialize (LPDDRAWI_DDRAWSURFACE_INT iface
, LPDIRECTDRAW pDD
, LPDDSURFACEDESC2 pDDSD2
)
38 return DDERR_ALREADYINITIALIZED
;
41 ULONG WINAPI
Main_DDrawSurface_AddRef(LPDDRAWI_DDRAWSURFACE_INT This
)
49 This
->lpLcl
->dwLocalRefCnt
++;
51 if (This
->lpLcl
->lpGbl
!= NULL
)
53 This
->lpLcl
->lpGbl
->dwRefCnt
++;
56 return This
->dwIntRefCnt
;
61 Main_DDrawSurface_QueryInterface(LPDDRAWI_DDRAWSURFACE_INT This
, REFIID riid
, LPVOID
* ppObj
)
63 HRESULT retVal
= DD_OK
;
70 if (IsEqualGUID(&IID_IDirectDrawSurface7
, riid
))
72 if (This
->lpVtbl
!= &DirectDrawSurface7_Vtable
)
74 This
= internal_directdrawsurface_int_alloc(This
);
77 retVal
= DDERR_OUTOFVIDEOMEMORY
;
81 This
->lpVtbl
= &DirectDrawSurface7_Vtable
;
83 Main_DDrawSurface_AddRef(This
);
85 else if (IsEqualGUID(&IID_IDirectDrawSurface4
, riid
))
87 if (This
->lpVtbl
!= &DirectDrawSurface4_Vtable
)
89 This
= internal_directdrawsurface_int_alloc(This
);
92 retVal
= DDERR_OUTOFVIDEOMEMORY
;
96 This
->lpVtbl
= &DirectDrawSurface4_Vtable
;
98 Main_DDrawSurface_AddRef(This
);
100 else if (IsEqualGUID(&IID_IDirectDrawSurface3
, riid
))
102 if (This
->lpVtbl
!= &DirectDrawSurface3_Vtable
)
104 This
= internal_directdrawsurface_int_alloc(This
);
107 retVal
= DDERR_OUTOFVIDEOMEMORY
;
111 This
->lpVtbl
= &DirectDrawSurface3_Vtable
;
113 Main_DDrawSurface_AddRef(This
);
115 else if (IsEqualGUID(&IID_IDirectDrawSurface2
, riid
))
117 if (This
->lpVtbl
!= &DirectDrawSurface2_Vtable
)
119 This
= internal_directdrawsurface_int_alloc(This
);
122 retVal
= DDERR_OUTOFVIDEOMEMORY
;
126 This
->lpVtbl
= &DirectDrawSurface2_Vtable
;
128 Main_DDrawSurface_AddRef(This
);
130 else if (IsEqualGUID(&IID_IDirectDrawSurface
, riid
))
132 if (This
->lpVtbl
!= &DirectDrawSurface_Vtable
)
134 This
= internal_directdrawsurface_int_alloc(This
);
137 retVal
= DDERR_OUTOFVIDEOMEMORY
;
141 This
->lpVtbl
= &DirectDrawSurface_Vtable
;
143 Main_DDrawSurface_AddRef(This
);
145 else if (IsEqualGUID(&IID_IDirectDrawColorControl
, riid
))
147 if (This
->lpVtbl
!= &DirectDrawColorControl_Vtable
)
149 This
= internal_directdrawsurface_int_alloc(This
);
152 retVal
= DDERR_OUTOFVIDEOMEMORY
;
156 This
->lpVtbl
= &DirectDrawColorControl_Vtable
;
158 Main_DDrawSurface_AddRef(This
);
160 else if (IsEqualGUID(&IID_IDirectDrawGammaControl
, riid
))
162 if (This
->lpVtbl
!= &DirectDrawGammaControl_Vtable
)
164 This
= internal_directdrawsurface_int_alloc(This
);
167 retVal
= DDERR_OUTOFVIDEOMEMORY
;
171 This
->lpVtbl
= &DirectDrawGammaControl_Vtable
;
173 Main_DDrawSurface_AddRef(This
);
175 else if (IsEqualGUID(&IID_IDirectDrawSurfaceKernel
, riid
))
177 if (This
->lpVtbl
!= &DirectDrawSurfaceKernel_Vtable
)
179 This
= internal_directdrawsurface_int_alloc(This
);
182 retVal
= DDERR_OUTOFVIDEOMEMORY
;
186 This
->lpVtbl
= &DirectDrawSurfaceKernel_Vtable
;
188 Main_DDrawSurface_AddRef(This
);
190 else if (IsEqualGUID(&IID_IDirect3D
, riid
))
192 if (This
->lpVtbl
!= &IDirect3D_Vtbl
)
194 This
= internal_directdrawsurface_int_alloc(This
);
197 retVal
= DDERR_OUTOFVIDEOMEMORY
;
201 This
->lpVtbl
= &IDirect3D_Vtbl
;
203 Main_DDrawSurface_AddRef(This
);
205 else if (IsEqualGUID(&IID_IDirect3D2
, riid
))
207 if (This
->lpVtbl
!= &IDirect3D2_Vtbl
)
209 This
= internal_directdrawsurface_int_alloc(This
);
212 retVal
= DDERR_OUTOFVIDEOMEMORY
;
216 This
->lpVtbl
= &IDirect3D2_Vtbl
;
218 Main_DDrawSurface_AddRef(This
);
220 else if (IsEqualGUID(&IID_IDirect3D3
, riid
))
222 if (This
->lpVtbl
!= &IDirect3D3_Vtbl
)
224 This
= internal_directdrawsurface_int_alloc(This
);
227 retVal
= DDERR_OUTOFVIDEOMEMORY
;
231 This
->lpVtbl
= &IDirect3D3_Vtbl
;
233 Main_DDrawSurface_AddRef(This
);
235 else if (IsEqualGUID(&IID_IDirect3D7
, riid
))
237 if (This
->lpVtbl
!= &IDirect3D7_Vtbl
)
239 This
= internal_directdrawsurface_int_alloc(This
);
242 retVal
= DDERR_OUTOFVIDEOMEMORY
;
246 This
->lpVtbl
= &IDirect3D7_Vtbl
;
248 Main_DDrawSurface_AddRef(This
);
252 DX_STUB_str("E_NOINTERFACE");
253 retVal
= E_NOINTERFACE
;
256 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
265 ULONG WINAPI
Main_DDrawSurface_Release(LPDDRAWI_DDRAWSURFACE_INT This
)
268 This is not right exiame how it should be done
270 ULONG ret
= --This
->dwIntRefCnt
;
273 DX_STUB_str("Release is a bit simplistic right now\n");
274 AcquireDDThreadLock();
276 ReleaseDDThreadLock();
281 ULONG WINAPI
Main_DDrawSurface_Release4(LPDDRAWI_DDRAWSURFACE_INT This
)
283 ULONG ref
= Main_DDrawSurface_Release(This
) ;
285 if(ref
== 0) Main_DirectDraw_Release(This
->lpLcl
->lpSurfMore
->lpDD_int
);
290 HRESULT WINAPI
Main_DDrawSurface_Blt(LPDDRAWI_DDRAWSURFACE_INT ThisDest
, LPRECT rdst
,
291 LPDDRAWI_DDRAWSURFACE_INT ThisSrc
, LPRECT rsrc
, DWORD dwFlags
, LPDDBLTFX lpbltfx
)
293 DDHAL_BLTDATA mDdBlt
;
297 if (ThisDest
== NULL
)
299 return DDERR_INVALIDPARAMS
;
302 /* Zero out members in DDHAL_BLTDATA */
303 ZeroMemory(&mDdBlt
, sizeof(DDHAL_BLTDATA
));
304 ZeroMemory(&mDdBlt
.bltFX
, sizeof(DDBLTFX
));
306 /* Check if we got HAL support for this api */
307 if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HALDDSurface
.dwFlags
&
308 DDHAL_SURFCB32_BLT
) == DDHAL_SURFCB32_BLT
)
310 mDdBlt
.Blt
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HALDDSurface
.Blt
;
312 /* Check if we got HEL support for this api */
313 else if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HELDDSurface
.dwFlags
&
314 DDHAL_SURFCB32_BLT
) == DDHAL_SURFCB32_BLT
)
316 mDdBlt
.Blt
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Blt
;
319 if (mDdBlt
.Blt
== NULL
)
321 /* This API is unsupported */
322 return DDERR_UNSUPPORTED
;
325 /* Prepare for draw, if we do not reset the DdResetVisrgn some graphics card will not draw on the screen */
326 if (!DdResetVisrgn( ThisDest
->lpLcl
->lpSurfMore
->slist
[0], NULL
))
328 DX_STUB_str("DdResetVisrgn failed");
331 mDdBlt
.lpDD
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
;
332 mDdBlt
.lpDDDestSurface
= ThisDest
->lpLcl
->lpSurfMore
->slist
[0];
333 ThisDest
->lpLcl
->lpSurfMore
->slist
[0]->hDC
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->hDC
;
336 if (( ThisSrc
!= NULL
) )
339 mDdBlt
.lpDDSrcSurface
= ThisSrc
->lpLcl
->lpSurfMore
->slist
[0];
340 ThisSrc
->lpLcl
->lpSurfMore
->slist
[0]->hDC
= ThisSrc
->lpLcl
->lpSurfMore
->lpDD_lcl
->hDC
;
344 memmove(&mDdBlt
.rSrc
, rsrc
, sizeof (RECTL
));
348 if(!GetWindowRect((HWND
)ThisSrc
->lpLcl
->lpSurfMore
->lpDD_lcl
->hWnd
,
349 (RECT
*)&mDdBlt
.rSrc
))
351 DX_STUB_str("GetWindowRect failed");
356 * compare so we do not write too far
357 * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
358 * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
359 * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
367 memmove(&mDdBlt
.rDest
, rdst
, sizeof (RECTL
));
371 if (!GetWindowRect((HWND
)ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->hWnd
,
372 (RECT
*)&mDdBlt
.rDest
))
374 DX_STUB_str("GetWindowRect failed");
379 * compare so we do not write too far
380 * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
381 * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
382 * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
389 memmove(&mDdBlt
.bltFX
, lpbltfx
, sizeof (DDBLTFX
));
392 /* setup value that are not config yet */
393 mDdBlt
.dwFlags
= dwFlags
;
394 mDdBlt
.IsClipped
= FALSE
;
395 mDdBlt
.bltFX
.dwSize
= sizeof(DDBLTFX
);
408 if (mDdBlt
.Blt(&mDdBlt
) != DDHAL_DRIVER_HANDLED
)
410 DX_STUB_str("mDdBlt DDHAL_DRIVER_HANDLED");
411 return DDERR_NOBLTHW
;
414 return mDdBlt
.ddRVal
;
419 Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT ThisDest
, LPRECT prect
,
420 LPDDSURFACEDESC2 pDDSD
, DWORD flags
, HANDLE events
)
422 DDHAL_LOCKDATA mdLock
;
426 DX_WINDBG_trace_res( (DWORD
)ThisDest
->lpLcl
->lpGbl
->wWidth
, (DWORD
)ThisDest
->lpLcl
->lpGbl
->wHeight
, (DWORD
)ThisDest
->lpLcl
->lpGbl
->lPitch
, (DWORD
) 0);
428 /* Zero out members in DDHAL_LOCKDATA */
429 ZeroMemory(&mdLock
, sizeof(DDHAL_LOCKDATA
));
431 /* Check if we got HAL support for this api */
432 if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HALDDSurface
.dwFlags
&
433 DDHAL_SURFCB32_LOCK
) == DDHAL_SURFCB32_LOCK
)
435 mdLock
.Lock
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HALDDSurface
.Lock
;
437 /* Check if we got HEL support for this api */
438 else if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HELDDSurface
.dwFlags
&
439 DDHAL_SURFCB32_LOCK
) == DDHAL_SURFCB32_LOCK
)
441 mdLock
.Lock
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Lock
;
444 if (mdLock
.Lock
== NULL
)
446 /* This api are unsupported */
447 return DDERR_UNSUPPORTED
;
452 return DDERR_INVALIDPARAMS
;
455 /* FIXME add a check see if lock suport or not */
459 mdLock
.bHasRect
= TRUE
;
460 memcpy(&mdLock
.rArea
,prect
,sizeof(RECTL
));
464 mdLock
.bHasRect
= FALSE
;
467 //FIXME check if it primary or not and use primary or pixelformat data, at moment it is hardcode to primary
469 mdLock
.ddRVal
= DDERR_CANTLOCKSURFACE
;
470 mdLock
.dwFlags
= flags
;
471 mdLock
.lpDDSurface
= ThisDest
->lpLcl
->lpSurfMore
->slist
[0];
472 mdLock
.lpDD
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
;
473 mdLock
.lpSurfData
= NULL
;
476 if (!DdResetVisrgn(ThisDest
->lpLcl
->lpSurfMore
->slist
[0], NULL
))
478 DX_STUB_str("Here DdResetVisrgn lock");
479 // return DDERR_UNSUPPORTED;
482 if (mdLock
.Lock(&mdLock
)!= DDHAL_DRIVER_HANDLED
)
484 DX_STUB_str("Here DDHAL_DRIVER_HANDLED lock");
485 return DDERR_UNSUPPORTED
;
488 // FIXME ??? is this right ??
492 ZeroMemory(pDDSD
,sizeof(DDSURFACEDESC2
));
493 pDDSD
->dwSize
= sizeof(DDSURFACEDESC2
);
495 //if (pDDSD->dwSize == sizeof(DDSURFACEDESC2))
497 // ZeroMemory(pDDSD,sizeof(DDSURFACEDESC2));
498 // // FIXME the interanl mddsdPrimary shall be DDSURFACEDESC2
499 // memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC));
500 // pDDSD->dwSize = sizeof(DDSURFACEDESC2);
502 //if (pDDSD->dwSize == sizeof(DDSURFACEDESC))
504 // RtlZeroMemory(pDDSD,sizeof(DDSURFACEDESC));
505 // memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC));
506 // pDDSD->dwSize = sizeof(DDSURFACEDESC);
510 pDDSD
->lpSurface
= (LPVOID
) mdLock
.lpSurfData
;
512 pDDSD
->dwHeight
= ThisDest
->lpLcl
->lpGbl
->wHeight
;
513 pDDSD
->dwWidth
= ThisDest
->lpLcl
->lpGbl
->wWidth
;
515 pDDSD
->ddpfPixelFormat
.dwRGBBitCount
= ThisDest
->lpLcl
->lpGbl
->lpDD
->lpModeInfo
->dwBPP
;// .lpModeInfo->dwBPP; //This->lpLcl->lpGbl->lPitch/ 8;
516 pDDSD
->lPitch
= ThisDest
->lpLcl
->lpGbl
->lPitch
;
517 pDDSD
->dwFlags
= DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
520 return mdLock
.ddRVal
;
524 HRESULT WINAPI
Main_DDrawSurface_Unlock (LPDDRAWI_DDRAWSURFACE_INT This
, LPRECT pRect
)
526 DDHAL_UNLOCKDATA mdUnLock
;
530 /* Zero out members in DDHAL_UNLOCKDATA */
531 ZeroMemory(&mdUnLock
, sizeof(DDHAL_UNLOCKDATA
));
533 /* Check if we got HAL support for this api */
534 if (( This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HALDDSurface
.dwFlags
&
535 DDHAL_SURFCB32_UNLOCK
) == DDHAL_SURFCB32_UNLOCK
)
537 mdUnLock
.Unlock
= This
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HALDDSurface
.Unlock
;
539 /* Check if we got HEL support for this api */
540 else if (( This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HELDDSurface
.dwFlags
&
541 DDHAL_SURFCB32_UNLOCK
) == DDHAL_SURFCB32_UNLOCK
)
543 mdUnLock
.Unlock
= This
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Unlock
;
546 if (mdUnLock
.Unlock
== NULL
)
548 /* This api are unsupported */
549 return DDERR_UNSUPPORTED
;
552 mdUnLock
.ddRVal
= DDERR_NOTPALETTIZED
;
553 mdUnLock
.lpDD
= This
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
;
554 mdUnLock
.lpDDSurface
= This
->lpLcl
->lpSurfMore
->slist
[0];
556 if (!DdResetVisrgn( mdUnLock
.lpDDSurface
, NULL
))
558 DX_STUB_str("DdResetVisrgn fail");
559 //return DDERR_UNSUPPORTED; /* this can fail */
562 if (mdUnLock
.Unlock(&mdUnLock
)!= DDHAL_DRIVER_HANDLED
)
564 DX_STUB_str("unLock fail");
565 return DDERR_UNSUPPORTED
;
568 return mdUnLock
.ddRVal
;
572 Main_DDrawSurface_AddAttachedSurface(LPDDRAWI_DDRAWSURFACE_INT iface
,
573 LPDDRAWI_DDRAWSURFACE_INT pAttach
)
576 // LPDDRAWI_DDRAWSURFACE_INT This = (LPDDRAWI_DDRAWSURFACE_INT)iface;
577 // LPDDRAWI_DDRAWSURFACE_INT That = (LPDDRAWI_DDRAWSURFACE_INT)pAttach;
585 Main_DDrawSurface_GetAttachedSurface(LPDDRAWI_DDRAWSURFACE_INT This
,
587 LPDDRAWI_DDRAWSURFACE_INT
* ppSurface
)
594 *ppSurface
= This
->lpLcl
->lpGbl
->lpDD
->dsList
;
601 Main_DDrawSurface_GetBltStatus(LPDDRAWI_DDRAWSURFACE_INT This
, DWORD dwFlags
)
606 if (!(This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.dwFlags
& DDHAL_SURFCB32_FLIP
))
608 return DDERR_GENERIC
;
615 Main_DDrawSurface_GetCaps(LPDDRAWI_DDRAWSURFACE_INT This
, LPDDSCAPS2 pCaps
)
622 return DDERR_INVALIDOBJECT
;
627 return DDERR_INVALIDPARAMS
;
630 RtlZeroMemory(pCaps
,sizeof(DDSCAPS2
));
632 pCaps
->dwCaps
= This
->lpLcl
->ddsCaps
.dwCaps
;
638 Main_DDrawSurface_GetClipper(LPDDRAWI_DDRAWSURFACE_INT This
,
639 LPDIRECTDRAWCLIPPER
* ppClipper
)
646 return DDERR_INVALIDOBJECT
;
649 if (ppClipper
== NULL
)
651 return DDERR_INVALIDPARAMS
;
654 if (This
->lpLcl
->lp16DDClipper
== NULL
)
656 return DDERR_NOCLIPPERATTACHED
;
659 *ppClipper
= (LPDIRECTDRAWCLIPPER
)This
->lpLcl
->lp16DDClipper
;
665 Main_DDrawSurface_SetClipper (LPDDRAWI_DDRAWSURFACE_INT This
,
666 LPDIRECTDRAWCLIPPER pDDClipper
)
673 return DDERR_INVALIDOBJECT
;
676 if(pDDClipper
== NULL
)
678 if(!This
->lpLcl
->lp16DDClipper
)
679 return DDERR_NOCLIPPERATTACHED
;
681 DirectDrawClipper_Release((LPDIRECTDRAWCLIPPER
)This
->lpLcl
->lp16DDClipper
);
682 This
->lpLcl
->lp16DDClipper
= NULL
;
686 // FIXME: Check Surface type and return DDERR_INVALIDSURFACETYPE
688 DirectDrawClipper_AddRef((LPDIRECTDRAWCLIPPER
)pDDClipper
);
689 This
->lpLcl
->lp16DDClipper
= (LPDDRAWI_DDRAWCLIPPER_INT
)pDDClipper
;
695 Main_DDrawSurface_GetDC(LPDDRAWI_DDRAWSURFACE_INT This
, HDC
*phDC
)
702 return DDERR_INVALIDOBJECT
;
707 return DDERR_INVALIDPARAMS
;
711 *phDC
= (HDC
)This
->lpLcl
->lpSurfMore
->lpDD_lcl
->hDC
;
717 Main_DDrawSurface_GetPixelFormat(LPDDRAWI_DDRAWSURFACE_INT This
,
718 LPDDPIXELFORMAT pDDPixelFormat
)
720 HRESULT retVale
= DDERR_INVALIDPARAMS
;
724 if (pDDPixelFormat
!= NULL
)
726 if (This
->lpLcl
->dwFlags
& DDRAWISURF_HASPIXELFORMAT
)
728 memcpy(pDDPixelFormat
,&This
->lpLcl
->lpGbl
->ddpfSurface
,sizeof(DDPIXELFORMAT
));
732 memcpy(pDDPixelFormat
,&This
->lpLcl
->lpSurfMore
->
733 lpDD_lcl
->lpGbl
->vmiData
.ddpfDisplay
,sizeof(DDPIXELFORMAT
));
742 Main_DDrawSurface_GetSurfaceDesc(LPDDRAWI_DDRAWSURFACE_INT This
,
743 LPDDSURFACEDESC2 pDDSD
)
749 dwSize
= pDDSD
->dwSize
;
751 if ((dwSize
!= sizeof(DDSURFACEDESC
)) &&
752 (dwSize
!= sizeof(DDSURFACEDESC2
)))
754 return DDERR_GENERIC
;
757 ZeroMemory(pDDSD
,dwSize
);
759 if (dwSize
== sizeof(DDSURFACEDESC
))
761 LPDDSURFACEDESC lpDS
= (LPDDSURFACEDESC
) pDDSD
;
762 memcpy(&lpDS
->ddckCKDestBlt
, &This
->lpLcl
->ddckCKDestBlt
, sizeof(DDCOLORKEY
));
763 memcpy(&lpDS
->ddckCKDestOverlay
, &This
->lpLcl
->ddckCKDestOverlay
, sizeof(DDCOLORKEY
));
764 memcpy(&lpDS
->ddckCKSrcBlt
, &This
->lpLcl
->ddckCKSrcBlt
, sizeof(DDCOLORKEY
));
765 memcpy(&lpDS
->ddckCKSrcOverlay
, &This
->lpLcl
->ddckCKSrcOverlay
, sizeof(DDCOLORKEY
));
766 memcpy(&lpDS
->ddpfPixelFormat
, &This
->lpLcl
->lpGbl
->ddpfSurface
, sizeof(DDPIXELFORMAT
));
767 memcpy(&lpDS
->ddsCaps
, &This
->lpLcl
->ddsCaps
, sizeof(DDSCAPS
));
769 lpDS
->dwAlphaBitDepth
= This
->lpLcl
->dwAlpha
;
770 lpDS
->dwBackBufferCount
= This
->lpLcl
->dwBackBufferCount
;
772 /* FIXME setting the flags right */
773 // lpDS->dwFlags = This->lpLcl->dwFlags;
775 lpDS
->dwHeight
= This
->lpLcl
->lpGbl
->wHeight
;
776 lpDS
->dwWidth
= This
->lpLcl
->lpGbl
->wWidth
;
778 /* This two are a union in lpDS and in This->lpLcl->lpGbl
779 so I comment out lPitch
780 lpDS->lPitch = This->lpLcl->lpGbl->lPitch;
782 lpDS
->dwLinearSize
= This
->lpLcl
->lpGbl
->dwLinearSize
;
785 /* This tree are a union */
786 //lpDS->dwMipMapCount
787 //lpDS->dwRefreshRate
788 //lpDS->dwZBufferBitDepth
796 memcpy(&pDDSD
->ddckCKDestBlt
, &This
->lpLcl
->ddckCKDestBlt
, sizeof(DDCOLORKEY
));
799 pDDSD->dwEmptyFaceColor is a union to ddckCKDestOverlay
801 memcpy(&pDDSD
->ddckCKDestOverlay
, &This
->lpLcl
->ddckCKDestOverlay
, sizeof(DDCOLORKEY
));
802 memcpy(&pDDSD
->ddckCKSrcBlt
, &This
->lpLcl
->ddckCKSrcBlt
, sizeof(DDCOLORKEY
));
803 memcpy(&pDDSD
->ddckCKSrcOverlay
, &This
->lpLcl
->ddckCKSrcOverlay
, sizeof(DDCOLORKEY
));
806 pDDSD->dwFVF is a union to ddpfPixelFormat
808 memcpy(&pDDSD
->ddpfPixelFormat
, &This
->lpLcl
->lpGbl
->ddpfSurface
, sizeof(DDPIXELFORMAT
));
809 memcpy(&pDDSD
->ddsCaps
, &This
->lpLcl
->ddsCaps
, sizeof(DDSCAPS
));
812 pDDSD
->dwAlphaBitDepth
= This
->lpLcl
->dwAlpha
;
813 pDDSD
->dwBackBufferCount
= This
->lpLcl
->dwBackBufferCount
;
815 /* FIXME setting the flags right */
816 // lpDS->dwFlags = This->lpLcl->dwFlags;
818 pDDSD
->dwHeight
= This
->lpLcl
->lpGbl
->wHeight
;
819 pDDSD
->dwWidth
= This
->lpLcl
->lpGbl
->wWidth
;
821 /* This two are a union in lpDS and in This->lpLcl->lpGbl
822 so I comment out lPitch
823 lpDS->lPitch = This->lpLcl->lpGbl->lPitch;
825 pDDSD
->dwLinearSize
= This
->lpLcl
->lpGbl
->dwLinearSize
;
827 /* This tree are a union */
828 // pDDSD->dwMipMapCount
829 // pDDSD->dwRefreshRate
830 // pDDSD->dwSrcVBHandle
835 // pDDSD->dwTextureStage
842 Main_DDrawSurface_ReleaseDC(LPDDRAWI_DDRAWSURFACE_INT This
, HDC hDC
)
848 return DDERR_INVALIDOBJECT
;
853 return DDERR_INVALIDPARAMS
;
856 /* FIXME check if surface exits or not */
859 if ((HDC
)This
->lpLcl
->hDC
== NULL
)
861 return DDERR_GENERIC
;
868 Main_DDrawSurface_SetColorKey (LPDDRAWI_DDRAWSURFACE_INT This
,
869 DWORD dwFlags
, LPDDCOLORKEY pCKey
)
872 DDHAL_SETCOLORKEYDATA ColorKeyData
;
876 ColorKeyData
.ddRVal
= DDERR_COLORKEYNOTSET
;
878 if (This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.dwFlags
& DDHAL_SURFCB32_SETCOLORKEY
)
881 ColorKeyData
.lpDD
= This
->lpLcl
->lpGbl
->lpDD
;
882 ColorKeyData
.SetColorKey
= This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.SetColorKey
;
884 //ColorKeyData.lpDDSurface = &This->lpLcl->hDDSurface;
885 ColorKeyData
.dwFlags
= dwFlags
;
887 ColorKeyData.ckNew = ?
888 add / move dwFlags to This->lpLcl->dwFlags ??
891 if (ColorKeyData
.SetColorKey(&ColorKeyData
) == DDHAL_DRIVER_HANDLED
)
893 return ColorKeyData
.ddRVal
;
896 return DDERR_COLORKEYNOTSET
;
902 Main_DDrawSurface_SetOverlayPosition (LPDDRAWI_DDRAWSURFACE_INT This
, LONG X
, LONG Y
)
905 DDHAL_SETOVERLAYPOSITIONDATA OverLayPositionData
;
909 OverLayPositionData
.ddRVal
= DDERR_COLORKEYNOTSET
;
911 if (This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.dwFlags
& DDHAL_SURFCB32_SETOVERLAYPOSITION
)
914 OverLayPositionData
.lpDD
= This
->lpLcl
->lpGbl
->lpDD
;
915 OverLayPositionData
.SetOverlayPosition
= This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.SetOverlayPosition
;
917 //OverLayPositionData.lpDDSrcSurface = This->lpLcl->lpSurfaceOverlaying->lpLcl->hDDSurface;
918 //OverLayPositionData.lpDDDestSurface = This->lpLcl->hDDSurface;
920 OverLayPositionData
.lXPos
= X
;
921 OverLayPositionData
.lYPos
= Y
;
925 Should X and Y be save ??
928 if (OverLayPositionData
.SetOverlayPosition(&OverLayPositionData
) == DDHAL_DRIVER_HANDLED
)
930 return OverLayPositionData
.ddRVal
;
934 return DDERR_GENERIC
;