1 | /* $Id: cr_vreg.h 47623 2013-08-08 21:19:43Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * Visible Regions processing API
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2012 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 | #ifndef ___cr_vreg_h_
|
---|
19 | #define ___cr_vreg_h_
|
---|
20 |
|
---|
21 | #include <iprt/list.h>
|
---|
22 | #include <iprt/types.h>
|
---|
23 | #include <iprt/mem.h>
|
---|
24 | #include <iprt/string.h>
|
---|
25 | #include <iprt/assert.h>
|
---|
26 | #include <iprt/critsect.h>
|
---|
27 |
|
---|
28 | #ifndef IN_RING0
|
---|
29 | # define VBOXVREGDECL(_type) DECLEXPORT(_type)
|
---|
30 | #else
|
---|
31 | # define VBOXVREGDECL(_type) RTDECL(_type)
|
---|
32 | #endif
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | RT_C_DECLS_BEGIN
|
---|
37 |
|
---|
38 | typedef struct VBOXVR_LIST
|
---|
39 | {
|
---|
40 | RTLISTNODE ListHead;
|
---|
41 | uint32_t cEntries;
|
---|
42 | } VBOXVR_LIST, *PVBOXVR_LIST;
|
---|
43 |
|
---|
44 | DECLINLINE(int) VBoxRectCmp(const RTRECT * pRect1, const RTRECT * pRect2)
|
---|
45 | {
|
---|
46 | return memcmp(pRect1, pRect2, sizeof (*pRect1));
|
---|
47 | }
|
---|
48 |
|
---|
49 | DECLINLINE(void) VBoxRectIntersect(PRTRECT pRect1, const RTRECT * pRect2)
|
---|
50 | {
|
---|
51 | Assert(pRect1);
|
---|
52 | Assert(pRect2);
|
---|
53 | pRect1->xLeft = RT_MAX(pRect1->xLeft, pRect2->xLeft);
|
---|
54 | pRect1->yTop = RT_MAX(pRect1->yTop, pRect2->yTop);
|
---|
55 | pRect1->xRight = RT_MIN(pRect1->xRight, pRect2->xRight);
|
---|
56 | pRect1->yBottom = RT_MIN(pRect1->yBottom, pRect2->yBottom);
|
---|
57 | }
|
---|
58 |
|
---|
59 | DECLINLINE(void) VBoxRectIntersected(const RTRECT *pRect1, const RTRECT * pRect2, RTRECT *pResult)
|
---|
60 | {
|
---|
61 | *pResult = *pRect1;
|
---|
62 | VBoxRectIntersect(pResult, pRect2);
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 | DECLINLINE(void) VBoxRectTranslate(RTRECT * pRect, int32_t x, int32_t y)
|
---|
67 | {
|
---|
68 | pRect->xLeft += x;
|
---|
69 | pRect->yTop += y;
|
---|
70 | pRect->xRight += x;
|
---|
71 | pRect->yBottom += y;
|
---|
72 | }
|
---|
73 |
|
---|
74 | DECLINLINE(void) VBoxRectTranslated(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
|
---|
75 | {
|
---|
76 | *pResult = *pRect;
|
---|
77 | VBoxRectTranslate(pResult, x, y);
|
---|
78 | }
|
---|
79 |
|
---|
80 | DECLINLINE(void) VBoxRectMove(RTRECT * pRect, int32_t x, int32_t y)
|
---|
81 | {
|
---|
82 | int32_t w = pRect->xRight - pRect->xLeft;
|
---|
83 | int32_t h = pRect->yBottom - pRect->yTop;
|
---|
84 | pRect->xLeft = x;
|
---|
85 | pRect->yTop = y;
|
---|
86 | pRect->xRight = w + x;
|
---|
87 | pRect->yBottom = h + y;
|
---|
88 | }
|
---|
89 |
|
---|
90 | DECLINLINE(void) VBoxRectMoved(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
|
---|
91 | {
|
---|
92 | *pResult = *pRect;
|
---|
93 | VBoxRectMove(pResult, x, y);
|
---|
94 | }
|
---|
95 |
|
---|
96 | DECLINLINE(bool) VBoxRectIsCoveres(const RTRECT *pRect, const RTRECT *pCovered)
|
---|
97 | {
|
---|
98 | Assert(pRect);
|
---|
99 | Assert(pCovered);
|
---|
100 | if (pRect->xLeft > pCovered->xLeft)
|
---|
101 | return false;
|
---|
102 | if (pRect->yTop > pCovered->yTop)
|
---|
103 | return false;
|
---|
104 | if (pRect->xRight < pCovered->xRight)
|
---|
105 | return false;
|
---|
106 | if (pRect->yBottom < pCovered->yBottom)
|
---|
107 | return false;
|
---|
108 | return true;
|
---|
109 | }
|
---|
110 |
|
---|
111 | DECLINLINE(bool) VBoxRectIsZero(const RTRECT *pRect)
|
---|
112 | {
|
---|
113 | return pRect->xLeft == pRect->xRight || pRect->yTop == pRect->yBottom;
|
---|
114 | }
|
---|
115 |
|
---|
116 | DECLINLINE(bool) VBoxRectIsIntersect(const RTRECT * pRect1, const RTRECT * pRect2)
|
---|
117 | {
|
---|
118 | return !((pRect1->xLeft < pRect2->xLeft && pRect1->xRight <= pRect2->xLeft)
|
---|
119 | || (pRect2->xLeft < pRect1->xLeft && pRect2->xRight <= pRect1->xLeft)
|
---|
120 | || (pRect1->yTop < pRect2->yTop && pRect1->yBottom <= pRect2->yTop)
|
---|
121 | || (pRect2->yTop < pRect1->yTop && pRect2->yBottom <= pRect1->yTop));
|
---|
122 | }
|
---|
123 |
|
---|
124 | DECLINLINE(uint32_t) VBoxVrListRectsCount(const VBOXVR_LIST *pList)
|
---|
125 | {
|
---|
126 | return pList->cEntries;
|
---|
127 | }
|
---|
128 |
|
---|
129 | DECLINLINE(bool) VBoxVrListIsEmpty(const VBOXVR_LIST *pList)
|
---|
130 | {
|
---|
131 | return !VBoxVrListRectsCount(pList);
|
---|
132 | }
|
---|
133 |
|
---|
134 | DECLINLINE(void) VBoxVrListInit(PVBOXVR_LIST pList)
|
---|
135 | {
|
---|
136 | RTListInit(&pList->ListHead);
|
---|
137 | pList->cEntries = 0;
|
---|
138 | }
|
---|
139 |
|
---|
140 | VBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList);
|
---|
141 |
|
---|
142 | VBOXVREGDECL(void) VBoxVrListTranslate(PVBOXVR_LIST pList, int32_t x, int32_t y);
|
---|
143 |
|
---|
144 | VBOXVREGDECL(int) VBoxVrListCmp(const VBOXVR_LIST *pList1, const VBOXVR_LIST *pList2);
|
---|
145 |
|
---|
146 | VBOXVREGDECL(int) VBoxVrListRectsSet(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
|
---|
147 | VBOXVREGDECL(int) VBoxVrListRectsAdd(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
|
---|
148 | VBOXVREGDECL(int) VBoxVrListRectsSubst(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
|
---|
149 | VBOXVREGDECL(int) VBoxVrListRectsGet(PVBOXVR_LIST pList, uint32_t cRects, RTRECT * aRects);
|
---|
150 |
|
---|
151 | VBOXVREGDECL(int) VBoxVrListClone(const VBOXVR_LIST *pList, VBOXVR_LIST *pDstList);
|
---|
152 |
|
---|
153 | /* NOTE: with the current implementation the VBoxVrListIntersect is faster than VBoxVrListRectsIntersect,
|
---|
154 | * i.e. VBoxVrListRectsIntersect is actually a convenience function that create a temporary list and calls VBoxVrListIntersect internally */
|
---|
155 | VBOXVREGDECL(int) VBoxVrListRectsIntersect(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
|
---|
156 | VBOXVREGDECL(int) VBoxVrListIntersect(PVBOXVR_LIST pList, const VBOXVR_LIST *pList2, bool *pfChanged);
|
---|
157 |
|
---|
158 | VBOXVREGDECL(int) VBoxVrInit();
|
---|
159 | VBOXVREGDECL(void) VBoxVrTerm();
|
---|
160 |
|
---|
161 | typedef struct VBOXVR_LIST_ITERATOR
|
---|
162 | {
|
---|
163 | PVBOXVR_LIST pList;
|
---|
164 | PRTLISTNODE pNextEntry;
|
---|
165 | } VBOXVR_LIST_ITERATOR, *PVBOXVR_LIST_ITERATOR;
|
---|
166 |
|
---|
167 | DECLINLINE(void) VBoxVrListIterInit(PVBOXVR_LIST pList, PVBOXVR_LIST_ITERATOR pIter)
|
---|
168 | {
|
---|
169 | pIter->pList = pList;
|
---|
170 | pIter->pNextEntry = pList->ListHead.pNext;
|
---|
171 | }
|
---|
172 |
|
---|
173 | typedef struct VBOXVR_REG
|
---|
174 | {
|
---|
175 | RTLISTNODE ListEntry;
|
---|
176 | RTRECT Rect;
|
---|
177 | } VBOXVR_REG, *PVBOXVR_REG;
|
---|
178 |
|
---|
179 | #define PVBOXVR_REG_FROM_ENTRY(_pEntry) ((PVBOXVR_REG)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXVR_REG, ListEntry)))
|
---|
180 |
|
---|
181 | DECLINLINE(PCRTRECT) VBoxVrListIterNext(PVBOXVR_LIST_ITERATOR pIter)
|
---|
182 | {
|
---|
183 | PRTLISTNODE pNextEntry = pIter->pNextEntry;
|
---|
184 | if (pNextEntry != &pIter->pList->ListHead)
|
---|
185 | {
|
---|
186 | PCRTRECT pRect = &(PVBOXVR_REG_FROM_ENTRY(pNextEntry)->Rect);
|
---|
187 | pIter->pNextEntry = pNextEntry->pNext;
|
---|
188 | return pRect;
|
---|
189 | }
|
---|
190 | return NULL;
|
---|
191 | }
|
---|
192 |
|
---|
193 | typedef struct VBOXVR_COMPOSITOR_ENTRY
|
---|
194 | {
|
---|
195 | RTLISTNODE Node;
|
---|
196 | VBOXVR_LIST Vr;
|
---|
197 | uint32_t cRefs;
|
---|
198 | } VBOXVR_COMPOSITOR_ENTRY, *PVBOXVR_COMPOSITOR_ENTRY;
|
---|
199 |
|
---|
200 | struct VBOXVR_COMPOSITOR;
|
---|
201 |
|
---|
202 | typedef DECLCALLBACK(void) FNVBOXVRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry);
|
---|
203 | typedef FNVBOXVRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED;
|
---|
204 |
|
---|
205 | typedef struct VBOXVR_COMPOSITOR
|
---|
206 | {
|
---|
207 | RTLISTNODE List;
|
---|
208 | PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
|
---|
209 | } VBOXVR_COMPOSITOR, *PVBOXVR_COMPOSITOR;
|
---|
210 |
|
---|
211 | typedef DECLCALLBACK(bool) FNVBOXVRCOMPOSITOR_VISITOR(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
|
---|
212 | typedef FNVBOXVRCOMPOSITOR_VISITOR *PFNVBOXVRCOMPOSITOR_VISITOR;
|
---|
213 |
|
---|
214 | VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased);
|
---|
215 | VBOXVREGDECL(void) VBoxVrCompositorClear(PVBOXVR_COMPOSITOR pCompositor);
|
---|
216 | VBOXVREGDECL(void) VBoxVrCompositorRegionsClear(PVBOXVR_COMPOSITOR pCompositor, bool *pfChanged);
|
---|
217 | VBOXVREGDECL(void) VBoxVrCompositorEntryInit(PVBOXVR_COMPOSITOR_ENTRY pEntry);
|
---|
218 | DECLINLINE(bool) VBoxVrCompositorEntryIsInList(const VBOXVR_COMPOSITOR_ENTRY *pEntry)
|
---|
219 | {
|
---|
220 | return !VBoxVrListIsEmpty(&pEntry->Vr);
|
---|
221 | }
|
---|
222 |
|
---|
223 | #define CRBLT_F_LINEAR 0x00000001
|
---|
224 | #define CRBLT_F_INVERT_SRC_YCOORDS 0x00000002
|
---|
225 | #define CRBLT_F_INVERT_DST_YCOORDS 0x00000004
|
---|
226 | #define CRBLT_F_INVERT_YCOORDS (CRBLT_F_INVERT_SRC_YCOORDS | CRBLT_F_INVERT_DST_YCOORDS)
|
---|
227 |
|
---|
228 | #define CRBLT_FTYPE_XOR CRBLT_F_INVERT_YCOORDS
|
---|
229 | #define CRBLT_FTYPE_OR CRBLT_F_LINEAR
|
---|
230 | #define CRBLT_FOP_COMBINE(_f1, _f2) ((((_f1) ^ (_f2)) & CRBLT_FTYPE_XOR) | (((_f1) | (_f2)) & CRBLT_FTYPE_OR))
|
---|
231 |
|
---|
232 | #define CRBLT_FLAGS_FROM_FILTER(_f) ( ((_f) & GL_LINEAR) ? CRBLT_F_LINEAR : 0)
|
---|
233 | #define CRBLT_FILTER_FROM_FLAGS(_f) (((_f) & CRBLT_F_LINEAR) ? GL_LINEAR : GL_NEAREST)
|
---|
234 |
|
---|
235 | /* compositor regions changed */
|
---|
236 | #define VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED 0x00000001
|
---|
237 | /* other entries changed along while doing current entry modification
|
---|
238 | * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */
|
---|
239 | #define VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED 0x00000002
|
---|
240 | /* only current entry regions changed
|
---|
241 | * can come wither with VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED or with VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED */
|
---|
242 | #define VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED 0x00000004
|
---|
243 | /* the given entry has replaced some other entry, while overal regions did NOT change.
|
---|
244 | * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */
|
---|
245 | #define VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED 0x00000008
|
---|
246 |
|
---|
247 |
|
---|
248 | VBOXVREGDECL(bool) VBoxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry);
|
---|
249 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, PVBOXVR_COMPOSITOR_ENTRY *ppReplacedEntry, uint32_t *pfChangeFlags);
|
---|
250 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
251 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSet(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
252 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
253 | VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged);
|
---|
254 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersectAll(PVBOXVR_COMPOSITOR pCompositor, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
255 | VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersectAll(PVBOXVR_COMPOSITOR pCompositor, const VBOXVR_LIST *pList2, bool *pfChanged);
|
---|
256 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsTranslate(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, int32_t x, int32_t y, bool *pfChanged);
|
---|
257 | VBOXVREGDECL(void) VBoxVrCompositorVisit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor);
|
---|
258 |
|
---|
259 | DECLINLINE(bool) VBoxVrCompositorIsEmpty(const VBOXVR_COMPOSITOR *pCompositor)
|
---|
260 | {
|
---|
261 | return RTListIsEmpty(&pCompositor->List);
|
---|
262 | }
|
---|
263 |
|
---|
264 | typedef struct VBOXVR_COMPOSITOR_ITERATOR
|
---|
265 | {
|
---|
266 | PVBOXVR_COMPOSITOR pCompositor;
|
---|
267 | PRTLISTNODE pNextEntry;
|
---|
268 | } VBOXVR_COMPOSITOR_ITERATOR ,*PVBOXVR_COMPOSITOR_ITERATOR;
|
---|
269 |
|
---|
270 | DECLINLINE(void) VBoxVrCompositorIterInit(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ITERATOR pIter)
|
---|
271 | {
|
---|
272 | pIter->pCompositor = pCompositor;
|
---|
273 | pIter->pNextEntry = pCompositor->List.pNext;
|
---|
274 | }
|
---|
275 |
|
---|
276 | #define VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(_p) ((PVBOXVR_COMPOSITOR_ENTRY)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_COMPOSITOR_ENTRY, Node)))
|
---|
277 |
|
---|
278 | DECLINLINE(PVBOXVR_COMPOSITOR_ENTRY) VBoxVrCompositorIterNext(PVBOXVR_COMPOSITOR_ITERATOR pIter)
|
---|
279 | {
|
---|
280 | PRTLISTNODE pNextEntry = pIter->pNextEntry;
|
---|
281 | if (pNextEntry != &pIter->pCompositor->List)
|
---|
282 | {
|
---|
283 | PVBOXVR_COMPOSITOR_ENTRY pEntry = VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(pNextEntry);
|
---|
284 | pIter->pNextEntry = pNextEntry->pNext;
|
---|
285 | return pEntry;
|
---|
286 | }
|
---|
287 | return NULL;
|
---|
288 | }
|
---|
289 |
|
---|
290 | /* Compositor with Stretching & Cached Rectangles info */
|
---|
291 |
|
---|
292 | typedef struct VBOXVR_TEXTURE
|
---|
293 | {
|
---|
294 | int32_t width;
|
---|
295 | int32_t height;
|
---|
296 | uint32_t target;
|
---|
297 | uint32_t hwid;
|
---|
298 | } VBOXVR_TEXTURE, *PVBOXVR_TEXTURE;
|
---|
299 |
|
---|
300 | struct VBOXVR_SCR_COMPOSITOR_ENTRY;
|
---|
301 | struct VBOXVR_SCR_COMPOSITOR;
|
---|
302 |
|
---|
303 | typedef DECLCALLBACK(void) FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_SCR_COMPOSITOR *pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacingEntry);
|
---|
304 | typedef FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED;
|
---|
305 |
|
---|
306 |
|
---|
307 | typedef struct VBOXVR_SCR_COMPOSITOR_ENTRY
|
---|
308 | {
|
---|
309 | VBOXVR_COMPOSITOR_ENTRY Ce;
|
---|
310 | VBOXVR_TEXTURE Tex;
|
---|
311 | RTPOINT Pos;
|
---|
312 | uint32_t fChanged;
|
---|
313 | uint32_t fFlags;
|
---|
314 | uint32_t cRects;
|
---|
315 | PRTRECT paSrcRects;
|
---|
316 | PRTRECT paDstRects;
|
---|
317 | PRTRECT paDstUnstretchedRects;
|
---|
318 | PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
|
---|
319 | } VBOXVR_SCR_COMPOSITOR_ENTRY, *PVBOXVR_SCR_COMPOSITOR_ENTRY;
|
---|
320 |
|
---|
321 | typedef struct VBOXVR_SCR_COMPOSITOR
|
---|
322 | {
|
---|
323 | VBOXVR_COMPOSITOR Compositor;
|
---|
324 | #ifndef IN_RING0
|
---|
325 | float StretchX;
|
---|
326 | float StretchY;
|
---|
327 | #endif
|
---|
328 | uint32_t fFlags;
|
---|
329 | uint32_t cRects;
|
---|
330 | uint32_t cRectsBuffer;
|
---|
331 | PRTRECT paSrcRects;
|
---|
332 | PRTRECT paDstRects;
|
---|
333 | PRTRECT paDstUnstretchedRects;
|
---|
334 | } VBOXVR_SCR_COMPOSITOR, *PVBOXVR_SCR_COMPOSITOR;
|
---|
335 |
|
---|
336 |
|
---|
337 | typedef DECLCALLBACK(bool) FNVBOXVRSCRCOMPOSITOR_VISITOR(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
|
---|
338 | typedef FNVBOXVRSCRCOMPOSITOR_VISITOR *PFNVBOXVRSCRCOMPOSITOR_VISITOR;
|
---|
339 |
|
---|
340 | DECLINLINE(void) CrVrScrCompositorEntryInit(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const VBOXVR_TEXTURE *pTex, PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased)
|
---|
341 | {
|
---|
342 | VBoxVrCompositorEntryInit(&pEntry->Ce);
|
---|
343 | pEntry->Tex = *pTex;
|
---|
344 | memset(&pEntry->Pos, 0, sizeof (VBOXVR_SCR_COMPOSITOR_ENTRY) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR_ENTRY, Pos));
|
---|
345 | pEntry->pfnEntryReleased = pfnEntryReleased;
|
---|
346 | }
|
---|
347 |
|
---|
348 | DECLINLINE(bool) CrVrScrCompositorEntryIsUsed(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
349 | {
|
---|
350 | return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
|
---|
351 | }
|
---|
352 |
|
---|
353 | DECLINLINE(void) CrVrScrCompositorEntrySetChanged(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, bool fChanged)
|
---|
354 | {
|
---|
355 | pEntry->fChanged = !!fChanged;
|
---|
356 | }
|
---|
357 |
|
---|
358 | DECLINLINE(void) CrVrScrCompositorEntryTexNameUpdate(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t hwid)
|
---|
359 | {
|
---|
360 | pEntry->Tex.hwid = hwid;
|
---|
361 | CrVrScrCompositorEntrySetChanged(pEntry, true);
|
---|
362 | }
|
---|
363 |
|
---|
364 | DECLINLINE(const VBOXVR_TEXTURE *) CrVrScrCompositorEntryTexGet(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
365 | {
|
---|
366 | return &pEntry->Tex;
|
---|
367 | }
|
---|
368 |
|
---|
369 | DECLINLINE(bool) CrVrScrCompositorEntryIsChanged(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
370 | {
|
---|
371 | return !!pEntry->fChanged;
|
---|
372 | }
|
---|
373 |
|
---|
374 | DECLINLINE(bool) CrVrScrCompositorIsEmpty(const VBOXVR_SCR_COMPOSITOR *pCompositor)
|
---|
375 | {
|
---|
376 | return VBoxVrCompositorIsEmpty(&pCompositor->Compositor);
|
---|
377 | }
|
---|
378 |
|
---|
379 | VBOXVREGDECL(int) CrVrScrCompositorEntryTexUpdate(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const VBOXVR_TEXTURE *pTex);
|
---|
380 | VBOXVREGDECL(void) CrVrScrCompositorVisit(PVBOXVR_SCR_COMPOSITOR pCompositor, PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor);
|
---|
381 | VBOXVREGDECL(void) CrVrScrCompositorEntrySetAllChanged(PVBOXVR_SCR_COMPOSITOR pCompositor, bool fChanged);
|
---|
382 | DECLINLINE(bool) CrVrScrCompositorEntryIsInList(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
383 | {
|
---|
384 | return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
|
---|
385 | }
|
---|
386 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsAdd(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions, bool fPosRelated, VBOXVR_SCR_COMPOSITOR_ENTRY **ppReplacedScrEntry, uint32_t *pfChangeFlags);
|
---|
387 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions, bool fPosRelated, bool *pfChanged);
|
---|
388 | VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged);
|
---|
389 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
390 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
391 | VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, const VBOXVR_LIST *pList2, bool *pfChanged);
|
---|
392 | VBOXVREGDECL(int) CrVrScrCompositorEntryPosSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTPOINT *pPos);
|
---|
393 | DECLINLINE(const RTPOINT*) CrVrScrCompositorEntryPosGet(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
394 | {
|
---|
395 | return &pEntry->Pos;
|
---|
396 | }
|
---|
397 |
|
---|
398 | /* regions are valid until the next CrVrScrCompositor call */
|
---|
399 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsGet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t *pcRegions, const RTRECT **ppaSrcRegions, const RTRECT **ppaDstRegions, const RTRECT **ppaDstUnstretchedRects);
|
---|
400 | VBOXVREGDECL(int) CrVrScrCompositorEntryRemove(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry);
|
---|
401 | VBOXVREGDECL(void) CrVrScrCompositorEntryFlagsSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t fFlags);
|
---|
402 | VBOXVREGDECL(uint32_t) CrVrScrCompositorEntryFlagsCombinedGet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry);
|
---|
403 | DECLINLINE(uint32_t) CrVrScrCompositorEntryFlagsGet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
|
---|
404 | {
|
---|
405 | return pEntry->fFlags;
|
---|
406 | }
|
---|
407 |
|
---|
408 | VBOXVREGDECL(void) CrVrScrCompositorInit(PVBOXVR_SCR_COMPOSITOR pCompositor);
|
---|
409 | VBOXVREGDECL(void) CrVrScrCompositorClear(PVBOXVR_SCR_COMPOSITOR pCompositor);
|
---|
410 | VBOXVREGDECL(void) CrVrScrCompositorRegionsClear(PVBOXVR_SCR_COMPOSITOR pCompositor, bool *pfChanged);
|
---|
411 |
|
---|
412 | typedef DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR(VBOXVR_SCR_COMPOSITOR_ENTRY*pEntry, void *pvContext);
|
---|
413 | typedef FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR *PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR;
|
---|
414 |
|
---|
415 | VBOXVREGDECL(int) CrVrScrCompositorClone(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR pDstCompositor, PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void* pvEntryFor);
|
---|
416 | VBOXVREGDECL(int) CrVrScrCompositorIntersectList(PVBOXVR_SCR_COMPOSITOR pCompositor, const VBOXVR_LIST *pVr, bool *pfChanged);
|
---|
417 | VBOXVREGDECL(int) CrVrScrCompositorIntersectedList(PVBOXVR_SCR_COMPOSITOR pCompositor, const VBOXVR_LIST *pVr, PVBOXVR_SCR_COMPOSITOR pDstCompositor, PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void* pvEntryFor, bool *pfChanged);
|
---|
418 | #ifndef IN_RING0
|
---|
419 | VBOXVREGDECL(void) CrVrScrCompositorSetStretching(PVBOXVR_SCR_COMPOSITOR pCompositor, float StretchX, float StretchY);
|
---|
420 | #endif
|
---|
421 | /* regions are valid until the next CrVrScrCompositor call */
|
---|
422 | VBOXVREGDECL(int) CrVrScrCompositorRegionsGet(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t *pcRegions, const RTRECT **ppaSrcRegions, const RTRECT **ppaDstRegions, const RTRECT **ppaDstUnstretchedRects);
|
---|
423 |
|
---|
424 | #define VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(_p) ((PVBOXVR_SCR_COMPOSITOR_ENTRY)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR_ENTRY, Ce)))
|
---|
425 | #define VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(_p) ((PVBOXVR_SCR_COMPOSITOR)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR, Compositor)))
|
---|
426 |
|
---|
427 | typedef struct VBOXVR_SCR_COMPOSITOR_ITERATOR
|
---|
428 | {
|
---|
429 | VBOXVR_COMPOSITOR_ITERATOR Base;
|
---|
430 | } VBOXVR_SCR_COMPOSITOR_ITERATOR ,*PVBOXVR_SCR_COMPOSITOR_ITERATOR;
|
---|
431 |
|
---|
432 | DECLINLINE(void) CrVrScrCompositorIterInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter)
|
---|
433 | {
|
---|
434 | VBoxVrCompositorIterInit(&pCompositor->Compositor, &pIter->Base);
|
---|
435 | }
|
---|
436 |
|
---|
437 | DECLINLINE(PVBOXVR_SCR_COMPOSITOR_ENTRY) CrVrScrCompositorIterNext(PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter)
|
---|
438 | {
|
---|
439 | PVBOXVR_COMPOSITOR_ENTRY pCe = VBoxVrCompositorIterNext(&pIter->Base);
|
---|
440 | if (pCe)
|
---|
441 | {
|
---|
442 | return VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pCe);
|
---|
443 | }
|
---|
444 | return NULL;
|
---|
445 | }
|
---|
446 |
|
---|
447 | RT_C_DECLS_END
|
---|
448 |
|
---|
449 | #endif /* #ifndef ___cr_vreg_h_ */
|
---|