1 | /* $Id: display_composite.cpp 69500 2017-10-28 15:14:05Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * Presenter API: display composite class implementation.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2014-2017 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 |
|
---|
19 | #include "server_presenter.h"
|
---|
20 |
|
---|
21 | CrFbDisplayComposite::CrFbDisplayComposite() :
|
---|
22 | mcDisplays(0)
|
---|
23 | {
|
---|
24 | RTListInit(&mDisplays);
|
---|
25 | }
|
---|
26 |
|
---|
27 |
|
---|
28 | bool CrFbDisplayComposite::isComposite()
|
---|
29 | {
|
---|
30 | return true;
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | uint32_t CrFbDisplayComposite::getDisplayCount()
|
---|
35 | {
|
---|
36 | return mcDisplays;
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | bool CrFbDisplayComposite::add(CrFbDisplayBase *pDisplay)
|
---|
41 | {
|
---|
42 | if (pDisplay->isInList())
|
---|
43 | {
|
---|
44 | WARN(("entry in list already"));
|
---|
45 | return false;
|
---|
46 | }
|
---|
47 |
|
---|
48 | RTListAppend(&mDisplays, &pDisplay->mNode);
|
---|
49 | pDisplay->mpContainer = this;
|
---|
50 | pDisplay->setFramebuffer(getFramebuffer());
|
---|
51 | ++mcDisplays;
|
---|
52 | return true;
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|
56 | bool CrFbDisplayComposite::remove(CrFbDisplayBase *pDisplay, bool fCleanupDisplay)
|
---|
57 | {
|
---|
58 | if (pDisplay->getContainer() != this)
|
---|
59 | {
|
---|
60 | WARN(("invalid entry container"));
|
---|
61 | return false;
|
---|
62 | }
|
---|
63 |
|
---|
64 | RTListNodeRemove(&pDisplay->mNode);
|
---|
65 | pDisplay->mpContainer = NULL;
|
---|
66 | if (fCleanupDisplay)
|
---|
67 | pDisplay->setFramebuffer(NULL);
|
---|
68 | --mcDisplays;
|
---|
69 | return true;
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 | CrFbDisplayBase* CrFbDisplayComposite::first()
|
---|
74 | {
|
---|
75 | return RTListGetFirstCpp(&mDisplays, CrFbDisplayBase, mNode);
|
---|
76 | }
|
---|
77 |
|
---|
78 |
|
---|
79 | CrFbDisplayBase* CrFbDisplayComposite::next(CrFbDisplayBase* pDisplay)
|
---|
80 | {
|
---|
81 | if (pDisplay->getContainer() != this)
|
---|
82 | {
|
---|
83 | WARN(("invalid entry container"));
|
---|
84 | return NULL;
|
---|
85 | }
|
---|
86 |
|
---|
87 | return RTListGetNextCpp(&mDisplays, pDisplay, CrFbDisplayBase, mNode);
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | int CrFbDisplayComposite::setFramebuffer(struct CR_FRAMEBUFFER *pFb)
|
---|
92 | {
|
---|
93 | CrFbDisplayBase::setFramebuffer(pFb);
|
---|
94 |
|
---|
95 | CrFbDisplayBase *pIter;
|
---|
96 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
97 | {
|
---|
98 | pIter->setFramebuffer(pFb);
|
---|
99 | }
|
---|
100 |
|
---|
101 | return VINF_SUCCESS;
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | int CrFbDisplayComposite::UpdateBegin(struct CR_FRAMEBUFFER *pFb)
|
---|
106 | {
|
---|
107 | int rc = CrFbDisplayBase::UpdateBegin(pFb);
|
---|
108 | if (!RT_SUCCESS(rc))
|
---|
109 | {
|
---|
110 | WARN(("err"));
|
---|
111 | return rc;
|
---|
112 | }
|
---|
113 |
|
---|
114 | CrFbDisplayBase *pIter;
|
---|
115 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
116 | {
|
---|
117 | rc = pIter->UpdateBegin(pFb);
|
---|
118 | if (!RT_SUCCESS(rc))
|
---|
119 | {
|
---|
120 | WARN(("err"));
|
---|
121 | return rc;
|
---|
122 | }
|
---|
123 | }
|
---|
124 | return VINF_SUCCESS;
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 | void CrFbDisplayComposite::UpdateEnd(struct CR_FRAMEBUFFER *pFb)
|
---|
129 | {
|
---|
130 | CrFbDisplayBase *pIter;
|
---|
131 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
132 | {
|
---|
133 | pIter->UpdateEnd(pFb);
|
---|
134 | }
|
---|
135 |
|
---|
136 | CrFbDisplayBase::UpdateEnd(pFb);
|
---|
137 | }
|
---|
138 |
|
---|
139 |
|
---|
140 | int CrFbDisplayComposite::EntryAdded(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
|
---|
141 | {
|
---|
142 | int rc = CrFbDisplayBase::EntryAdded(pFb, hEntry);
|
---|
143 | if (!RT_SUCCESS(rc))
|
---|
144 | {
|
---|
145 | WARN(("err"));
|
---|
146 | return rc;
|
---|
147 | }
|
---|
148 |
|
---|
149 | CrFbDisplayBase *pIter;
|
---|
150 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
151 | {
|
---|
152 | int rc = pIter->EntryAdded(pFb, hEntry);
|
---|
153 | if (!RT_SUCCESS(rc))
|
---|
154 | {
|
---|
155 | WARN(("err"));
|
---|
156 | return rc;
|
---|
157 | }
|
---|
158 | }
|
---|
159 | return VINF_SUCCESS;
|
---|
160 | }
|
---|
161 |
|
---|
162 |
|
---|
163 | int CrFbDisplayComposite::EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
|
---|
164 | {
|
---|
165 | int rc = CrFbDisplayBase::EntryAdded(pFb, hEntry);
|
---|
166 | if (!RT_SUCCESS(rc))
|
---|
167 | {
|
---|
168 | WARN(("err"));
|
---|
169 | return rc;
|
---|
170 | }
|
---|
171 |
|
---|
172 | CrFbDisplayBase *pIter;
|
---|
173 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
174 | {
|
---|
175 | int rc = pIter->EntryCreated(pFb, hEntry);
|
---|
176 | if (!RT_SUCCESS(rc))
|
---|
177 | {
|
---|
178 | WARN(("err"));
|
---|
179 | return rc;
|
---|
180 | }
|
---|
181 | }
|
---|
182 | return VINF_SUCCESS;
|
---|
183 | }
|
---|
184 |
|
---|
185 |
|
---|
186 | int CrFbDisplayComposite::EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry, HCR_FRAMEBUFFER_ENTRY hReplacedEntry)
|
---|
187 | {
|
---|
188 | int rc = CrFbDisplayBase::EntryReplaced(pFb, hNewEntry, hReplacedEntry);
|
---|
189 | if (!RT_SUCCESS(rc))
|
---|
190 | {
|
---|
191 | WARN(("err"));
|
---|
192 | return rc;
|
---|
193 | }
|
---|
194 |
|
---|
195 | CrFbDisplayBase *pIter;
|
---|
196 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
197 | {
|
---|
198 | int rc = pIter->EntryReplaced(pFb, hNewEntry, hReplacedEntry);
|
---|
199 | if (!RT_SUCCESS(rc))
|
---|
200 | {
|
---|
201 | WARN(("err"));
|
---|
202 | return rc;
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 | return VINF_SUCCESS;
|
---|
207 | }
|
---|
208 |
|
---|
209 |
|
---|
210 | int CrFbDisplayComposite::EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
|
---|
211 | {
|
---|
212 | int rc = CrFbDisplayBase::EntryTexChanged(pFb, hEntry);
|
---|
213 | if (!RT_SUCCESS(rc))
|
---|
214 | {
|
---|
215 | WARN(("err"));
|
---|
216 | return rc;
|
---|
217 | }
|
---|
218 |
|
---|
219 | CrFbDisplayBase *pIter;
|
---|
220 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
221 | {
|
---|
222 | int rc = pIter->EntryTexChanged(pFb, hEntry);
|
---|
223 | if (!RT_SUCCESS(rc))
|
---|
224 | {
|
---|
225 | WARN(("err"));
|
---|
226 | return rc;
|
---|
227 | }
|
---|
228 | }
|
---|
229 | return VINF_SUCCESS;
|
---|
230 | }
|
---|
231 |
|
---|
232 |
|
---|
233 | int CrFbDisplayComposite::EntryRemoved(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
|
---|
234 | {
|
---|
235 | int rc = CrFbDisplayBase::EntryRemoved(pFb, hEntry);
|
---|
236 | if (!RT_SUCCESS(rc))
|
---|
237 | {
|
---|
238 | WARN(("err"));
|
---|
239 | return rc;
|
---|
240 | }
|
---|
241 |
|
---|
242 | CrFbDisplayBase *pIter;
|
---|
243 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
244 | {
|
---|
245 | int rc = pIter->EntryRemoved(pFb, hEntry);
|
---|
246 | if (!RT_SUCCESS(rc))
|
---|
247 | {
|
---|
248 | WARN(("err"));
|
---|
249 | return rc;
|
---|
250 | }
|
---|
251 | }
|
---|
252 | return VINF_SUCCESS;
|
---|
253 | }
|
---|
254 |
|
---|
255 |
|
---|
256 | int CrFbDisplayComposite::EntryDestroyed(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
|
---|
257 | {
|
---|
258 | int rc = CrFbDisplayBase::EntryDestroyed(pFb, hEntry);
|
---|
259 | if (!RT_SUCCESS(rc))
|
---|
260 | {
|
---|
261 | WARN(("err"));
|
---|
262 | return rc;
|
---|
263 | }
|
---|
264 |
|
---|
265 | CrFbDisplayBase *pIter;
|
---|
266 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
267 | {
|
---|
268 | int rc = pIter->EntryDestroyed(pFb, hEntry);
|
---|
269 | if (!RT_SUCCESS(rc))
|
---|
270 | {
|
---|
271 | WARN(("err"));
|
---|
272 | return rc;
|
---|
273 | }
|
---|
274 | }
|
---|
275 |
|
---|
276 | return VINF_SUCCESS;
|
---|
277 | }
|
---|
278 |
|
---|
279 |
|
---|
280 | int CrFbDisplayComposite::RegionsChanged(struct CR_FRAMEBUFFER *pFb)
|
---|
281 | {
|
---|
282 | int rc = CrFbDisplayBase::RegionsChanged(pFb);
|
---|
283 | if (!RT_SUCCESS(rc))
|
---|
284 | {
|
---|
285 | WARN(("err"));
|
---|
286 | return rc;
|
---|
287 | }
|
---|
288 |
|
---|
289 | CrFbDisplayBase *pIter;
|
---|
290 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
291 | {
|
---|
292 | int rc = pIter->RegionsChanged(pFb);
|
---|
293 | if (!RT_SUCCESS(rc))
|
---|
294 | {
|
---|
295 | WARN(("err"));
|
---|
296 | return rc;
|
---|
297 | }
|
---|
298 | }
|
---|
299 | return VINF_SUCCESS;
|
---|
300 | }
|
---|
301 |
|
---|
302 |
|
---|
303 | int CrFbDisplayComposite::FramebufferChanged(struct CR_FRAMEBUFFER *pFb)
|
---|
304 | {
|
---|
305 | int rc = CrFbDisplayBase::FramebufferChanged(pFb);
|
---|
306 | if (!RT_SUCCESS(rc))
|
---|
307 | {
|
---|
308 | WARN(("err"));
|
---|
309 | return rc;
|
---|
310 | }
|
---|
311 |
|
---|
312 | CrFbDisplayBase *pIter;
|
---|
313 | RTListForEachCpp(&mDisplays, pIter, CrFbDisplayBase, mNode)
|
---|
314 | {
|
---|
315 | int rc = pIter->FramebufferChanged(pFb);
|
---|
316 | if (!RT_SUCCESS(rc))
|
---|
317 | {
|
---|
318 | WARN(("err"));
|
---|
319 | return rc;
|
---|
320 | }
|
---|
321 | }
|
---|
322 |
|
---|
323 | return VINF_SUCCESS;
|
---|
324 | }
|
---|
325 |
|
---|
326 |
|
---|
327 | CrFbDisplayComposite::~CrFbDisplayComposite()
|
---|
328 | {
|
---|
329 | cleanup();
|
---|
330 | }
|
---|
331 |
|
---|
332 |
|
---|
333 | void CrFbDisplayComposite::cleanup(bool fCleanupDisplays)
|
---|
334 | {
|
---|
335 | CrFbDisplayBase *pIter, *pIterNext;
|
---|
336 | RTListForEachSafeCpp(&mDisplays, pIter, pIterNext, CrFbDisplayBase, mNode)
|
---|
337 | {
|
---|
338 | remove(pIter, fCleanupDisplays);
|
---|
339 | }
|
---|
340 | }
|
---|
341 |
|
---|