1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * COPYRIGHT:            See COPYING in the top level directory
3*c2c66affSColin Finck  * PROJECT:              ReactOS DirectX
4*c2c66affSColin Finck  * FILE:                 dll/directx/ddraw/Surface/callbacks_surf_hel.c
5*c2c66affSColin Finck  * PURPOSE:              HEL Callbacks For Surface APIs
6*c2c66affSColin Finck  * PROGRAMMER:           Magnus Olsen
7*c2c66affSColin Finck  *
8*c2c66affSColin Finck  */
9*c2c66affSColin Finck 
10*c2c66affSColin Finck #include "rosdraw.h"
11*c2c66affSColin Finck 
HelDdSurfAddAttachedSurface(LPDDHAL_ADDATTACHEDSURFACEDATA lpDestroySurface)12*c2c66affSColin Finck DWORD CALLBACK HelDdSurfAddAttachedSurface(LPDDHAL_ADDATTACHEDSURFACEDATA lpDestroySurface)
13*c2c66affSColin Finck {
14*c2c66affSColin Finck     DX_STUB;
15*c2c66affSColin Finck }
16*c2c66affSColin Finck 
HelDdSurfBlt(LPDDHAL_BLTDATA lpBltData)17*c2c66affSColin Finck DWORD CALLBACK HelDdSurfBlt(LPDDHAL_BLTDATA lpBltData)
18*c2c66affSColin Finck {
19*c2c66affSColin Finck     DX_WINDBG_trace();
20*c2c66affSColin Finck 
21*c2c66affSColin Finck     if (lpBltData->dwFlags & DDBLT_COLORFILL)
22*c2c66affSColin Finck     {
23*c2c66affSColin Finck         HBRUSH hbr = CreateSolidBrush(lpBltData->bltFX.dwFillColor );
24*c2c66affSColin Finck         FillRect( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
25*c2c66affSColin Finck                   (CONST RECT *)&lpBltData->rDest,
26*c2c66affSColin Finck                   hbr);
27*c2c66affSColin Finck         DeleteObject(hbr);
28*c2c66affSColin Finck         lpBltData->ddRVal = DD_OK;
29*c2c66affSColin Finck     }
30*c2c66affSColin Finck     else if (lpBltData->dwFlags & DDBLT_ROP)
31*c2c66affSColin Finck     {
32*c2c66affSColin Finck         BitBlt( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
33*c2c66affSColin Finck                 lpBltData->rDest.top,
34*c2c66affSColin Finck                 lpBltData->rDest.left,
35*c2c66affSColin Finck                 lpBltData->rDest.right,
36*c2c66affSColin Finck                 lpBltData->rDest.bottom,
37*c2c66affSColin Finck                 (HDC)lpBltData->lpDDSrcSurface->lpSurfMore->lpDD_lcl->hDC,
38*c2c66affSColin Finck                 lpBltData->rSrc.top,
39*c2c66affSColin Finck                 lpBltData->rSrc.right,
40*c2c66affSColin Finck                 lpBltData->bltFX.dwROP);
41*c2c66affSColin Finck                 lpBltData->ddRVal = DD_OK;
42*c2c66affSColin Finck     }
43*c2c66affSColin Finck     return DDHAL_DRIVER_HANDLED;
44*c2c66affSColin Finck }
45*c2c66affSColin Finck 
HelDdSurfDestroySurface(LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData)46*c2c66affSColin Finck DWORD CALLBACK HelDdSurfDestroySurface(LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData)
47*c2c66affSColin Finck {
48*c2c66affSColin Finck     DX_STUB;
49*c2c66affSColin Finck }
50*c2c66affSColin Finck 
HelDdSurfFlip(LPDDHAL_FLIPDATA lpFlipData)51*c2c66affSColin Finck DWORD CALLBACK HelDdSurfFlip(LPDDHAL_FLIPDATA lpFlipData)
52*c2c66affSColin Finck {
53*c2c66affSColin Finck     DX_STUB;
54*c2c66affSColin Finck }
55*c2c66affSColin Finck 
HelDdSurfGetBltStatus(LPDDHAL_GETBLTSTATUSDATA lpGetBltStatusData)56*c2c66affSColin Finck DWORD CALLBACK HelDdSurfGetBltStatus(LPDDHAL_GETBLTSTATUSDATA lpGetBltStatusData)
57*c2c66affSColin Finck {
58*c2c66affSColin Finck     DX_STUB;
59*c2c66affSColin Finck }
60*c2c66affSColin Finck 
HelDdSurfGetFlipStatus(LPDDHAL_GETFLIPSTATUSDATA lpGetFlipStatusData)61*c2c66affSColin Finck DWORD CALLBACK HelDdSurfGetFlipStatus(LPDDHAL_GETFLIPSTATUSDATA lpGetFlipStatusData)
62*c2c66affSColin Finck {
63*c2c66affSColin Finck     DX_STUB;
64*c2c66affSColin Finck }
65*c2c66affSColin Finck 
HelDdSurfLock(LPDDHAL_LOCKDATA lpLockData)66*c2c66affSColin Finck DWORD CALLBACK HelDdSurfLock(LPDDHAL_LOCKDATA lpLockData)
67*c2c66affSColin Finck {
68*c2c66affSColin Finck 
69*c2c66affSColin Finck     HDC hDC;
70*c2c66affSColin Finck     HBITMAP hImage = NULL;
71*c2c66affSColin Finck 
72*c2c66affSColin Finck     LONG cbBuffer = 0;
73*c2c66affSColin Finck     LPDWORD pixels = NULL;
74*c2c66affSColin Finck 
75*c2c66affSColin Finck     HDC hMemDC = NULL;
76*c2c66affSColin Finck     HBITMAP hDCBmp = NULL;
77*c2c66affSColin Finck     BITMAP bm = {0};
78*c2c66affSColin Finck 
79*c2c66affSColin Finck     DX_WINDBG_trace();
80*c2c66affSColin Finck 
81*c2c66affSColin Finck     /* ToDo tell ddraw internal this surface is locked */
82*c2c66affSColin Finck     /* ToDo add support for dwFlags */
83*c2c66affSColin Finck 
84*c2c66affSColin Finck 
85*c2c66affSColin Finck     /* Get our hdc for the active window */
86*c2c66affSColin Finck     hDC = GetDC((HWND)lpLockData->lpDDSurface->lpSurfMore->lpDD_lcl->hFocusWnd);
87*c2c66affSColin Finck 
88*c2c66affSColin Finck     if (hDC != NULL)
89*c2c66affSColin Finck     {
90*c2c66affSColin Finck         /* Create a memory bitmap to store a copy of current hdc surface */
91*c2c66affSColin Finck 
92*c2c66affSColin Finck         if (!lpLockData->bHasRect)
93*c2c66affSColin Finck         {
94*c2c66affSColin Finck             hImage = CreateCompatibleBitmap (hDC, lpLockData->lpDDSurface->lpGbl->wWidth, lpLockData->lpDDSurface->lpGbl->wHeight);
95*c2c66affSColin Finck         }
96*c2c66affSColin Finck         else
97*c2c66affSColin Finck         {
98*c2c66affSColin Finck             hImage = CreateCompatibleBitmap (hDC, lpLockData->rArea.right, lpLockData->rArea.bottom);
99*c2c66affSColin Finck         }
100*c2c66affSColin Finck 
101*c2c66affSColin Finck         /* Create a memory hdc so we can draw on our current memory bitmap */
102*c2c66affSColin Finck         hMemDC = CreateCompatibleDC(hDC);
103*c2c66affSColin Finck 
104*c2c66affSColin Finck         if (hMemDC != NULL)
105*c2c66affSColin Finck         {
106*c2c66affSColin Finck             /* Select our memory bitmap to our memory hdc */
107*c2c66affSColin Finck             hDCBmp = (HBITMAP) SelectObject (hMemDC, hImage);
108*c2c66affSColin Finck 
109*c2c66affSColin Finck             /* Get our memory bitmap information */
110*c2c66affSColin Finck             GetObject(hImage, sizeof(BITMAP), &bm);
111*c2c66affSColin Finck 
112*c2c66affSColin Finck             if (!lpLockData->bHasRect)
113*c2c66affSColin Finck             {
114*c2c66affSColin Finck                 BitBlt (hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, hDC, 0, 0, SRCCOPY);
115*c2c66affSColin Finck             }
116*c2c66affSColin Finck             else
117*c2c66affSColin Finck             {
118*c2c66affSColin Finck                 BitBlt (hMemDC, lpLockData->rArea.top, lpLockData->rArea.left, lpLockData->rArea.right, lpLockData->rArea.bottom, hDC, 0, 0, SRCCOPY);
119*c2c66affSColin Finck             }
120*c2c66affSColin Finck 
121*c2c66affSColin Finck             SelectObject (hMemDC, hDCBmp);
122*c2c66affSColin Finck 
123*c2c66affSColin Finck             /* Allocate memory buffer for the bitmap pixel data  */
124*c2c66affSColin Finck             cbBuffer = bm.bmWidthBytes * bm.bmHeight ;
125*c2c66affSColin Finck             pixels = (PDWORD) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbBuffer );
126*c2c66affSColin Finck 
127*c2c66affSColin Finck             if (pixels != NULL)
128*c2c66affSColin Finck             {
129*c2c66affSColin Finck                 /* Get the bitmap bits */
130*c2c66affSColin Finck                 GetBitmapBits(hImage,cbBuffer,pixels);
131*c2c66affSColin Finck 
132*c2c66affSColin Finck                 /* Fixme HACK - check which member stores the HEL bitmap buffer */
133*c2c66affSColin Finck                 lpLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2 = pixels;
134*c2c66affSColin Finck 
135*c2c66affSColin Finck                 /* Setup return value */
136*c2c66affSColin Finck                 lpLockData->ddRVal = DD_OK;
137*c2c66affSColin Finck                 lpLockData->lpSurfData = pixels;
138*c2c66affSColin Finck             }
139*c2c66affSColin Finck         }
140*c2c66affSColin Finck     }
141*c2c66affSColin Finck 
142*c2c66affSColin Finck 
143*c2c66affSColin Finck     /* Free the pixels buffer if we fail */
144*c2c66affSColin Finck     if ( (pixels != NULL) &&
145*c2c66affSColin Finck          (lpLockData->ddRVal != DD_OK) )
146*c2c66affSColin Finck     {
147*c2c66affSColin Finck         HeapFree(GetProcessHeap(), 0, pixels );
148*c2c66affSColin Finck     }
149*c2c66affSColin Finck 
150*c2c66affSColin Finck     /* Cleanup after us */
151*c2c66affSColin Finck     if (hImage != NULL)
152*c2c66affSColin Finck     {
153*c2c66affSColin Finck         DeleteObject (hImage);
154*c2c66affSColin Finck     }
155*c2c66affSColin Finck 
156*c2c66affSColin Finck     if (hMemDC != NULL)
157*c2c66affSColin Finck     {
158*c2c66affSColin Finck         DeleteDC (hMemDC);
159*c2c66affSColin Finck     }
160*c2c66affSColin Finck 
161*c2c66affSColin Finck     return DDHAL_DRIVER_HANDLED;
162*c2c66affSColin Finck }
163*c2c66affSColin Finck 
HelDdSurfreserved4(DWORD * lpPtr)164*c2c66affSColin Finck DWORD CALLBACK HelDdSurfreserved4(DWORD *lpPtr)
165*c2c66affSColin Finck {
166*c2c66affSColin Finck     /* This api is not documented by MS, keep it stubbed */
167*c2c66affSColin Finck     DX_STUB;
168*c2c66affSColin Finck }
169*c2c66affSColin Finck 
HelDdSurfSetClipList(LPDDHAL_SETCLIPLISTDATA lpSetClipListData)170*c2c66affSColin Finck DWORD CALLBACK HelDdSurfSetClipList(LPDDHAL_SETCLIPLISTDATA lpSetClipListData)
171*c2c66affSColin Finck {
172*c2c66affSColin Finck     DX_STUB;
173*c2c66affSColin Finck }
174*c2c66affSColin Finck 
HelDdSurfSetColorKey(LPDDHAL_SETCOLORKEYDATA lpSetColorKeyData)175*c2c66affSColin Finck DWORD CALLBACK HelDdSurfSetColorKey(LPDDHAL_SETCOLORKEYDATA lpSetColorKeyData)
176*c2c66affSColin Finck {
177*c2c66affSColin Finck     DX_STUB;
178*c2c66affSColin Finck }
179*c2c66affSColin Finck 
HelDdSurfSetOverlayPosition(LPDDHAL_SETOVERLAYPOSITIONDATA lpSetOverlayPositionData)180*c2c66affSColin Finck DWORD CALLBACK HelDdSurfSetOverlayPosition(LPDDHAL_SETOVERLAYPOSITIONDATA lpSetOverlayPositionData)
181*c2c66affSColin Finck {
182*c2c66affSColin Finck     DX_STUB;
183*c2c66affSColin Finck }
184*c2c66affSColin Finck 
HelDdSurfSetPalette(LPDDHAL_SETPALETTEDATA lpSetPaletteData)185*c2c66affSColin Finck DWORD CALLBACK HelDdSurfSetPalette(LPDDHAL_SETPALETTEDATA lpSetPaletteData)
186*c2c66affSColin Finck {
187*c2c66affSColin Finck     DX_STUB;
188*c2c66affSColin Finck }
189*c2c66affSColin Finck 
HelDdSurfUnlock(LPDDHAL_UNLOCKDATA lpUnLockData)190*c2c66affSColin Finck DWORD CALLBACK HelDdSurfUnlock(LPDDHAL_UNLOCKDATA lpUnLockData)
191*c2c66affSColin Finck {
192*c2c66affSColin Finck     HDC hDC;
193*c2c66affSColin Finck     HBITMAP hImage = NULL;
194*c2c66affSColin Finck 
195*c2c66affSColin Finck     HDC hMemDC = NULL;
196*c2c66affSColin Finck     HBITMAP hDCBmp = NULL;
197*c2c66affSColin Finck     BITMAP bm = {0};
198*c2c66affSColin Finck 
199*c2c66affSColin Finck     DX_WINDBG_trace();
200*c2c66affSColin Finck 
201*c2c66affSColin Finck     /* Get our hdc for the active window */
202*c2c66affSColin Finck     hDC = GetDC((HWND)lpUnLockData->lpDDSurface->lpSurfMore->lpDD_lcl->hFocusWnd);
203*c2c66affSColin Finck 
204*c2c66affSColin Finck     if (hDC != NULL)
205*c2c66affSColin Finck     {
206*c2c66affSColin Finck         /* Create a memory bitmap to store a copy of current hdc surface */
207*c2c66affSColin Finck 
208*c2c66affSColin Finck         /* fixme the rcarea are not store in the struct yet so the data will look corrupted */
209*c2c66affSColin Finck         hImage = CreateCompatibleBitmap (hDC, lpUnLockData->lpDDSurface->lpGbl->wWidth, lpUnLockData->lpDDSurface->lpGbl->wHeight);
210*c2c66affSColin Finck 
211*c2c66affSColin Finck         /* Create a memory hdc so we can draw on our current memory bitmap */
212*c2c66affSColin Finck         hMemDC = CreateCompatibleDC(hDC);
213*c2c66affSColin Finck 
214*c2c66affSColin Finck         if (hMemDC != NULL)
215*c2c66affSColin Finck         {
216*c2c66affSColin Finck             /* Select our memory bitmap to our memory hdc */
217*c2c66affSColin Finck             hDCBmp = (HBITMAP) SelectObject (hMemDC, hImage);
218*c2c66affSColin Finck 
219*c2c66affSColin Finck             /* Get our memory bitmap information */
220*c2c66affSColin Finck             GetObject(hImage, sizeof(BITMAP), &bm);
221*c2c66affSColin Finck 
222*c2c66affSColin Finck             SetBitmapBits(hImage,bm.bmWidthBytes * bm.bmHeight, lpUnLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2);
223*c2c66affSColin Finck 
224*c2c66affSColin Finck             BitBlt (hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
225*c2c66affSColin Finck 
226*c2c66affSColin Finck             SelectObject (hMemDC, hDCBmp);
227*c2c66affSColin Finck 
228*c2c66affSColin Finck             /* Setup return value */
229*c2c66affSColin Finck              lpUnLockData->ddRVal = DD_OK;
230*c2c66affSColin Finck         }
231*c2c66affSColin Finck     }
232*c2c66affSColin Finck 
233*c2c66affSColin Finck     /* Cleanup after us */
234*c2c66affSColin Finck     if (hImage != NULL)
235*c2c66affSColin Finck     {
236*c2c66affSColin Finck         DeleteObject (hImage);
237*c2c66affSColin Finck     }
238*c2c66affSColin Finck 
239*c2c66affSColin Finck     if (hMemDC != NULL)
240*c2c66affSColin Finck     {
241*c2c66affSColin Finck         DeleteDC (hMemDC);
242*c2c66affSColin Finck     }
243*c2c66affSColin Finck 
244*c2c66affSColin Finck     if (lpUnLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2 != NULL)
245*c2c66affSColin Finck     {
246*c2c66affSColin Finck         HeapFree(GetProcessHeap(), 0, lpUnLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2 );
247*c2c66affSColin Finck     }
248*c2c66affSColin Finck 
249*c2c66affSColin Finck     return DDHAL_DRIVER_HANDLED;
250*c2c66affSColin Finck }
251*c2c66affSColin Finck 
HelDdSurfUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA lpUpDateOverLayData)252*c2c66affSColin Finck DWORD CALLBACK HelDdSurfUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA lpUpDateOverLayData)
253*c2c66affSColin Finck {
254*c2c66affSColin Finck     DX_STUB;
255*c2c66affSColin Finck }
256*c2c66affSColin Finck 
257