ReactOS  0.4.13-dev-544-gede3fdd
surface_main.c
Go to the documentation of this file.
1 /*
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
7  *
8  */
9 
10 #include "rosdraw.h"
11 
12 
13 /* FIXME adding hal and hel stub
14  DestroySurface;
15  SetClipList;
16  AddAttachedSurface;
17  GetFlipStatus;
18  SetOverlayPosition;
19  SetPalette;
20 */
21 
24 {
26  DxHeapMemAlloc(newThis, sizeof(DDRAWI_DDRAWSURFACE_INT));
27  if (newThis)
28  {
29  newThis->lpLcl = This->lpLcl;
30  newThis->lpLink = This;
31  }
32  return newThis;
33 }
34 
36 {
38 }
39 
41 {
42 
44 
45  if (This!=NULL)
46  {
47  This->dwIntRefCnt++;
48  This->lpLcl->dwLocalRefCnt++;
49 
50  if (This->lpLcl->lpGbl != NULL)
51  {
52  This->lpLcl->lpGbl->dwRefCnt++;
53  }
54  }
55  return This->dwIntRefCnt;
56 
57 }
58 
61 {
62  HRESULT retVal = DD_OK;
63  *ppObj = NULL;
64 
66 
67  _SEH2_TRY
68  {
69  if (IsEqualGUID(&IID_IDirectDrawSurface7, riid))
70  {
71  if (This->lpVtbl != &DirectDrawSurface7_Vtable)
72  {
74  if (!This)
75  {
76  retVal = DDERR_OUTOFVIDEOMEMORY;
78  }
79  }
81  *ppObj = This;
83  }
84  else if (IsEqualGUID(&IID_IDirectDrawSurface4, riid))
85  {
86  if (This->lpVtbl != &DirectDrawSurface4_Vtable)
87  {
89  if (!This)
90  {
91  retVal = DDERR_OUTOFVIDEOMEMORY;
93  }
94  }
96  *ppObj = This;
98  }
99  else if (IsEqualGUID(&IID_IDirectDrawSurface3, riid))
100  {
101  if (This->lpVtbl != &DirectDrawSurface3_Vtable)
102  {
104  if (!This)
105  {
106  retVal = DDERR_OUTOFVIDEOMEMORY;
107  _SEH2_LEAVE;
108  }
109  }
110  This->lpVtbl = &DirectDrawSurface3_Vtable;
111  *ppObj = This;
113  }
114  else if (IsEqualGUID(&IID_IDirectDrawSurface2, riid))
115  {
116  if (This->lpVtbl != &DirectDrawSurface2_Vtable)
117  {
119  if (!This)
120  {
121  retVal = DDERR_OUTOFVIDEOMEMORY;
122  _SEH2_LEAVE;
123  }
124  }
125  This->lpVtbl = &DirectDrawSurface2_Vtable;
126  *ppObj = This;
128  }
129  else if (IsEqualGUID(&IID_IDirectDrawSurface, riid))
130  {
131  if (This->lpVtbl != &DirectDrawSurface_Vtable)
132  {
134  if (!This)
135  {
136  retVal = DDERR_OUTOFVIDEOMEMORY;
137  _SEH2_LEAVE;
138  }
139  }
140  This->lpVtbl = &DirectDrawSurface_Vtable;
141  *ppObj = This;
143  }
144  else if (IsEqualGUID(&IID_IDirectDrawColorControl, riid))
145  {
146  if (This->lpVtbl != &DirectDrawColorControl_Vtable)
147  {
149  if (!This)
150  {
151  retVal = DDERR_OUTOFVIDEOMEMORY;
152  _SEH2_LEAVE;
153  }
154  }
156  *ppObj = This;
158  }
159  else if (IsEqualGUID(&IID_IDirectDrawGammaControl, riid))
160  {
161  if (This->lpVtbl != &DirectDrawGammaControl_Vtable)
162  {
164  if (!This)
165  {
166  retVal = DDERR_OUTOFVIDEOMEMORY;
167  _SEH2_LEAVE;
168  }
169  }
171  *ppObj = This;
173  }
174  else if (IsEqualGUID(&IID_IDirectDrawSurfaceKernel, riid))
175  {
176  if (This->lpVtbl != &DirectDrawSurfaceKernel_Vtable)
177  {
179  if (!This)
180  {
181  retVal = DDERR_OUTOFVIDEOMEMORY;
182  _SEH2_LEAVE;
183  }
184  }
186  *ppObj = This;
188  }
189  else if (IsEqualGUID(&IID_IDirect3D, riid))
190  {
191  if (This->lpVtbl != &IDirect3D_Vtbl)
192  {
194  if (!This)
195  {
196  retVal = DDERR_OUTOFVIDEOMEMORY;
197  _SEH2_LEAVE;
198  }
199  }
200  This->lpVtbl = &IDirect3D_Vtbl;
201  *ppObj = This;
203  }
204  else if (IsEqualGUID(&IID_IDirect3D2, riid))
205  {
206  if (This->lpVtbl != &IDirect3D2_Vtbl)
207  {
209  if (!This)
210  {
211  retVal = DDERR_OUTOFVIDEOMEMORY;
212  _SEH2_LEAVE;
213  }
214  }
215  This->lpVtbl = &IDirect3D2_Vtbl;
216  *ppObj = This;
218  }
219  else if (IsEqualGUID(&IID_IDirect3D3, riid))
220  {
221  if (This->lpVtbl != &IDirect3D3_Vtbl)
222  {
224  if (!This)
225  {
226  retVal = DDERR_OUTOFVIDEOMEMORY;
227  _SEH2_LEAVE;
228  }
229  }
230  This->lpVtbl = &IDirect3D3_Vtbl;
231  *ppObj = This;
233  }
234  else if (IsEqualGUID(&IID_IDirect3D7, riid))
235  {
236  if (This->lpVtbl != &IDirect3D7_Vtbl)
237  {
239  if (!This)
240  {
241  retVal = DDERR_OUTOFVIDEOMEMORY;
242  _SEH2_LEAVE;
243  }
244  }
245  This->lpVtbl = &IDirect3D7_Vtbl;
246  *ppObj = This;
248  }
249  else
250  {
251  DX_STUB_str("E_NOINTERFACE");
252  retVal = E_NOINTERFACE;
253  }
254  }
256  {
257  }
258  _SEH2_END;
259  return retVal;
260 }
261 
262 
263 
265 {
266  /* FIXME
267  This is not right exiame how it should be done
268  */
269  ULONG ret = --This->dwIntRefCnt;
270  if(!ret)
271  {
272  DX_STUB_str("Release is a bit simplistic right now\n");
276  }
277  return ret;
278 }
279 
281 {
283 
284  if(ref == 0) Main_DirectDraw_Release(This->lpLcl->lpSurfMore->lpDD_int);
285 
286  return ref;
287 }
288 
290  LPDDRAWI_DDRAWSURFACE_INT ThisSrc, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx)
291 {
293 
294  DX_WINDBG_trace();
295 
296  if (ThisDest == NULL)
297  {
298  return DDERR_INVALIDPARAMS;
299  }
300 
301  /* Zero out members in DDHAL_BLTDATA */
302  ZeroMemory(&mDdBlt, sizeof(DDHAL_BLTDATA));
303  ZeroMemory(&mDdBlt.bltFX, sizeof(DDBLTFX));
304 
305  /* Check if we got HAL support for this api */
306  if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags &
308  {
309  mDdBlt.Blt = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Blt;
310  }
311  /* Check if we got HEL support for this api */
312  else if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags &
314  {
315  mDdBlt.Blt = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Blt;
316  }
317 
318  if (mDdBlt.Blt == NULL)
319  {
320  /* This API is unsupported */
321  return DDERR_UNSUPPORTED;
322  }
323 
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))
326  {
327  DX_STUB_str("DdResetVisrgn failed");
328  }
329 
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;
333 
334  /* Setup Src */
335  if (( ThisSrc != NULL ) )
336  {
337 
338  mDdBlt.lpDDSrcSurface = ThisSrc->lpLcl->lpSurfMore->slist[0];
339  ThisSrc->lpLcl->lpSurfMore->slist[0]->hDC = ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hDC;
340 
341  if (rsrc != NULL)
342  {
343  memmove(&mDdBlt.rSrc, rsrc, sizeof (RECTL));
344  }
345  else
346  {
347  if(!GetWindowRect((HWND)ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hWnd,
348  (RECT *)&mDdBlt.rSrc))
349  {
350  DX_STUB_str("GetWindowRect failed");
351  }
352  }
353 
354  /* FIXME
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
359  */
360 
361  }
362 
363  /* Setup dest */
364  if (rdst != NULL)
365  {
366  memmove(&mDdBlt.rDest, rdst, sizeof (RECTL));
367  }
368  else
369  {
370  if (!GetWindowRect((HWND)ThisDest->lpLcl->lpSurfMore->lpDD_lcl->hWnd,
371  (RECT *)&mDdBlt.rDest))
372  {
373  DX_STUB_str("GetWindowRect failed");
374  }
375  }
376 
377  /* FIXME
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
382  */
383 
384 
385  /* setup bltFX */
386  if (lpbltfx != NULL)
387  {
388  memmove(&mDdBlt.bltFX, lpbltfx, sizeof (DDBLTFX));
389  }
390 
391  /* setup value that are not config yet */
394  mDdBlt.bltFX.dwSize = sizeof(DDBLTFX);
395 
396 
397  /* FIXME
398  BltData.dwRectCnt
399  BltData.dwROPFlags
400  BltData.IsClipped
401  BltData.prDestRects
402  BltData.rOrigDest
403  BltData.rOrigSrc
404  BltData.ddRVal
405  */
406 
408  {
409  DX_STUB_str("mDdBlt DDHAL_DRIVER_HANDLED");
410  return DDERR_NOBLTHW;
411  }
412 
413  return mDdBlt.ddRVal;
414 }
415 
416 
420 {
421  DDHAL_LOCKDATA mdLock;
422 
423  DX_WINDBG_trace();
424 
425  DX_WINDBG_trace_res( (DWORD)ThisDest->lpLcl->lpGbl->wWidth, (DWORD)ThisDest->lpLcl->lpGbl->wHeight, (DWORD)ThisDest->lpLcl->lpGbl->lPitch, (DWORD) 0);
426 
427  /* Zero out members in DDHAL_LOCKDATA */
428  ZeroMemory(&mdLock, sizeof(DDHAL_LOCKDATA));
429 
430  /* Check if we got HAL support for this api */
431  if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags &
433  {
434  mdLock.Lock = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Lock;
435  }
436  /* Check if we got HEL support for this api */
437  else if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags &
439  {
440  mdLock.Lock = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Lock;
441  }
442 
443  if (mdLock.Lock == NULL)
444  {
445  /* This api are unsupported */
446  return DDERR_UNSUPPORTED;
447  }
448 
449  if (events != NULL)
450  {
451  return DDERR_INVALIDPARAMS;
452  }
453 
454  /* FIXME add a check see if lock support or not */
455 
456  if (prect!=NULL)
457  {
458  mdLock.bHasRect = TRUE;
459  memcpy(&mdLock.rArea,prect,sizeof(RECTL));
460  }
461  else
462  {
463  mdLock.bHasRect = FALSE;
464  }
465 
466  //FIXME check if it primary or not and use primary or pixelformat data, at moment it is hardcode to primary
467 
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;
473 
474 
475  if (!DdResetVisrgn(ThisDest->lpLcl->lpSurfMore->slist[0], NULL))
476  {
477  DX_STUB_str("Here DdResetVisrgn lock");
478  // return DDERR_UNSUPPORTED;
479  }
480 
481  if (mdLock.Lock(&mdLock)!= DDHAL_DRIVER_HANDLED)
482  {
483  DX_STUB_str("Here DDHAL_DRIVER_HANDLED lock");
484  return DDERR_UNSUPPORTED;
485  }
486 
487  // FIXME ??? is this right ??
488 
489  if (pDDSD != NULL)
490  {
491  ZeroMemory(pDDSD,sizeof(DDSURFACEDESC2));
492  pDDSD->dwSize = sizeof(DDSURFACEDESC2);
493 
494  //if (pDDSD->dwSize == sizeof(DDSURFACEDESC2))
495  //{
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);
500  //}
501  //if (pDDSD->dwSize == sizeof(DDSURFACEDESC))
502  //{
503  // RtlZeroMemory(pDDSD,sizeof(DDSURFACEDESC));
504  // memcpy(pDDSD,&This->Surf->mddsdPrimary,sizeof(DDSURFACEDESC));
505  // pDDSD->dwSize = sizeof(DDSURFACEDESC);
506  //}
507 
508 
509  pDDSD->lpSurface = (LPVOID) mdLock.lpSurfData;
510 
511  pDDSD->dwHeight = ThisDest->lpLcl->lpGbl->wHeight;
512  pDDSD->dwWidth = ThisDest->lpLcl->lpGbl->wWidth;
513 
514  pDDSD->ddpfPixelFormat.dwRGBBitCount = ThisDest->lpLcl->lpGbl->lpDD->lpModeInfo->dwBPP;// .lpModeInfo->dwBPP; //This->lpLcl->lpGbl->lPitch/ 8;
515  pDDSD->lPitch = ThisDest->lpLcl->lpGbl->lPitch;
517  }
518 
519  return mdLock.ddRVal;
520 }
521 
522 
524 {
525  DDHAL_UNLOCKDATA mdUnLock;
526 
527  DX_WINDBG_trace();
528 
529  /* Zero out members in DDHAL_UNLOCKDATA */
530  ZeroMemory(&mdUnLock, sizeof(DDHAL_UNLOCKDATA));
531 
532  /* Check if we got HAL support for this api */
533  if (( This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags &
535  {
536  mdUnLock.Unlock = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Unlock;
537  }
538  /* Check if we got HEL support for this api */
539  else if (( This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags &
541  {
542  mdUnLock.Unlock = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Unlock;
543  }
544 
545  if (mdUnLock.Unlock == NULL)
546  {
547  /* This api are unsupported */
548  return DDERR_UNSUPPORTED;
549  }
550 
551  mdUnLock.ddRVal = DDERR_NOTPALETTIZED;
552  mdUnLock.lpDD = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
553  mdUnLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0];
554 
555  if (!DdResetVisrgn( mdUnLock.lpDDSurface, NULL))
556  {
557  DX_STUB_str("DdResetVisrgn fail");
558  //return DDERR_UNSUPPORTED; /* this can fail */
559  }
560 
561  if (mdUnLock.Unlock(&mdUnLock)!= DDHAL_DRIVER_HANDLED)
562  {
563  DX_STUB_str("unLock fail");
564  return DDERR_UNSUPPORTED;
565  }
566 
567  return mdUnLock.ddRVal;
568 }
569 
573 {
574 
575  // LPDDRAWI_DDRAWSURFACE_INT This = (LPDDRAWI_DDRAWSURFACE_INT)iface;
576  // LPDDRAWI_DDRAWSURFACE_INT That = (LPDDRAWI_DDRAWSURFACE_INT)pAttach;
577 
578  DX_WINDBG_trace();
579 
580  DX_STUB;
581 }
582 
585  LPDDSCAPS2 pCaps,
586  LPDDRAWI_DDRAWSURFACE_INT* ppSurface)
587 {
588  /* FIXME hacked */
589 
590 
591  DX_WINDBG_trace();
592 
593  *ppSurface = This->lpLcl->lpGbl->lpDD->dsList;
594 
595 
596  return DD_OK;
597 }
598 
601 {
602 
603  DX_WINDBG_trace();
604 
605  if (!(This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.dwFlags & DDHAL_SURFCB32_FLIP))
606  {
607  return DDERR_GENERIC;
608  }
609 
610  DX_STUB;
611 }
612 
615 {
616 
617  DX_WINDBG_trace();
618 
619  if (This == NULL)
620  {
621  return DDERR_INVALIDOBJECT;
622  }
623 
624  if (pCaps == NULL)
625  {
626  return DDERR_INVALIDPARAMS;
627  }
628 
629  RtlZeroMemory(pCaps,sizeof(DDSCAPS2));
630 
631  pCaps->dwCaps = This->lpLcl->ddsCaps.dwCaps;
632 
633  return DD_OK;
634 }
635 
638  LPDIRECTDRAWCLIPPER* ppClipper)
639 {
640 
641  DX_WINDBG_trace();
642 
643  if (This == NULL)
644  {
645  return DDERR_INVALIDOBJECT;
646  }
647 
648  if (ppClipper == NULL)
649  {
650  return DDERR_INVALIDPARAMS;
651  }
652 
653  if (This->lpLcl->lp16DDClipper == NULL)
654  {
656  }
657 
658  *ppClipper = (LPDIRECTDRAWCLIPPER)This->lpLcl->lp16DDClipper;
659 
660  return DD_OK;
661 }
662 
665  LPDIRECTDRAWCLIPPER pDDClipper)
666 {
667 
668  DX_WINDBG_trace();
669 
670  if (This == NULL)
671  {
672  return DDERR_INVALIDOBJECT;
673  }
674 
675  if(pDDClipper == NULL)
676  {
677  if(!This->lpLcl->lp16DDClipper)
679 
680  DirectDrawClipper_Release((LPDIRECTDRAWCLIPPER)This->lpLcl->lp16DDClipper);
681  This->lpLcl->lp16DDClipper = NULL;
682  return DD_OK;
683  }
684 
685  // FIXME: Check Surface type and return DDERR_INVALIDSURFACETYPE
686 
688  This->lpLcl->lp16DDClipper = (LPDDRAWI_DDRAWCLIPPER_INT)pDDClipper;
689 
690  return DD_OK;
691 }
692 
695 {
696 
697  DX_WINDBG_trace();
698 
699  if (This == NULL)
700  {
701  return DDERR_INVALIDOBJECT;
702  }
703 
704  if (phDC == NULL)
705  {
706  return DDERR_INVALIDPARAMS;
707  }
708 
709 
710  *phDC = (HDC)This->lpLcl->lpSurfMore->lpDD_lcl->hDC;
711 
712  return DD_OK;
713 }
714 
717  LPDDPIXELFORMAT pDDPixelFormat)
718 {
719  HRESULT retVale = DDERR_INVALIDPARAMS;
720 
721  DX_WINDBG_trace();
722 
723  if (pDDPixelFormat != NULL)
724  {
725  if (This->lpLcl->dwFlags & DDRAWISURF_HASPIXELFORMAT)
726  {
727  memcpy(pDDPixelFormat,&This->lpLcl->lpGbl->ddpfSurface,sizeof(DDPIXELFORMAT));
728  }
729  else
730  {
731  memcpy(pDDPixelFormat,&This->lpLcl->lpSurfMore->
732  lpDD_lcl->lpGbl->vmiData.ddpfDisplay,sizeof(DDPIXELFORMAT));
733  }
734  retVale = DD_OK;
735  }
736 
737  return retVale;
738 }
739 
742  LPDDSURFACEDESC2 pDDSD)
743 {
744  DWORD dwSize;
745 
746  DX_WINDBG_trace();
747 
748  dwSize = pDDSD->dwSize;
749 
750  if ((dwSize != sizeof(DDSURFACEDESC)) &&
751  (dwSize != sizeof(DDSURFACEDESC2)))
752  {
753  return DDERR_GENERIC;
754  }
755 
756  ZeroMemory(pDDSD,dwSize);
757 
758  if (dwSize == sizeof(DDSURFACEDESC))
759  {
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));
767 
768  lpDS->dwAlphaBitDepth = This->lpLcl->dwAlpha;
769  lpDS->dwBackBufferCount = This->lpLcl->dwBackBufferCount;
770 
771  /* FIXME setting the flags right */
772  // lpDS->dwFlags = This->lpLcl->dwFlags;
773 
774  lpDS->dwHeight = This->lpLcl->lpGbl->wHeight;
775  lpDS->dwWidth = This->lpLcl->lpGbl->wWidth;
776 
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;
780  */
781  lpDS->dwLinearSize = This->lpLcl->lpGbl->dwLinearSize;
782 
783 
784  /* This tree are a union */
785  //lpDS->dwMipMapCount
786  //lpDS->dwRefreshRate
787  //lpDS->dwZBufferBitDepth
788 
789  /* Unknown */
790  // lpDS->dwReserved
791  // lpDS->lpSurface
792  }
793  else
794  {
795  memcpy(&pDDSD->ddckCKDestBlt, &This->lpLcl->ddckCKDestBlt, sizeof(DDCOLORKEY));
796 
797  /*
798  pDDSD->dwEmptyFaceColor is a union to ddckCKDestOverlay
799  */
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));
803 
804  /*
805  pDDSD->dwFVF is a union to ddpfPixelFormat
806  */
807  memcpy(&pDDSD->ddpfPixelFormat, &This->lpLcl->lpGbl->ddpfSurface, sizeof(DDPIXELFORMAT));
808  memcpy(&pDDSD->ddsCaps, &This->lpLcl->ddsCaps, sizeof(DDSCAPS));
809 
810 
811  pDDSD->dwAlphaBitDepth = This->lpLcl->dwAlpha;
812  pDDSD->dwBackBufferCount = This->lpLcl->dwBackBufferCount;
813 
814  /* FIXME setting the flags right */
815  // lpDS->dwFlags = This->lpLcl->dwFlags;
816 
817  pDDSD->dwHeight = This->lpLcl->lpGbl->wHeight;
818  pDDSD->dwWidth = This->lpLcl->lpGbl->wWidth;
819 
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;
823  */
824  pDDSD->dwLinearSize = This->lpLcl->lpGbl->dwLinearSize;
825 
826  /* This tree are a union */
827  // pDDSD->dwMipMapCount
828  // pDDSD->dwRefreshRate
829  // pDDSD->dwSrcVBHandle
830 
831  /* Unknown */
832  // lpDS->dwReserved
833  // lpDS->lpSurface
834  // pDDSD->dwTextureStage
835  }
836 
837  return DD_OK;
838 }
839 
842 {
843  DX_WINDBG_trace();
844 
845  if (This == NULL)
846  {
847  return DDERR_INVALIDOBJECT;
848  }
849 
850  if (hDC == NULL)
851  {
852  return DDERR_INVALIDPARAMS;
853  }
854 
855  /* FIXME check if surface exits or not */
856 
857 
858  if ((HDC)This->lpLcl->hDC == NULL)
859  {
860  return DDERR_GENERIC;
861  }
862 
863  return DD_OK;
864 }
865 
868  DWORD dwFlags, LPDDCOLORKEY pCKey)
869 {
870 
871  DDHAL_SETCOLORKEYDATA ColorKeyData;
872 
873  DX_WINDBG_trace();
874 
875  ColorKeyData.ddRVal = DDERR_COLORKEYNOTSET;
876 
877  if (This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.dwFlags & DDHAL_SURFCB32_SETCOLORKEY)
878  {
879 
880  ColorKeyData.lpDD = This->lpLcl->lpGbl->lpDD;
881  ColorKeyData.SetColorKey = This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.SetColorKey;
882 
883  //ColorKeyData.lpDDSurface = &This->lpLcl->hDDSurface;
884  ColorKeyData.dwFlags = dwFlags;
885  /* FIXME
886  ColorKeyData.ckNew = ?
887  add / move dwFlags to This->lpLcl->dwFlags ??
888  */
889 
890  if (ColorKeyData.SetColorKey(&ColorKeyData) == DDHAL_DRIVER_HANDLED )
891  {
892  return ColorKeyData.ddRVal;
893  }
894  }
895  return DDERR_COLORKEYNOTSET;
896 }
897 
898 
899 
902 {
903 
904  DDHAL_SETOVERLAYPOSITIONDATA OverLayPositionData;
905 
906  DX_WINDBG_trace();
907 
908  OverLayPositionData.ddRVal = DDERR_COLORKEYNOTSET;
909 
910  if (This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.dwFlags & DDHAL_SURFCB32_SETOVERLAYPOSITION)
911  {
912 
913  OverLayPositionData.lpDD = This->lpLcl->lpGbl->lpDD;
914  OverLayPositionData.SetOverlayPosition = This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.SetOverlayPosition;
915 
916  //OverLayPositionData.lpDDSrcSurface = This->lpLcl->lpSurfaceOverlaying->lpLcl->hDDSurface;
917  //OverLayPositionData.lpDDDestSurface = This->lpLcl->hDDSurface;
918 
919  OverLayPositionData.lXPos = X;
920  OverLayPositionData.lYPos = Y;
921 
922 
923  /* FIXME
924  Should X and Y be save ??
925  */
926 
927  if (OverLayPositionData.SetOverlayPosition(&OverLayPositionData) == DDHAL_DRIVER_HANDLED )
928  {
929  return OverLayPositionData.ddRVal;
930  }
931  }
932 
933  return DDERR_GENERIC;
934 }
HRESULT ddRVal
Definition: ddrawi.h:833
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
LPDDRAWI_DIRECTDRAW_GBL lpDD
Definition: ddrawi.h:1850
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
HRESULT WINAPI Main_DDrawSurface_GetClipper(LPDDRAWI_DDRAWSURFACE_INT This, LPDIRECTDRAWCLIPPER *ppClipper)
Definition: surface_main.c:637
DWORD dwFlags
Definition: ddraw.h:1153
#define REFIID
Definition: guiddef.h:113
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
DDCOLORKEY ddckCKDestBlt
Definition: ddraw.h:1180
RECTL rDest
Definition: ddrawi.h:848
#define Y(I)
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
DWORD dwFlags
Definition: ddrawi.h:835
LPDDRAWI_DDRAWSURFACE_LCL lpDDSrcSurface
Definition: ddrawi.h:849
LPVOID lpSurface
Definition: ddraw.h:1174
REFIID riid
Definition: precomp.h:44
LPDDHALSURFCB_SETCOLORKEY SetColorKey
Definition: ddrawi.h:1855
#define DdResetVisrgn
Definition: ddrawgdi.h:29
LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface
Definition: ddrawi.h:829
HRESULT WINAPI Main_DDrawSurface_SetColorKey(LPDDRAWI_DDRAWSURFACE_INT This, DWORD dwFlags, LPDDCOLORKEY pCKey)
Definition: surface_main.c:867
HRESULT WINAPI Main_DDrawSurface_GetSurfaceDesc(LPDDRAWI_DDRAWSURFACE_INT This, LPDDSURFACEDESC2 pDDSD)
Definition: surface_main.c:741
#define DDRAWISURF_HASPIXELFORMAT
Definition: ddrawi.h:1515
static HDC
Definition: imagelist.c:92
DWORD dwSize
Definition: ddraw.h:1272
#define DX_STUB_str(x)
Definition: rosdraw.h:254
RECTL rArea
Definition: ddrawi.h:831
HRESULT WINAPI Main_DDrawSurface_QueryInterface(LPDDRAWI_DDRAWSURFACE_INT This, REFIID riid, LPVOID *ppObj)
Definition: surface_main.c:60
LPDDRAWI_DDRAWSURFACE_LCL lpLcl
Definition: ddrawi.h:1328
LPDDRAWI_DDRAWSURFACE_INT internal_directdrawsurface_int_alloc(LPDDRAWI_DDRAWSURFACE_INT This)
Definition: surface_main.c:23
HRESULT WINAPI Main_DDrawSurface_GetDC(LPDDRAWI_DDRAWSURFACE_INT This, HDC *phDC)
Definition: surface_main.c:694
#define DDERR_OUTOFVIDEOMEMORY
Definition: ddraw.h:112
LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface
Definition: ddrawi.h:840
#define ZeroMemory
Definition: winbase.h:1635
#define DDERR_NOCLIPPERATTACHED
Definition: ddraw.h:142
#define DDERR_COLORKEYNOTSET
Definition: ddraw.h:116
HRESULT WINAPI Main_DDrawSurface_AddAttachedSurface(LPDDRAWI_DDRAWSURFACE_INT iface, LPDDRAWI_DDRAWSURFACE_INT pAttach)
Definition: surface_main.c:571
IDirectDrawSurface2Vtbl DirectDrawSurface2_Vtable
LPDDRAWI_DDRAWSURFACE_INT lpLink
Definition: ddrawi.h:1329
HRESULT WINAPI Main_DDrawSurface_GetCaps(LPDDRAWI_DDRAWSURFACE_INT This, LPDDSCAPS2 pCaps)
Definition: surface_main.c:614
#define DxHeapMemFree(p)
Definition: rosdraw.h:120
#define DDERR_NOTPALETTIZED
Definition: ddraw.h:163
#define DDHAL_SURFCB32_FLIP
Definition: ddrawi.h:675
LPDDRAWI_DIRECTDRAW_GBL lpDD
Definition: ddrawi.h:839
Definition: send.c:47
#define DX_WINDBG_trace_res(width, height, bpp, freq)
Definition: rosdraw.h:273
_SEH2_TRY
Definition: create.c:4250
VOID WINAPI AcquireDDThreadLock()
Definition: main.c:412
DWORD dwWidth
Definition: ddraw.h:1155
#define DDERR_NOBLTHW
Definition: ddraw.h:149
#define DDHAL_SURFCB32_SETCOLORKEY
Definition: ddrawi.h:680
DDCOLORKEY ddckCKSrcOverlay
Definition: ddraw.h:1181
#define DDHAL_DRIVER_HANDLED
Definition: ddrawi.h:321
IDirectDrawSurfaceKernelVtbl DirectDrawSurfaceKernel_Vtable
Definition: kernel_stubs.c:123
#define DD_OK
Definition: ddraw.h:186
#define DDERR_INVALIDOBJECT
Definition: ddraw.h:78
ULONG WINAPI Main_DDrawSurface_Release(LPDDRAWI_DDRAWSURFACE_INT This)
Definition: surface_main.c:264
DWORD bHasRect
Definition: ddrawi.h:830
long LONG
Definition: pedump.c:60
#define DDHAL_SURFCB32_BLT
Definition: ddrawi.h:679
IDirectDrawSurface4Vtbl DirectDrawSurface4_Vtable
GLenum GLint ref
Definition: glext.h:6028
DWORD dwBackBufferCount
Definition: ddraw.h:1163
DDSCAPS2 ddsCaps
Definition: ddraw.h:1188
struct IDirectDraw * LPDIRECTDRAW
Definition: ddraw.h:710
DDPIXELFORMAT ddpfPixelFormat
Definition: ddraw.h:1185
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define DDHAL_SURFCB32_LOCK
Definition: ddrawi.h:677
DWORD dwCaps
Definition: ddraw.h:732
smooth NULL
Definition: ftsmooth.c:416
IDirectDrawGammaControlVtbl DirectDrawGammaControl_Vtable
Definition: gamma_stubs.c:60
HRESULT WINAPI Main_DDrawSurface_Initialize(LPDDRAWI_DDRAWSURFACE_INT iface, LPDIRECTDRAW pDD, LPDDSURFACEDESC2 pDDSD2)
Definition: surface_main.c:35
IDirectDrawColorControlVtbl DirectDrawColorControl_Vtable
Definition: color_stubs.c:58
LPDDHALSURFCB_LOCK Lock
Definition: ddrawi.h:834
HRESULT WINAPI Main_DDrawSurface_SetClipper(LPDDRAWI_DDRAWSURFACE_INT This, LPDIRECTDRAWCLIPPER pDDClipper)
Definition: surface_main.c:664
HRESULT WINAPI Main_DDrawSurface_GetPixelFormat(LPDDRAWI_DDRAWSURFACE_INT This, LPDDPIXELFORMAT pDDPixelFormat)
Definition: surface_main.c:716
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:67
#define DDERR_GENERIC
Definition: ddraw.h:72
#define DDERR_CANTLOCKSURFACE
Definition: ddraw.h:120
DWORD dwFlags
Definition: ddrawi.h:851
#define DDSD_HEIGHT
Definition: ddraw.h:209
IDirect3D2Vtbl IDirect3D2_Vtbl
IDirectDrawSurface3Vtbl DirectDrawSurface3_Vtable
HRESULT WINAPI Main_DDrawSurface_Lock(LPDDRAWI_DDRAWSURFACE_INT ThisDest, LPRECT prect, LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE events)
Definition: surface_main.c:418
DWORD dwRGBBitCount
Definition: ddraw.h:1075
IDirectDrawSurfaceVtbl DirectDrawSurface_Vtable
LPDDRAWI_DIRECTDRAW_GBL lpDD
Definition: ddrawi.h:828
ULONG WINAPI DirectDrawClipper_AddRef(LPDIRECTDRAWCLIPPER)
Definition: clipper_main.c:75
IDirect3D7Vtbl IDirect3D7_Vtbl
LONG HRESULT
Definition: typedefs.h:77
HRESULT ddRVal
Definition: ddrawi.h:854
struct _DDBLTFX DDBLTFX
#define DxHeapMemAlloc(p, m)
Definition: rosdraw.h:113
LPDDHALSURFCB_UNLOCK Unlock
Definition: ddrawi.h:842
#define WINAPI
Definition: msvc.h:8
HRESULT WINAPI Main_DDrawSurface_SetOverlayPosition(LPDDRAWI_DDRAWSURFACE_INT This, LONG X, LONG Y)
Definition: surface_main.c:901
VOID WINAPI ReleaseDDThreadLock()
Definition: main.c:421
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT ddRVal
Definition: ddrawi.h:841
#define LPVOID
Definition: nt_native.h:45
ULONG WINAPI DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER)
Definition: clipper_main.c:54
GLbitfield flags
Definition: glext.h:7161
HRESULT WINAPI Main_DDrawSurface_ReleaseDC(LPDDRAWI_DDRAWSURFACE_INT This, HDC hDC)
Definition: surface_main.c:841
struct _DDRAWI_DDRAWCLIPPER_INT * LPDDRAWI_DDRAWCLIPPER_INT
Definition: ddrawi.h:145
int ret
DWORD dwSize
Definition: ddraw.h:1152
HRESULT WINAPI Main_DDrawSurface_Unlock(LPDDRAWI_DDRAWSURFACE_INT This, LPRECT pRect)
Definition: surface_main.c:523
LPDDRAWI_DIRECTDRAW_GBL lpDD
Definition: ddrawi.h:1859
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
IDirect3DVtbl IDirect3D_Vtbl
LPDDRAWI_DDRAWSURFACE_LCL lpDDDestSurface
Definition: ddrawi.h:847
RECTL rSrc
Definition: ddrawi.h:850
#define DDHAL_SURFCB32_SETOVERLAYPOSITION
Definition: ddrawi.h:685
DWORD dwHeight
Definition: ddraw.h:1154
LPDDRAWI_DIRECTDRAW_GBL lpDD
Definition: ddrawi.h:846
#define DDSD_WIDTH
Definition: ddraw.h:210
IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable
#define DX_STUB
Definition: rosdraw.h:224
static HDC hDC
Definition: 3dtext.c:33
struct IDirectDrawClipper * LPDIRECTDRAWCLIPPER
Definition: ddraw.h:721
DWORD dwAlphaBitDepth
Definition: ddraw.h:1172
_SEH2_END
Definition: create.c:4424
ULONG WINAPI Main_DDrawSurface_AddRef(LPDDRAWI_DDRAWSURFACE_INT This)
Definition: surface_main.c:40
HRESULT WINAPI Main_DDrawSurface_Blt(LPDDRAWI_DDRAWSURFACE_INT ThisDest, LPRECT rdst, LPDDRAWI_DDRAWSURFACE_INT ThisSrc, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx)
Definition: surface_main.c:289
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
DDBLTFX bltFX
Definition: ddrawi.h:853
DDHAL_BLTDATA mDdBlt
Definition: main.c:47
HRESULT WINAPI Main_DDrawSurface_GetBltStatus(LPDDRAWI_DDRAWSURFACE_INT This, DWORD dwFlags)
Definition: surface_main.c:600
DDCOLORKEY ddckCKDestOverlay
Definition: ddraw.h:1177
HANDLE events[2]
Definition: event.c:4
DWORD dwLinearSize
Definition: ddraw.h:1159
struct _DDSURFACEDESC2 DDSURFACEDESC2
unsigned int ULONG
Definition: retypes.h:1
LPDDHALSURFCB_BLT Blt
Definition: ddrawi.h:855
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_LEAVE
Definition: filesup.c:20
ULONG WINAPI Main_DDrawSurface_Release4(LPDDRAWI_DDRAWSURFACE_INT This)
Definition: surface_main.c:280
#define DDHAL_SURFCB32_UNLOCK
Definition: ddrawi.h:678
void * LPDDSURFACEDESC
Definition: ddstream.idl:19
LPDDHALSURFCB_SETOVERLAYPOSITION SetOverlayPosition
Definition: ddrawi.h:1865
ULONG WINAPI Main_DirectDraw_Release(LPDDRAWI_DIRECTDRAW_INT This)
Definition: ddraw_main.c:194
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define X(b, s)
#define DDSD_PITCH
Definition: ddraw.h:211
IDirect3D3Vtbl IDirect3D3_Vtbl
BOOL IsClipped
Definition: ddrawi.h:856
DDCOLORKEY ddckCKSrcBlt
Definition: ddraw.h:1182
HRESULT WINAPI Main_DDrawSurface_GetAttachedSurface(LPDDRAWI_DDRAWSURFACE_INT This, LPDDSCAPS2 pCaps, LPDDRAWI_DDRAWSURFACE_INT *ppSurface)
Definition: surface_main.c:584
LPVOID lpSurfData
Definition: ddrawi.h:832