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
)
269 This is not right exiame how it should be done
271 DX_STUB_str("FIXME This is not right exiame how it should be done\n");
272 return This
->dwIntRefCnt
;
276 HRESULT WINAPI
Main_DDrawSurface_Blt(LPDDRAWI_DDRAWSURFACE_INT ThisDest
, LPRECT rdst
,
277 LPDDRAWI_DDRAWSURFACE_INT ThisSrc
, LPRECT rsrc
, DWORD dwFlags
, LPDDBLTFX lpbltfx
)
279 DDHAL_BLTDATA mDdBlt
;
283 if (ThisDest
== NULL
)
285 return DDERR_INVALIDPARAMS
;
288 /* Zero out members in DDHAL_BLTDATA */
289 ZeroMemory(&mDdBlt
, sizeof(DDHAL_BLTDATA
));
290 ZeroMemory(&mDdBlt
.bltFX
, sizeof(DDBLTFX
));
292 /* Check if we got HAL support for this api */
293 if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HALDDSurface
.dwFlags
&
294 DDHAL_SURFCB32_BLT
) == DDHAL_SURFCB32_BLT
)
296 mDdBlt
.Blt
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HALDDSurface
.Blt
;
298 /* Check if we got HEL support for this api */
299 else if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HELDDSurface
.dwFlags
&
300 DDHAL_SURFCB32_BLT
) == DDHAL_SURFCB32_BLT
)
302 mDdBlt
.Blt
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Blt
;
305 if (mDdBlt
.Blt
== NULL
)
307 /* This API is unsupported */
308 return DDERR_UNSUPPORTED
;
311 /* Prepare for draw, if we do not reset the DdResetVisrgn some graphics card will not draw on the screen */
312 if (!DdResetVisrgn( ThisDest
->lpLcl
->lpSurfMore
->slist
[0], NULL
))
314 DX_STUB_str("DdResetVisrgn failed");
317 mDdBlt
.lpDD
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
;
318 mDdBlt
.lpDDDestSurface
= ThisDest
->lpLcl
->lpSurfMore
->slist
[0];
319 ThisDest
->lpLcl
->lpSurfMore
->slist
[0]->hDC
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->hDC
;
322 if (( ThisSrc
!= NULL
) )
325 mDdBlt
.lpDDSrcSurface
= ThisSrc
->lpLcl
->lpSurfMore
->slist
[0];
326 ThisSrc
->lpLcl
->lpSurfMore
->slist
[0]->hDC
= ThisSrc
->lpLcl
->lpSurfMore
->lpDD_lcl
->hDC
;
330 memmove(&mDdBlt
.rSrc
, rsrc
, sizeof (RECTL
));
334 if(!GetWindowRect((HWND
)ThisSrc
->lpLcl
->lpSurfMore
->lpDD_lcl
->hWnd
,
335 (RECT
*)&mDdBlt
.rSrc
))
337 DX_STUB_str("GetWindowRect failed");
342 * compare so we do not write too far
343 * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
344 * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
345 * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
353 memmove(&mDdBlt
.rDest
, rdst
, sizeof (RECTL
));
357 if (!GetWindowRect((HWND
)ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->hWnd
,
358 (RECT
*)&mDdBlt
.rDest
))
360 DX_STUB_str("GetWindowRect failed");
365 * compare so we do not write too far
366 * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
367 * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
368 * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
375 memmove(&mDdBlt
.bltFX
, lpbltfx
, sizeof (DDBLTFX
));
378 /* setup value that are not config yet */
379 mDdBlt
.dwFlags
= dwFlags
;
380 mDdBlt
.IsClipped
= FALSE
;
381 mDdBlt
.bltFX
.dwSize
= sizeof(DDBLTFX
);
394 if (mDdBlt
.Blt(&mDdBlt
) != DDHAL_DRIVER_HANDLED
)
396 DX_STUB_str("mDdBlt DDHAL_DRIVER_HANDLED");
397 return DDERR_NOBLTHW
;
400 return mDdBlt
.ddRVal
;
405 Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT ThisDest
, LPRECT prect
,
406 LPDDSURFACEDESC2 pDDSD
, DWORD flags
, HANDLE events
)
408 DDHAL_LOCKDATA mdLock
;
412 DX_WINDBG_trace_res( (DWORD
)ThisDest
->lpLcl
->lpGbl
->wWidth
, (DWORD
)ThisDest
->lpLcl
->lpGbl
->wHeight
, (DWORD
)ThisDest
->lpLcl
->lpGbl
->lPitch
, (DWORD
) 0);
414 /* Zero out members in DDHAL_LOCKDATA */
415 ZeroMemory(&mdLock
, sizeof(DDHAL_LOCKDATA
));
417 /* Check if we got HAL support for this api */
418 if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HALDDSurface
.dwFlags
&
419 DDHAL_SURFCB32_LOCK
) == DDHAL_SURFCB32_LOCK
)
421 mdLock
.Lock
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HALDDSurface
.Lock
;
423 /* Check if we got HEL support for this api */
424 else if (( ThisDest
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HELDDSurface
.dwFlags
&
425 DDHAL_SURFCB32_LOCK
) == DDHAL_SURFCB32_LOCK
)
427 mdLock
.Lock
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Lock
;
430 if (mdLock
.Lock
== NULL
)
432 /* This api are unsupported */
433 return DDERR_UNSUPPORTED
;
438 return DDERR_INVALIDPARAMS
;
441 /* FIXME add a check see if lock suport or not */
445 mdLock
.bHasRect
= TRUE
;
446 memcpy(&mdLock
.rArea
,prect
,sizeof(RECTL
));
450 mdLock
.bHasRect
= FALSE
;
453 //FIXME check if it primary or not and use primary or pixelformat data, at moment it is hardcode to primary
455 mdLock
.ddRVal
= DDERR_CANTLOCKSURFACE
;
456 mdLock
.dwFlags
= flags
;
457 mdLock
.lpDDSurface
= ThisDest
->lpLcl
->lpSurfMore
->slist
[0];
458 mdLock
.lpDD
= ThisDest
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
;
459 mdLock
.lpSurfData
= NULL
;
462 if (!DdResetVisrgn(ThisDest
->lpLcl
->lpSurfMore
->slist
[0], NULL
))
464 DX_STUB_str("Here DdResetVisrgn lock");
465 // return DDERR_UNSUPPORTED;
468 if (mdLock
.Lock(&mdLock
)!= DDHAL_DRIVER_HANDLED
)
470 DX_STUB_str("Here DDHAL_DRIVER_HANDLED lock");
471 return DDERR_UNSUPPORTED
;
474 // FIXME ??? is this right ??
478 ZeroMemory(pDDSD
,sizeof(DDSURFACEDESC2
));
479 pDDSD
->dwSize
= sizeof(DDSURFACEDESC2
);
481 //if (pDDSD->dwSize == sizeof(DDSURFACEDESC2))
483 // ZeroMemory(pDDSD,sizeof(DDSURFACEDESC2));
484 // // FIXME the interanl mddsdPrimary shall be DDSURFACEDESC2
485 // memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC));
486 // pDDSD->dwSize = sizeof(DDSURFACEDESC2);
488 //if (pDDSD->dwSize == sizeof(DDSURFACEDESC))
490 // RtlZeroMemory(pDDSD,sizeof(DDSURFACEDESC));
491 // memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC));
492 // pDDSD->dwSize = sizeof(DDSURFACEDESC);
496 pDDSD
->lpSurface
= (LPVOID
) mdLock
.lpSurfData
;
498 pDDSD
->dwHeight
= ThisDest
->lpLcl
->lpGbl
->wHeight
;
499 pDDSD
->dwWidth
= ThisDest
->lpLcl
->lpGbl
->wWidth
;
501 pDDSD
->ddpfPixelFormat
.dwRGBBitCount
= ThisDest
->lpLcl
->lpGbl
->lpDD
->lpModeInfo
->dwBPP
;// .lpModeInfo->dwBPP; //This->lpLcl->lpGbl->lPitch/ 8;
502 pDDSD
->lPitch
= ThisDest
->lpLcl
->lpGbl
->lPitch
;
503 pDDSD
->dwFlags
= DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
506 return mdLock
.ddRVal
;
510 HRESULT WINAPI
Main_DDrawSurface_Unlock (LPDDRAWI_DDRAWSURFACE_INT This
, LPRECT pRect
)
512 DDHAL_UNLOCKDATA mdUnLock
;
516 /* Zero out members in DDHAL_UNLOCKDATA */
517 ZeroMemory(&mdUnLock
, sizeof(DDHAL_UNLOCKDATA
));
519 /* Check if we got HAL support for this api */
520 if (( This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HALDDSurface
.dwFlags
&
521 DDHAL_SURFCB32_UNLOCK
) == DDHAL_SURFCB32_UNLOCK
)
523 mdUnLock
.Unlock
= This
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HALDDSurface
.Unlock
;
525 /* Check if we got HEL support for this api */
526 else if (( This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->HELDDSurface
.dwFlags
&
527 DDHAL_SURFCB32_UNLOCK
) == DDHAL_SURFCB32_UNLOCK
)
529 mdUnLock
.Unlock
= This
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Unlock
;
532 if (mdUnLock
.Unlock
== NULL
)
534 /* This api are unsupported */
535 return DDERR_UNSUPPORTED
;
538 mdUnLock
.ddRVal
= DDERR_NOTPALETTIZED
;
539 mdUnLock
.lpDD
= This
->lpLcl
->lpSurfMore
->lpDD_lcl
->lpGbl
;
540 mdUnLock
.lpDDSurface
= This
->lpLcl
->lpSurfMore
->slist
[0];
542 if (!DdResetVisrgn( mdUnLock
.lpDDSurface
, NULL
))
544 DX_STUB_str("DdResetVisrgn fail");
545 //return DDERR_UNSUPPORTED; /* this can fail */
548 if (mdUnLock
.Unlock(&mdUnLock
)!= DDHAL_DRIVER_HANDLED
)
550 DX_STUB_str("unLock fail");
551 return DDERR_UNSUPPORTED
;
554 return mdUnLock
.ddRVal
;
558 Main_DDrawSurface_AddAttachedSurface(LPDDRAWI_DDRAWSURFACE_INT iface
,
559 LPDDRAWI_DDRAWSURFACE_INT pAttach
)
562 // LPDDRAWI_DDRAWSURFACE_INT This = (LPDDRAWI_DDRAWSURFACE_INT)iface;
563 // LPDDRAWI_DDRAWSURFACE_INT That = (LPDDRAWI_DDRAWSURFACE_INT)pAttach;
571 Main_DDrawSurface_GetAttachedSurface(LPDDRAWI_DDRAWSURFACE_INT This
,
573 LPDDRAWI_DDRAWSURFACE_INT
* ppSurface
)
580 *ppSurface
= This
->lpLcl
->lpGbl
->lpDD
->dsList
;
587 Main_DDrawSurface_GetBltStatus(LPDDRAWI_DDRAWSURFACE_INT This
, DWORD dwFlags
)
592 if (!(This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.dwFlags
& DDHAL_SURFCB32_FLIP
))
594 return DDERR_GENERIC
;
601 Main_DDrawSurface_GetCaps(LPDDRAWI_DDRAWSURFACE_INT This
, LPDDSCAPS2 pCaps
)
608 return DDERR_INVALIDOBJECT
;
613 return DDERR_INVALIDPARAMS
;
616 RtlZeroMemory(pCaps
,sizeof(DDSCAPS2
));
618 pCaps
->dwCaps
= This
->lpLcl
->ddsCaps
.dwCaps
;
624 Main_DDrawSurface_GetClipper(LPDDRAWI_DDRAWSURFACE_INT This
,
625 LPDIRECTDRAWCLIPPER
* ppClipper
)
632 return DDERR_INVALIDOBJECT
;
635 if (ppClipper
== NULL
)
637 return DDERR_INVALIDPARAMS
;
640 if (This
->lpLcl
->lp16DDClipper
== NULL
)
642 return DDERR_NOCLIPPERATTACHED
;
645 *ppClipper
= (LPDIRECTDRAWCLIPPER
)This
->lpLcl
->lp16DDClipper
;
651 Main_DDrawSurface_SetClipper (LPDDRAWI_DDRAWSURFACE_INT This
,
652 LPDIRECTDRAWCLIPPER pDDClipper
)
659 return DDERR_INVALIDOBJECT
;
662 if(pDDClipper
== NULL
)
664 if(!This
->lpLcl
->lp16DDClipper
)
665 return DDERR_NOCLIPPERATTACHED
;
667 DirectDrawClipper_Release((LPDIRECTDRAWCLIPPER
)This
->lpLcl
->lp16DDClipper
);
668 This
->lpLcl
->lp16DDClipper
= NULL
;
672 // FIXME: Check Surface type and return DDERR_INVALIDSURFACETYPE
674 DirectDrawClipper_AddRef((LPDIRECTDRAWCLIPPER
)pDDClipper
);
675 This
->lpLcl
->lp16DDClipper
= (LPDDRAWI_DDRAWCLIPPER_INT
)pDDClipper
;
681 Main_DDrawSurface_GetDC(LPDDRAWI_DDRAWSURFACE_INT This
, HDC
*phDC
)
688 return DDERR_INVALIDOBJECT
;
693 return DDERR_INVALIDPARAMS
;
697 *phDC
= (HDC
)This
->lpLcl
->lpSurfMore
->lpDD_lcl
->hDC
;
703 Main_DDrawSurface_GetPixelFormat(LPDDRAWI_DDRAWSURFACE_INT This
,
704 LPDDPIXELFORMAT pDDPixelFormat
)
706 HRESULT retVale
= DDERR_INVALIDPARAMS
;
710 if (pDDPixelFormat
!= NULL
)
712 if (This
->lpLcl
->dwFlags
& DDRAWISURF_HASPIXELFORMAT
)
714 memcpy(pDDPixelFormat
,&This
->lpLcl
->lpGbl
->ddpfSurface
,sizeof(DDPIXELFORMAT
));
718 memcpy(pDDPixelFormat
,&This
->lpLcl
->lpSurfMore
->
719 lpDD_lcl
->lpGbl
->vmiData
.ddpfDisplay
,sizeof(DDPIXELFORMAT
));
728 Main_DDrawSurface_GetSurfaceDesc(LPDDRAWI_DDRAWSURFACE_INT This
,
729 LPDDSURFACEDESC2 pDDSD
)
735 dwSize
= pDDSD
->dwSize
;
737 if ((dwSize
!= sizeof(DDSURFACEDESC
)) &&
738 (dwSize
!= sizeof(DDSURFACEDESC2
)))
740 return DDERR_GENERIC
;
743 ZeroMemory(pDDSD
,dwSize
);
745 if (dwSize
== sizeof(DDSURFACEDESC
))
747 LPDDSURFACEDESC lpDS
= (LPDDSURFACEDESC
) pDDSD
;
748 memcpy(&lpDS
->ddckCKDestBlt
, &This
->lpLcl
->ddckCKDestBlt
, sizeof(DDCOLORKEY
));
749 memcpy(&lpDS
->ddckCKDestOverlay
, &This
->lpLcl
->ddckCKDestOverlay
, sizeof(DDCOLORKEY
));
750 memcpy(&lpDS
->ddckCKSrcBlt
, &This
->lpLcl
->ddckCKSrcBlt
, sizeof(DDCOLORKEY
));
751 memcpy(&lpDS
->ddckCKSrcOverlay
, &This
->lpLcl
->ddckCKSrcOverlay
, sizeof(DDCOLORKEY
));
752 memcpy(&lpDS
->ddpfPixelFormat
, &This
->lpLcl
->lpGbl
->ddpfSurface
, sizeof(DDPIXELFORMAT
));
753 memcpy(&lpDS
->ddsCaps
, &This
->lpLcl
->ddsCaps
, sizeof(DDSCAPS
));
755 lpDS
->dwAlphaBitDepth
= This
->lpLcl
->dwAlpha
;
756 lpDS
->dwBackBufferCount
= This
->lpLcl
->dwBackBufferCount
;
758 /* FIXME setting the flags right */
759 // lpDS->dwFlags = This->lpLcl->dwFlags;
761 lpDS
->dwHeight
= This
->lpLcl
->lpGbl
->wHeight
;
762 lpDS
->dwWidth
= This
->lpLcl
->lpGbl
->wWidth
;
764 /* This two are a union in lpDS and in This->lpLcl->lpGbl
765 so I comment out lPitch
766 lpDS->lPitch = This->lpLcl->lpGbl->lPitch;
768 lpDS
->dwLinearSize
= This
->lpLcl
->lpGbl
->dwLinearSize
;
771 /* This tree are a union */
772 //lpDS->dwMipMapCount
773 //lpDS->dwRefreshRate
774 //lpDS->dwZBufferBitDepth
782 memcpy(&pDDSD
->ddckCKDestBlt
, &This
->lpLcl
->ddckCKDestBlt
, sizeof(DDCOLORKEY
));
785 pDDSD->dwEmptyFaceColor is a union to ddckCKDestOverlay
787 memcpy(&pDDSD
->ddckCKDestOverlay
, &This
->lpLcl
->ddckCKDestOverlay
, sizeof(DDCOLORKEY
));
788 memcpy(&pDDSD
->ddckCKSrcBlt
, &This
->lpLcl
->ddckCKSrcBlt
, sizeof(DDCOLORKEY
));
789 memcpy(&pDDSD
->ddckCKSrcOverlay
, &This
->lpLcl
->ddckCKSrcOverlay
, sizeof(DDCOLORKEY
));
792 pDDSD->dwFVF is a union to ddpfPixelFormat
794 memcpy(&pDDSD
->ddpfPixelFormat
, &This
->lpLcl
->lpGbl
->ddpfSurface
, sizeof(DDPIXELFORMAT
));
795 memcpy(&pDDSD
->ddsCaps
, &This
->lpLcl
->ddsCaps
, sizeof(DDSCAPS
));
798 pDDSD
->dwAlphaBitDepth
= This
->lpLcl
->dwAlpha
;
799 pDDSD
->dwBackBufferCount
= This
->lpLcl
->dwBackBufferCount
;
801 /* FIXME setting the flags right */
802 // lpDS->dwFlags = This->lpLcl->dwFlags;
804 pDDSD
->dwHeight
= This
->lpLcl
->lpGbl
->wHeight
;
805 pDDSD
->dwWidth
= This
->lpLcl
->lpGbl
->wWidth
;
807 /* This two are a union in lpDS and in This->lpLcl->lpGbl
808 so I comment out lPitch
809 lpDS->lPitch = This->lpLcl->lpGbl->lPitch;
811 pDDSD
->dwLinearSize
= This
->lpLcl
->lpGbl
->dwLinearSize
;
813 /* This tree are a union */
814 // pDDSD->dwMipMapCount
815 // pDDSD->dwRefreshRate
816 // pDDSD->dwSrcVBHandle
821 // pDDSD->dwTextureStage
828 Main_DDrawSurface_ReleaseDC(LPDDRAWI_DDRAWSURFACE_INT This
, HDC hDC
)
834 return DDERR_INVALIDOBJECT
;
839 return DDERR_INVALIDPARAMS
;
842 /* FIXME check if surface exits or not */
845 if ((HDC
)This
->lpLcl
->hDC
== NULL
)
847 return DDERR_GENERIC
;
854 Main_DDrawSurface_SetColorKey (LPDDRAWI_DDRAWSURFACE_INT This
,
855 DWORD dwFlags
, LPDDCOLORKEY pCKey
)
858 DDHAL_SETCOLORKEYDATA ColorKeyData
;
862 ColorKeyData
.ddRVal
= DDERR_COLORKEYNOTSET
;
864 if (This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.dwFlags
& DDHAL_SURFCB32_SETCOLORKEY
)
867 ColorKeyData
.lpDD
= This
->lpLcl
->lpGbl
->lpDD
;
868 ColorKeyData
.SetColorKey
= This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.SetColorKey
;
870 //ColorKeyData.lpDDSurface = &This->lpLcl->hDDSurface;
871 ColorKeyData
.dwFlags
= dwFlags
;
873 ColorKeyData.ckNew = ?
874 add / move dwFlags to This->lpLcl->dwFlags ??
877 if (ColorKeyData
.SetColorKey(&ColorKeyData
) == DDHAL_DRIVER_HANDLED
)
879 return ColorKeyData
.ddRVal
;
882 return DDERR_COLORKEYNOTSET
;
888 Main_DDrawSurface_SetOverlayPosition (LPDDRAWI_DDRAWSURFACE_INT This
, LONG X
, LONG Y
)
891 DDHAL_SETOVERLAYPOSITIONDATA OverLayPositionData
;
895 OverLayPositionData
.ddRVal
= DDERR_COLORKEYNOTSET
;
897 if (This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.dwFlags
& DDHAL_SURFCB32_SETOVERLAYPOSITION
)
900 OverLayPositionData
.lpDD
= This
->lpLcl
->lpGbl
->lpDD
;
901 OverLayPositionData
.SetOverlayPosition
= This
->lpLcl
->lpGbl
->lpDD
->lpDDCBtmp
->cbDDSurfaceCallbacks
.SetOverlayPosition
;
903 //OverLayPositionData.lpDDSrcSurface = This->lpLcl->lpSurfaceOverlaying->lpLcl->hDDSurface;
904 //OverLayPositionData.lpDDDestSurface = This->lpLcl->hDDSurface;
906 OverLayPositionData
.lXPos
= X
;
907 OverLayPositionData
.lYPos
= Y
;
911 Should X and Y be save ??
914 if (OverLayPositionData
.SetOverlayPosition(&OverLayPositionData
) == DDHAL_DRIVER_HANDLED
)
916 return OverLayPositionData
.ddRVal
;
920 return DDERR_GENERIC
;