VirtualBox

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

Last change on this file since 53814 was 53814, checked in by vboxsync, 10 years ago

Host 3D: prepare for content scaling.

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

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