VirtualBox

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

Last change on this file since 8170 was 6973, checked in by vboxsync, 17 years ago

Initial commit of VRDP text cache (disabled).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.3 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+ddraw heap+VBVA buffer+displayinfo=cScreenSize
56 */
57typedef struct _VRAMLAYOUT
58{
59 ULONG cbVRAM;
60
61 ULONG offFrameBuffer;
62 ULONG cbFrameBuffer;
63
64 ULONG offDDRAWHeap; //@todo
65 ULONG cbDDRAWHeap;
66
67 ULONG offVBVABuffer;
68 ULONG cbVBVABuffer;
69
70 ULONG offDisplayInformation;
71 ULONG cbDisplayInformation;
72} VRAMLAYOUT;
73
74typedef struct
75{
76 PPDEV ppdev;
77} VBOXSURF, *PVBOXSURF;
78
79struct _PDEV
80{
81 HANDLE hDriver; // Handle to \Device\Screen
82 HDEV hdevEng; // Engine's handle to PDEV
83 HSURF hsurfScreenBitmap; // Engine's handle to VRAM screen bitmap surface
84 SURFOBJ *psoScreenBitmap; // VRAM screen bitmap surface
85 HSURF hsurfScreen; // Engine's handle to VRAM screen device surface
86 ULONG ulBitmapType;
87 HPALETTE hpalDefault; // Handle to the default palette for device.
88 PBYTE pjScreen; // This is pointer to base screen address
89 ULONG cxScreen; // Visible screen width
90 ULONG cyScreen; // Visible screen height
91 POINTL ptlOrg; // Where this display is anchored in
92 // the virtual desktop.
93 POINTL ptlDevOrg; // Device origin for DualView (0,0 for primary view).
94 ULONG ulMode; // Mode the mini-port driver is in.
95 LONG lDeltaScreen; // Distance from one scan to the next.
96
97 PVOID pOffscreenList; // linked list of DCI offscreen surfaces.
98 FLONG flRed; // For bitfields device, Red Mask
99 FLONG flGreen; // For bitfields device, Green Mask
100 FLONG flBlue; // For bitfields device, Blue Mask
101 ULONG cPaletteShift; // number of bits the 8-8-8 palette must
102 // be shifted by to fit in the hardware
103 // palette.
104 ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported.
105 POINTL ptlHotSpot; // adjustment for pointer hot spot
106 VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
107 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // hardware pointer attributes
108 DWORD cjPointerAttributes; // Size of buffer allocated
109 BOOL fHwCursorActive; // Are we currently using the hw cursor
110 PALETTEENTRY *pPal; // If this is pal managed, this is the pal
111 BOOL bSupportDCI; // Does the miniport support DCI?
112 FLONG flHooks;
113
114 VBVAENABLERESULT vbva;
115 uint32_t u32VRDPResetFlag;
116 BOOL fHwBufferOverflow;
117 VBVARECORD *pRecord;
118 VRDPBC cache;
119
120 ULONG cSSB; // Number of active saved screen bits records in the following array.
121 SSB aSSB[4]; // LIFO type stack for saved screen areas.
122
123 VBOXDISPLAYINFO *pInfo;
124 BOOLEAN bVBoxVideoSupported;
125 ULONG iDevice;
126 VRAMLAYOUT layout;
127
128 PVBOXSURF pdsurfScreen;
129
130#ifdef VBOX_WITH_DDRAW
131 BOOL bDdExclusiveMode;
132 DWORD dwNewDDSurfaceOffset;
133 DWORD cHeaps;
134 VIDEOMEMORY* pvmList;
135 struct {
136 DWORD bLocked;
137 RECTL rArea;
138 } ddLock;
139#endif /* VBOX_WITH_DDRAW */
140};
141
142#ifdef VBOX_WITH_OPENGL
143typedef struct
144{
145 DWORD dwVersion;
146 DWORD dwDriverVersion;
147 WCHAR szDriverName[256];
148} OPENGL_INFO, *POPENGL_INFO;
149#endif
150
151/* The global semaphore handle for all driver instances. */
152extern HSEMAPHORE ghsemHwBuffer;
153
154extern BOOL g_bOnNT40;
155
156DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
157BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *);
158BOOL bInitSURF(PPDEV, BOOL);
159BOOL bInitPaletteInfo(PPDEV, DEVINFO *);
160BOOL bInitPointer(PPDEV, DEVINFO *);
161BOOL bInit256ColorPalette(PPDEV);
162BOOL bInitNotificationThread(PPDEV);
163VOID vStopNotificationThread (PPDEV);
164VOID vDisablePalette(PPDEV);
165VOID vDisableSURF(PPDEV);
166
167#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
168
169//
170// Determines the size of the DriverExtra information in the DEVMODE
171// structure passed to and from the display driver.
172//
173
174#define DRIVER_EXTRA_SIZE 0
175
176#define DLL_NAME L"VBoxDisp" // Name of the DLL in UNICODE
177#define STANDARD_DEBUG_PREFIX "VBOXDISP: " // All debug output is prefixed
178#define ALLOC_TAG 'bvDD' // Four byte tag (characters in
179 // reverse order) used for memory
180 // allocations
181
182// VBOX
183typedef struct _CLIPRECTS {
184 ULONG c;
185 RECTL arcl[64];
186} CLIPRECTS;
187
188typedef struct _VRDPCLIPRECTS
189{
190 RECTL rclDstOrig; /* Original bounding rectancle. */
191 RECTL rclDst; /* Bounding rectangle of all rects. */
192 CLIPRECTS rects; /* Rectangles to update. */
193} VRDPCLIPRECTS;
194
195
196BOOL vboxVbvaEnable (PPDEV ppdev);
197void vboxVbvaDisable (PPDEV ppdev);
198
199BOOL vboxHwBufferBeginUpdate (PPDEV ppdev);
200void vboxHwBufferEndUpdate (PPDEV ppdev);
201
202BOOL vboxWrite (PPDEV ppdev, const void *pv, uint32_t cb);
203
204BOOL vboxOrderSupported (PPDEV ppdev, unsigned code);
205
206void VBoxProcessDisplayInfo(PPDEV ppdev);
207void VBoxUpdateDisplayInfo (PPDEV ppdev);
208
209void drvLoadEng (void);
210
211BOOL bIsScreenSurface (SURFOBJ *pso);
212
213__inline SURFOBJ *getSurfObj (SURFOBJ *pso)
214{
215 if (pso)
216 {
217 PPDEV ppdev = (PPDEV)pso->dhpdev;
218
219 if (ppdev)
220 {
221 if (ppdev->psoScreenBitmap && pso->hsurf == ppdev->hsurfScreen)
222 {
223 /* Convert the device PSO to the bitmap PSO which can be passed to Eng*. */
224 pso = ppdev->psoScreenBitmap;
225 }
226 }
227 }
228
229 return pso;
230}
231
232#define CONV_SURF(_pso) getSurfObj (_pso)
233
234__inline int format2BytesPerPixel(const SURFOBJ *pso)
235{
236 switch (pso->iBitmapFormat)
237 {
238 case BMF_16BPP: return 2;
239 case BMF_24BPP: return 3;
240 case BMF_32BPP: return 4;
241 }
242
243 return 0;
244}
245
246#ifdef VBOX_VBVA_ADJUST_RECT
247void vrdpAdjustRect (SURFOBJ *pso, RECTL *prcl);
248BOOL vbvaFindChangedRect (SURFOBJ *psoDest, SURFOBJ *psoSrc, RECTL *prclDest, POINTL *pptlSrc);
249#endif /* VBOX_VBVA_ADJUST_RECT */
250
251void vrdpReportDirtyRect (PPDEV ppdev, RECTL *prcl);
252void vbvaReportDirtyRect (PPDEV ppdev, RECTL *prcl);
253
254#define VRDP_TEXT_MAX_GLYPH_SIZE 0x100
255#define VRDP_TEXT_MAX_GLYPHS 0xfe
256
257BOOL vboxReportText (PPDEV ppdev,
258 VRDPCLIPRECTS *pClipRects,
259 STROBJ *pstro,
260 FONTOBJ *pfo,
261 RECTL *prclOpaque,
262 ULONG ulForeRGB,
263 ULONG ulBackRGB
264 );
265
266BOOL vrdpReportOrderGeneric (PPDEV ppdev,
267 const VRDPCLIPRECTS *pClipRects,
268 const void *pvOrder,
269 unsigned cbOrder,
270 unsigned code);
271
272
273#include <iprt/assert.h>
274
275#define VBVA_ASSERT(expr) \
276 do { \
277 if (!(expr)) \
278 { \
279 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
280 AssertMsg2("!!!\n"); \
281 } \
282 } while (0)
283
284#ifdef STAT_sunlover
285extern ULONG gStatCopyBitsOffscreenToScreen;
286extern ULONG gStatCopyBitsScreenToScreen;
287extern ULONG gStatBitBltOffscreenToScreen;
288extern ULONG gStatBitBltScreenToScreen;
289extern ULONG gStatUnchangedOffscreenToScreen;
290extern ULONG gStatUnchangedOffscreenToScreenCRC;
291extern ULONG gStatNonTransientEngineBitmaps;
292extern ULONG gStatTransientEngineBitmaps;
293extern ULONG gStatUnchangedBitmapsCRC;
294extern ULONG gStatUnchangedBitmapsDeviceCRC;
295extern ULONG gStatBitmapsCRC;
296extern ULONG gStatBitBltScreenPattern;
297extern ULONG gStatBitBltScreenSquare;
298extern ULONG gStatBitBltScreenPatternReported;
299extern ULONG gStatBitBltScreenSquareReported;
300extern ULONG gStatCopyBitsScreenSquare;
301
302extern ULONG gStatEnablePDEV;
303extern ULONG gStatCompletePDEV;
304extern ULONG gStatDisablePDEV;
305extern ULONG gStatEnableSurface;
306extern ULONG gStatDisableSurface;
307extern ULONG gStatAssertMode;
308extern ULONG gStatDisableDriver;
309extern ULONG gStatCreateDeviceBitmap;
310extern ULONG gStatDeleteDeviceBitmap;
311extern ULONG gStatDitherColor;
312extern ULONG gStatStrokePath;
313extern ULONG gStatFillPath;
314extern ULONG gStatStrokeAndFillPath;
315extern ULONG gStatPaint;
316extern ULONG gStatBitBlt;
317extern ULONG gStatCopyBits;
318extern ULONG gStatStretchBlt;
319extern ULONG gStatSetPalette;
320extern ULONG gStatTextOut;
321extern ULONG gStatSetPointerShape;
322extern ULONG gStatMovePointer;
323extern ULONG gStatLineTo;
324extern ULONG gStatSynchronize;
325extern ULONG gStatGetModes;
326extern ULONG gStatGradientFill;
327extern ULONG gStatStretchBltROP;
328extern ULONG gStatPlgBlt;
329extern ULONG gStatAlphaBlend;
330extern ULONG gStatTransparentBlt;
331
332void statPrint (void);
333
334#define STATDRVENTRY(a, b) do { if (bIsScreenSurface (b)) gStat##a++; } while (0)
335#define STATPRINT do { statPrint (); } while (0)
336#else
337#define STATDRVENTRY(a, b)
338#define STATPRINT
339#endif /* STAT_sunlover */
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