VirtualBox

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

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

Host 3D: Chromium server: drop non-functional code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.0 KB
Line 
1/* $Id: server_presenter.h 53232 2014-11-05 11:23:32Z 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 IsVisivle() const;
209 int Reparent(uint64_t parentId);
210 int SetVisible(bool fVisible);
211 int SetSize(uint32_t width, uint32_t height);
212 int SetPosition(int32_t x, int32_t y);
213 int SetVisibleRegionsChanged();
214 int SetCompositor(const struct VBOXVR_SCR_COMPOSITOR * pCompositor);
215 int UpdateBegin();
216 void UpdateEnd();
217 uint64_t GetParentId();
218 ~CrFbWindow();
219
220 protected:
221
222 int Create();
223 void checkRegions();
224 bool isPresentNeeded();
225 bool checkInitedUpdating();
226 void Destroy();
227
228 private:
229
230 typedef union CR_FBWIN_FLAGS
231 {
232 struct {
233 uint32_t fVisible : 1;
234 uint32_t fDataPresented : 1;
235 uint32_t fForcePresentOnReenable : 1;
236 uint32_t fCompositoEntriesModified : 1;
237 uint32_t Reserved : 28;
238 };
239 uint32_t Value;
240 } CR_FBWIN_FLAGS;
241
242 GLint mSpuWindow;
243 const struct VBOXVR_SCR_COMPOSITOR * mpCompositor;
244 uint32_t mcUpdates;
245 int32_t mxPos;
246 int32_t myPos;
247 uint32_t mWidth;
248 uint32_t mHeight;
249 CR_FBWIN_FLAGS mFlags;
250 uint64_t mParentId;
251};
252
253
254class CrFbDisplayWindow : public CrFbDisplayBase
255{
256 public:
257
258 CrFbDisplayWindow(const RTRECT *pViewportRect, uint64_t parentId);
259 virtual ~CrFbDisplayWindow();
260 virtual int UpdateBegin(struct CR_FRAMEBUFFER *pFb);
261 virtual void UpdateEnd(struct CR_FRAMEBUFFER *pFb);
262 virtual int FramebufferChanged(struct CR_FRAMEBUFFER *pFb);
263 const RTRECT* getViewportRect();
264 virtual int setViewportRect(const RTRECT *pViewportRect);
265 virtual CrFbWindow * windowDetach(bool fCleanup = true);
266 virtual CrFbWindow * windowAttach(CrFbWindow * pNewWindow);
267 virtual int reparent(uint64_t parentId);
268 virtual bool isVisible();
269 int winVisibilityChanged();
270 CrFbWindow* getWindow();
271
272 protected:
273
274 virtual void onUpdateEnd();
275 virtual void ueRegions();
276 virtual int screenChanged();
277 virtual int windowSetCompositor(bool fSet);
278 virtual int windowCleanup();
279 virtual int fbCleanup();
280 bool isActive();
281 int windowDimensionsSync(bool fForceCleanup = false);
282 virtual int windowSync();
283 virtual int fbSync();
284 virtual const struct RTRECT* getRect();
285
286 private:
287
288 typedef union CR_FBDISPWINDOW_FLAGS
289 {
290 struct {
291 uint32_t fNeVisible : 1;
292 uint32_t fNeForce : 1;
293 uint32_t Reserved : 30;
294 };
295 uint32_t u32Value;
296 } CR_FBDISPWINDOW_FLAGS;
297
298 CrFbWindow *mpWindow;
299 RTRECT mViewportRect;
300 CR_FBDISPWINDOW_FLAGS mFlags;
301 uint32_t mu32Screen;
302 uint64_t mParentId;
303};
304
305
306class CrFbDisplayWindowRootVr : public CrFbDisplayWindow
307{
308 public:
309
310 CrFbDisplayWindowRootVr(const RTRECT *pViewportRect, uint64_t parentId);
311 virtual int EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
312 virtual int EntryAdded(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
313 virtual int EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry, HCR_FRAMEBUFFER_ENTRY hReplacedEntry);
314 virtual int EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
315 virtual int EntryRemoved(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
316 virtual int EntryDestroyed(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
317 virtual int setViewportRect(const RTRECT *pViewportRect);
318
319 protected:
320
321 virtual int windowSetCompositor(bool fSet);
322 virtual void ueRegions();
323 int compositorMarkUpdated();
324 virtual int screenChanged();
325 virtual const struct RTRECT* getRect();
326 virtual int fbCleanup();
327 virtual int fbSync();
328 VBOXVR_SCR_COMPOSITOR_ENTRY* entryAlloc();
329 void entryFree(VBOXVR_SCR_COMPOSITOR_ENTRY* pEntry);
330 int synchCompositorRegions();
331 virtual int synchCompositor();
332 virtual int clearCompositor();
333 void rootVrTranslateForPos();
334 static DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) rootVrGetCEntry(const VBOXVR_SCR_COMPOSITOR_ENTRY*pEntry, void *pvContext);
335
336 private:
337
338 VBOXVR_SCR_COMPOSITOR mCompositor;
339};
340
341
342class CrFbDisplayVrdp : public CrFbDisplayBase
343{
344 public:
345
346 CrFbDisplayVrdp();
347 virtual int EntryCreated(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
348 virtual int EntryReplaced(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hNewEntry, HCR_FRAMEBUFFER_ENTRY hReplacedEntry);
349 virtual int EntryTexChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
350 virtual int EntryRemoved(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
351 virtual int EntryDestroyed(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
352 virtual int EntryPosChanged(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
353 virtual int RegionsChanged(struct CR_FRAMEBUFFER *pFb);
354 virtual int FramebufferChanged(struct CR_FRAMEBUFFER *pFb);
355
356 protected:
357
358 void syncPos();
359 virtual int fbCleanup();
360 virtual int fbSync();
361 void vrdpDestroy(HCR_FRAMEBUFFER_ENTRY hEntry);
362 void vrdpGeometry(HCR_FRAMEBUFFER_ENTRY hEntry);
363 int vrdpRegions(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
364 int vrdpFrame(HCR_FRAMEBUFFER_ENTRY hEntry);
365 int vrdpRegionsAll(struct CR_FRAMEBUFFER *pFb);
366 int vrdpSynchEntry(struct CR_FRAMEBUFFER *pFb, HCR_FRAMEBUFFER_ENTRY hEntry);
367 int vrdpSyncEntryAll(struct CR_FRAMEBUFFER *pFb);
368 int vrdpCreate(HCR_FRAMEBUFFER hFb, HCR_FRAMEBUFFER_ENTRY hEntry);
369
370 private:
371
372 RTPOINT mPos;
373};
374
375
376typedef struct CR_FB_INFO
377{
378 CrFbDisplayComposite *pDpComposite;
379 uint32_t u32Id;
380 VBOXCMDVBVA_SCREENMAP_DECL(uint32_t, aTargetMap);
381} CR_FB_INFO;
382
383typedef struct CR_FBDISPLAY_INFO
384{
385 CrFbDisplayWindow *pDpWin;
386 CrFbDisplayWindowRootVr *pDpWinRootVr;
387 CrFbDisplayVrdp *pDpVrdp;
388 CrFbWindow *pWindow;
389 uint32_t u32DisplayMode;
390 uint32_t u32Id;
391 int32_t iFb;
392} CR_FBDISPLAY_INFO;
393
394typedef struct CR_PRESENTER_GLOBALS
395{
396#ifndef VBOXVDBG_MEMCACHE_DISABLE
397 RTMEMCACHE FbEntryLookasideList;
398 RTMEMCACHE FbTexLookasideList;
399 RTMEMCACHE CEntryLookasideList;
400#endif
401 uint32_t u32DisplayMode;
402 uint32_t u32DisabledDisplayMode;
403 bool fEnabled;
404 CRHashTable *pFbTexMap;
405 CR_FBDISPLAY_INFO aDisplayInfos[CR_MAX_GUEST_MONITORS];
406 CR_FBMAP FramebufferInitMap;
407 CR_FRAMEBUFFER aFramebuffers[CR_MAX_GUEST_MONITORS];
408 CR_FB_INFO aFbInfos[CR_MAX_GUEST_MONITORS];
409 bool fWindowsForceHidden;
410 uint32_t cbTmpBuf;
411 void *pvTmpBuf;
412 uint32_t cbTmpBuf2;
413 void *pvTmpBuf2;
414} CR_PRESENTER_GLOBALS;
415
416extern CR_PRESENTER_GLOBALS g_CrPresenter;
417
418
419HCR_FRAMEBUFFER_ENTRY CrFbEntryFromCompositorEntry(const struct VBOXVR_SCR_COMPOSITOR_ENTRY* pCEntry);
420
421#endif /* __SERVER_PRESENTER_H__ */
422
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