VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_vreg.h@ 50333

最後變更 在這個檔案從50333是 50316,由 vboxsync 提交於 11 年 前

warnings

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 13.4 KB
 
1/* $Id: cr_vreg.h 50316 2014-02-04 08:03:23Z 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.alldomusa.eu.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#include <iprt/asm.h>
28
29#ifndef IN_RING0
30# define VBOXVREGDECL(_type) DECLEXPORT(_type)
31#else
32# define VBOXVREGDECL(_type) RTDECL(_type)
33#endif
34
35
36
37RT_C_DECLS_BEGIN
38
39typedef struct VBOXVR_LIST
40{
41 RTLISTNODE ListHead;
42 uint32_t cEntries;
43} VBOXVR_LIST, *PVBOXVR_LIST;
44
45DECLINLINE(int) VBoxRectCmp(const RTRECT * pRect1, const RTRECT * pRect2)
46{
47 return memcmp(pRect1, pRect2, sizeof (*pRect1));
48}
49
50#ifndef IN_RING0
51DECLINLINE(void) VBoxRectStretch(PRTRECT pRect, float xStretch, float yStretch)
52{
53 pRect->xLeft = (int32_t)(pRect->xLeft * xStretch);
54 pRect->yTop = (int32_t)(pRect->yTop * yStretch);
55 pRect->xRight = (int32_t)(pRect->xRight * xStretch);
56 pRect->yBottom = (int32_t)(pRect->yBottom * yStretch);
57}
58
59DECLINLINE(void) VBoxRectStretched(const RTRECT *pRect, float xStretch, float yStretch, PRTRECT pResult)
60{
61 *pResult = *pRect;
62 VBoxRectStretch(pResult, xStretch, yStretch);
63}
64#endif
65
66DECLINLINE(void) VBoxRectIntersect(PRTRECT pRect1, const RTRECT * pRect2)
67{
68 Assert(pRect1);
69 Assert(pRect2);
70 pRect1->xLeft = RT_MAX(pRect1->xLeft, pRect2->xLeft);
71 pRect1->yTop = RT_MAX(pRect1->yTop, pRect2->yTop);
72 pRect1->xRight = RT_MIN(pRect1->xRight, pRect2->xRight);
73 pRect1->yBottom = RT_MIN(pRect1->yBottom, pRect2->yBottom);
74}
75
76DECLINLINE(void) VBoxRectIntersected(const RTRECT *pRect1, const RTRECT * pRect2, RTRECT *pResult)
77{
78 *pResult = *pRect1;
79 VBoxRectIntersect(pResult, pRect2);
80}
81
82
83DECLINLINE(void) VBoxRectTranslate(RTRECT * pRect, int32_t x, int32_t y)
84{
85 pRect->xLeft += x;
86 pRect->yTop += y;
87 pRect->xRight += x;
88 pRect->yBottom += y;
89}
90
91DECLINLINE(void) VBoxRectTranslated(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
92{
93 *pResult = *pRect;
94 VBoxRectTranslate(pResult, x, y);
95}
96
97DECLINLINE(void) VBoxRectInvertY(RTRECT * pRect)
98{
99 int32_t y = pRect->yTop;
100 pRect->yTop = pRect->yBottom;
101 pRect->yBottom = y;
102}
103
104DECLINLINE(void) VBoxRectInvertedY(const RTRECT * pRect, RTRECT * pResult)
105{
106 *pResult = *pRect;
107 VBoxRectInvertY(pResult);
108}
109
110DECLINLINE(void) VBoxRectMove(RTRECT * pRect, int32_t x, int32_t y)
111{
112 int32_t w = pRect->xRight - pRect->xLeft;
113 int32_t h = pRect->yBottom - pRect->yTop;
114 pRect->xLeft = x;
115 pRect->yTop = y;
116 pRect->xRight = w + x;
117 pRect->yBottom = h + y;
118}
119
120DECLINLINE(void) VBoxRectMoved(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
121{
122 *pResult = *pRect;
123 VBoxRectMove(pResult, x, y);
124}
125
126DECLINLINE(bool) VBoxRectCovers(const RTRECT *pRect, const RTRECT *pCovered)
127{
128 Assert(pRect);
129 Assert(pCovered);
130 if (pRect->xLeft > pCovered->xLeft)
131 return false;
132 if (pRect->yTop > pCovered->yTop)
133 return false;
134 if (pRect->xRight < pCovered->xRight)
135 return false;
136 if (pRect->yBottom < pCovered->yBottom)
137 return false;
138 return true;
139}
140
141DECLINLINE(bool) VBoxRectIsZero(const RTRECT *pRect)
142{
143 return pRect->xLeft == pRect->xRight || pRect->yTop == pRect->yBottom;
144}
145
146DECLINLINE(bool) VBoxRectIsIntersect(const RTRECT * pRect1, const RTRECT * pRect2)
147{
148 return !((pRect1->xLeft < pRect2->xLeft && pRect1->xRight <= pRect2->xLeft)
149 || (pRect2->xLeft < pRect1->xLeft && pRect2->xRight <= pRect1->xLeft)
150 || (pRect1->yTop < pRect2->yTop && pRect1->yBottom <= pRect2->yTop)
151 || (pRect2->yTop < pRect1->yTop && pRect2->yBottom <= pRect1->yTop));
152}
153
154DECLINLINE(uint32_t) VBoxVrListRectsCount(const VBOXVR_LIST *pList)
155{
156 return pList->cEntries;
157}
158
159DECLINLINE(bool) VBoxVrListIsEmpty(const VBOXVR_LIST *pList)
160{
161 return !VBoxVrListRectsCount(pList);
162}
163
164DECLINLINE(void) VBoxVrListInit(PVBOXVR_LIST pList)
165{
166 RTListInit(&pList->ListHead);
167 pList->cEntries = 0;
168}
169
170VBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList);
171
172/* moves list data to pDstList and empties the pList */
173VBOXVREGDECL(void) VBoxVrListMoveTo(PVBOXVR_LIST pList, PVBOXVR_LIST pDstList);
174
175VBOXVREGDECL(void) VBoxVrListTranslate(PVBOXVR_LIST pList, int32_t x, int32_t y);
176
177VBOXVREGDECL(int) VBoxVrListCmp(const VBOXVR_LIST *pList1, const VBOXVR_LIST *pList2);
178
179VBOXVREGDECL(int) VBoxVrListRectsSet(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
180VBOXVREGDECL(int) VBoxVrListRectsAdd(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
181VBOXVREGDECL(int) VBoxVrListRectsSubst(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
182VBOXVREGDECL(int) VBoxVrListRectsGet(PVBOXVR_LIST pList, uint32_t cRects, RTRECT * aRects);
183
184VBOXVREGDECL(int) VBoxVrListClone(const VBOXVR_LIST *pList, VBOXVR_LIST *pDstList);
185
186/* NOTE: with the current implementation the VBoxVrListIntersect is faster than VBoxVrListRectsIntersect,
187 * i.e. VBoxVrListRectsIntersect is actually a convenience function that create a temporary list and calls VBoxVrListIntersect internally */
188VBOXVREGDECL(int) VBoxVrListRectsIntersect(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
189VBOXVREGDECL(int) VBoxVrListIntersect(PVBOXVR_LIST pList, const VBOXVR_LIST *pList2, bool *pfChanged);
190
191VBOXVREGDECL(int) VBoxVrInit(void);
192VBOXVREGDECL(void) VBoxVrTerm(void);
193
194typedef struct VBOXVR_LIST_ITERATOR
195{
196 PVBOXVR_LIST pList;
197 PRTLISTNODE pNextEntry;
198} VBOXVR_LIST_ITERATOR, *PVBOXVR_LIST_ITERATOR;
199
200DECLINLINE(void) VBoxVrListIterInit(PVBOXVR_LIST pList, PVBOXVR_LIST_ITERATOR pIter)
201{
202 pIter->pList = pList;
203 pIter->pNextEntry = pList->ListHead.pNext;
204}
205
206typedef struct VBOXVR_REG
207{
208 RTLISTNODE ListEntry;
209 RTRECT Rect;
210} VBOXVR_REG, *PVBOXVR_REG;
211
212#define PVBOXVR_REG_FROM_ENTRY(_pEntry) ((PVBOXVR_REG)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXVR_REG, ListEntry)))
213
214DECLINLINE(PCRTRECT) VBoxVrListIterNext(PVBOXVR_LIST_ITERATOR pIter)
215{
216 PRTLISTNODE pNextEntry = pIter->pNextEntry;
217 if (pNextEntry != &pIter->pList->ListHead)
218 {
219 PCRTRECT pRect = &(PVBOXVR_REG_FROM_ENTRY(pNextEntry)->Rect);
220 pIter->pNextEntry = pNextEntry->pNext;
221 return pRect;
222 }
223 return NULL;
224}
225
226typedef struct VBOXVR_COMPOSITOR_ENTRY
227{
228 RTLISTNODE Node;
229 VBOXVR_LIST Vr;
230 uint32_t cRefs;
231} VBOXVR_COMPOSITOR_ENTRY, *PVBOXVR_COMPOSITOR_ENTRY;
232
233struct VBOXVR_COMPOSITOR;
234
235typedef DECLCALLBACK(void) FNVBOXVRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry);
236typedef FNVBOXVRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED;
237
238typedef struct VBOXVR_COMPOSITOR
239{
240 RTLISTNODE List;
241 PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
242} VBOXVR_COMPOSITOR, *PVBOXVR_COMPOSITOR;
243
244typedef DECLCALLBACK(bool) FNVBOXVRCOMPOSITOR_VISITOR(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
245typedef FNVBOXVRCOMPOSITOR_VISITOR *PFNVBOXVRCOMPOSITOR_VISITOR;
246
247VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased);
248VBOXVREGDECL(void) VBoxVrCompositorClear(PVBOXVR_COMPOSITOR pCompositor);
249VBOXVREGDECL(void) VBoxVrCompositorRegionsClear(PVBOXVR_COMPOSITOR pCompositor, bool *pfChanged);
250VBOXVREGDECL(void) VBoxVrCompositorEntryInit(PVBOXVR_COMPOSITOR_ENTRY pEntry);
251DECLINLINE(bool) VBoxVrCompositorEntryIsInList(const VBOXVR_COMPOSITOR_ENTRY *pEntry)
252{
253 return !VBoxVrListIsEmpty(&pEntry->Vr);
254}
255
256#define CRBLT_F_LINEAR 0x00000001
257#define CRBLT_F_INVERT_SRC_YCOORDS 0x00000002
258#define CRBLT_F_INVERT_DST_YCOORDS 0x00000004
259#define CRBLT_F_INVERT_YCOORDS (CRBLT_F_INVERT_SRC_YCOORDS | CRBLT_F_INVERT_DST_YCOORDS)
260/* the blit operation with discard the source alpha channel values and set the destination alpha values to 1.0 */
261#define CRBLT_F_NOALPHA 0x00000010
262
263#define CRBLT_FTYPE_XOR CRBLT_F_INVERT_YCOORDS
264#define CRBLT_FTYPE_OR (CRBLT_F_LINEAR | CRBLT_F_NOALPHA)
265#define CRBLT_FOP_COMBINE(_f1, _f2) ((((_f1) ^ (_f2)) & CRBLT_FTYPE_XOR) | (((_f1) | (_f2)) & CRBLT_FTYPE_OR))
266
267#define CRBLT_FLAGS_FROM_FILTER(_f) ( ((_f) & GL_LINEAR) ? CRBLT_F_LINEAR : 0)
268#define CRBLT_FILTER_FROM_FLAGS(_f) (((_f) & CRBLT_F_LINEAR) ? GL_LINEAR : GL_NEAREST)
269
270/* compositor regions changed */
271#define VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED 0x00000001
272/* other entries changed along while doing current entry modification
273 * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */
274#define VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED 0x00000002
275/* only current entry regions changed
276 * can come wither with VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED or with VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED */
277#define VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED 0x00000004
278/* the given entry has replaced some other entry, while overal regions did NOT change.
279 * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */
280#define VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED 0x00000008
281
282
283VBOXVREGDECL(bool) VBoxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry);
284VBOXVREGDECL(bool) VBoxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pNewEntry);
285VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, PVBOXVR_COMPOSITOR_ENTRY *ppReplacedEntry, uint32_t *pfChangeFlags);
286VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
287VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSet(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
288VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
289VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged);
290VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersectAll(PVBOXVR_COMPOSITOR pCompositor, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
291VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersectAll(PVBOXVR_COMPOSITOR pCompositor, const VBOXVR_LIST *pList2, bool *pfChanged);
292VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsTranslate(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, int32_t x, int32_t y, bool *pfChanged);
293VBOXVREGDECL(void) VBoxVrCompositorVisit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor);
294
295DECLINLINE(bool) VBoxVrCompositorIsEmpty(const VBOXVR_COMPOSITOR *pCompositor)
296{
297 return RTListIsEmpty(&pCompositor->List);
298}
299
300typedef struct VBOXVR_COMPOSITOR_ITERATOR
301{
302 PVBOXVR_COMPOSITOR pCompositor;
303 PRTLISTNODE pNextEntry;
304} VBOXVR_COMPOSITOR_ITERATOR ,*PVBOXVR_COMPOSITOR_ITERATOR;
305
306typedef struct VBOXVR_COMPOSITOR_CONST_ITERATOR
307{
308 const VBOXVR_COMPOSITOR *pCompositor;
309 const RTLISTNODE *pNextEntry;
310} VBOXVR_COMPOSITOR_CONST_ITERATOR ,*PVBOXVR_COMPOSITOR_CONST_ITERATOR;
311
312DECLINLINE(void) VBoxVrCompositorIterInit(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ITERATOR pIter)
313{
314 pIter->pCompositor = pCompositor;
315 pIter->pNextEntry = pCompositor->List.pNext;
316}
317
318DECLINLINE(void) VBoxVrCompositorConstIterInit(const VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter)
319{
320 pIter->pCompositor = pCompositor;
321 pIter->pNextEntry = pCompositor->List.pNext;
322}
323
324#define VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(_p) ((PVBOXVR_COMPOSITOR_ENTRY)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_COMPOSITOR_ENTRY, Node)))
325#define VBOXVR_COMPOSITOR_CONST_ENTRY_FROM_NODE(_p) ((const VBOXVR_COMPOSITOR_ENTRY*)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_COMPOSITOR_ENTRY, Node)))
326
327DECLINLINE(PVBOXVR_COMPOSITOR_ENTRY) VBoxVrCompositorIterNext(PVBOXVR_COMPOSITOR_ITERATOR pIter)
328{
329 PRTLISTNODE pNextEntry = pIter->pNextEntry;
330 if (pNextEntry != &pIter->pCompositor->List)
331 {
332 PVBOXVR_COMPOSITOR_ENTRY pEntry = VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(pNextEntry);
333 pIter->pNextEntry = pNextEntry->pNext;
334 return pEntry;
335 }
336 return NULL;
337}
338
339DECLINLINE(const VBOXVR_COMPOSITOR_ENTRY*) VBoxVrCompositorConstIterNext(PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter)
340{
341 const RTLISTNODE *pNextEntry = pIter->pNextEntry;
342 if (pNextEntry != &pIter->pCompositor->List)
343 {
344 const VBOXVR_COMPOSITOR_ENTRY *pEntry = VBOXVR_COMPOSITOR_CONST_ENTRY_FROM_NODE(pNextEntry);
345 pIter->pNextEntry = pNextEntry->pNext;
346 return pEntry;
347 }
348 return NULL;
349}
350
351typedef struct VBOXVR_TEXTURE
352{
353 int32_t width;
354 int32_t height;
355 uint32_t target;
356 uint32_t hwid;
357} VBOXVR_TEXTURE, *PVBOXVR_TEXTURE;
358
359RT_C_DECLS_END
360
361#endif /* #ifndef ___cr_vreg_h_ */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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