VirtualBox

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

Last change on this file since 16615 was 16615, checked in by vboxsync, 16 years ago

additional header updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.1 KB
Line 
1/******************************Module*Header*******************************\
2*
3* Copyright (C) 2006-2007 Sun Microsystems, Inc.
4*
5* This file is part of VirtualBox Open Source Edition (OSE), as
6* available from http://www.virtualbox.org. This file is free software;
7* you can redistribute it and/or modify it under the terms of the GNU
8* General Public License (GPL) as published by the Free Software
9* Foundation, in version 2 as it comes in the "COPYING" file of the
10* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
11* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
12*
13* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
14* Clara, CA 95054 USA or visit http://www.sun.com if you need
15* additional information or have any questions.
16*/
17/*
18* Based in part on Microsoft DDK sample code
19*
20* *******************
21* * GDI SAMPLE CODE *
22* *******************
23*
24* Module Name: driver.h
25*
26* contains prototypes for the frame buffer driver.
27*
28* Copyright (c) 1992-1998 Microsoft Corporation
29\**************************************************************************/
30
31#include "stddef.h"
32#include <stdarg.h>
33#include "windef.h"
34#include "wingdi.h"
35#include "winddi.h"
36#include "devioctl.h"
37#include "ntddvdeo.h"
38#include "debug.h"
39
40#include "../Miniport/vboxioctl.h"
41
42#include <VBox/VBoxVideo.h>
43
44/* Forward declaration. */
45struct _PDEV;
46typedef struct _PDEV PDEV;
47typedef PDEV *PPDEV;
48
49typedef struct _VBOXDISPLAYINFO
50{
51 VBOXVIDEOINFOHDR hdrLink;
52 VBOXVIDEOINFOLINK link;
53 VBOXVIDEOINFOHDR hdrScreen;
54 VBOXVIDEOINFOSCREEN screen;
55 VBOXVIDEOINFOHDR hdrHostEvents;
56 VBOXVIDEOINFOHOSTEVENTS hostEvents;
57 VBOXVIDEOINFOHDR hdrEnd;
58} VBOXDISPLAYINFO;
59
60#include "vbvavrdp.h"
61#include "vrdpbmp.h"
62
63/* Saved screen bits information. */
64typedef struct _SSB
65{
66 ULONG ident; /* 1 based index in the stack = the handle returned by DrvSaveScreenBits (SS_SAVE) */
67 BYTE *pBuffer; /* Buffer where screen bits are saved. */
68} SSB;
69
70/* VRAM
71 * | | | | |
72 * 0+framebuffer+ddraw heap+VBVA buffer+displayinfo=cScreenSize
73 */
74typedef struct _VRAMLAYOUT
75{
76 ULONG cbVRAM;
77
78 ULONG offFrameBuffer;
79 ULONG cbFrameBuffer;
80
81 ULONG offDDRAWHeap; //@todo
82 ULONG cbDDRAWHeap;
83
84 ULONG offVBVABuffer;
85 ULONG cbVBVABuffer;
86
87 ULONG offDisplayInformation;
88 ULONG cbDisplayInformation;
89} VRAMLAYOUT;
90
91typedef struct
92{
93 PPDEV ppdev;
94} VBOXSURF, *PVBOXSURF;
95
96struct _PDEV
97{
98 HANDLE hDriver; // Handle to \Device\Screen
99 HDEV hdevEng; // Engine's handle to PDEV
100 HSURF hsurfScreenBitmap; // Engine's handle to VRAM screen bitmap surface
101 SURFOBJ *psoScreenBitmap; // VRAM screen bitmap surface
102 HSURF hsurfScreen; // Engine's handle to VRAM screen device surface
103 ULONG ulBitmapType;
104 HPALETTE hpalDefault; // Handle to the default palette for device.
105 PBYTE pjScreen; // This is pointer to base screen address
106 ULONG cxScreen; // Visible screen width
107 ULONG cyScreen; // Visible screen height
108 POINTL ptlOrg; // Where this display is anchored in
109 // the virtual desktop.
110 POINTL ptlDevOrg; // Device origin for DualView (0,0 for primary view).
111 ULONG ulMode; // Mode the mini-port driver is in.
112 LONG lDeltaScreen; // Distance from one scan to the next.
113
114 PVOID pOffscreenList; // linked list of DCI offscreen surfaces.
115 FLONG flRed; // For bitfields device, Red Mask
116 FLONG flGreen; // For bitfields device, Green Mask
117 FLONG flBlue; // For bitfields device, Blue Mask
118 ULONG cPaletteShift; // number of bits the 8-8-8 palette must
119 // be shifted by to fit in the hardware
120 // palette.
121 ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported.
122 POINTL ptlHotSpot; // adjustment for pointer hot spot
123 VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
124 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // hardware pointer attributes
125 DWORD cjPointerAttributes; // Size of buffer allocated
126 BOOL fHwCursorActive; // Are we currently using the hw cursor
127 PALETTEENTRY *pPal; // If this is pal managed, this is the pal
128 BOOL bSupportDCI; // Does the miniport support DCI?
129 FLONG flHooks;
130
131 VBVAENABLERESULT vbva;
132 uint32_t u32VRDPResetFlag;
133 BOOL fHwBufferOverflow;
134 VBVARECORD *pRecord;
135 VRDPBC cache;
136
137 ULONG cSSB; // Number of active saved screen bits records in the following array.
138 SSB aSSB[4]; // LIFO type stack for saved screen areas.
139
140 VBOXDISPLAYINFO *pInfo;
141 BOOLEAN bVBoxVideoSupported;
142 ULONG iDevice;
143 VRAMLAYOUT layout;
144
145 PVBOXSURF pdsurfScreen;
146
147#ifdef VBOX_WITH_DDRAW
148 BOOL bDdExclusiveMode;
149 DWORD dwNewDDSurfaceOffset;
150 DWORD cHeaps;
151 VIDEOMEMORY* pvmList;
152 struct {
153 DWORD bLocked;
154 RECTL rArea;
155 } ddLock;
156#endif /* VBOX_WITH_DDRAW */
157};
158
159#ifdef VBOX_WITH_OPENGL
160typedef struct
161{
162 DWORD dwVersion;
163 DWORD dwDriverVersion;
164 WCHAR szDriverName[256];
165} OPENGL_INFO, *POPENGL_INFO;
166#endif
167
168/* The global semaphore handle for all driver instances. */
169extern HSEMAPHORE ghsemHwBuffer;
170
171extern BOOL g_bOnNT40;
172
173DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
174BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *);
175BOOL bInitSURF(PPDEV, BOOL);
176BOOL bInitPaletteInfo(PPDEV, DEVINFO *);
177BOOL bInitPointer(PPDEV, DEVINFO *);
178BOOL bInit256ColorPalette(PPDEV);
179BOOL bInitNotificationThread(PPDEV);
180VOID vStopNotificationThread (PPDEV);
181VOID vDisablePalette(PPDEV);
182VOID vDisableSURF(PPDEV);
183
184#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
185
186//
187// Determines the size of the DriverExtra information in the DEVMODE
188// structure passed to and from the display driver.
189//
190
191#define DRIVER_EXTRA_SIZE 0
192
193#define DLL_NAME L"VBoxDisp" // Name of the DLL in UNICODE
194#define STANDARD_DEBUG_PREFIX "VBOXDISP: " // All debug output is prefixed
195#define ALLOC_TAG 'bvDD' // Four byte tag (characters in
196 // reverse order) used for memory
197 // allocations
198
199// VBOX
200typedef struct _CLIPRECTS {
201 ULONG c;
202 RECTL arcl[64];
203} CLIPRECTS;
204
205typedef struct _VRDPCLIPRECTS
206{
207 RECTL rclDstOrig; /* Original bounding rectancle. */
208 RECTL rclDst; /* Bounding rectangle of all rects. */
209 CLIPRECTS rects; /* Rectangles to update. */
210} VRDPCLIPRECTS;
211
212
213BOOL vboxVbvaEnable (PPDEV ppdev);
214void vboxVbvaDisable (PPDEV ppdev);
215
216BOOL vboxHwBufferBeginUpdate (PPDEV ppdev);
217void vboxHwBufferEndUpdate (PPDEV ppdev);
218
219BOOL vboxWrite (PPDEV ppdev, const void *pv, uint32_t cb);
220
221BOOL vboxOrderSupported (PPDEV ppdev, unsigned code);
222
223void VBoxProcessDisplayInfo(PPDEV ppdev);
224void VBoxUpdateDisplayInfo (PPDEV ppdev);
225
226void drvLoadEng (void);
227
228BOOL bIsScreenSurface (SURFOBJ *pso);
229
230__inline SURFOBJ *getSurfObj (SURFOBJ *pso)
231{
232 if (pso)
233 {
234 PPDEV ppdev = (PPDEV)pso->dhpdev;
235
236 if (ppdev)
237 {
238 if (ppdev->psoScreenBitmap && pso->hsurf == ppdev->hsurfScreen)
239 {
240 /* Convert the device PSO to the bitmap PSO which can be passed to Eng*. */
241 pso = ppdev->psoScreenBitmap;
242 }
243 }
244 }
245
246 return pso;
247}
248
249#define CONV_SURF(_pso) getSurfObj (_pso)
250
251__inline int format2BytesPerPixel(const SURFOBJ *pso)
252{
253 switch (pso->iBitmapFormat)
254 {
255 case BMF_16BPP: return 2;
256 case BMF_24BPP: return 3;
257 case BMF_32BPP: return 4;
258 }
259
260 return 0;
261}
262
263#ifdef VBOX_VBVA_ADJUST_RECT
264void vrdpAdjustRect (SURFOBJ *pso, RECTL *prcl);
265BOOL vbvaFindChangedRect (SURFOBJ *psoDest, SURFOBJ *psoSrc, RECTL *prclDest, POINTL *pptlSrc);
266#endif /* VBOX_VBVA_ADJUST_RECT */
267
268void vrdpReportDirtyRect (PPDEV ppdev, RECTL *prcl);
269void vbvaReportDirtyRect (PPDEV ppdev, RECTL *prcl);
270
271#define VRDP_TEXT_MAX_GLYPH_SIZE 0x100
272#define VRDP_TEXT_MAX_GLYPHS 0xfe
273
274BOOL vboxReportText (PPDEV ppdev,
275 VRDPCLIPRECTS *pClipRects,
276 STROBJ *pstro,
277 FONTOBJ *pfo,
278 RECTL *prclOpaque,
279 ULONG ulForeRGB,
280 ULONG ulBackRGB
281 );
282
283BOOL vrdpReportOrderGeneric (PPDEV ppdev,
284 const VRDPCLIPRECTS *pClipRects,
285 const void *pvOrder,
286 unsigned cbOrder,
287 unsigned code);
288
289
290#include <iprt/assert.h>
291
292#define VBVA_ASSERT(expr) \
293 do { \
294 if (!(expr)) \
295 { \
296 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
297 AssertMsg2("!!!\n"); \
298 } \
299 } while (0)
300
301#ifdef STAT_sunlover
302extern ULONG gStatCopyBitsOffscreenToScreen;
303extern ULONG gStatCopyBitsScreenToScreen;
304extern ULONG gStatBitBltOffscreenToScreen;
305extern ULONG gStatBitBltScreenToScreen;
306extern ULONG gStatUnchangedOffscreenToScreen;
307extern ULONG gStatUnchangedOffscreenToScreenCRC;
308extern ULONG gStatNonTransientEngineBitmaps;
309extern ULONG gStatTransientEngineBitmaps;
310extern ULONG gStatUnchangedBitmapsCRC;
311extern ULONG gStatUnchangedBitmapsDeviceCRC;
312extern ULONG gStatBitmapsCRC;
313extern ULONG gStatBitBltScreenPattern;
314extern ULONG gStatBitBltScreenSquare;
315extern ULONG gStatBitBltScreenPatternReported;
316extern ULONG gStatBitBltScreenSquareReported;
317extern ULONG gStatCopyBitsScreenSquare;
318
319extern ULONG gStatEnablePDEV;
320extern ULONG gStatCompletePDEV;
321extern ULONG gStatDisablePDEV;
322extern ULONG gStatEnableSurface;
323extern ULONG gStatDisableSurface;
324extern ULONG gStatAssertMode;
325extern ULONG gStatDisableDriver;
326extern ULONG gStatCreateDeviceBitmap;
327extern ULONG gStatDeleteDeviceBitmap;
328extern ULONG gStatDitherColor;
329extern ULONG gStatStrokePath;
330extern ULONG gStatFillPath;
331extern ULONG gStatStrokeAndFillPath;
332extern ULONG gStatPaint;
333extern ULONG gStatBitBlt;
334extern ULONG gStatCopyBits;
335extern ULONG gStatStretchBlt;
336extern ULONG gStatSetPalette;
337extern ULONG gStatTextOut;
338extern ULONG gStatSetPointerShape;
339extern ULONG gStatMovePointer;
340extern ULONG gStatLineTo;
341extern ULONG gStatSynchronize;
342extern ULONG gStatGetModes;
343extern ULONG gStatGradientFill;
344extern ULONG gStatStretchBltROP;
345extern ULONG gStatPlgBlt;
346extern ULONG gStatAlphaBlend;
347extern ULONG gStatTransparentBlt;
348
349void statPrint (void);
350
351#define STATDRVENTRY(a, b) do { if (bIsScreenSurface (b)) gStat##a++; } while (0)
352#define STATPRINT do { statPrint (); } while (0)
353#else
354#define STATDRVENTRY(a, b)
355#define STATPRINT
356#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