VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h@ 4071

Last change on this file since 4071 was 4061, checked in by vboxsync, 18 years ago

Reserve VBVA memory buffer in the guest VRAM (Windows guest).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.9 KB
Line 
1/******************************Module*Header*******************************\
2*
3* *******************
4* * GDI SAMPLE CODE *
5* *******************
6*
7* Module Name: driver.h
8*
9* contains prototypes for the frame buffer driver.
10*
11* Copyright (c) 1992-1998 Microsoft Corporation
12\**************************************************************************/
13
14#include "stddef.h"
15#include <stdarg.h>
16#include "windef.h"
17#include "wingdi.h"
18#include "winddi.h"
19#include "devioctl.h"
20#include "ntddvdeo.h"
21#include "debug.h"
22
23#include "../Miniport/vboxioctl.h"
24
25#include <VBox/VBoxVideo.h>
26
27/* Forward declaration. */
28struct _PDEV;
29typedef struct _PDEV PDEV;
30typedef PDEV *PPDEV;
31
32typedef struct _VBOXDISPLAYINFO
33{
34 VBOXVIDEOINFOHDR hdrLink;
35 VBOXVIDEOINFOLINK link;
36 VBOXVIDEOINFOHDR hdrScreen;
37 VBOXVIDEOINFOSCREEN screen;
38 VBOXVIDEOINFOHDR hdrHostEvents;
39 VBOXVIDEOINFOHOSTEVENTS hostEvents;
40 VBOXVIDEOINFOHDR hdrEnd;
41} VBOXDISPLAYINFO;
42
43#include "vbvavrdp.h"
44#include "vrdpbmp.h"
45
46/* Saved screen bits information. */
47typedef struct _SSB
48{
49 ULONG ident; /* 1 based index in the stack = the handle returned by DrvSaveScreenBits (SS_SAVE) */
50 BYTE *pBuffer; /* Buffer where screen bits are saved. */
51} SSB;
52
53/* VRAM
54 * | | | | |
55 * 0+framebuffer+VBVA buffer+ddraw heap+displayinfo=cScreenSize
56 */
57typedef struct _VRAMLAYOUT
58{
59 ULONG cbVRAM;
60
61 ULONG offFrameBuffer;
62 ULONG cbFrameBuffer;
63
64 ULONG offVBVABuffer;
65 ULONG cbVBVABuffer;
66
67 ULONG offDDRAWHeap;
68 ULONG cbDDRAWHeap;
69
70 ULONG offDisplayInformation;
71 ULONG cbDisplayInformation;
72} VRAMLAYOUT;
73
74struct _PDEV
75{
76 HANDLE hDriver; // Handle to \Device\Screen
77 HDEV hdevEng; // Engine's handle to PDEV
78 HSURF hsurfScreenBitmap; // Engine's handle to VRAM screen bitmap surface
79 SURFOBJ *psoScreenBitmap; // VRAM screen bitmap surface
80 HSURF hsurfScreen; // Engine's handle to VRAM screen device surface
81 ULONG ulBitmapType;
82 HPALETTE hpalDefault; // Handle to the default palette for device.
83 PBYTE pjScreen; // This is pointer to base screen address
84 ULONG cxScreen; // Visible screen width
85 ULONG cyScreen; // Visible screen height
86 POINTL ptlOrg; // Where this display is anchored in
87 // the virtual desktop.
88 POINTL ptlDevOrg; // Device origin for DualView (0,0 for primary view).
89 ULONG ulMode; // Mode the mini-port driver is in.
90 LONG lDeltaScreen; // Distance from one scan to the next.
91
92 PVOID pOffscreenList; // linked list of DCI offscreen surfaces.
93 FLONG flRed; // For bitfields device, Red Mask
94 FLONG flGreen; // For bitfields device, Green Mask
95 FLONG flBlue; // For bitfields device, Blue Mask
96 ULONG cPaletteShift; // number of bits the 8-8-8 palette must
97 // be shifted by to fit in the hardware
98 // palette.
99 ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported.
100 POINTL ptlHotSpot; // adjustment for pointer hot spot
101 VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
102 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // hardware pointer attributes
103 DWORD cjPointerAttributes; // Size of buffer allocated
104 BOOL fHwCursorActive; // Are we currently using the hw cursor
105 PALETTEENTRY *pPal; // If this is pal managed, this is the pal
106 BOOL bSupportDCI; // Does the miniport support DCI?
107 FLONG flHooks;
108
109 VBVAENABLERESULT vbva;
110 uint32_t u32VRDPResetFlag;
111 BOOL fHwBufferOverflow;
112 VBVARECORD *pRecord;
113 VRDPBC cache;
114
115 ULONG cSSB; // Number of active saved screen bits records in the following array.
116 SSB aSSB[4]; // LIFO type stack for saved screen areas.
117
118 VBOXDISPLAYINFO *pInfo;
119 BOOLEAN bVBoxVideoSupported;
120 ULONG iDevice;
121 VRAMLAYOUT layout;
122
123#ifdef VBOX_WITH_DDRAW
124 BOOL bDdExclusiveMode;
125 DWORD dwNewDDSurfaceOffset;
126 DWORD cHeaps;
127 VIDEOMEMORY* pvmList;
128#endif
129};
130
131#ifdef VBOX_WITH_OPENGL
132typedef struct
133{
134 DWORD dwVersion;
135 DWORD dwDriverVersion;
136 WCHAR szDriverName[256];
137} OPENGL_INFO, *POPENGL_INFO;
138#endif
139
140/* The global semaphore handle for all driver instances. */
141extern HSEMAPHORE ghsemHwBuffer;
142
143
144DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
145BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *);
146BOOL bInitSURF(PPDEV, BOOL);
147BOOL bInitPaletteInfo(PPDEV, DEVINFO *);
148BOOL bInitPointer(PPDEV, DEVINFO *);
149BOOL bInit256ColorPalette(PPDEV);
150BOOL bInitNotificationThread(PPDEV);
151VOID vStopNotificationThread (PPDEV);
152VOID vDisablePalette(PPDEV);
153VOID vDisableSURF(PPDEV);
154
155#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
156
157//
158// Determines the size of the DriverExtra information in the DEVMODE
159// structure passed to and from the display driver.
160//
161
162#define DRIVER_EXTRA_SIZE 0
163
164#define DLL_NAME L"VBoxDisp" // Name of the DLL in UNICODE
165#define STANDARD_DEBUG_PREFIX "VBOXDISP: " // All debug output is prefixed
166#define ALLOC_TAG 'bvDD' // Four byte tag (characters in
167 // reverse order) used for memory
168 // allocations
169
170// VBOX
171typedef struct _CLIPRECTS {
172 ULONG c;
173 RECTL arcl[64];
174} CLIPRECTS;
175
176
177BOOL vboxVbvaEnable (PPDEV ppdev);
178void vboxVbvaDisable (PPDEV ppdev);
179
180BOOL vboxHwBufferBeginUpdate (PPDEV ppdev);
181void vboxHwBufferEndUpdate (PPDEV ppdev);
182
183BOOL vboxWrite (PPDEV ppdev, const void *pv, uint32_t cb);
184
185BOOL vboxOrderSupported (PPDEV ppdev, unsigned code);
186
187void VBoxProcessDisplayInfo(PPDEV ppdev);
188void VBoxUpdateDisplayInfo (PPDEV ppdev);
189
190void drvLoadEng (void);
191
192BOOL bIsScreenSurface (SURFOBJ *pso);
193
194__inline SURFOBJ *getSurfObj (SURFOBJ *pso)
195{
196 if (pso)
197 {
198 PPDEV ppdev = (PPDEV)pso->dhpdev;
199
200 if (ppdev)
201 {
202 if (bIsScreenSurface(pso))
203 {
204 pso = ppdev->psoScreenBitmap;
205 }
206 }
207 }
208
209 return pso;
210}
211
212#define CONV_SURF(_pso) getSurfObj (_pso)
213
214__inline int format2BytesPerPixel(const SURFOBJ *pso)
215{
216 switch (pso->iBitmapFormat)
217 {
218 case BMF_16BPP: return 2;
219 case BMF_24BPP: return 3;
220 case BMF_32BPP: return 4;
221 }
222
223 return 0;
224}
225
226#include <iprt/assert.h>
227
228#define VBVA_ASSERT(expr) \
229 do { \
230 if (!(expr)) \
231 { \
232 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
233 AssertMsg2("!!!\n"); \
234 } \
235 } while (0)
236
237#ifdef STAT_sunlover
238extern ULONG gStatCopyBitsOffscreenToScreen;
239extern ULONG gStatCopyBitsScreenToScreen;
240extern ULONG gStatBitBltOffscreenToScreen;
241extern ULONG gStatBitBltScreenToScreen;
242extern ULONG gStatUnchangedOffscreenToScreen;
243extern ULONG gStatUnchangedOffscreenToScreenCRC;
244extern ULONG gStatNonTransientEngineBitmaps;
245extern ULONG gStatTransientEngineBitmaps;
246extern ULONG gStatUnchangedBitmapsCRC;
247extern ULONG gStatUnchangedBitmapsDeviceCRC;
248extern ULONG gStatBitmapsCRC;
249extern ULONG gStatBitBltScreenPattern;
250extern ULONG gStatBitBltScreenSquare;
251extern ULONG gStatBitBltScreenPatternReported;
252extern ULONG gStatBitBltScreenSquareReported;
253extern ULONG gStatCopyBitsScreenSquare;
254
255extern ULONG gStatEnablePDEV;
256extern ULONG gStatCompletePDEV;
257extern ULONG gStatDisablePDEV;
258extern ULONG gStatEnableSurface;
259extern ULONG gStatDisableSurface;
260extern ULONG gStatAssertMode;
261extern ULONG gStatDisableDriver;
262extern ULONG gStatCreateDeviceBitmap;
263extern ULONG gStatDeleteDeviceBitmap;
264extern ULONG gStatDitherColor;
265extern ULONG gStatStrokePath;
266extern ULONG gStatFillPath;
267extern ULONG gStatStrokeAndFillPath;
268extern ULONG gStatPaint;
269extern ULONG gStatBitBlt;
270extern ULONG gStatCopyBits;
271extern ULONG gStatStretchBlt;
272extern ULONG gStatSetPalette;
273extern ULONG gStatTextOut;
274extern ULONG gStatSetPointerShape;
275extern ULONG gStatMovePointer;
276extern ULONG gStatLineTo;
277extern ULONG gStatSynchronize;
278extern ULONG gStatGetModes;
279extern ULONG gStatGradientFill;
280extern ULONG gStatStretchBltROP;
281extern ULONG gStatPlgBlt;
282extern ULONG gStatAlphaBlend;
283extern ULONG gStatTransparentBlt;
284
285void statPrint (void);
286
287#define STATDRVENTRY(a, b) do { if (bIsScreenSurface (b)) gStat##a++; } while (0)
288#define STATPRINT do { statPrint (); } while (0)
289#else
290#define STATDRVENTRY(a, b)
291#define STATPRINT
292#endif /* STAT_sunlover */
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