VirtualBox

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

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

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