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 |
|
---|
27 | RT_C_DECLS_BEGIN
|
---|
28 |
|
---|
29 | struct VBOXVR_SCR_COMPOSITOR_ENTRY;
|
---|
30 | struct VBOXVR_SCR_COMPOSITOR;
|
---|
31 |
|
---|
32 | typedef 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);
|
---|
35 | typedef FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED;
|
---|
36 |
|
---|
37 |
|
---|
38 | typedef 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;
|
---|
51 | typedef VBOXVR_SCR_COMPOSITOR_ENTRY *PVBOXVR_SCR_COMPOSITOR_ENTRY;
|
---|
52 | typedef VBOXVR_SCR_COMPOSITOR_ENTRY const *PCVBOXVR_SCR_COMPOSITOR_ENTRY;
|
---|
53 |
|
---|
54 | typedef 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;
|
---|
69 | typedef VBOXVR_SCR_COMPOSITOR *PVBOXVR_SCR_COMPOSITOR;
|
---|
70 | typedef VBOXVR_SCR_COMPOSITOR const *PCVBOXVR_SCR_COMPOSITOR;
|
---|
71 |
|
---|
72 |
|
---|
73 | typedef DECLCALLBACK(bool) FNVBOXVRSCRCOMPOSITOR_VISITOR(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
|
---|
74 | void *pvVisitor);
|
---|
75 | typedef FNVBOXVRSCRCOMPOSITOR_VISITOR *PFNVBOXVRSCRCOMPOSITOR_VISITOR;
|
---|
76 |
|
---|
77 | DECLINLINE(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 |
|
---|
91 | DECLINLINE(void) CrVrScrCompositorEntryCleanup(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
|
---|
92 | {
|
---|
93 | if (pEntry->pTex)
|
---|
94 | {
|
---|
95 | CrTdRelease(pEntry->pTex);
|
---|
96 | pEntry->pTex = NULL;
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | DECLINLINE(bool) CrVrScrCompositorEntryIsUsed(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
|
---|
101 | {
|
---|
102 | return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
|
---|
103 | }
|
---|
104 |
|
---|
105 | DECLINLINE(void) CrVrScrCompositorEntrySetChanged(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, bool fChanged)
|
---|
106 | {
|
---|
107 | pEntry->fChanged = !!fChanged;
|
---|
108 | }
|
---|
109 |
|
---|
110 | DECLINLINE(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 |
|
---|
121 | DECLINLINE(CR_TEXDATA *) CrVrScrCompositorEntryTexGet(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
|
---|
122 | {
|
---|
123 | return pEntry->pTex;
|
---|
124 | }
|
---|
125 |
|
---|
126 | DECLINLINE(bool) CrVrScrCompositorEntryIsChanged(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
|
---|
127 | {
|
---|
128 | return !!pEntry->fChanged;
|
---|
129 | }
|
---|
130 |
|
---|
131 | DECLINLINE(bool) CrVrScrCompositorIsEmpty(PCVBOXVR_SCR_COMPOSITOR pCompositor)
|
---|
132 | {
|
---|
133 | return VBoxVrCompositorIsEmpty(&pCompositor->Compositor);
|
---|
134 | }
|
---|
135 |
|
---|
136 | VBOXVREGDECL(int) CrVrScrCompositorEntryRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
|
---|
137 | PCRTRECT pRect);
|
---|
138 | VBOXVREGDECL(int) CrVrScrCompositorEntryTexAssign(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
|
---|
139 | CR_TEXDATA *pTex);
|
---|
140 | VBOXVREGDECL(void) CrVrScrCompositorVisit(PVBOXVR_SCR_COMPOSITOR pCompositor, PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor,
|
---|
141 | void *pvVisitor);
|
---|
142 | VBOXVREGDECL(void) CrVrScrCompositorEntrySetAllChanged(PVBOXVR_SCR_COMPOSITOR pCompositor, bool fChanged);
|
---|
143 | DECLINLINE(bool) CrVrScrCompositorEntryIsInList(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
|
---|
144 | {
|
---|
145 | return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
|
---|
146 | }
|
---|
147 | VBOXVREGDECL(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);
|
---|
150 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
|
---|
151 | PCRTPOINT pPos, uint32_t cRegions, PCRTRECT paRegions, bool fPosRelated,
|
---|
152 | bool *pfChanged);
|
---|
153 | VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
|
---|
154 | PCVBOXVR_LIST pList2, bool *pfChanged);
|
---|
155 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
|
---|
156 | uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged);
|
---|
157 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRegions,
|
---|
158 | PCRTRECT paRegions, bool *pfChanged);
|
---|
159 | VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pList2,
|
---|
160 | bool *pfChanged);
|
---|
161 | VBOXVREGDECL(int) CrVrScrCompositorEntryPosSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
|
---|
162 | PCRTPOINT pPos);
|
---|
163 | DECLINLINE(PCRTRECT) CrVrScrCompositorEntryRectGet(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
|
---|
164 | {
|
---|
165 | return &pEntry->Rect;
|
---|
166 | }
|
---|
167 |
|
---|
168 | /* regions are valid until the next CrVrScrCompositor call */
|
---|
169 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsGet(PCVBOXVR_SCR_COMPOSITOR pCompositor,
|
---|
170 | PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t *pcRegions,
|
---|
171 | PCRTRECT *ppaSrcRegions, PCRTRECT *ppaDstRegions,
|
---|
172 | PCRTRECT *ppaDstUnstretchedRects);
|
---|
173 | VBOXVREGDECL(int) CrVrScrCompositorEntryRemove(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry);
|
---|
174 | VBOXVREGDECL(bool) CrVrScrCompositorEntryReplace(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
|
---|
175 | PVBOXVR_SCR_COMPOSITOR_ENTRY pNewEntry);
|
---|
176 | VBOXVREGDECL(void) CrVrScrCompositorEntryFlagsSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t fFlags);
|
---|
177 | VBOXVREGDECL(uint32_t) CrVrScrCompositorEntryFlagsCombinedGet(PCVBOXVR_SCR_COMPOSITOR pCompositor,
|
---|
178 | PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry);
|
---|
179 | DECLINLINE(uint32_t) CrVrScrCompositorEntryFlagsGet(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
|
---|
180 | {
|
---|
181 | return pEntry->fFlags;
|
---|
182 | }
|
---|
183 |
|
---|
184 | VBOXVREGDECL(void) CrVrScrCompositorInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect);
|
---|
185 | VBOXVREGDECL(int) CrVrScrCompositorRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect, bool *pfChanged);
|
---|
186 | DECLINLINE(PCRTRECT) CrVrScrCompositorRectGet(PCVBOXVR_SCR_COMPOSITOR pCompositor)
|
---|
187 | {
|
---|
188 | return &pCompositor->Rect;
|
---|
189 | }
|
---|
190 |
|
---|
191 | VBOXVREGDECL(void) CrVrScrCompositorClear(PVBOXVR_SCR_COMPOSITOR pCompositor);
|
---|
192 | VBOXVREGDECL(void) CrVrScrCompositorRegionsClear(PVBOXVR_SCR_COMPOSITOR pCompositor, bool *pfChanged);
|
---|
193 |
|
---|
194 | typedef DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry,
|
---|
195 | void *pvContext);
|
---|
196 | typedef FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR *PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR;
|
---|
197 |
|
---|
198 | VBOXVREGDECL(int) CrVrScrCompositorClone(PCVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR pDstCompositor,
|
---|
199 | PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void *pvEntryFor);
|
---|
200 | VBOXVREGDECL(int) CrVrScrCompositorIntersectList(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pVr, bool *pfChanged);
|
---|
201 | VBOXVREGDECL(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
|
---|
205 | VBOXVREGDECL(void) CrVrScrCompositorSetStretching(PVBOXVR_SCR_COMPOSITOR pCompositor, float StretchX, float StretchY);
|
---|
206 | DECLINLINE(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 */
|
---|
216 | VBOXVREGDECL(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 |
|
---|
223 | typedef struct VBOXVR_SCR_COMPOSITOR_ITERATOR
|
---|
224 | {
|
---|
225 | VBOXVR_COMPOSITOR_ITERATOR Base;
|
---|
226 | } VBOXVR_SCR_COMPOSITOR_ITERATOR;
|
---|
227 | typedef VBOXVR_SCR_COMPOSITOR_ITERATOR *PVBOXVR_SCR_COMPOSITOR_ITERATOR;
|
---|
228 |
|
---|
229 | typedef struct VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR
|
---|
230 | {
|
---|
231 | VBOXVR_COMPOSITOR_CONST_ITERATOR Base;
|
---|
232 | } VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR;
|
---|
233 | typedef VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR *PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR;
|
---|
234 |
|
---|
235 | DECLINLINE(void) CrVrScrCompositorIterInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter)
|
---|
236 | {
|
---|
237 | VBoxVrCompositorIterInit(&pCompositor->Compositor, &pIter->Base);
|
---|
238 | }
|
---|
239 |
|
---|
240 | DECLINLINE(void) CrVrScrCompositorConstIterInit(PCVBOXVR_SCR_COMPOSITOR pCompositor,
|
---|
241 | PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR pIter)
|
---|
242 | {
|
---|
243 | VBoxVrCompositorConstIterInit(&pCompositor->Compositor, &pIter->Base);
|
---|
244 | }
|
---|
245 |
|
---|
246 | DECLINLINE(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 |
|
---|
254 | DECLINLINE(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 |
|
---|
262 | RT_C_DECLS_END
|
---|
263 |
|
---|
264 | #endif
|
---|
265 |
|
---|