VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.h@ 53262

Last change on this file since 53262 was 53262, checked in by vboxsync, 11 years ago

Revert r96781, r96707 and r96693 since these commits affect 3D overlay window badly on Windows host.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.4 KB
Line 
1/* $Id: server_presenter.h 53262 2014-11-07 13:06:25Z vboxsync $ */
2
3/** @file
4 * Presenter API definitions.
5 */
6
7/*
8 * Copyright (C) 2014 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.215389.xyz. 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#ifndef __SERVER_PRESENTER_H__
20#define __SERVER_PRESENTER_H__
21
22#include "cr_spu.h"
23#include "chromium.h"
24#include "cr_error.h"
25#include "cr_net.h"
26#include "cr_rand.h"
27#include "server_dispatch.h"
28#include "server.h"
29#include "cr_mem.h"
30#include "cr_string.h"
31#include <cr_vreg.h>
32#include <cr_htable.h>
33#include <cr_bmpscale.h>
34
35#include "render/renderspu.h"
36
37#include <iprt/cdefs.h>
38#include <iprt/types.h>
39#include <iprt/asm.h>
40#include <iprt/mem.h>
41#include <iprt/list.h>
42
43
44class ICrFbDisplay
45{
46 public:
47 virtual int UpdateBegin(struct CR_FRAMEBUFFER *pFb) = 0;
48 virtual void UpdateEnd(struct CR_FRAMEBUFFER *pFb) = 0;
49
50 virtual int EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry) = 0;
51 virtual int EntryAdded(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry) = 0;
52 virtual int EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry, HCR_FRAMEBUFFER_ENTRY hReplacedEntry) = 0;
53 virtual int EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry) = 0;
54 virtual int EntryRemoved(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry) = 0;
55 virtual int EntryDestroyed(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry) = 0;
56 virtual int EntryPosChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry) = 0;
57
58 virtual int RegionsChanged(struct CR_FRAMEBUFFER *pFb) = 0;
59
60 virtual int FramebufferChanged(struct CR_FRAMEBUFFER *pFb) = 0;
61
62 virtual ~ICrFbDisplay() {}
63};
64
65
66typedef struct CR_FRAMEBUFFER
67{
68 VBOXVR_SCR_COMPOSITOR Compositor;
69 struct VBVAINFOSCREEN ScreenInfo;
70 void *pvVram;
71 ICrFbDisplay *pDisplay;
72 RTLISTNODE EntriesList;
73 uint32_t cEntries; /* <- just for debugging */
74 uint32_t cUpdating;
75 CRHTABLE SlotTable;
76} CR_FRAMEBUFFER;
77
78
79typedef union CR_FBENTRY_FLAGS
80{
81 struct {
82 uint32_t fCreateNotified : 1;
83 uint32_t fInList : 1;
84 uint32_t Reserved : 30;
85 };
86 uint32_t Value;
87} CR_FBENTRY_FLAGS;
88
89
90typedef struct CR_FRAMEBUFFER_ENTRY
91{
92 VBOXVR_SCR_COMPOSITOR_ENTRY Entry;
93 RTLISTNODE Node;
94 uint32_t cRefs;
95 CR_FBENTRY_FLAGS Flags;
96 CRHTABLE HTable;
97} CR_FRAMEBUFFER_ENTRY;
98
99
100typedef struct CR_FBTEX
101{
102 CR_TEXDATA Tex;
103 CRTextureObj *pTobj;
104} CR_FBTEX;
105
106
107class CrFbDisplayBase : public ICrFbDisplay
108{
109 public:
110
111 CrFbDisplayBase();
112
113 virtual bool isComposite();
114 class CrFbDisplayComposite* getContainer();
115 bool isInList();
116 bool isUpdating();
117 int setRegionsChanged();
118 int setFramebuffer(struct CR_FRAMEBUFFER *pFb);
119 struct CR_FRAMEBUFFER* getFramebuffer();
120 virtual int UpdateBegin(struct CR_FRAMEBUFFER *pFb);
121 virtual void UpdateEnd(struct CR_FRAMEBUFFER *pFb);
122 virtual int EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
123 virtual int EntryAdded(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
124 virtual int EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry, HCR_FRAMEBUFFER_ENTRY hReplacedEntry);
125 virtual int EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
126 virtual int EntryRemoved(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
127 virtual int EntryDestroyed(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
128 virtual int EntryPosChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
129 virtual int RegionsChanged(struct CR_FRAMEBUFFER *pFb);
130 virtual int FramebufferChanged(struct CR_FRAMEBUFFER *pFb);
131 virtual ~CrFbDisplayBase();
132
133 /*@todo: move to protected and switch from RTLISTNODE*/
134 RTLISTNODE mNode;
135 class CrFbDisplayComposite* mpContainer;
136
137 protected:
138
139 virtual void onUpdateEnd();
140 virtual void ueRegions();
141 static DECLCALLBACK(bool) entriesCreateCb(HCR_FRAMEBUFFER hFb, HCR_FRAMEBUFFER_ENTRY hEntry, void *pvContext);
142 static DECLCALLBACK(bool) entriesDestroyCb(HCR_FRAMEBUFFER hFb, HCR_FRAMEBUFFER_ENTRY hEntry, void *pvContext);
143 int fbSynchAddAllEntries();
144 int fbCleanupRemoveAllEntries();
145 virtual int setFramebufferBegin(struct CR_FRAMEBUFFER *pFb);
146 virtual void setFramebufferEnd(struct CR_FRAMEBUFFER *pFb);
147 static DECLCALLBACK(void) slotEntryReleaseCB(HCR_FRAMEBUFFER hFb, HCR_FRAMEBUFFER_ENTRY hEntry, void *pvContext);
148 virtual void slotRelease();
149 virtual int fbCleanup();
150 virtual int fbSync();
151 CRHTABLE_HANDLE slotGet();
152
153 private:
154
155 typedef union CR_FBDISPBASE_FLAGS
156 {
157 struct {
158 uint32_t fRegionsShanged : 1;
159 uint32_t Reserved : 31;
160 };
161 uint32_t u32Value;
162 } CR_FBDISPBASE_FLAGS;
163
164 struct CR_FRAMEBUFFER *mpFb;
165 uint32_t mcUpdates;
166 CRHTABLE_HANDLE mhSlot;
167 CR_FBDISPBASE_FLAGS mFlags;
168};
169
170
171class CrFbDisplayComposite : public CrFbDisplayBase
172{
173 public:
174
175 CrFbDisplayComposite();
176 virtual bool isComposite();
177 uint32_t getDisplayCount();
178 bool add(CrFbDisplayBase *pDisplay);
179 bool remove(CrFbDisplayBase *pDisplay, bool fCleanupDisplay = true);
180 CrFbDisplayBase* first();
181 CrFbDisplayBase* next(CrFbDisplayBase* pDisplay);
182 virtual int setFramebuffer(struct CR_FRAMEBUFFER *pFb);
183 virtual int UpdateBegin(struct CR_FRAMEBUFFER *pFb);
184 virtual void UpdateEnd(struct CR_FRAMEBUFFER *pFb);
185 virtual int EntryAdded(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
186 virtual int EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
187 virtual int EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry, HCR_FRAMEBUFFER_ENTRY hReplacedEntry);
188 virtual int EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
189 virtual int EntryRemoved(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
190 virtual int EntryDestroyed(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
191 virtual int RegionsChanged(struct CR_FRAMEBUFFER *pFb);
192 virtual int FramebufferChanged(struct CR_FRAMEBUFFER *pFb);
193 virtual ~CrFbDisplayComposite();
194 void cleanup(bool fCleanupDisplays = true);
195
196 private:
197
198 RTLISTNODE mDisplays;
199 uint32_t mcDisplays;
200};
201
202
203class CrFbWindow
204{
205 public:
206
207 CrFbWindow(uint64_t parentId);
208 bool IsCreated() const;
209 bool IsVisivle() const;
210 void Destroy();
211 int Reparent(uint64_t parentId);
212 int SetVisible(bool fVisible);
213 int SetSize(uint32_t width, uint32_t height);
214 int SetPosition(int32_t x, int32_t y);
215 int SetVisibleRegionsChanged();
216 int SetCompositor(const struct VBOXVR_SCR_COMPOSITOR * pCompositor);
217 int UpdateBegin();
218 void UpdateEnd();
219 uint64_t GetParentId();
220 int Create();
221 ~CrFbWindow();
222
223 protected:
224
225 void checkRegions();
226 bool isPresentNeeded();
227 bool checkInitedUpdating();
228
229 private:
230
231 typedef union CR_FBWIN_FLAGS
232 {
233 struct {
234 uint32_t fVisible : 1;
235 uint32_t fDataPresented : 1;
236 uint32_t fForcePresentOnReenable : 1;
237 uint32_t fCompositoEntriesModified : 1;
238 uint32_t Reserved : 28;
239 };
240 uint32_t Value;
241 } CR_FBWIN_FLAGS;
242
243 GLint mSpuWindow;
244 const struct VBOXVR_SCR_COMPOSITOR * mpCompositor;
245 uint32_t mcUpdates;
246 int32_t mxPos;
247 int32_t myPos;
248 uint32_t mWidth;
249 uint32_t mHeight;
250 CR_FBWIN_FLAGS mFlags;
251 uint64_t mParentId;
252};
253
254
255class CrFbDisplayWindow : public CrFbDisplayBase
256{
257 public:
258
259 CrFbDisplayWindow(const RTRECT *pViewportRect, uint64_t parentId);
260 virtual ~CrFbDisplayWindow();
261 virtual int UpdateBegin(struct CR_FRAMEBUFFER *pFb);
262 virtual void UpdateEnd(struct CR_FRAMEBUFFER *pFb);
263 virtual int RegionsChanged(struct CR_FRAMEBUFFER *pFb);
264 virtual int EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
265 virtual int EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry, HCR_FRAMEBUFFER_ENTRY hReplacedEntry);
266 virtual int EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
267 virtual int FramebufferChanged(struct CR_FRAMEBUFFER *pFb);
268 const RTRECT* getViewportRect();
269 virtual int setViewportRect(const RTRECT *pViewportRect);
270 virtual CrFbWindow * windowDetach(bool fCleanup = true);
271 virtual CrFbWindow * windowAttach(CrFbWindow * pNewWindow);
272 virtual int reparent(uint64_t parentId);
273 virtual bool isVisible();
274 int winVisibilityChanged();
275 CrFbWindow* getWindow();
276
277 protected:
278
279 virtual void onUpdateEnd();
280 virtual void ueRegions();
281 virtual int screenChanged();
282 virtual int windowSetCompositor(bool fSet);
283 virtual int windowCleanup();
284 virtual int fbCleanup();
285 bool isActive();
286 int windowDimensionsSync(bool fForceCleanup = false);
287 virtual int windowSync();
288 virtual int fbSync();
289 virtual const struct RTRECT* getRect();
290
291 private:
292
293 typedef union CR_FBDISPWINDOW_FLAGS
294 {
295 struct {
296 uint32_t fNeVisible : 1;
297 uint32_t fNeForce : 1;
298 uint32_t Reserved : 30;
299 };
300 uint32_t u32Value;
301 } CR_FBDISPWINDOW_FLAGS;
302
303 CrFbWindow *mpWindow;
304 RTRECT mViewportRect;
305 CR_FBDISPWINDOW_FLAGS mFlags;
306 uint32_t mu32Screen;
307 uint64_t mParentId;
308};
309
310
311class CrFbDisplayWindowRootVr : public CrFbDisplayWindow
312{
313 public:
314
315 CrFbDisplayWindowRootVr(const RTRECT *pViewportRect, uint64_t parentId);
316 virtual int EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
317 virtual int EntryAdded(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
318 virtual int EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry, HCR_FRAMEBUFFER_ENTRY hReplacedEntry);
319 virtual int EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
320 virtual int EntryRemoved(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
321 virtual int EntryDestroyed(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
322 virtual int setViewportRect(const RTRECT *pViewportRect);
323
324 protected:
325
326 virtual int windowSetCompositor(bool fSet);
327 virtual void ueRegions();
328 int compositorMarkUpdated();
329 virtual int screenChanged();
330 virtual const struct RTRECT* getRect();
331 virtual int fbCleanup();
332 virtual int fbSync();
333 VBOXVR_SCR_COMPOSITOR_ENTRY* entryAlloc();
334 void entryFree(VBOXVR_SCR_COMPOSITOR_ENTRY* pEntry);
335 int synchCompositorRegions();
336 virtual int synchCompositor();
337 virtual int clearCompositor();
338 void rootVrTranslateForPos();
339 static DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) rootVrGetCEntry(const VBOXVR_SCR_COMPOSITOR_ENTRY*pEntry, void *pvContext);
340
341 private:
342
343 VBOXVR_SCR_COMPOSITOR mCompositor;
344};
345
346
347class CrFbDisplayVrdp : public CrFbDisplayBase
348{
349 public:
350
351 CrFbDisplayVrdp();
352 virtual int EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
353 virtual int EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry, HCR_FRAMEBUFFER_ENTRY hReplacedEntry);
354 virtual int EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
355 virtual int EntryRemoved(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
356 virtual int EntryDestroyed(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
357 virtual int EntryPosChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
358 virtual int RegionsChanged(struct CR_FRAMEBUFFER *pFb);
359 virtual int FramebufferChanged(struct CR_FRAMEBUFFER *pFb);
360
361 protected:
362
363 void syncPos();
364 virtual int fbCleanup();
365 virtual int fbSync();
366 void vrdpDestroy(HCR_FRAMEBUFFER_ENTRY hEntry);
367 void vrdpGeometry(HCR_FRAMEBUFFER_ENTRY hEntry);
368 int vrdpRegions(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
369 int vrdpFrame(HCR_FRAMEBUFFER_ENTRY hEntry);
370 int vrdpRegionsAll(struct CR_FRAMEBUFFER *pFb);
371 int vrdpSynchEntry(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
372 int vrdpSyncEntryAll(struct CR_FRAMEBUFFER *pFb);
373 int vrdpCreate(HCR_FRAMEBUFFER hFb, HCR_FRAMEBUFFER_ENTRY hEntry);
374
375 private:
376
377 RTPOINT mPos;
378};
379
380
381typedef struct CR_FB_INFO
382{
383 CrFbDisplayComposite *pDpComposite;
384 uint32_t u32Id;
385 VBOXCMDVBVA_SCREENMAP_DECL(uint32_t, aTargetMap);
386} CR_FB_INFO;
387
388typedef struct CR_FBDISPLAY_INFO
389{
390 CrFbDisplayWindow *pDpWin;
391 CrFbDisplayWindowRootVr *pDpWinRootVr;
392 CrFbDisplayVrdp *pDpVrdp;
393 CrFbWindow *pWindow;
394 uint32_t u32DisplayMode;
395 uint32_t u32Id;
396 int32_t iFb;
397} CR_FBDISPLAY_INFO;
398
399typedef struct CR_PRESENTER_GLOBALS
400{
401#ifndef VBOXVDBG_MEMCACHE_DISABLE
402 RTMEMCACHE FbEntryLookasideList;
403 RTMEMCACHE FbTexLookasideList;
404 RTMEMCACHE CEntryLookasideList;
405#endif
406 uint32_t u32DisplayMode;
407 uint32_t u32DisabledDisplayMode;
408 bool fEnabled;
409 CRHashTable *pFbTexMap;
410 CR_FBDISPLAY_INFO aDisplayInfos[CR_MAX_GUEST_MONITORS];
411 CR_FBMAP FramebufferInitMap;
412 CR_FRAMEBUFFER aFramebuffers[CR_MAX_GUEST_MONITORS];
413 CR_FB_INFO aFbInfos[CR_MAX_GUEST_MONITORS];
414 bool fWindowsForceHidden;
415 uint32_t cbTmpBuf;
416 void *pvTmpBuf;
417 uint32_t cbTmpBuf2;
418 void *pvTmpBuf2;
419} CR_PRESENTER_GLOBALS;
420
421extern CR_PRESENTER_GLOBALS g_CrPresenter;
422
423
424HCR_FRAMEBUFFER_ENTRY CrFbEntryFromCompositorEntry(const struct VBOXVR_SCR_COMPOSITOR_ENTRY* pCEntry);
425
426#endif /* __SERVER_PRESENTER_H__ */
427
Note: See TracBrowser for help on using the repository browser.

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