VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/display_base.cpp@ 80334

最後變更 在這個檔案從80334是 78263,由 vboxsync 提交於 6 年 前

Config.kmk,GuestHost\OpenGL,HostServices\SharedOpenGL: Fix a bunch of compiler warnings and enable them again

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.7 KB
 
1/* $Id: display_base.cpp 78263 2019-04-23 18:41:06Z vboxsync $ */
2
3/** @file
4 * Presenter API: display base class implementation.
5 */
6
7/*
8 * Copyright (C) 2014-2019 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.alldomusa.eu.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
21CrFbDisplayBase::CrFbDisplayBase() :
22 mpContainer(NULL),
23 mpFb(NULL),
24 mcUpdates(0),
25 mhSlot(CRHTABLE_HANDLE_INVALID)
26{
27 mFlags.u32Value = 0;
28}
29
30
31CrFbDisplayBase::~CrFbDisplayBase()
32{
33 Assert(!mcUpdates);
34
35 if (mpContainer)
36 mpContainer->remove(this);
37}
38
39
40bool CrFbDisplayBase::isComposite()
41{
42 return false;
43}
44
45
46class CrFbDisplayComposite* CrFbDisplayBase::getContainer()
47{
48 return mpContainer;
49}
50
51
52bool CrFbDisplayBase::isInList()
53{
54 return !!mpContainer;
55}
56
57
58bool CrFbDisplayBase::isUpdating()
59{
60 return !!mcUpdates;
61}
62
63
64int CrFbDisplayBase::setRegionsChanged()
65{
66 if (!mcUpdates)
67 {
68 WARN(("err"));
69 return VERR_INVALID_STATE;
70 }
71
72 mFlags.fRegionsShanged = 1;
73 return VINF_SUCCESS;
74}
75
76
77int CrFbDisplayBase::setFramebuffer(struct CR_FRAMEBUFFER *pFb)
78{
79 if (mcUpdates)
80 {
81 WARN(("trying to set framebuffer while update is in progress"));
82 return VERR_INVALID_STATE;
83 }
84
85 if (mpFb == pFb)
86 return VINF_SUCCESS;
87
88 int rc = setFramebufferBegin(pFb);
89 if (!RT_SUCCESS(rc))
90 {
91 WARN(("err"));
92 return rc;
93 }
94
95 if (mpFb)
96 {
97 rc = fbCleanup();
98 if (!RT_SUCCESS(rc))
99 {
100 WARN(("err"));
101 setFramebufferEnd(pFb);
102 return rc;
103 }
104 }
105
106 mpFb = pFb;
107
108 if (mpFb)
109 {
110 rc = fbSync();
111 if (!RT_SUCCESS(rc))
112 {
113 WARN(("err"));
114 setFramebufferEnd(pFb);
115 return rc;
116 }
117 }
118
119 setFramebufferEnd(pFb);
120 return VINF_SUCCESS;
121}
122
123
124struct CR_FRAMEBUFFER* CrFbDisplayBase::getFramebuffer()
125{
126 return mpFb;
127}
128
129
130int CrFbDisplayBase::UpdateBegin(struct CR_FRAMEBUFFER *pFb)
131{
132 RT_NOREF(pFb);
133
134 ++mcUpdates;
135 Assert(!mFlags.fRegionsShanged || mcUpdates > 1);
136 return VINF_SUCCESS;
137}
138
139
140void CrFbDisplayBase::UpdateEnd(struct CR_FRAMEBUFFER *pFb)
141{
142 RT_NOREF(pFb);
143
144 --mcUpdates;
145 Assert(mcUpdates < UINT32_MAX/2);
146 if (!mcUpdates)
147 onUpdateEnd();
148}
149
150
151int CrFbDisplayBase::EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
152{
153 RT_NOREF(pFb, hEntry);
154
155 if (!mcUpdates)
156 {
157 WARN(("err"));
158 return VERR_INVALID_STATE;
159 }
160 return VINF_SUCCESS;
161}
162
163
164int CrFbDisplayBase::EntryAdded(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
165{
166 RT_NOREF(pFb, hEntry);
167
168 if (!mcUpdates)
169 {
170 WARN(("err"));
171 return VERR_INVALID_STATE;
172 }
173 mFlags.fRegionsShanged = 1;
174 return VINF_SUCCESS;
175}
176
177
178int CrFbDisplayBase::EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry,
179 HCR_FRAMEBUFFER_ENTRY hReplacedEntry)
180{
181 RT_NOREF(pFb, hNewEntry, hReplacedEntry);
182
183 if (!mcUpdates)
184 {
185 WARN(("err"));
186 return VERR_INVALID_STATE;
187 }
188 return VINF_SUCCESS;
189}
190
191
192int CrFbDisplayBase::EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
193{
194 RT_NOREF(pFb, hEntry);
195
196 if (!mcUpdates)
197 {
198 WARN(("err"));
199 return VERR_INVALID_STATE;
200 }
201 return VINF_SUCCESS;
202}
203
204
205int CrFbDisplayBase::EntryRemoved(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
206{
207 RT_NOREF(pFb, hEntry);
208
209 if (!mcUpdates)
210 {
211 WARN(("err"));
212 return VERR_INVALID_STATE;
213 }
214 mFlags.fRegionsShanged = 1;
215 return VINF_SUCCESS;
216}
217
218
219int CrFbDisplayBase::EntryDestroyed(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
220{
221 RT_NOREF(pFb, hEntry);
222 return VINF_SUCCESS;
223}
224
225
226int CrFbDisplayBase::EntryPosChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry)
227{
228 RT_NOREF(pFb, hEntry);
229
230 if (!mcUpdates)
231 {
232 WARN(("err"));
233 return VERR_INVALID_STATE;
234 }
235 mFlags.fRegionsShanged = 1;
236 return VINF_SUCCESS;
237}
238
239
240int CrFbDisplayBase::RegionsChanged(struct CR_FRAMEBUFFER *pFb)
241{
242 RT_NOREF(pFb);
243
244 if (!mcUpdates)
245 {
246 WARN(("err"));
247 return VERR_INVALID_STATE;
248 }
249 mFlags.fRegionsShanged = 1;
250 return VINF_SUCCESS;
251}
252
253
254int CrFbDisplayBase::FramebufferChanged(struct CR_FRAMEBUFFER *pFb)
255{
256 RT_NOREF(pFb);
257
258 if (!mcUpdates)
259 {
260 WARN(("err"));
261 return VERR_INVALID_STATE;
262 }
263 return VINF_SUCCESS;
264}
265
266
267void CrFbDisplayBase::onUpdateEnd()
268{
269 if (mFlags.fRegionsShanged)
270 {
271 mFlags.fRegionsShanged = 0;
272 if (getFramebuffer()) /*<-dont't do anything on cleanup*/
273 ueRegions();
274 }
275}
276
277
278void CrFbDisplayBase::ueRegions()
279{
280}
281
282
283DECLCALLBACK(bool) CrFbDisplayBase::entriesCreateCb(HCR_FRAMEBUFFER hFb, HCR_FRAMEBUFFER_ENTRY hEntry, void *pvContext)
284{
285 int rc = ((ICrFbDisplay*)(pvContext))->EntryCreated(hFb, hEntry);
286 if (!RT_SUCCESS(rc))
287 {
288 WARN(("err"));
289 }
290 return true;
291}
292
293
294DECLCALLBACK(bool) CrFbDisplayBase::entriesDestroyCb(HCR_FRAMEBUFFER hFb, HCR_FRAMEBUFFER_ENTRY hEntry, void *pvContext)
295{
296 int rc = ((ICrFbDisplay*)(pvContext))->EntryDestroyed(hFb, hEntry);
297 if (!RT_SUCCESS(rc))
298 {
299 WARN(("err"));
300 }
301 return true;
302}
303
304
305int CrFbDisplayBase::fbSynchAddAllEntries()
306{
307 VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR Iter;
308 const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
309
310 CrVrScrCompositorConstIterInit(CrFbGetCompositor(mpFb), &Iter);
311 int rc = VINF_SUCCESS;
312
313 CrFbVisitCreatedEntries(mpFb, entriesCreateCb, this);
314
315 while ((pEntry = CrVrScrCompositorConstIterNext(&Iter)) != NULL)
316 {
317 HCR_FRAMEBUFFER_ENTRY hEntry = CrFbEntryFromCompositorEntry(pEntry);
318
319 rc = EntryAdded(mpFb, hEntry);
320 if (!RT_SUCCESS(rc))
321 {
322 WARN(("err"));
323 EntryDestroyed(mpFb, hEntry);
324 break;
325 }
326 }
327
328 return rc;
329}
330
331
332int CrFbDisplayBase::fbCleanupRemoveAllEntries()
333{
334 VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR Iter;
335 const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry;
336
337 CrVrScrCompositorConstIterInit(CrFbGetCompositor(mpFb), &Iter);
338
339 int rc = VINF_SUCCESS;
340
341 while ((pEntry = CrVrScrCompositorConstIterNext(&Iter)) != NULL)
342 {
343 HCR_FRAMEBUFFER_ENTRY hEntry = CrFbEntryFromCompositorEntry(pEntry);
344 rc = EntryRemoved(mpFb, hEntry);
345 if (!RT_SUCCESS(rc))
346 {
347 WARN(("err"));
348 break;
349 }
350 }
351
352 CrFbVisitCreatedEntries(mpFb, entriesDestroyCb, this);
353
354 return rc;
355}
356
357
358int CrFbDisplayBase::setFramebufferBegin(struct CR_FRAMEBUFFER *pFb)
359{
360 return UpdateBegin(pFb);
361}
362
363
364void CrFbDisplayBase::setFramebufferEnd(struct CR_FRAMEBUFFER *pFb)
365{
366 UpdateEnd(pFb);
367}
368
369
370DECLCALLBACK(void) CrFbDisplayBase::slotEntryReleaseCB(HCR_FRAMEBUFFER hFb, HCR_FRAMEBUFFER_ENTRY hEntry, void *pvContext)
371{
372 RT_NOREF(hFb, hEntry, pvContext);
373}
374
375
376void CrFbDisplayBase::slotRelease()
377{
378 Assert(mhSlot);
379 CrFbDDataReleaseSlot(mpFb, mhSlot, slotEntryReleaseCB, this);
380}
381
382
383int CrFbDisplayBase::fbCleanup()
384{
385 if (mhSlot)
386 {
387 slotRelease();
388 mhSlot = 0;
389 }
390
391 mpFb = NULL;
392 return VINF_SUCCESS;
393}
394
395
396int CrFbDisplayBase::fbSync()
397{
398 return VINF_SUCCESS;
399}
400
401
402CRHTABLE_HANDLE CrFbDisplayBase::slotGet()
403{
404 if (!mhSlot)
405 {
406 if (mpFb)
407 mhSlot = CrFbDDataAllocSlot(mpFb);
408 }
409
410 return mhSlot;
411}
412
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette