1 | /* $Id: cr_vreg.h 43888 2012-11-15 21:23:50Z 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 |
|
---|
27 | #ifndef IN_RING0
|
---|
28 | # define VBOXVREGDECL(_type) DECLEXPORT(_type)
|
---|
29 | #else
|
---|
30 | # define VBOXVREGDECL(_type) RTDECL(_type)
|
---|
31 | #endif
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 | RT_C_DECLS_BEGIN
|
---|
36 |
|
---|
37 | typedef struct VBOXVR_LIST
|
---|
38 | {
|
---|
39 | RTLISTNODE ListHead;
|
---|
40 | uint32_t cEntries;
|
---|
41 | } VBOXVR_LIST, *PVBOXVR_LIST;
|
---|
42 |
|
---|
43 | DECLINLINE(int) VBoxRectCmp(const RTRECT * pRect1, const RTRECT * pRect2)
|
---|
44 | {
|
---|
45 | return memcmp(pRect1, pRect2, sizeof (*pRect1));
|
---|
46 | }
|
---|
47 |
|
---|
48 | DECLINLINE(void) VBoxRectTranslate(RTRECT * pRect, int32_t x, int32_t y)
|
---|
49 | {
|
---|
50 | pRect->xLeft += x;
|
---|
51 | pRect->yTop += y;
|
---|
52 | pRect->xRight += x;
|
---|
53 | pRect->yBottom += y;
|
---|
54 | }
|
---|
55 |
|
---|
56 | DECLINLINE(void) VBoxRectMove(RTRECT * pRect, int32_t x, int32_t y)
|
---|
57 | {
|
---|
58 | int32_t w = pRect->xRight - pRect->xLeft;
|
---|
59 | int32_t h = pRect->yBottom - pRect->yTop;
|
---|
60 | pRect->xLeft = x;
|
---|
61 | pRect->yTop = y;
|
---|
62 | pRect->xRight = w + x;
|
---|
63 | pRect->yBottom = h + y;
|
---|
64 | }
|
---|
65 |
|
---|
66 | DECLINLINE(bool) VBoxRectIsCoveres(const RTRECT *pRect, const RTRECT *pCovered)
|
---|
67 | {
|
---|
68 | Assert(pRect);
|
---|
69 | Assert(pCovered);
|
---|
70 | if (pRect->xLeft > pCovered->xLeft)
|
---|
71 | return false;
|
---|
72 | if (pRect->yTop > pCovered->yTop)
|
---|
73 | return false;
|
---|
74 | if (pRect->xRight < pCovered->xRight)
|
---|
75 | return false;
|
---|
76 | if (pRect->yBottom < pCovered->yBottom)
|
---|
77 | return false;
|
---|
78 | return true;
|
---|
79 | }
|
---|
80 |
|
---|
81 | DECLINLINE(bool) VBoxRectIsIntersect(const RTRECT * pRect1, const RTRECT * pRect2)
|
---|
82 | {
|
---|
83 | return !((pRect1->xLeft < pRect2->xLeft && pRect1->xRight <= pRect2->xLeft)
|
---|
84 | || (pRect2->xLeft < pRect1->xLeft && pRect2->xRight <= pRect1->xLeft)
|
---|
85 | || (pRect1->yTop < pRect2->yTop && pRect1->yBottom <= pRect2->yTop)
|
---|
86 | || (pRect2->yTop < pRect1->yTop && pRect2->yBottom <= pRect1->yTop));
|
---|
87 | }
|
---|
88 |
|
---|
89 | DECLINLINE(uint32_t) VBoxVrListRectsCount(PVBOXVR_LIST pList)
|
---|
90 | {
|
---|
91 | return pList->cEntries;
|
---|
92 | }
|
---|
93 |
|
---|
94 | DECLINLINE(bool) VBoxVrListIsEmpty(const PVBOXVR_LIST pList)
|
---|
95 | {
|
---|
96 | return !VBoxVrListRectsCount(pList);
|
---|
97 | }
|
---|
98 |
|
---|
99 | DECLINLINE(void) VBoxVrListInit(PVBOXVR_LIST pList)
|
---|
100 | {
|
---|
101 | RTListInit(&pList->ListHead);
|
---|
102 | pList->cEntries = 0;
|
---|
103 | }
|
---|
104 |
|
---|
105 | VBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList);
|
---|
106 |
|
---|
107 | VBOXVREGDECL(void) VBoxVrListTranslate(PVBOXVR_LIST pList, int32_t x, int32_t y);
|
---|
108 |
|
---|
109 | VBOXVREGDECL(int) VBoxVrListCmp(PVBOXVR_LIST pList1, PVBOXVR_LIST pList2);
|
---|
110 |
|
---|
111 | VBOXVREGDECL(int) VBoxVrListRectsAdd(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
|
---|
112 | VBOXVREGDECL(int) VBoxVrListRectsSubst(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
|
---|
113 | VBOXVREGDECL(int) VBoxVrListRectsGet(PVBOXVR_LIST pList, uint32_t cRects, RTRECT * aRects);
|
---|
114 |
|
---|
115 | VBOXVREGDECL(int) VBoxVrInit();
|
---|
116 | VBOXVREGDECL(void) VBoxVrTerm();
|
---|
117 |
|
---|
118 | typedef struct VBOXVR_COMPOSITOR_ENTRY
|
---|
119 | {
|
---|
120 | RTLISTNODE Node;
|
---|
121 | VBOXVR_LIST Vr;
|
---|
122 | } VBOXVR_COMPOSITOR_ENTRY, *PVBOXVR_COMPOSITOR_ENTRY;
|
---|
123 |
|
---|
124 | struct VBOXVR_COMPOSITOR;
|
---|
125 |
|
---|
126 | typedef DECLCALLBACK(void) FNVBOXVRCOMPOSITOR_ENTRY_REMOVED(const struct VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry);
|
---|
127 | typedef FNVBOXVRCOMPOSITOR_ENTRY_REMOVED *PFNVBOXVRCOMPOSITOR_ENTRY_REMOVED;
|
---|
128 |
|
---|
129 | typedef struct VBOXVR_COMPOSITOR
|
---|
130 | {
|
---|
131 | RTLISTNODE List;
|
---|
132 | PFNVBOXVRCOMPOSITOR_ENTRY_REMOVED pfnEntryRemoved;
|
---|
133 | } VBOXVR_COMPOSITOR, *PVBOXVR_COMPOSITOR;
|
---|
134 |
|
---|
135 | typedef DECLCALLBACK(bool) FNVBOXVRCOMPOSITOR_VISITOR(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
|
---|
136 | typedef FNVBOXVRCOMPOSITOR_VISITOR *PFNVBOXVRCOMPOSITOR_VISITOR;
|
---|
137 |
|
---|
138 | VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_REMOVED pfnEntryRemoved);
|
---|
139 | VBOXVREGDECL(void) VBoxVrCompositorTerm(PVBOXVR_COMPOSITOR pCompositor);
|
---|
140 | VBOXVREGDECL(void) VBoxVrCompositorEntryInit(PVBOXVR_COMPOSITOR_ENTRY pEntry);
|
---|
141 | DECLINLINE(bool) VBoxVrCompositorEntryIsInList(const PVBOXVR_COMPOSITOR_ENTRY pEntry)
|
---|
142 | {
|
---|
143 | return !VBoxVrListIsEmpty(&pEntry->Vr);
|
---|
144 | }
|
---|
145 |
|
---|
146 | #define VBOXVR_COMPOSITOR_CF_ENTRIES_REGIONS_CHANGED 0x00000001
|
---|
147 | #define VBOXVR_COMPOSITOR_CF_COMPOSITED_REGIONS_CHANGED 0x00000002
|
---|
148 |
|
---|
149 | VBOXVREGDECL(bool) VBoxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry);
|
---|
150 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, uint32_t *pfChangeFlags);
|
---|
151 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
152 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSet(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
|
---|
153 | VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsTranslate(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, int32_t x, int32_t y, bool *pfChanged);
|
---|
154 | VBOXVREGDECL(void) VBoxVrCompositorVisit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor);
|
---|
155 |
|
---|
156 | RT_C_DECLS_END
|
---|
157 |
|
---|
158 | #endif /* #ifndef ___cr_vreg_h_ */
|
---|