1 | /* $Id: VBoxDispDDrawVHWA.cpp 37423 2011-06-12 18:37:56Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox XPDM Display driver, DirectDraw callbacks VHWA related
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2011 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "VBoxDisp.h"
|
---|
20 | #include "VBoxDispDDraw.h"
|
---|
21 | #include <iprt/asm.h>
|
---|
22 |
|
---|
23 | static DECLCALLBACK(void) VBoxDispVHWASurfBltCompletion(PVBOXDISPDEV pDev, VBOXVHWACMD * pCmd, void * pContext)
|
---|
24 | {
|
---|
25 | VBOXVHWACMD_SURF_BLT *pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_BLT);
|
---|
26 | PVBOXVHWASURFDESC pSrcDesc = (PVBOXVHWASURFDESC)pBody->SrcGuestSurfInfo;
|
---|
27 | PVBOXVHWASURFDESC pDestDesc = (PVBOXVHWASURFDESC)pBody->DstGuestSurfInfo;
|
---|
28 |
|
---|
29 | ASMAtomicDecU32(&pSrcDesc->cPendingBltsSrc);
|
---|
30 | ASMAtomicDecU32(&pDestDesc->cPendingBltsDst);
|
---|
31 |
|
---|
32 | VBoxDispVHWACommandRelease(pDev, pCmd);
|
---|
33 | }
|
---|
34 |
|
---|
35 | static DECLCALLBACK(void) VBoxDispVHWASurfFlipCompletion(PVBOXDISPDEV pDev, VBOXVHWACMD * pCmd, void * pContext)
|
---|
36 | {
|
---|
37 | VBOXVHWACMD_SURF_FLIP *pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_FLIP);
|
---|
38 | PVBOXVHWASURFDESC pCurrDesc = (PVBOXVHWASURFDESC)pBody->CurrGuestSurfInfo;
|
---|
39 | PVBOXVHWASURFDESC pTargDesc = (PVBOXVHWASURFDESC)pBody->TargGuestSurfInfo;
|
---|
40 |
|
---|
41 | ASMAtomicDecU32(&pCurrDesc->cPendingFlipsCurr);
|
---|
42 | ASMAtomicDecU32(&pTargDesc->cPendingFlipsTarg);
|
---|
43 |
|
---|
44 | VBoxDispVHWACommandRelease(pDev, pCmd);
|
---|
45 | }
|
---|
46 |
|
---|
47 | #define VBOXVHWA_CAP(_pdev, _cap) ((_pdev)->vhwa.caps & (_cap))
|
---|
48 | #define ROP_INDEX(_rop) ((BYTE)((_rop)>>16))
|
---|
49 | #define SET_SUPPORT_ROP(_aRops, _rop) _aRops[ROP_INDEX(_rop)/32] |= 1L << ((DWORD)(ROP_INDEX(_rop)%32))
|
---|
50 |
|
---|
51 | int VBoxDispVHWAUpdateDDHalInfo(PVBOXDISPDEV pDev, DD_HALINFO *pHalInfo)
|
---|
52 | {
|
---|
53 | if (!VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLT) && !VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_OVERLAY))
|
---|
54 | {
|
---|
55 | return VERR_NOT_SUPPORTED;
|
---|
56 | }
|
---|
57 |
|
---|
58 | pHalInfo->ddCaps.dwCaps |= VBoxDispVHWAToDDCAPS(pDev->vhwa.caps);
|
---|
59 | if (VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLT))
|
---|
60 | {
|
---|
61 | /* we only support simple dst=src copy
|
---|
62 | * Note: search "ternary raster operations" on msdn for more info
|
---|
63 | */
|
---|
64 | SET_SUPPORT_ROP(pHalInfo->ddCaps.dwRops, SRCCOPY);
|
---|
65 | }
|
---|
66 |
|
---|
67 | pHalInfo->ddCaps.ddsCaps.dwCaps |= VBoxDispVHWAToDDSCAPS(pDev->vhwa.surfaceCaps);
|
---|
68 | pHalInfo->ddCaps.dwCaps2 |= VBoxDispVHWAToDDCAPS2(pDev->vhwa.caps2);
|
---|
69 |
|
---|
70 | if (VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLT) && VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_BLTSTRETCH))
|
---|
71 | {
|
---|
72 | pHalInfo->ddCaps.dwFXCaps |= DDFXCAPS_BLTSTRETCHX|DDFXCAPS_BLTSTRETCHY|
|
---|
73 | DDFXCAPS_BLTSTRETCHXN|DDFXCAPS_BLTSTRETCHYN|
|
---|
74 | DDFXCAPS_BLTSHRINKX|DDFXCAPS_BLTSHRINKY|
|
---|
75 | DDFXCAPS_BLTSHRINKXN|DDFXCAPS_BLTSHRINKYN|
|
---|
76 | DDFXCAPS_BLTARITHSTRETCHY;
|
---|
77 | }
|
---|
78 |
|
---|
79 | if (VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_OVERLAY) && VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_OVERLAYSTRETCH))
|
---|
80 | {
|
---|
81 | pHalInfo->ddCaps.dwFXCaps |= DDFXCAPS_OVERLAYSTRETCHX|DDFXCAPS_OVERLAYSTRETCHY|
|
---|
82 | DDFXCAPS_OVERLAYSTRETCHXN|DDFXCAPS_OVERLAYSTRETCHYN|
|
---|
83 | DDFXCAPS_OVERLAYSHRINKX|DDFXCAPS_OVERLAYSHRINKY|
|
---|
84 | DDFXCAPS_OVERLAYSHRINKXN|DDFXCAPS_OVERLAYSHRINKYN|
|
---|
85 | DDFXCAPS_OVERLAYARITHSTRETCHY;
|
---|
86 | }
|
---|
87 |
|
---|
88 | pHalInfo->ddCaps.dwCKeyCaps = VBoxDispVHWAToDDCKEYCAPS(pDev->vhwa.colorKeyCaps);
|
---|
89 |
|
---|
90 | if (VBOXVHWA_CAP(pDev, VBOXVHWA_CAPS_OVERLAY))
|
---|
91 | {
|
---|
92 | pHalInfo->ddCaps.dwMaxVisibleOverlays = pDev->vhwa.numOverlays;
|
---|
93 | pHalInfo->ddCaps.dwCurrVisibleOverlays = 0;
|
---|
94 | pHalInfo->ddCaps.dwMinOverlayStretch = 1;
|
---|
95 | pHalInfo->ddCaps.dwMaxOverlayStretch = 32000;
|
---|
96 | }
|
---|
97 |
|
---|
98 | return VINF_SUCCESS;
|
---|
99 | }
|
---|
100 |
|
---|
101 | /*
|
---|
102 | * DirectDraw callbacks.
|
---|
103 | */
|
---|
104 |
|
---|
105 | #define IF_NOT_SUPPORTED(_guid) \
|
---|
106 | if (IsEqualIID(&lpData->guidInfo, &(_guid))) \
|
---|
107 | { \
|
---|
108 | LOG((#_guid)); \
|
---|
109 | }
|
---|
110 |
|
---|
111 | DWORD APIENTRY VBoxDispDDGetDriverInfo(DD_GETDRIVERINFODATA *lpData)
|
---|
112 | {
|
---|
113 | LOGF_ENTER();
|
---|
114 |
|
---|
115 | lpData->ddRVal = DDERR_CURRENTLYNOTAVAIL;
|
---|
116 |
|
---|
117 | if (IsEqualIID(&lpData->guidInfo, &GUID_NTPrivateDriverCaps))
|
---|
118 | {
|
---|
119 | LOG(("GUID_NTPrivateDriverCaps"));
|
---|
120 |
|
---|
121 | DD_NTPRIVATEDRIVERCAPS caps;
|
---|
122 | memset(&caps, 0, sizeof(caps));
|
---|
123 | caps.dwSize = sizeof(DD_NTPRIVATEDRIVERCAPS);
|
---|
124 | caps.dwPrivateCaps = DDHAL_PRIVATECAP_NOTIFYPRIMARYCREATION;
|
---|
125 |
|
---|
126 | lpData->dwActualSize = sizeof(DD_NTPRIVATEDRIVERCAPS);
|
---|
127 | lpData->ddRVal = DD_OK;
|
---|
128 | memcpy(lpData->lpvData, &caps, min(lpData->dwExpectedSize, sizeof(DD_NTPRIVATEDRIVERCAPS)));
|
---|
129 | }
|
---|
130 | else IF_NOT_SUPPORTED(GUID_NTCallbacks)
|
---|
131 | else IF_NOT_SUPPORTED(GUID_D3DCallbacks2)
|
---|
132 | else IF_NOT_SUPPORTED(GUID_D3DCallbacks3)
|
---|
133 | else IF_NOT_SUPPORTED(GUID_D3DExtendedCaps)
|
---|
134 | else IF_NOT_SUPPORTED(GUID_ZPixelFormats)
|
---|
135 | else IF_NOT_SUPPORTED(GUID_D3DParseUnknownCommandCallback)
|
---|
136 | else IF_NOT_SUPPORTED(GUID_Miscellaneous2Callbacks)
|
---|
137 | else IF_NOT_SUPPORTED(GUID_UpdateNonLocalHeap)
|
---|
138 | else IF_NOT_SUPPORTED(GUID_GetHeapAlignment)
|
---|
139 | else IF_NOT_SUPPORTED(GUID_DDStereoMode)
|
---|
140 | else IF_NOT_SUPPORTED(GUID_NonLocalVidMemCaps)
|
---|
141 | else IF_NOT_SUPPORTED(GUID_KernelCaps)
|
---|
142 | else IF_NOT_SUPPORTED(GUID_KernelCallbacks)
|
---|
143 | else IF_NOT_SUPPORTED(GUID_MotionCompCallbacks)
|
---|
144 | else IF_NOT_SUPPORTED(GUID_VideoPortCallbacks)
|
---|
145 | else IF_NOT_SUPPORTED(GUID_ColorControlCallbacks)
|
---|
146 | else IF_NOT_SUPPORTED(GUID_VideoPortCaps)
|
---|
147 | else IF_NOT_SUPPORTED(GUID_DDMoreSurfaceCaps)
|
---|
148 | else
|
---|
149 | {
|
---|
150 | LOG(("unknown guid"));
|
---|
151 | }
|
---|
152 |
|
---|
153 |
|
---|
154 | LOGF_LEAVE();
|
---|
155 | return DDHAL_DRIVER_HANDLED;
|
---|
156 | }
|
---|
157 |
|
---|
158 | DWORD APIENTRY VBoxDispDDSetColorKey(PDD_SETCOLORKEYDATA lpSetColorKey)
|
---|
159 | {
|
---|
160 | PVBOXDISPDEV pDev = (PVBOXDISPDEV) lpSetColorKey->lpDD->dhpdev;
|
---|
161 | LOGF_ENTER();
|
---|
162 |
|
---|
163 | DD_SURFACE_LOCAL *pSurf = lpSetColorKey->lpDDSurface;
|
---|
164 | PVBOXVHWASURFDESC pDesc = (PVBOXVHWASURFDESC)pSurf->lpGbl->dwReserved1;
|
---|
165 | VBOXVHWACMD* pCmd;
|
---|
166 |
|
---|
167 | lpSetColorKey->ddRVal = DD_OK;
|
---|
168 |
|
---|
169 | if (pDesc)
|
---|
170 | {
|
---|
171 | pCmd = VBoxDispVHWACommandCreate(pDev, VBOXVHWACMD_TYPE_SURF_COLORKEY_SET, sizeof(VBOXVHWACMD_SURF_COLORKEY_SET));
|
---|
172 |
|
---|
173 | if (pCmd)
|
---|
174 | {
|
---|
175 | VBOXVHWACMD_SURF_COLORKEY_SET *pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_COLORKEY_SET);
|
---|
176 | memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_COLORKEY_SET));
|
---|
177 |
|
---|
178 | pBody->u.in.offSurface = VBoxDispVHWAVramOffsetFromPDEV(pDev, pSurf->lpGbl->fpVidMem);
|
---|
179 | pBody->u.in.hSurf = pDesc->hHostHandle;
|
---|
180 | pBody->u.in.flags = VBoxDispVHWAFromDDCKEYs(lpSetColorKey->dwFlags);
|
---|
181 | VBoxDispVHWAFromDDCOLORKEY(&pBody->u.in.CKey, &lpSetColorKey->ckNew);
|
---|
182 |
|
---|
183 | VBoxDispVHWACommandSubmitAsynchAndComplete(pDev, pCmd);
|
---|
184 | }
|
---|
185 | else
|
---|
186 | {
|
---|
187 | WARN(("VBoxDispVHWACommandCreate failed!"));
|
---|
188 | lpSetColorKey->ddRVal = DDERR_GENERIC;
|
---|
189 | }
|
---|
190 | }
|
---|
191 | else
|
---|
192 | {
|
---|
193 | WARN(("!pDesc"));
|
---|
194 | lpSetColorKey->ddRVal = DDERR_GENERIC;
|
---|
195 | }
|
---|
196 |
|
---|
197 | LOGF_LEAVE();
|
---|
198 | return DDHAL_DRIVER_HANDLED;
|
---|
199 | }
|
---|
200 |
|
---|
201 | DWORD APIENTRY VBoxDispDDAddAttachedSurface(PDD_ADDATTACHEDSURFACEDATA lpAddAttachedSurface)
|
---|
202 | {
|
---|
203 | LOGF_ENTER();
|
---|
204 |
|
---|
205 | lpAddAttachedSurface->ddRVal = DD_OK;
|
---|
206 |
|
---|
207 | LOGF_LEAVE();
|
---|
208 | return DDHAL_DRIVER_HANDLED;
|
---|
209 | }
|
---|
210 |
|
---|
211 | DWORD APIENTRY VBoxDispDDBlt(PDD_BLTDATA lpBlt)
|
---|
212 | {
|
---|
213 | PVBOXDISPDEV pDev = (PVBOXDISPDEV) lpBlt->lpDD->dhpdev;
|
---|
214 | LOGF_ENTER();
|
---|
215 |
|
---|
216 | DD_SURFACE_LOCAL *pSrcSurf = lpBlt->lpDDSrcSurface;
|
---|
217 | DD_SURFACE_LOCAL *pDstSurf = lpBlt->lpDDDestSurface;
|
---|
218 | PVBOXVHWASURFDESC pSrcDesc = (PVBOXVHWASURFDESC) pSrcSurf->lpGbl->dwReserved1;
|
---|
219 | PVBOXVHWASURFDESC pDstDesc = (PVBOXVHWASURFDESC) pDstSurf->lpGbl->dwReserved1;
|
---|
220 |
|
---|
221 | if (pSrcDesc && pDstDesc)
|
---|
222 | {
|
---|
223 | VBOXVHWACMD *pCmd;
|
---|
224 |
|
---|
225 | pCmd = VBoxDispVHWACommandCreate(pDev, VBOXVHWACMD_TYPE_SURF_BLT, sizeof(VBOXVHWACMD_SURF_BLT));
|
---|
226 | if (pCmd)
|
---|
227 | {
|
---|
228 | VBOXVHWACMD_SURF_BLT *pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_BLT);
|
---|
229 | memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_BLT));
|
---|
230 |
|
---|
231 | pBody->u.in.offSrcSurface = VBoxDispVHWAVramOffsetFromPDEV(pDev, pSrcSurf->lpGbl->fpVidMem);
|
---|
232 | pBody->u.in.offDstSurface = VBoxDispVHWAVramOffsetFromPDEV(pDev, pDstSurf->lpGbl->fpVidMem);
|
---|
233 |
|
---|
234 | pBody->u.in.hDstSurf = pDstDesc->hHostHandle;
|
---|
235 | VBoxDispVHWAFromRECTL(&pBody->u.in.dstRect, &lpBlt->rDest);
|
---|
236 | pBody->u.in.hSrcSurf = pSrcDesc->hHostHandle;
|
---|
237 | VBoxDispVHWAFromRECTL(&pBody->u.in.srcRect, &lpBlt->rSrc);
|
---|
238 | pBody->DstGuestSurfInfo = (uint64_t)pDstDesc;
|
---|
239 | pBody->SrcGuestSurfInfo = (uint64_t)pSrcDesc;
|
---|
240 |
|
---|
241 | pBody->u.in.flags = VBoxDispVHWAFromDDBLTs(lpBlt->dwFlags);
|
---|
242 | VBoxDispVHWAFromDDBLTFX(&pBody->u.in.desc, &lpBlt->bltFX);
|
---|
243 |
|
---|
244 | ASMAtomicIncU32(&pSrcDesc->cPendingBltsSrc);
|
---|
245 | ASMAtomicIncU32(&pDstDesc->cPendingBltsDst);
|
---|
246 |
|
---|
247 | VBoxDispVHWARegionAdd(&pDstDesc->NonupdatedMemRegion, &lpBlt->rDest);
|
---|
248 | VBoxDispVHWARegionTrySubstitute(&pDstDesc->UpdatedMemRegion, &lpBlt->rDest);
|
---|
249 |
|
---|
250 | if(pSrcDesc->UpdatedMemRegion.bValid)
|
---|
251 | {
|
---|
252 | pBody->u.in.xUpdatedSrcMemValid = 1;
|
---|
253 | VBoxDispVHWAFromRECTL(&pBody->u.in.xUpdatedSrcMemRect, &pSrcDesc->UpdatedMemRegion.Rect);
|
---|
254 | VBoxDispVHWARegionClear(&pSrcDesc->UpdatedMemRegion);
|
---|
255 | }
|
---|
256 |
|
---|
257 | VBoxDispVHWACommandSubmitAsynch(pDev, pCmd, VBoxDispVHWASurfBltCompletion, NULL);
|
---|
258 |
|
---|
259 | lpBlt->ddRVal = DD_OK;
|
---|
260 | }
|
---|
261 | else
|
---|
262 | {
|
---|
263 | WARN(("VBoxDispVHWACommandCreate failed!"));
|
---|
264 | lpBlt->ddRVal = DDERR_GENERIC;
|
---|
265 | }
|
---|
266 | }
|
---|
267 | else
|
---|
268 | {
|
---|
269 | WARN(("!(pSrcDesc && pDstDesc)"));
|
---|
270 | lpBlt->ddRVal = DDERR_GENERIC;
|
---|
271 | }
|
---|
272 |
|
---|
273 | LOGF_LEAVE();
|
---|
274 | return DDHAL_DRIVER_HANDLED;
|
---|
275 | }
|
---|
276 |
|
---|
277 | DWORD APIENTRY VBoxDispDDFlip(PDD_FLIPDATA lpFlip)
|
---|
278 | {
|
---|
279 | PVBOXDISPDEV pDev = (PVBOXDISPDEV) lpFlip->lpDD->dhpdev;
|
---|
280 | LOGF_ENTER();
|
---|
281 |
|
---|
282 | DD_SURFACE_LOCAL *pCurrSurf = lpFlip->lpSurfCurr;
|
---|
283 | DD_SURFACE_LOCAL *pTargSurf = lpFlip->lpSurfTarg;
|
---|
284 | PVBOXVHWASURFDESC pCurrDesc = (PVBOXVHWASURFDESC) pCurrSurf->lpGbl->dwReserved1;
|
---|
285 | PVBOXVHWASURFDESC pTargDesc = (PVBOXVHWASURFDESC) pTargSurf->lpGbl->dwReserved1;
|
---|
286 |
|
---|
287 | if (pCurrDesc && pTargDesc)
|
---|
288 | {
|
---|
289 | if(ASMAtomicUoReadU32(&pCurrDesc->cPendingFlipsTarg) || ASMAtomicUoReadU32(&pCurrDesc->cPendingFlipsCurr)
|
---|
290 | || ASMAtomicUoReadU32(&pTargDesc->cPendingFlipsTarg) || ASMAtomicUoReadU32(&pTargDesc->cPendingFlipsCurr))
|
---|
291 | {
|
---|
292 | VBoxDispVHWACommandCheckHostCmds(pDev);
|
---|
293 |
|
---|
294 | if(ASMAtomicUoReadU32(&pCurrDesc->cPendingFlipsTarg) || ASMAtomicUoReadU32(&pCurrDesc->cPendingFlipsCurr)
|
---|
295 | || ASMAtomicUoReadU32(&pTargDesc->cPendingFlipsTarg) || ASMAtomicUoReadU32(&pTargDesc->cPendingFlipsCurr))
|
---|
296 | {
|
---|
297 | lpFlip->ddRVal = DDERR_WASSTILLDRAWING;
|
---|
298 | return DDHAL_DRIVER_HANDLED;
|
---|
299 | }
|
---|
300 | }
|
---|
301 |
|
---|
302 | VBOXVHWACMD *pCmd;
|
---|
303 |
|
---|
304 | pCmd = VBoxDispVHWACommandCreate(pDev, VBOXVHWACMD_TYPE_SURF_FLIP, sizeof(VBOXVHWACMD_SURF_FLIP));
|
---|
305 |
|
---|
306 | if (pCmd)
|
---|
307 | {
|
---|
308 | VBOXVHWACMD_SURF_FLIP *pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_FLIP);
|
---|
309 | memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_FLIP));
|
---|
310 |
|
---|
311 | pBody->u.in.offCurrSurface = VBoxDispVHWAVramOffsetFromPDEV(pDev, pCurrSurf->lpGbl->fpVidMem);
|
---|
312 | pBody->u.in.offTargSurface = VBoxDispVHWAVramOffsetFromPDEV(pDev, pTargSurf->lpGbl->fpVidMem);
|
---|
313 |
|
---|
314 | pBody->u.in.hTargSurf = pTargDesc->hHostHandle;
|
---|
315 | pBody->u.in.hCurrSurf = pCurrDesc->hHostHandle;
|
---|
316 | pBody->TargGuestSurfInfo = (uint64_t)pTargDesc;
|
---|
317 | pBody->CurrGuestSurfInfo = (uint64_t)pCurrDesc;
|
---|
318 |
|
---|
319 | pTargDesc->bVisible = pCurrDesc->bVisible;
|
---|
320 | pCurrDesc->bVisible = false;
|
---|
321 |
|
---|
322 |
|
---|
323 | ASMAtomicIncU32(&pCurrDesc->cPendingFlipsCurr);
|
---|
324 | ASMAtomicIncU32(&pTargDesc->cPendingFlipsTarg);
|
---|
325 | #ifdef DEBUG
|
---|
326 | ASMAtomicIncU32(&pCurrDesc->cFlipsCurr);
|
---|
327 | ASMAtomicIncU32(&pTargDesc->cFlipsTarg);
|
---|
328 | #endif
|
---|
329 |
|
---|
330 | if(pTargDesc->UpdatedMemRegion.bValid)
|
---|
331 | {
|
---|
332 | pBody->u.in.xUpdatedTargMemValid = 1;
|
---|
333 | VBoxDispVHWAFromRECTL(&pBody->u.in.xUpdatedTargMemRect, &pTargDesc->UpdatedMemRegion.Rect);
|
---|
334 | VBoxDispVHWARegionClear(&pTargDesc->UpdatedMemRegion);
|
---|
335 | }
|
---|
336 |
|
---|
337 | VBoxDispVHWACommandSubmitAsynch(pDev, pCmd, VBoxDispVHWASurfFlipCompletion, NULL);
|
---|
338 |
|
---|
339 | lpFlip->ddRVal = DD_OK;
|
---|
340 | }
|
---|
341 | else
|
---|
342 | {
|
---|
343 | WARN(("VBoxDispVHWACommandCreate failed!"));
|
---|
344 | lpFlip->ddRVal = DDERR_GENERIC;
|
---|
345 | }
|
---|
346 | }
|
---|
347 | else
|
---|
348 | {
|
---|
349 | WARN(("!(pCurrDesc && pTargDesc)"));
|
---|
350 | lpFlip->ddRVal = DDERR_GENERIC;
|
---|
351 | }
|
---|
352 |
|
---|
353 | LOGF_LEAVE();
|
---|
354 | return DDHAL_DRIVER_HANDLED;
|
---|
355 | }
|
---|
356 |
|
---|
357 | DWORD APIENTRY VBoxDispDDGetBltStatus(PDD_GETBLTSTATUSDATA lpGetBltStatus)
|
---|
358 | {
|
---|
359 | PVBOXDISPDEV pDev = (PVBOXDISPDEV) lpGetBltStatus->lpDD->dhpdev;
|
---|
360 | PVBOXVHWASURFDESC pDesc = (PVBOXVHWASURFDESC)lpGetBltStatus->lpDDSurface->lpGbl->dwReserved1;
|
---|
361 | LOGF_ENTER();
|
---|
362 |
|
---|
363 | if(lpGetBltStatus->dwFlags == DDGBS_CANBLT)
|
---|
364 | {
|
---|
365 | lpGetBltStatus->ddRVal = DD_OK;
|
---|
366 | }
|
---|
367 | else /* DDGBS_ISBLTDONE */
|
---|
368 | {
|
---|
369 | if (pDesc)
|
---|
370 | {
|
---|
371 | if(ASMAtomicUoReadU32(&pDesc->cPendingBltsSrc) || ASMAtomicUoReadU32(&pDesc->cPendingBltsDst))
|
---|
372 | {
|
---|
373 | VBoxDispVHWACommandCheckHostCmds(pDev);
|
---|
374 |
|
---|
375 | if(ASMAtomicUoReadU32(&pDesc->cPendingBltsSrc) || ASMAtomicUoReadU32(&pDesc->cPendingBltsDst))
|
---|
376 | {
|
---|
377 | lpGetBltStatus->ddRVal = DDERR_WASSTILLDRAWING;
|
---|
378 | }
|
---|
379 | else
|
---|
380 | {
|
---|
381 | lpGetBltStatus->ddRVal = DD_OK;
|
---|
382 | }
|
---|
383 | }
|
---|
384 | else
|
---|
385 | {
|
---|
386 | lpGetBltStatus->ddRVal = DD_OK;
|
---|
387 | }
|
---|
388 | }
|
---|
389 | else
|
---|
390 | {
|
---|
391 | WARN(("!pDesc"));
|
---|
392 | lpGetBltStatus->ddRVal = DDERR_GENERIC;
|
---|
393 | }
|
---|
394 | }
|
---|
395 |
|
---|
396 |
|
---|
397 | LOGF_LEAVE();
|
---|
398 | return DDHAL_DRIVER_HANDLED;
|
---|
399 | }
|
---|
400 |
|
---|
401 | DWORD APIENTRY VBoxDispDDGetFlipStatus(PDD_GETFLIPSTATUSDATA lpGetFlipStatus)
|
---|
402 | {
|
---|
403 | PVBOXDISPDEV pDev = (PVBOXDISPDEV) lpGetFlipStatus->lpDD->dhpdev;
|
---|
404 | PVBOXVHWASURFDESC pDesc = (PVBOXVHWASURFDESC)lpGetFlipStatus->lpDDSurface->lpGbl->dwReserved1;
|
---|
405 | LOGF_ENTER();
|
---|
406 |
|
---|
407 | /*can't flip is there's a flip pending, so result is same for DDGFS_CANFLIP/DDGFS_ISFLIPDONE */
|
---|
408 |
|
---|
409 | if (pDesc)
|
---|
410 | {
|
---|
411 | if(ASMAtomicUoReadU32(&pDesc->cPendingFlipsTarg) || ASMAtomicUoReadU32(&pDesc->cPendingFlipsCurr))
|
---|
412 | {
|
---|
413 | VBoxDispVHWACommandCheckHostCmds(pDev);
|
---|
414 |
|
---|
415 | if(ASMAtomicUoReadU32(&pDesc->cPendingFlipsTarg) || ASMAtomicUoReadU32(&pDesc->cPendingFlipsCurr))
|
---|
416 | {
|
---|
417 | lpGetFlipStatus->ddRVal = DDERR_WASSTILLDRAWING;
|
---|
418 | }
|
---|
419 | else
|
---|
420 | {
|
---|
421 | lpGetFlipStatus->ddRVal = DD_OK;
|
---|
422 | }
|
---|
423 | }
|
---|
424 | else
|
---|
425 | {
|
---|
426 | lpGetFlipStatus->ddRVal = DD_OK;
|
---|
427 | }
|
---|
428 | }
|
---|
429 | else
|
---|
430 | {
|
---|
431 | WARN(("!pDesc"));
|
---|
432 | lpGetFlipStatus->ddRVal = DDERR_GENERIC;
|
---|
433 | }
|
---|
434 |
|
---|
435 | LOGF_LEAVE();
|
---|
436 | return DDHAL_DRIVER_HANDLED;
|
---|
437 | }
|
---|
438 |
|
---|
439 | DWORD APIENTRY VBoxDispDDSetOverlayPosition(PDD_SETOVERLAYPOSITIONDATA lpSetOverlayPosition)
|
---|
440 | {
|
---|
441 | PVBOXDISPDEV pDev = (PVBOXDISPDEV) lpSetOverlayPosition->lpDD->dhpdev;
|
---|
442 | DD_SURFACE_LOCAL *pSrcSurf = lpSetOverlayPosition->lpDDSrcSurface;
|
---|
443 | DD_SURFACE_LOCAL *pDstSurf = lpSetOverlayPosition->lpDDDestSurface;
|
---|
444 | PVBOXVHWASURFDESC pSrcDesc = (PVBOXVHWASURFDESC) pSrcSurf->lpGbl->dwReserved1;
|
---|
445 | PVBOXVHWASURFDESC pDstDesc = (PVBOXVHWASURFDESC) pDstSurf->lpGbl->dwReserved1;
|
---|
446 |
|
---|
447 | LOGF_ENTER();
|
---|
448 |
|
---|
449 | if (pSrcDesc && pDstDesc)
|
---|
450 | {
|
---|
451 | if (!pSrcDesc->bVisible)
|
---|
452 | {
|
---|
453 | WARN(("!pSrcDesc->bVisible"));
|
---|
454 | lpSetOverlayPosition->ddRVal = DDERR_GENERIC;
|
---|
455 | return DDHAL_DRIVER_HANDLED;
|
---|
456 | }
|
---|
457 |
|
---|
458 | VBOXVHWACMD *pCmd;
|
---|
459 |
|
---|
460 | pCmd = VBoxDispVHWACommandCreate(pDev, VBOXVHWACMD_TYPE_SURF_OVERLAY_SETPOSITION, sizeof(VBOXVHWACMD_SURF_OVERLAY_SETPOSITION));
|
---|
461 | if (pCmd)
|
---|
462 | {
|
---|
463 | VBOXVHWACMD_SURF_OVERLAY_SETPOSITION *pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_OVERLAY_SETPOSITION);
|
---|
464 | memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_OVERLAY_SETPOSITION));
|
---|
465 |
|
---|
466 | pBody->u.in.offSrcSurface = VBoxDispVHWAVramOffsetFromPDEV(pDev, pSrcSurf->lpGbl->fpVidMem);
|
---|
467 | pBody->u.in.offDstSurface = VBoxDispVHWAVramOffsetFromPDEV(pDev, pDstSurf->lpGbl->fpVidMem);
|
---|
468 |
|
---|
469 | pBody->u.in.hSrcSurf = pSrcDesc->hHostHandle;
|
---|
470 | pBody->u.in.hDstSurf = pDstDesc->hHostHandle;
|
---|
471 |
|
---|
472 | pBody->u.in.xPos = lpSetOverlayPosition->lXPos;
|
---|
473 | pBody->u.in.yPos = lpSetOverlayPosition->lYPos;
|
---|
474 |
|
---|
475 | VBoxDispVHWACommandSubmitAsynchAndComplete(pDev, pCmd);
|
---|
476 |
|
---|
477 | lpSetOverlayPosition->ddRVal = DD_OK;
|
---|
478 | }
|
---|
479 | else
|
---|
480 | {
|
---|
481 | WARN(("VBoxDispVHWACommandCreate failed!"));
|
---|
482 | lpSetOverlayPosition->ddRVal = DDERR_GENERIC;
|
---|
483 | }
|
---|
484 | }
|
---|
485 | else
|
---|
486 | {
|
---|
487 | WARN(("!(pSrcDesc && pDstDesc)"));
|
---|
488 | lpSetOverlayPosition->ddRVal = DDERR_GENERIC;
|
---|
489 | }
|
---|
490 |
|
---|
491 | LOGF_LEAVE();
|
---|
492 | return DDHAL_DRIVER_HANDLED;
|
---|
493 | }
|
---|
494 |
|
---|
495 | DWORD APIENTRY VBoxDispDDUpdateOverlay(PDD_UPDATEOVERLAYDATA lpUpdateOverlay)
|
---|
496 | {
|
---|
497 | PVBOXDISPDEV pDev = (PVBOXDISPDEV) lpUpdateOverlay->lpDD->dhpdev;
|
---|
498 | DD_SURFACE_LOCAL* pSrcSurf = lpUpdateOverlay->lpDDSrcSurface;
|
---|
499 | DD_SURFACE_LOCAL* pDstSurf = lpUpdateOverlay->lpDDDestSurface;
|
---|
500 | PVBOXVHWASURFDESC pSrcDesc = (PVBOXVHWASURFDESC) pSrcSurf->lpGbl->dwReserved1;
|
---|
501 |
|
---|
502 | LOGF_ENTER();
|
---|
503 |
|
---|
504 | if (pSrcDesc)
|
---|
505 | {
|
---|
506 | VBOXVHWACMD* pCmd;
|
---|
507 |
|
---|
508 | pCmd = VBoxDispVHWACommandCreate (pDev, VBOXVHWACMD_TYPE_SURF_OVERLAY_UPDATE, sizeof(VBOXVHWACMD_SURF_OVERLAY_UPDATE));
|
---|
509 | if (pCmd)
|
---|
510 | {
|
---|
511 | VBOXVHWACMD_SURF_OVERLAY_UPDATE *pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_OVERLAY_UPDATE);
|
---|
512 | memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_OVERLAY_UPDATE));
|
---|
513 |
|
---|
514 | pBody->u.in.offSrcSurface = VBoxDispVHWAVramOffsetFromPDEV(pDev, pSrcSurf->lpGbl->fpVidMem);
|
---|
515 |
|
---|
516 | pBody->u.in.hSrcSurf = pSrcDesc->hHostHandle;
|
---|
517 |
|
---|
518 | VBoxDispVHWAFromRECTL(&pBody->u.in.dstRect, &lpUpdateOverlay->rDest);
|
---|
519 | VBoxDispVHWAFromRECTL(&pBody->u.in.srcRect, &lpUpdateOverlay->rSrc);
|
---|
520 |
|
---|
521 | pBody->u.in.flags = VBoxDispVHWAFromDDOVERs(lpUpdateOverlay->dwFlags);
|
---|
522 | VBoxDispVHWAFromDDOVERLAYFX(&pBody->u.in.desc, &lpUpdateOverlay->overlayFX);
|
---|
523 |
|
---|
524 | if (lpUpdateOverlay->dwFlags & DDOVER_HIDE)
|
---|
525 | {
|
---|
526 | pSrcDesc->bVisible = false;
|
---|
527 | }
|
---|
528 | else if(lpUpdateOverlay->dwFlags & DDOVER_SHOW)
|
---|
529 | {
|
---|
530 | pSrcDesc->bVisible = true;
|
---|
531 | if(pSrcDesc->UpdatedMemRegion.bValid)
|
---|
532 | {
|
---|
533 | pBody->u.in.xFlags = VBOXVHWACMD_SURF_OVERLAY_UPDATE_F_SRCMEMRECT;
|
---|
534 | VBoxDispVHWAFromRECTL(&pBody->u.in.xUpdatedSrcMemRect, &pSrcDesc->UpdatedMemRegion.Rect);
|
---|
535 | VBoxDispVHWARegionClear(&pSrcDesc->UpdatedMemRegion);
|
---|
536 | }
|
---|
537 | }
|
---|
538 |
|
---|
539 | if(pDstSurf)
|
---|
540 | {
|
---|
541 | PVBOXVHWASURFDESC pDstDesc = (PVBOXVHWASURFDESC) pDstSurf->lpGbl->dwReserved1;
|
---|
542 |
|
---|
543 | if (!pDstDesc)
|
---|
544 | {
|
---|
545 | WARN(("!pDstDesc"));
|
---|
546 | lpUpdateOverlay->ddRVal = DDERR_GENERIC;
|
---|
547 | return DDHAL_DRIVER_HANDLED;
|
---|
548 | }
|
---|
549 |
|
---|
550 | pBody->u.in.hDstSurf = pDstDesc->hHostHandle;
|
---|
551 | pBody->u.in.offDstSurface = VBoxDispVHWAVramOffsetFromPDEV(pDev, pDstSurf->lpGbl->fpVidMem);
|
---|
552 | }
|
---|
553 |
|
---|
554 | VBoxDispVHWACommandSubmitAsynchAndComplete(pDev, pCmd);
|
---|
555 |
|
---|
556 | lpUpdateOverlay->ddRVal = DD_OK;
|
---|
557 | }
|
---|
558 | else
|
---|
559 | {
|
---|
560 | WARN(("VBoxDispVHWACommandCreate failed!"));
|
---|
561 | lpUpdateOverlay->ddRVal = DDERR_GENERIC;
|
---|
562 | }
|
---|
563 | }
|
---|
564 | else
|
---|
565 | {
|
---|
566 | WARN(("!pSrcDesc"));
|
---|
567 | lpUpdateOverlay->ddRVal = DDERR_GENERIC;
|
---|
568 | }
|
---|
569 |
|
---|
570 | LOGF_LEAVE();
|
---|
571 | return DDHAL_DRIVER_HANDLED;
|
---|
572 | }
|
---|