VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h@ 33890

Last change on this file since 33890 was 33530, checked in by vboxsync, 14 years ago

wddm/3d: chromium hgsmi: better alloc/submit engine

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.0 KB
Line 
1/** @file
2 * Contains base definitions of constants & structures used
3 * to control & perform rendering,
4 * such as DMA commands types, allocation types, escape codes, etc.
5 * used by both miniport & display drivers.
6 *
7 * The latter uses these and only these defs to communicate with the former
8 * by posting appropriate requests via D3D RT Krnl Svc accessing callbacks.
9 */
10/*
11 * Copyright (C) 2010 Oracle Corporation
12 *
13 * This file is part of VirtualBox Open Source Edition (OSE), as
14 * available from http://www.virtualbox.org. This file is free software;
15 * you can redistribute it and/or modify it under the terms of the GNU
16 * General Public License (GPL) as published by the Free Software
17 * Foundation, in version 2 as it comes in the "COPYING" file of the
18 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20 */
21#ifndef ___VBoxVideoIf_h___
22#define ___VBoxVideoIf_h___
23
24#include <VBox/VBoxVideo.h>
25#include "../../../include/VBoxDisplay.h"
26#include <VBox/VBoxUhgsmi.h>
27
28#include <iprt/assert.h>
29
30
31/* One would increase this whenever definitions in this file are changed */
32#define VBOXVIDEOIF_VERSION 7
33
34/* create allocation func */
35typedef enum
36{
37 VBOXWDDM_ALLOC_TYPE_UNEFINED = 0,
38 VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE,
39 VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE,
40 VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE,
41 /* this one is win 7-specific and hence unused for now */
42 VBOXWDDM_ALLOC_TYPE_STD_GDISURFACE
43 /* custom allocation types requested from user-mode d3d module will go here */
44 , VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC
45 , VBOXWDDM_ALLOC_TYPE_UMD_HGSMI_BUFFER
46} VBOXWDDM_ALLOC_TYPE;
47
48/* usage */
49typedef enum
50{
51 VBOXWDDM_ALLOCUSAGE_TYPE_UNEFINED = 0,
52 /* set for the allocation being primary */
53 VBOXWDDM_ALLOCUSAGE_TYPE_PRIMARY,
54} VBOXWDDM_ALLOCUSAGE_TYPE;
55
56typedef struct VBOXWDDM_SURFACE_DESC
57{
58 UINT width;
59 UINT height;
60 D3DDDIFORMAT format;
61 UINT bpp;
62 UINT pitch;
63 UINT depth;
64 UINT slicePitch;
65 UINT cbSize;
66 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
67 D3DDDI_RATIONAL RefreshRate;
68} VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
69
70typedef struct VBOXWDDM_ALLOCINFO
71{
72 VBOXWDDM_ALLOC_TYPE enmType;
73 union
74 {
75 struct
76 {
77 D3DDDI_RESOURCEFLAGS fFlags;
78 HANDLE hSharedHandle;
79 VBOXWDDM_SURFACE_DESC SurfDesc;
80 };
81
82 struct
83 {
84 uint32_t cbBuffer;
85 HANDLE hSynch;
86 VBOXUHGSMI_SYNCHOBJECT_TYPE enmSynchType;
87 };
88 };
89} VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
90
91/* this resource is OpenResource'd rather than CreateResource'd */
92#define VBOXWDDM_RESOURCE_F_OPENNED 0x00000001
93/* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
94#define VBOXWDDM_RESOURCE_F_TYPE_GENERIC 0x00000002
95
96typedef struct VBOXWDDM_RC_DESC
97{
98 D3DDDI_RESOURCEFLAGS fFlags;
99 D3DDDIFORMAT enmFormat;
100 D3DDDI_POOL enmPool;
101 D3DDDIMULTISAMPLE_TYPE enmMultisampleType;
102 UINT MultisampleQuality;
103 UINT MipLevels;
104 UINT Fvf;
105 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
106 D3DDDI_RATIONAL RefreshRate;
107 D3DDDI_ROTATION enmRotation;
108} VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC;
109
110typedef struct VBOXWDDM_RCINFO
111{
112 uint32_t fFlags;
113 VBOXWDDM_RC_DESC RcDesc;
114 uint32_t cAllocInfos;
115// VBOXWDDM_ALLOCINFO aAllocInfos[1];
116} VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO;
117
118typedef struct VBOXWDDM_DMA_PRIVATEDATA_FLAFS
119{
120 union
121 {
122 struct
123 {
124 UINT bCmdInDmaBuffer : 1;
125 UINT bReserved : 31;
126 };
127 uint32_t Value;
128 };
129} VBOXWDDM_DMA_PRIVATEDATA_FLAFS, *PVBOXWDDM_DMA_PRIVATEDATA_FLAFS;
130
131typedef struct VBOXWDDM_DMA_PRIVATEDATA_BASEHDR
132{
133 VBOXVDMACMD_TYPE enmCmd;
134 union
135 {
136 VBOXWDDM_DMA_PRIVATEDATA_FLAFS fFlags;
137 uint32_t u32CmdReserved;
138 };
139} VBOXWDDM_DMA_PRIVATEDATA_BASEHDR, *PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR;
140
141typedef struct VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO
142{
143 VBOXUHGSMI_BUFFER_SUBMIT_FLAGS fSubFlags;
144 uint32_t offData;
145 uint32_t cbData;
146} VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO, *PVBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO;
147
148typedef struct VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD
149{
150 VBOXWDDM_DMA_PRIVATEDATA_BASEHDR Base;
151 VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO aBufInfos[1];
152} VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, *PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD;
153
154#define VBOXVHWA_F_ENABLED 0x00000001
155#define VBOXVHWA_F_CKEY_DST 0x00000002
156#define VBOXVHWA_F_CKEY_SRC 0x00000004
157
158#define VBOXVHWA_MAX_FORMATS 8
159
160typedef struct VBOXVHWA_INFO
161{
162 uint32_t fFlags;
163 uint32_t cOverlaysSupported;
164 uint32_t cFormats;
165 D3DDDIFORMAT aFormats[VBOXVHWA_MAX_FORMATS];
166} VBOXVHWA_INFO;
167
168#define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
169#define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
170#define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
171#define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
172#define VBOXWDDM_OVERLAY_F_BOB 0x00000010
173#define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
174#define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
175#define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
176#define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
177
178typedef struct VBOXWDDM_OVERLAY_DESC
179{
180 uint32_t fFlags;
181 UINT DstColorKeyLow;
182 UINT DstColorKeyHigh;
183 UINT SrcColorKeyLow;
184 UINT SrcColorKeyHigh;
185} VBOXWDDM_OVERLAY_DESC, *PVBOXWDDM_OVERLAY_DESC;
186
187/* the dirty rect info is valid */
188#define VBOXWDDM_DIRTYREGION_F_VALID 0x00000001
189#define VBOXWDDM_DIRTYREGION_F_RECT_VALID 0x00000002
190
191typedef struct VBOXWDDM_DIRTYREGION
192{
193 uint32_t fFlags; /* <-- see VBOXWDDM_DIRTYREGION_F_xxx flags above */
194 RECT Rect;
195} VBOXWDDM_DIRTYREGION, *PVBOXWDDM_DIRTYREGION;
196
197typedef struct VBOXWDDM_OVERLAY_INFO
198{
199 VBOXWDDM_OVERLAY_DESC OverlayDesc;
200 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
201} VBOXWDDM_OVERLAY_INFO, *PVBOXWDDM_OVERLAY_INFO;
202
203typedef struct VBOXWDDM_OVERLAYFLIP_INFO
204{
205 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
206} VBOXWDDM_OVERLAYFLIP_INFO, *PVBOXWDDM_OVERLAYFLIP_INFO;
207
208
209typedef enum
210{
211 VBOXWDDM_CONTEXT_TYPE_UNDEFINED = 0,
212 VBOXWDDM_CONTEXT_TYPE_SYSTEM,
213 VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D,
214 VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D,
215 VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D,
216 VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL
217} VBOXWDDM_CONTEXT_TYPE;
218
219typedef struct VBOXWDDM_CREATECONTEXT_INFO
220{
221 /* interface version, i.e. 9 for d3d9, 8 for d3d8, etc. */
222 uint32_t u32IfVersion;
223 /* true if d3d false if ddraw */
224 VBOXWDDM_CONTEXT_TYPE enmType;
225 /* we use uint64_t instead of HANDLE to ensure structure def is the same for both 32-bit and 64-bit
226 * since x64 kernel driver can be called by 32-bit UMD */
227 uint64_t hUmEvent;
228 /* info to be passed to UMD notification to identify the context */
229 uint64_t u64UmInfo;
230} VBOXWDDM_CREATECONTEXT_INFO, *PVBOXWDDM_CREATECONTEXT_INFO;
231
232typedef void *VBOXDISP_UMHANDLE;
233typedef uint32_t VBOXDISP_KMHANDLE;
234
235typedef struct VBOXWDDM_RECTS_FLAFS
236{
237 union
238 {
239 struct
240 {
241 /* used only in conjunction with bSetVisibleRects.
242 * if set - VBOXWDDM_RECTS_INFO::aRects[0] contains view rectangle */
243 UINT bSetViewRect : 1;
244 /* sets visible regions */
245 UINT bSetVisibleRects : 1;
246 /* adds hidden regions */
247 UINT bAddHiddenRects : 1;
248 UINT Reserved : 29;
249 };
250 uint32_t Value;
251 };
252} VBOXWDDM_RECTS_FLAFS, *PVBOXWDDM_RECTS_FLAFS;
253
254typedef struct VBOXWDDM_RECTS_INFO
255{
256 uint32_t cRects;
257 RECT aRects[1];
258} VBOXWDDM_RECTS_INFO, *PVBOXWDDM_RECTS_INFO;
259
260#define VBOXWDDM_RECTS_INFO_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXWDDM_RECTS_INFO, aRects[(_cRects)]))
261#define VBOXWDDM_RECTS_INFO_SIZE(_pRects) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pRects)->cRects))
262
263typedef struct VBOXVIDEOCM_CMD_HDR
264{
265 uint64_t u64UmData;
266 uint32_t cbCmd;
267 uint32_t u32CmdSpecific;
268}VBOXVIDEOCM_CMD_HDR, *PVBOXVIDEOCM_CMD_HDR;
269
270AssertCompile((sizeof (VBOXVIDEOCM_CMD_HDR) & 7) == 0);
271
272typedef struct VBOXVIDEOCM_CMD_RECTS
273{
274 VBOXWDDM_RECTS_FLAFS fFlags;
275 VBOXWDDM_RECTS_INFO RectsInfo;
276} VBOXVIDEOCM_CMD_RECTS, *PVBOXVIDEOCM_CMD_RECTS;
277
278typedef struct VBOXVIDEOCM_CMD_RECTS_INTERNAL
279{
280 union
281 {
282 VBOXDISP_UMHANDLE hSwapchainUm;
283 uint64_t u64Alignment;
284 };
285 VBOXVIDEOCM_CMD_RECTS Cmd;
286} VBOXVIDEOCM_CMD_RECTS_INTERNAL, *PVBOXVIDEOCM_CMD_RECTS_INTERNAL;
287
288#define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS_INTERNAL, Cmd.RectsInfo.aRects[(_cRects)]))
289#define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS((_pCmd)->cRects))
290
291typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR
292{
293 uint32_t cbCmdsReturned;
294 uint32_t cbRemainingCmds;
295 uint32_t cbRemainingFirstCmd;
296 uint32_t u32Reserved;
297} VBOXWDDM_GETVBOXVIDEOCMCMD_HDR, *PVBOXWDDM_GETVBOXVIDEOCMCMD_HDR;
298
299typedef struct VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD
300{
301 VBOXDISPIFESCAPE EscapeHdr;
302 VBOXWDDM_GETVBOXVIDEOCMCMD_HDR Hdr;
303} VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, *PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD;
304
305AssertCompile((sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD) & 7) == 0);
306AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD, EscapeHdr) == 0);
307
308typedef struct VBOXDISPIFESCAPE_DBGPRINT
309{
310 VBOXDISPIFESCAPE EscapeHdr;
311 /* null-terminated string to DbgPrint including \0 */
312 char aStringBuf[1];
313} VBOXDISPIFESCAPE_DBGPRINT, *PVBOXDISPIFESCAPE_DBGPRINT;
314AssertCompile(RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, EscapeHdr) == 0);
315
316typedef struct VBOXSCREENLAYOUT_ELEMENT
317{
318 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
319 POINT pos;
320} VBOXSCREENLAYOUT_ELEMENT, *PVBOXSCREENLAYOUT_ELEMENT;
321
322typedef struct VBOXSCREENLAYOUT
323{
324 uint32_t cScreens;
325 VBOXSCREENLAYOUT_ELEMENT aScreens[1];
326} VBOXSCREENLAYOUT, *PVBOXSCREENLAYOUT;
327
328typedef struct VBOXDISPIFESCAPE_SCREENLAYOUT
329{
330 VBOXDISPIFESCAPE EscapeHdr;
331 VBOXSCREENLAYOUT ScreenLayout;
332} VBOXDISPIFESCAPE_SCREENLAYOUT, *PVBOXDISPIFESCAPE_SCREENLAYOUT;
333
334typedef struct VBOXSWAPCHAININFO
335{
336 VBOXDISP_KMHANDLE hSwapchainKm; /* in, NULL if new is being created */
337 VBOXDISP_UMHANDLE hSwapchainUm; /* in, UMD private data */
338 RECT Rect;
339 UINT u32Reserved;
340 UINT cAllocs;
341 D3DKMT_HANDLE ahAllocs[1];
342}VBOXSWAPCHAININFO, *PVBOXSWAPCHAININFO;
343typedef struct VBOXDISPIFESCAPE_SWAPCHAININFO
344{
345 VBOXDISPIFESCAPE EscapeHdr;
346 VBOXSWAPCHAININFO SwapchainInfo;
347} VBOXDISPIFESCAPE_SWAPCHAININFO, *PVBOXDISPIFESCAPE_SWAPCHAININFO;
348
349typedef struct VBOXVIDEOCM_UM_ALLOC
350{
351 VBOXDISP_KMHANDLE hAlloc;
352 uint32_t cbData;
353 uint8_t *pvData;
354 HANDLE hSynch;
355 VBOXUHGSMI_SYNCHOBJECT_TYPE enmSynchType;
356} VBOXVIDEOCM_UM_ALLOC, *PVBOXVIDEOCM_UM_ALLOC;
357
358typedef struct VBOXDISPIFESCAPE_UHGSMI_ALLOCATE
359{
360 VBOXDISPIFESCAPE EscapeHdr;
361 VBOXVIDEOCM_UM_ALLOC Alloc;
362} VBOXDISPIFESCAPE_UHGSMI_ALLOCATE, *PVBOXDISPIFESCAPE_UHGSMI_ALLOCATE;
363
364typedef struct VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE
365{
366 VBOXDISPIFESCAPE EscapeHdr;
367 VBOXDISP_KMHANDLE hAlloc;
368} VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE, *PVBOXDISPIFESCAPE_UHGSMI_DEALLOCATE;
369
370typedef struct VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE
371{
372 VBOXDISP_KMHANDLE hAlloc;
373 VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO Info;
374} VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE, *PVBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE;
375
376typedef struct VBOXDISPIFESCAPE_UHGSMI_SUBMIT
377{
378 VBOXDISPIFESCAPE EscapeHdr;
379 VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE aBuffers[1];
380} VBOXDISPIFESCAPE_UHGSMI_SUBMIT, *PVBOXDISPIFESCAPE_UHGSMI_SUBMIT;
381
382/* query info func */
383typedef struct VBOXWDDM_QI
384{
385 uint32_t u32Version;
386 uint32_t cInfos;
387 VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS];
388} VBOXWDDM_QI;
389
390/* submit cmd func */
391
392/* tooling */
393DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
394{
395 switch (format)
396 {
397 case D3DDDIFMT_R8G8B8:
398 return 24;
399 case D3DDDIFMT_A8R8G8B8:
400 case D3DDDIFMT_X8R8G8B8:
401 return 32;
402 case D3DDDIFMT_R5G6B5:
403 case D3DDDIFMT_X1R5G5B5:
404 case D3DDDIFMT_A1R5G5B5:
405 case D3DDDIFMT_A4R4G4B4:
406 return 16;
407 case D3DDDIFMT_R3G3B2:
408 case D3DDDIFMT_A8:
409 return 8;
410 case D3DDDIFMT_A8R3G3B2:
411 case D3DDDIFMT_X4R4G4B4:
412 return 16;
413 case D3DDDIFMT_A2B10G10R10:
414 case D3DDDIFMT_A8B8G8R8:
415 case D3DDDIFMT_X8B8G8R8:
416 case D3DDDIFMT_G16R16:
417 case D3DDDIFMT_A2R10G10B10:
418 return 32;
419 case D3DDDIFMT_A16B16G16R16:
420 return 64;
421 case D3DDDIFMT_A8P8:
422 return 16;
423 case D3DDDIFMT_P8:
424 case D3DDDIFMT_L8:
425 return 8;
426 case D3DDDIFMT_A8L8:
427 return 16;
428 case D3DDDIFMT_A4L4:
429 return 8;
430 case D3DDDIFMT_V8U8:
431 case D3DDDIFMT_L6V5U5:
432 return 16;
433 case D3DDDIFMT_X8L8V8U8:
434 case D3DDDIFMT_Q8W8V8U8:
435 case D3DDDIFMT_V16U16:
436 case D3DDDIFMT_W11V11U10:
437 case D3DDDIFMT_A2W10V10U10:
438 return 32;
439 case D3DDDIFMT_D16_LOCKABLE:
440 case D3DDDIFMT_D16:
441 case D3DDDIFMT_D15S1:
442 return 16;
443 case D3DDDIFMT_D32:
444 case D3DDDIFMT_D24S8:
445 case D3DDDIFMT_D24X8:
446 case D3DDDIFMT_D24X4S4:
447 case D3DDDIFMT_D24FS8:
448 case D3DDDIFMT_D32_LOCKABLE:
449 case D3DDDIFMT_D32F_LOCKABLE:
450 return 32;
451 case D3DDDIFMT_S8_LOCKABLE:
452 return 8;
453 default:
454 AssertBreakpoint();
455 return 0;
456 }
457}
458
459DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format)
460{
461 uint32_t uFormat = (uint32_t)format;
462 /* assume that in case both four bytes are non-zero, this is a fourcc */
463 if ((format & 0xff000000)
464 && (format & 0x00ff0000)
465 && (format & 0x0000ff00)
466 && (format & 0x000000ff)
467 )
468 return uFormat;
469 return 0;
470}
471
472#define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
473
474DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
475{
476 UINT Pitch = bitsPerPixel * w;
477 /* pitch is now in bits, translate in bytes */
478 return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
479}
480
481DECLINLINE(void) vboxWddmRectUnite(RECT *pR, const RECT *pR2Unite)
482{
483 pR->left = RT_MIN(pR->left, pR2Unite->left);
484 pR->top = RT_MIN(pR->top, pR2Unite->top);
485 pR->right = RT_MAX(pR->right, pR2Unite->right);
486 pR->bottom = RT_MAX(pR->bottom, pR2Unite->bottom);
487}
488
489DECLINLINE(bool) vboxWddmRectIntersection(const RECT *a, const RECT *b, RECT *rect)
490{
491 Assert(a);
492 Assert(b);
493 Assert(rect);
494 rect->left = RT_MAX(a->left, b->left);
495 rect->right = RT_MIN(a->right, b->right);
496 rect->top = RT_MAX(a->top, b->top);
497 rect->bottom = RT_MIN(a->bottom, b->bottom);
498 return (rect->right>rect->left) && (rect->bottom>rect->top);
499}
500
501DECLINLINE(bool) vboxWddmRectIsEqual(const RECT *pRect1, const RECT *pRect2)
502{
503 Assert(pRect1);
504 Assert(pRect2);
505 if (pRect1->left != pRect2->left)
506 return false;
507 if (pRect1->top != pRect2->top)
508 return false;
509 if (pRect1->right != pRect2->right)
510 return false;
511 if (pRect1->bottom != pRect2->bottom)
512 return false;
513 return true;
514}
515
516DECLINLINE(bool) vboxWddmRectIsCoveres(const RECT *pRect, const RECT *pCovered)
517{
518 Assert(pRect);
519 Assert(pCovered);
520 if (pRect->left > pCovered->left)
521 return false;
522 if (pRect->top > pCovered->top)
523 return false;
524 if (pRect->right < pCovered->right)
525 return false;
526 if (pRect->bottom < pCovered->bottom)
527 return false;
528 return true;
529}
530
531DECLINLINE(bool) vboxWddmRectIsEmpty(const RECT * pRect)
532{
533 return pRect->left == pRect->right-1 && pRect->top == pRect->bottom-1;
534}
535
536DECLINLINE(bool) vboxWddmRectIsIntersect(const RECT * pRect1, const RECT * pRect2)
537{
538 return !((pRect1->left < pRect2->left && pRect1->right < pRect2->left)
539 || (pRect2->left < pRect1->left && pRect2->right < pRect1->left)
540 || (pRect1->top < pRect2->top && pRect1->bottom < pRect2->top)
541 || (pRect2->top < pRect1->top && pRect2->bottom < pRect1->top));
542}
543
544DECLINLINE(void) vboxWddmRectUnited(RECT * pDst, const RECT * pRect1, const RECT * pRect2)
545{
546 pDst->left = RT_MIN(pRect1->left, pRect2->left);
547 pDst->top = RT_MIN(pRect1->top, pRect2->top);
548 pDst->right = RT_MAX(pRect1->right, pRect2->right);
549 pDst->bottom = RT_MAX(pRect1->bottom, pRect2->bottom);
550}
551
552DECLINLINE(void) vboxWddmRectTranslate(RECT * pRect, int x, int y)
553{
554 pRect->left += x;
555 pRect->top += y;
556 pRect->right += x;
557 pRect->bottom += y;
558}
559
560DECLINLINE(void) vboxWddmRectMove(RECT * pRect, int x, int y)
561{
562 LONG w = pRect->right - pRect->left;
563 LONG h = pRect->bottom - pRect->top;
564 pRect->left = x;
565 pRect->top = y;
566 pRect->right = w + x;
567 pRect->bottom = h + y;
568}
569
570DECLINLINE(void) vboxWddmRectTranslated(RECT *pDst, const RECT * pRect, int x, int y)
571{
572 *pDst = *pRect;
573 vboxWddmRectTranslate(pDst, x, y);
574}
575
576DECLINLINE(void) vboxWddmRectMoved(RECT *pDst, const RECT * pRect, int x, int y)
577{
578 *pDst = *pRect;
579 vboxWddmRectMove(pDst, x, y);
580}
581
582DECLINLINE(void) vboxWddmDirtyRegionAddRect(PVBOXWDDM_DIRTYREGION pInfo, const RECT *pRect)
583{
584 if (!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_VALID))
585 {
586 pInfo->fFlags = VBOXWDDM_DIRTYREGION_F_VALID;
587 if (pRect)
588 {
589 pInfo->fFlags |= VBOXWDDM_DIRTYREGION_F_RECT_VALID;
590 pInfo->Rect = *pRect;
591 }
592 }
593 else if (!!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID))
594 {
595 if (pRect)
596 vboxWddmRectUnite(&pInfo->Rect, pRect);
597 else
598 pInfo->fFlags &= ~VBOXWDDM_DIRTYREGION_F_RECT_VALID;
599 }
600}
601
602DECLINLINE(void) vboxWddmDirtyRegionUnite(PVBOXWDDM_DIRTYREGION pInfo, const PVBOXWDDM_DIRTYREGION pInfo2)
603{
604 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_VALID)
605 {
606 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID)
607 vboxWddmDirtyRegionAddRect(pInfo, &pInfo2->Rect);
608 else
609 vboxWddmDirtyRegionAddRect(pInfo, NULL);
610 }
611}
612
613DECLINLINE(void) vboxWddmDirtyRegionClear(PVBOXWDDM_DIRTYREGION pInfo)
614{
615 pInfo->fFlags = 0;
616}
617
618#endif /* #ifndef ___VBoxVideoIf_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette