VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_compositor.h@ 57181

Last change on this file since 57181 was 53588, checked in by vboxsync, 10 years ago

Some style cleanups (no actual changes).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.6 KB
Line 
1/* $Id: cr_compositor.h 53588 2014-12-21 16:13:18Z vboxsync $ */
2/** @file
3 * Compositor API.
4 */
5
6/*
7 * Copyright (C) 2013-2014 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___cr_compositor_h
19#define ___cr_compositor_h
20
21#include "cr_vreg.h"
22#include "cr_blitter.h"
23
24
25/* Compositor with Stretching & Cached Rectangles info */
26
27RT_C_DECLS_BEGIN
28
29struct VBOXVR_SCR_COMPOSITOR_ENTRY;
30struct VBOXVR_SCR_COMPOSITOR;
31
32typedef DECLCALLBACK(void) FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_SCR_COMPOSITOR *pCompositor,
33 struct VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry,
34 struct VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacingEntry);
35typedef FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED;
36
37
38typedef struct VBOXVR_SCR_COMPOSITOR_ENTRY
39{
40 VBOXVR_COMPOSITOR_ENTRY Ce;
41 RTRECT Rect;
42 uint32_t fChanged;
43 uint32_t fFlags;
44 uint32_t cRects;
45 PRTRECT paSrcRects;
46 PRTRECT paDstRects;
47 PRTRECT paDstUnstretchedRects;
48 PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
49 PCR_TEXDATA pTex;
50} VBOXVR_SCR_COMPOSITOR_ENTRY;
51typedef VBOXVR_SCR_COMPOSITOR_ENTRY *PVBOXVR_SCR_COMPOSITOR_ENTRY;
52typedef VBOXVR_SCR_COMPOSITOR_ENTRY const *PCVBOXVR_SCR_COMPOSITOR_ENTRY;
53
54typedef struct VBOXVR_SCR_COMPOSITOR
55{
56 VBOXVR_COMPOSITOR Compositor;
57 RTRECT Rect;
58#ifndef IN_RING0
59 float StretchX;
60 float StretchY;
61#endif
62 uint32_t fFlags;
63 uint32_t cRects;
64 uint32_t cRectsBuffer;
65 PRTRECT paSrcRects;
66 PRTRECT paDstRects;
67 PRTRECT paDstUnstretchedRects;
68} VBOXVR_SCR_COMPOSITOR;
69typedef VBOXVR_SCR_COMPOSITOR *PVBOXVR_SCR_COMPOSITOR;
70typedef VBOXVR_SCR_COMPOSITOR const *PCVBOXVR_SCR_COMPOSITOR;
71
72
73typedef DECLCALLBACK(bool) FNVBOXVRSCRCOMPOSITOR_VISITOR(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
74 void *pvVisitor);
75typedef FNVBOXVRSCRCOMPOSITOR_VISITOR *PFNVBOXVRSCRCOMPOSITOR_VISITOR;
76
77DECLINLINE(void) CrVrScrCompositorEntryInit(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, PCRTRECT pRect, CR_TEXDATA *pTex,
78 PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased)
79{
80 memset(pEntry, 0, sizeof (*pEntry));
81 VBoxVrCompositorEntryInit(&pEntry->Ce);
82 pEntry->Rect = *pRect;
83 pEntry->pfnEntryReleased = pfnEntryReleased;
84 if (pTex)
85 {
86 CrTdAddRef(pTex);
87 pEntry->pTex = pTex;
88 }
89}
90
91DECLINLINE(void) CrVrScrCompositorEntryCleanup(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
92{
93 if (pEntry->pTex)
94 {
95 CrTdRelease(pEntry->pTex);
96 pEntry->pTex = NULL;
97 }
98}
99
100DECLINLINE(bool) CrVrScrCompositorEntryIsUsed(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
101{
102 return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
103}
104
105DECLINLINE(void) CrVrScrCompositorEntrySetChanged(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, bool fChanged)
106{
107 pEntry->fChanged = !!fChanged;
108}
109
110DECLINLINE(void) CrVrScrCompositorEntryTexSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, CR_TEXDATA *pTex)
111{
112 if (pEntry->pTex)
113 CrTdRelease(pEntry->pTex);
114
115 if (pTex)
116 CrTdAddRef(pTex);
117
118 pEntry->pTex = pTex;
119}
120
121DECLINLINE(CR_TEXDATA *) CrVrScrCompositorEntryTexGet(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
122{
123 return pEntry->pTex;
124}
125
126DECLINLINE(bool) CrVrScrCompositorEntryIsChanged(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
127{
128 return !!pEntry->fChanged;
129}
130
131DECLINLINE(bool) CrVrScrCompositorIsEmpty(PCVBOXVR_SCR_COMPOSITOR pCompositor)
132{
133 return VBoxVrCompositorIsEmpty(&pCompositor->Compositor);
134}
135
136VBOXVREGDECL(int) CrVrScrCompositorEntryRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
137 PCRTRECT pRect);
138VBOXVREGDECL(int) CrVrScrCompositorEntryTexAssign(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
139 CR_TEXDATA *pTex);
140VBOXVREGDECL(void) CrVrScrCompositorVisit(PVBOXVR_SCR_COMPOSITOR pCompositor, PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor,
141 void *pvVisitor);
142VBOXVREGDECL(void) CrVrScrCompositorEntrySetAllChanged(PVBOXVR_SCR_COMPOSITOR pCompositor, bool fChanged);
143DECLINLINE(bool) CrVrScrCompositorEntryIsInList(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
144{
145 return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
146}
147VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsAdd(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
148 PCRTPOINT pPos, uint32_t cRegions, PCRTRECT paRegions, bool fPosRelated,
149 VBOXVR_SCR_COMPOSITOR_ENTRY **ppReplacedScrEntry, uint32_t *pfChangeFlags);
150VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
151 PCRTPOINT pPos, uint32_t cRegions, PCRTRECT paRegions, bool fPosRelated,
152 bool *pfChanged);
153VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
154 PCVBOXVR_LIST pList2, bool *pfChanged);
155VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
156 uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged);
157VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRegions,
158 PCRTRECT paRegions, bool *pfChanged);
159VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pList2,
160 bool *pfChanged);
161VBOXVREGDECL(int) CrVrScrCompositorEntryPosSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
162 PCRTPOINT pPos);
163DECLINLINE(PCRTRECT) CrVrScrCompositorEntryRectGet(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
164{
165 return &pEntry->Rect;
166}
167
168/* regions are valid until the next CrVrScrCompositor call */
169VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsGet(PCVBOXVR_SCR_COMPOSITOR pCompositor,
170 PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t *pcRegions,
171 PCRTRECT *ppaSrcRegions, PCRTRECT *ppaDstRegions,
172 PCRTRECT *ppaDstUnstretchedRects);
173VBOXVREGDECL(int) CrVrScrCompositorEntryRemove(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry);
174VBOXVREGDECL(bool) CrVrScrCompositorEntryReplace(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
175 PVBOXVR_SCR_COMPOSITOR_ENTRY pNewEntry);
176VBOXVREGDECL(void) CrVrScrCompositorEntryFlagsSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t fFlags);
177VBOXVREGDECL(uint32_t) CrVrScrCompositorEntryFlagsCombinedGet(PCVBOXVR_SCR_COMPOSITOR pCompositor,
178 PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry);
179DECLINLINE(uint32_t) CrVrScrCompositorEntryFlagsGet(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
180{
181 return pEntry->fFlags;
182}
183
184VBOXVREGDECL(void) CrVrScrCompositorInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect);
185VBOXVREGDECL(int) CrVrScrCompositorRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect, bool *pfChanged);
186DECLINLINE(PCRTRECT) CrVrScrCompositorRectGet(PCVBOXVR_SCR_COMPOSITOR pCompositor)
187{
188 return &pCompositor->Rect;
189}
190
191VBOXVREGDECL(void) CrVrScrCompositorClear(PVBOXVR_SCR_COMPOSITOR pCompositor);
192VBOXVREGDECL(void) CrVrScrCompositorRegionsClear(PVBOXVR_SCR_COMPOSITOR pCompositor, bool *pfChanged);
193
194typedef DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
195 void *pvContext);
196typedef FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR *PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR;
197
198VBOXVREGDECL(int) CrVrScrCompositorClone(PCVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR pDstCompositor,
199 PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void *pvEntryFor);
200VBOXVREGDECL(int) CrVrScrCompositorIntersectList(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pVr, bool *pfChanged);
201VBOXVREGDECL(int) CrVrScrCompositorIntersectedList(PCVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pVr,
202 PVBOXVR_SCR_COMPOSITOR pDstCompositor,
203 PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void *pvEntryFor, bool *pfChanged);
204#ifndef IN_RING0
205VBOXVREGDECL(void) CrVrScrCompositorSetStretching(PVBOXVR_SCR_COMPOSITOR pCompositor, float StretchX, float StretchY);
206DECLINLINE(void) CrVrScrCompositorGetStretching(PCVBOXVR_SCR_COMPOSITOR pCompositor, float *pStretchX, float *pStretchY)
207{
208 if (pStretchX)
209 *pStretchX = pCompositor->StretchX;
210
211 if (pStretchY)
212 *pStretchY = pCompositor->StretchY;
213}
214#endif
215/* regions are valid until the next CrVrScrCompositor call */
216VBOXVREGDECL(int) CrVrScrCompositorRegionsGet(PCVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t *pcRegions,
217 PCRTRECT *ppaSrcRegions, PCRTRECT *ppaDstRegions, PCRTRECT *ppaDstUnstretchedRects);
218
219#define VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(_p) RT_FROM_MEMBER(_p, VBOXVR_SCR_COMPOSITOR_ENTRY, Ce)
220#define VBOXVR_SCR_COMPOSITOR_CONST_ENTRY_FROM_ENTRY(_p) RT_FROM_MEMBER(_p, const VBOXVR_SCR_COMPOSITOR_ENTRY, Ce)
221#define VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(_p) RT_FROM_MEMBER(_p, VBOXVR_SCR_COMPOSITOR, Compositor)
222
223typedef struct VBOXVR_SCR_COMPOSITOR_ITERATOR
224{
225 VBOXVR_COMPOSITOR_ITERATOR Base;
226} VBOXVR_SCR_COMPOSITOR_ITERATOR;
227typedef VBOXVR_SCR_COMPOSITOR_ITERATOR *PVBOXVR_SCR_COMPOSITOR_ITERATOR;
228
229typedef struct VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR
230{
231 VBOXVR_COMPOSITOR_CONST_ITERATOR Base;
232} VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR;
233typedef VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR *PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR;
234
235DECLINLINE(void) CrVrScrCompositorIterInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter)
236{
237 VBoxVrCompositorIterInit(&pCompositor->Compositor, &pIter->Base);
238}
239
240DECLINLINE(void) CrVrScrCompositorConstIterInit(PCVBOXVR_SCR_COMPOSITOR pCompositor,
241 PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR pIter)
242{
243 VBoxVrCompositorConstIterInit(&pCompositor->Compositor, &pIter->Base);
244}
245
246DECLINLINE(PVBOXVR_SCR_COMPOSITOR_ENTRY) CrVrScrCompositorIterNext(PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter)
247{
248 PVBOXVR_COMPOSITOR_ENTRY pCe = VBoxVrCompositorIterNext(&pIter->Base);
249 if (pCe)
250 return VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pCe);
251 return NULL;
252}
253
254DECLINLINE(PCVBOXVR_SCR_COMPOSITOR_ENTRY) CrVrScrCompositorConstIterNext(PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR pIter)
255{
256 PCVBOXVR_COMPOSITOR_ENTRY pCe = VBoxVrCompositorConstIterNext(&pIter->Base);
257 if (pCe)
258 return VBOXVR_SCR_COMPOSITOR_CONST_ENTRY_FROM_ENTRY(pCe);
259 return NULL;
260}
261
262RT_C_DECLS_END
263
264#endif
265
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