1 | /* $Id: cr_compositor.h 50095 2014-01-17 16:34:07Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * uint32_t compositor API
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2013 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_compositor_h_
|
---|
19 | #define ___cr_compositor_h_
|
---|
20 | #include <cr_vreg.h>
|
---|
21 | #include <cr_blitter.h>
|
---|
22 |
|
---|
23 | /* Compositor with Stretching & Cached Rectangles info */
|
---|
24 |
|
---|
25 | RT_C_DECLS_BEGIN
|
---|
26 |
|
---|
27 | struct VBOXVR_SCR_COMPOSITOR_ENTRY;
|
---|
28 | struct VBOXVR_SCR_COMPOSITOR;
|
---|
29 |
|
---|
30 | typedef DECLCALLBACK(void) FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_SCR_COMPOSITOR *pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacingEntry);
|
---|
31 | typedef FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED;
|
---|
32 |
|
---|
33 |
|
---|
34 | typedef struct VBOXVR_SCR_COMPOSITOR_ENTRY
|
---|
35 | {
|
---|
36 | VBOXVR_COMPOSITOR_ENTRY Ce;
|
---|
37 | RTRECT Rect;
|
---|
38 | uint32_t fChanged;
|
---|
39 | uint32_t fFlags;
|
---|
40 | uint32_t cRects;
|
---|
41 | PRTRECT paSrcRects;
|
---|
42 | PRTRECT paDstRects;
|
---|
43 | PRTRECT paDstUnstretchedRects;
|
---|
44 | PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
|
---|
45 | PCR_TEXDATA pTex;
|
---|
46 | } VBOXVR_SCR_COMPOSITOR_ENTRY, *PVBOXVR_SCR_COMPOSITOR_ENTRY;
|
---|
47 |
|
---|
48 | typedef struct VBOXVR_SCR_COMPOSITOR
|
---|
49 | {
|
---|
50 | VBOXVR_COMPOSITOR Compositor;
|
---|
51 | RTRECT Rect;
|
---|
52 | #ifndef IN_RING0
|
---|
53 | float StretchX;
|
---|
54 | float StretchY;
|
---|
55 | #endif
|
---|
56 | uint32_t fFlags;
|
---|
57 | uint32_t cRects;
|
---|
58 | uint32_t cRectsBuffer;
|
---|
59 | PRTRECT paSrcRects;
|
---|
60 | PRTRECT paDstRects;
|
---|
61 | PRTRECT paDstUnstretchedRects;
|
---|
62 | } VBOXVR_SCR_COMPOSITOR, *PVBOXVR_SCR_COMPOSITOR;
|
---|
63 |
|
---|
64 |
|
---|
65 | typedef DECLCALLBACK(bool) FNVBOXVRSCRCOMPOSITOR_VISITOR(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
|
---|
66 | typedef FNVBOXVRSCRCOMPOSITOR_VISITOR *PFNVBOXVRSCRCOMPOSITOR_VISITOR;
|
---|
67 |
|
---|
68 | DECLINLINE(void) CrVrScrCompositorEntryInit(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTRECT *pRect, CR_TEXDATA *pTex, PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased)
|
---|
69 | {
|
---|
70 | memset(pEntry, 0, sizeof (*pEntry));
|
---|
71 | VBoxVrCompositorEntryInit(&pEntry->Ce);
|
---|
72 | pEntry->Rect = *pRect;
|
---|
73 | pEntry->pfnEntryReleased = pfnEntryReleased;
|
---|
74 | if (pTex)
|
---|
75 | {
|
---|
76 | CrTdAddRef(pTex);
|
---|
77 | pEntry->pTex = pTex;
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | DECLINLINE(void) CrVrScrCompositorEntryCleanup(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
|
---|
82 | {
|
---|
83 | if (pEntry->pTex)
|
---|
84 | {
|
---|
85 | CrTdRelease(pEntry->pTex);
|
---|
86 | pEntry->pTex = NULL;
|
---|
87 | }
|
---|
88 | }
|
---|
89 |
|
---|
90 | DECLINLINE(bool) CrVrScrCompositorEntryIsUsed(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
91 | {
|
---|
92 | return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
|
---|
93 | }
|
---|
94 |
|
---|
95 | DECLINLINE(void) CrVrScrCompositorEntrySetChanged(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, bool fChanged)
|
---|
96 | {
|
---|
97 | pEntry->fChanged = !!fChanged;
|
---|
98 | }
|
---|
99 |
|
---|
100 | DECLINLINE(void) CrVrScrCompositorEntryTexSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, CR_TEXDATA *pTex)
|
---|
101 | {
|
---|
102 | if (pEntry->pTex)
|
---|
103 | CrTdRelease(pEntry->pTex);
|
---|
104 |
|
---|
105 | if (pTex)
|
---|
106 | CrTdAddRef(pTex);
|
---|
107 |
|
---|
108 | pEntry->pTex = pTex;
|
---|
109 | }
|
---|
110 |
|
---|
111 | DECLINLINE(CR_TEXDATA *) CrVrScrCompositorEntryTexGet(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
112 | {
|
---|
113 | return pEntry->pTex;
|
---|
114 | }
|
---|
115 |
|
---|
116 | DECLINLINE(bool) CrVrScrCompositorEntryIsChanged(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
117 | {
|
---|
118 | return !!pEntry->fChanged;
|
---|
119 | }
|
---|
120 |
|
---|
121 | DECLINLINE(bool) CrVrScrCompositorIsEmpty(const VBOXVR_SCR_COMPOSITOR *pCompositor)
|
---|
122 | {
|
---|
123 | return VBoxVrCompositorIsEmpty(&pCompositor->Compositor);
|
---|
124 | }
|
---|
125 |
|
---|
126 | VBOXVREGDECL(int) CrVrScrCompositorEntryRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTRECT *pRect);
|
---|
127 | VBOXVREGDECL(int) CrVrScrCompositorEntryTexAssign(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, CR_TEXDATA *pTex);
|
---|
128 | VBOXVREGDECL(void) CrVrScrCompositorVisit(PVBOXVR_SCR_COMPOSITOR pCompositor, PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor);
|
---|
129 | VBOXVREGDECL(void) CrVrScrCompositorEntrySetAllChanged(PVBOXVR_SCR_COMPOSITOR pCompositor, bool fChanged);
|
---|
130 | DECLINLINE(bool) CrVrScrCompositorEntryIsInList(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
131 | {
|
---|
132 | return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
|
---|
133 | }
|
---|
134 | 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);
|
---|
135 | 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);
|
---|
136 | VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged);
|
---|
137 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
138 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
139 | VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, const VBOXVR_LIST *pList2, bool *pfChanged);
|
---|
140 | VBOXVREGDECL(int) CrVrScrCompositorEntryPosSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTPOINT *pPos);
|
---|
141 | DECLINLINE(const RTRECT*) CrVrScrCompositorEntryRectGet(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
142 | {
|
---|
143 | return &pEntry->Rect;
|
---|
144 | }
|
---|
145 |
|
---|
146 | /* regions are valid until the next CrVrScrCompositor call */
|
---|
147 | VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsGet(const VBOXVR_SCR_COMPOSITOR *pCompositor, const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry, uint32_t *pcRegions, const RTRECT **ppaSrcRegions, const RTRECT **ppaDstRegions, const RTRECT **ppaDstUnstretchedRects);
|
---|
148 | VBOXVREGDECL(int) CrVrScrCompositorEntryRemove(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry);
|
---|
149 | VBOXVREGDECL(bool) CrVrScrCompositorEntryReplace(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, PVBOXVR_SCR_COMPOSITOR_ENTRY pNewEntry);
|
---|
150 | VBOXVREGDECL(void) CrVrScrCompositorEntryFlagsSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t fFlags);
|
---|
151 | VBOXVREGDECL(uint32_t) CrVrScrCompositorEntryFlagsCombinedGet(const VBOXVR_SCR_COMPOSITOR *pCompositor, const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry);
|
---|
152 | DECLINLINE(uint32_t) CrVrScrCompositorEntryFlagsGet(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
|
---|
153 | {
|
---|
154 | return pEntry->fFlags;
|
---|
155 | }
|
---|
156 |
|
---|
157 | VBOXVREGDECL(void) CrVrScrCompositorInit(PVBOXVR_SCR_COMPOSITOR pCompositor, const RTRECT *pRect);
|
---|
158 | VBOXVREGDECL(int) CrVrScrCompositorRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, const RTRECT *pRect, bool *pfChanged);
|
---|
159 | DECLINLINE(const RTRECT*) CrVrScrCompositorRectGet(const VBOXVR_SCR_COMPOSITOR *pCompositor)
|
---|
160 | {
|
---|
161 | return &pCompositor->Rect;
|
---|
162 | }
|
---|
163 |
|
---|
164 | VBOXVREGDECL(void) CrVrScrCompositorClear(PVBOXVR_SCR_COMPOSITOR pCompositor);
|
---|
165 | VBOXVREGDECL(void) CrVrScrCompositorRegionsClear(PVBOXVR_SCR_COMPOSITOR pCompositor, bool *pfChanged);
|
---|
166 |
|
---|
167 | typedef DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR(const VBOXVR_SCR_COMPOSITOR_ENTRY*pEntry, void *pvContext);
|
---|
168 | typedef FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR *PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR;
|
---|
169 |
|
---|
170 | VBOXVREGDECL(int) CrVrScrCompositorClone(const VBOXVR_SCR_COMPOSITOR *pCompositor, PVBOXVR_SCR_COMPOSITOR pDstCompositor, PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void* pvEntryFor);
|
---|
171 | VBOXVREGDECL(int) CrVrScrCompositorIntersectList(PVBOXVR_SCR_COMPOSITOR pCompositor, const VBOXVR_LIST *pVr, bool *pfChanged);
|
---|
172 | VBOXVREGDECL(int) CrVrScrCompositorIntersectedList(const VBOXVR_SCR_COMPOSITOR *pCompositor, const VBOXVR_LIST *pVr, PVBOXVR_SCR_COMPOSITOR pDstCompositor, PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void* pvEntryFor, bool *pfChanged);
|
---|
173 | #ifndef IN_RING0
|
---|
174 | VBOXVREGDECL(void) CrVrScrCompositorSetStretching(PVBOXVR_SCR_COMPOSITOR pCompositor, float StretchX, float StretchY);
|
---|
175 | DECLINLINE(void) CrVrScrCompositorGetStretching(const VBOXVR_SCR_COMPOSITOR *pCompositor, float *pStretchX, float *pStretchY)
|
---|
176 | {
|
---|
177 | if (pStretchX)
|
---|
178 | *pStretchX = pCompositor->StretchX;
|
---|
179 |
|
---|
180 | if (pStretchY)
|
---|
181 | *pStretchY = pCompositor->StretchY;
|
---|
182 | }
|
---|
183 | #endif
|
---|
184 | /* regions are valid until the next CrVrScrCompositor call */
|
---|
185 | VBOXVREGDECL(int) CrVrScrCompositorRegionsGet(const VBOXVR_SCR_COMPOSITOR *pCompositor, uint32_t *pcRegions, const RTRECT **ppaSrcRegions, const RTRECT **ppaDstRegions, const RTRECT **ppaDstUnstretchedRects);
|
---|
186 |
|
---|
187 | #define VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(_p) ((PVBOXVR_SCR_COMPOSITOR_ENTRY)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR_ENTRY, Ce)))
|
---|
188 | #define VBOXVR_SCR_COMPOSITOR_CONST_ENTRY_FROM_ENTRY(_p) ((const VBOXVR_SCR_COMPOSITOR_ENTRY*)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR_ENTRY, Ce)))
|
---|
189 | #define VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(_p) ((PVBOXVR_SCR_COMPOSITOR)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR, Compositor)))
|
---|
190 |
|
---|
191 | typedef struct VBOXVR_SCR_COMPOSITOR_ITERATOR
|
---|
192 | {
|
---|
193 | VBOXVR_COMPOSITOR_ITERATOR Base;
|
---|
194 | } VBOXVR_SCR_COMPOSITOR_ITERATOR ,*PVBOXVR_SCR_COMPOSITOR_ITERATOR;
|
---|
195 |
|
---|
196 | typedef struct VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR
|
---|
197 | {
|
---|
198 | VBOXVR_COMPOSITOR_CONST_ITERATOR Base;
|
---|
199 | } VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR ,*PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR;
|
---|
200 |
|
---|
201 | DECLINLINE(void) CrVrScrCompositorIterInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter)
|
---|
202 | {
|
---|
203 | VBoxVrCompositorIterInit(&pCompositor->Compositor, &pIter->Base);
|
---|
204 | }
|
---|
205 |
|
---|
206 | DECLINLINE(void) CrVrScrCompositorConstIterInit(const VBOXVR_SCR_COMPOSITOR *pCompositor, PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR pIter)
|
---|
207 | {
|
---|
208 | VBoxVrCompositorConstIterInit(&pCompositor->Compositor, &pIter->Base);
|
---|
209 | }
|
---|
210 |
|
---|
211 | DECLINLINE(PVBOXVR_SCR_COMPOSITOR_ENTRY) CrVrScrCompositorIterNext(PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter)
|
---|
212 | {
|
---|
213 | PVBOXVR_COMPOSITOR_ENTRY pCe = VBoxVrCompositorIterNext(&pIter->Base);
|
---|
214 | if (pCe)
|
---|
215 | {
|
---|
216 | return VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pCe);
|
---|
217 | }
|
---|
218 | return NULL;
|
---|
219 | }
|
---|
220 |
|
---|
221 | DECLINLINE(const VBOXVR_SCR_COMPOSITOR_ENTRY*) CrVrScrCompositorConstIterNext(PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR pIter)
|
---|
222 | {
|
---|
223 | const VBOXVR_COMPOSITOR_ENTRY *pCe = VBoxVrCompositorConstIterNext(&pIter->Base);
|
---|
224 | if (pCe)
|
---|
225 | {
|
---|
226 | return VBOXVR_SCR_COMPOSITOR_CONST_ENTRY_FROM_ENTRY(pCe);
|
---|
227 | }
|
---|
228 | return NULL;
|
---|
229 | }
|
---|
230 |
|
---|
231 | RT_C_DECLS_END
|
---|
232 |
|
---|
233 | #endif /* ___cr_compositor_h_ */
|
---|