VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/Mirror/enable.c@ 26505

Last change on this file since 26505 was 26505, checked in by vboxsync, 15 years ago

Additions: tabs -> spaces.

  • Property svn:eol-style set to native
File size: 11.0 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: enable.c
25*
26* This module contains the functions that enable and disable the
27* driver, the pdev, and the surface.
28*
29* Copyright (c) 1992-1998 Microsoft Corporation
30\**************************************************************************/
31#define DBG 1
32
33#include "driver.h"
34
35// The driver function table with all function index/address pairs
36
37static DRVFN gadrvfn[] =
38{
39 { INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV },
40 { INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV },
41 { INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV },
42 { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface },
43 { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface },
44 { INDEX_DrvAssertMode, (PFN) DrvAssertMode },
45 { INDEX_DrvTextOut, (PFN) DrvTextOut },
46 { INDEX_DrvBitBlt, (PFN) DrvBitBlt },
47 { INDEX_DrvCopyBits, (PFN) DrvCopyBits },
48 { INDEX_DrvStrokePath, (PFN) DrvStrokePath },
49};
50
51//
52// always hook these routines to ensure the mirrored driver
53// is called for our surfaces
54//
55
56#define flGlobalHooks HOOK_BITBLT|HOOK_TEXTOUT|HOOK_COPYBITS|HOOK_STROKEPATH
57
58// Define the functions you want to hook for 8/16/24/32 pel formats
59
60#define HOOKS_BMF8BPP 0
61
62#define HOOKS_BMF16BPP 0
63
64#define HOOKS_BMF24BPP 0
65
66#define HOOKS_BMF32BPP 0
67
68/******************************Public*Routine******************************\
69* DrvEnableDriver
70*
71* Enables the driver by retrieving the drivers function table and version.
72*
73\**************************************************************************/
74
75BOOL DrvEnableDriver(
76ULONG iEngineVersion,
77ULONG cj,
78PDRVENABLEDATA pded)
79{
80// Engine Version is passed down so future drivers can support previous
81// engine versions. A next generation driver can support both the old
82// and new engine conventions if told what version of engine it is
83// working with. For the first version the driver does nothing with it.
84
85 iEngineVersion;
86
87 DISPDBG((0,"DrvEnableDriver: mirror\n"));
88
89// Fill in as much as we can.
90
91 if (cj >= sizeof(DRVENABLEDATA))
92 pded->pdrvfn = gadrvfn;
93
94 if (cj >= (sizeof(ULONG) * 2))
95 pded->c = sizeof(gadrvfn) / sizeof(DRVFN);
96
97// DDI version this driver was targeted for is passed back to engine.
98// Future graphic's engine may break calls down to old driver format.
99
100 if (cj >= sizeof(ULONG))
101 // DDI_DRIVER_VERSION is now out-dated. See winddi.h
102 // DDI_DRIVER_VERSION_NT4 is equivalent to the old DDI_DRIVER_VERSION
103 pded->iDriverVersion = DDI_DRIVER_VERSION_NT4;
104
105 return(TRUE);
106}
107
108/******************************Public*Routine******************************\
109* DrvEnablePDEV
110*
111* DDI function, Enables the Physical Device.
112*
113* Return Value: device handle to pdev.
114*
115\**************************************************************************/
116
117DHPDEV DrvEnablePDEV(
118DEVMODEW *pDevmode, // Pointer to DEVMODE
119PWSTR pwszLogAddress, // Logical address
120ULONG cPatterns, // number of patterns
121HSURF *ahsurfPatterns, // return standard patterns
122ULONG cjGdiInfo, // Length of memory pointed to by pGdiInfo
123ULONG *pGdiInfo, // Pointer to GdiInfo structure
124ULONG cjDevInfo, // Length of following PDEVINFO structure
125DEVINFO *pDevInfo, // physical device information structure
126HDEV hdev, // HDEV, used for callbacks
127PWSTR pwszDeviceName, // DeviceName - not used
128HANDLE hDriver) // Handle to base driver
129{
130 GDIINFO GdiInfo;
131 DEVINFO DevInfo;
132 PPDEV ppdev = (PPDEV) NULL;
133
134 DISPDBG((0,"DrvEnablePDEV\n"));
135
136 UNREFERENCED_PARAMETER(pwszLogAddress);
137 UNREFERENCED_PARAMETER(pwszDeviceName);
138
139 // Allocate a physical device structure.
140
141 ppdev = (PPDEV) EngAllocMem(0, sizeof(PDEV), ALLOC_TAG);
142
143 if (ppdev == (PPDEV) NULL)
144 {
145 RIP("DISP DrvEnablePDEV failed EngAllocMem\n");
146 return((DHPDEV) 0);
147 }
148
149 memset(ppdev, 0, sizeof(PDEV));
150
151 // Save the screen handle in the PDEV.
152
153 ppdev->hDriver = hDriver;
154
155 // Get the current screen mode information. Set up device caps and devinfo.
156
157 if (!bInitPDEV(ppdev, pDevmode, &GdiInfo, &DevInfo))
158 {
159 DISPDBG((0,"DISP DrvEnablePDEV failed\n"));
160 goto error_free;
161 }
162
163 // Copy the devinfo into the engine buffer.
164
165 memcpy(pDevInfo, &DevInfo, min(sizeof(DEVINFO), cjDevInfo));
166
167 // Set the pdevCaps with GdiInfo we have prepared to the list of caps for this
168 // pdev.
169
170 memcpy(pGdiInfo, &GdiInfo, min(cjGdiInfo, sizeof(GDIINFO)));
171
172 //
173 DISPDBG((0,"DrvEnablePDEV OK\n"));
174 return((DHPDEV) ppdev);
175
176 // Error case for failure.
177error_free:
178 EngFreeMem(ppdev);
179 DISPDBG((0,"DrvEnablePDEV FAIL!!!\n"));
180 return((DHPDEV) 0);
181}
182
183/******************************Public*Routine******************************\
184* DrvCompletePDEV
185*
186* Store the HPDEV, the engines handle for this PDEV, in the DHPDEV.
187*
188\**************************************************************************/
189
190VOID DrvCompletePDEV(
191DHPDEV dhpdev,
192HDEV hdev)
193{
194 DISPDBG((0,"DrvCompletePDEV\n"));
195 ((PPDEV) dhpdev)->hdevEng = hdev;
196 DISPDBG((0,"DrvCompletePDEV OK\n"));
197}
198
199/******************************Public*Routine******************************\
200* DrvDisablePDEV
201*
202* Release the resources allocated in DrvEnablePDEV. If a surface has been
203* enabled DrvDisableSurface will have already been called.
204*
205\**************************************************************************/
206
207VOID DrvDisablePDEV(
208DHPDEV dhpdev)
209{
210 PPDEV ppdev = (PPDEV) dhpdev;
211 DISPDBG((0,"DrvDisablePDEV\n"));
212
213 EngDeletePalette(ppdev->hpalDefault);
214
215 EngFreeMem(dhpdev);
216}
217
218/******************************Public*Routine******************************\
219* DrvEnableSurface
220*
221* Enable the surface for the device. Hook the calls this driver supports.
222*
223* Return: Handle to the surface if successful, 0 for failure.
224*
225\**************************************************************************/
226
227HSURF DrvEnableSurface(
228DHPDEV dhpdev)
229{
230 PPDEV ppdev;
231 HSURF hsurf;
232 SIZEL sizl;
233 ULONG ulBitmapType;
234 FLONG flHooks;
235 ULONG mirrorsize;
236 MIRRSURF *mirrsurf;
237 DHSURF dhsurf;
238
239 // Create engine bitmap around frame buffer.
240
241 DISPDBG((0,"DrvEnableSurface:\n"));
242
243 ppdev = (PPDEV) dhpdev;
244
245 ppdev->ptlOrg.x = 0;
246 ppdev->ptlOrg.y = 0;
247
248 sizl.cx = ppdev->cxScreen;
249 sizl.cy = ppdev->cyScreen;
250
251 if (ppdev->ulBitCount == 16)
252 {
253 ulBitmapType = BMF_16BPP;
254 flHooks = HOOKS_BMF16BPP;
255 }
256 else if (ppdev->ulBitCount == 24)
257 {
258 ulBitmapType = BMF_24BPP;
259 flHooks = HOOKS_BMF24BPP;
260 }
261 else
262 {
263 ulBitmapType = BMF_32BPP;
264 flHooks = HOOKS_BMF32BPP;
265 }
266
267 flHooks |= flGlobalHooks;
268
269 mirrorsize = (ULONG)(sizeof(MIRRSURF) +
270 ppdev->lDeltaScreen * sizl.cy);
271
272 mirrsurf = (MIRRSURF *) EngAllocMem(FL_ZERO_MEMORY,
273 mirrorsize,
274 0x4D495252);
275 if (!mirrsurf) {
276 RIP("DISP DrvEnableSurface failed EngAllocMem\n");
277 return(FALSE);
278 }
279
280
281 dhsurf = (DHSURF) mirrsurf;
282
283// dhsurf = (DHSURF) ppdev;
284
285 hsurf = EngCreateDeviceSurface(dhsurf,
286 sizl,
287 ulBitmapType);
288
289 if (hsurf == (HSURF) 0)
290 {
291 RIP("DISP DrvEnableSurface failed EngCreateBitmap\n");
292 return(FALSE);
293 }
294
295 if (!EngAssociateSurface(hsurf, ppdev->hdevEng, flHooks))
296 {
297 RIP("DISP DrvEnableSurface failed EngAssociateSurface\n");
298 EngDeleteSurface(hsurf);
299 return(FALSE);
300 }
301
302 ppdev->hsurfEng = (HSURF) hsurf;
303 ppdev->pvTmpBuffer = (PVOID) dhsurf;
304
305 mirrsurf->cx = ppdev->cxScreen;
306 mirrsurf->cy = ppdev->cyScreen;
307 mirrsurf->lDelta = ppdev->lDeltaScreen;
308 mirrsurf->ulBitCount = ppdev->ulBitCount;
309 mirrsurf->bIsScreen = TRUE;
310
311 DISPDBG((0,"DrvEnableSurface OK\n"));
312
313 return(hsurf);
314}
315
316/******************************Public*Routine******************************\
317* DrvDisableSurface
318*
319* Free resources allocated by DrvEnableSurface. Release the surface.
320*
321\**************************************************************************/
322
323VOID DrvDisableSurface(
324DHPDEV dhpdev)
325{
326 PPDEV ppdev = (PPDEV) dhpdev;
327
328 DISPDBG((0,"DrvDisableSurface:\n"));
329
330 EngDeleteSurface( ppdev->hsurfEng );
331
332 // deallocate MIRRSURF structure.
333
334 EngFreeMem( ppdev->pvTmpBuffer );
335}
336
337/******************************Public*Routine******************************\
338* DrvCopyBits
339*
340\**************************************************************************/
341
342BOOL DrvCopyBits(
343 OUT SURFOBJ *psoDst,
344 IN SURFOBJ *psoSrc,
345 IN CLIPOBJ *pco,
346 IN XLATEOBJ *pxlo,
347 IN RECTL *prclDst,
348 IN POINTL *pptlSrc
349 )
350{
351 DISPDBG((0,"DrvCopyBits\n"));
352 return TRUE;
353}
354
355/******************************Public*Routine******************************\
356* DrvBitBlt
357*
358\**************************************************************************/
359
360BOOL DrvBitBlt(
361 IN SURFOBJ *psoDst,
362 IN SURFOBJ *psoSrc,
363 IN SURFOBJ *psoMask,
364 IN CLIPOBJ *pco,
365 IN XLATEOBJ *pxlo,
366 IN RECTL *prclDst,
367 IN POINTL *pptlSrc,
368 IN POINTL *pptlMask,
369 IN BRUSHOBJ *pbo,
370 IN POINTL *pptlBrush,
371 IN ROP4 rop4
372 )
373{
374 DISPDBG((0,"DrvBitBlt\n"));
375 return TRUE;
376}
377
378BOOL DrvTextOut(
379 IN SURFOBJ *psoDst,
380 IN STROBJ *pstro,
381 IN FONTOBJ *pfo,
382 IN CLIPOBJ *pco,
383 IN RECTL *prclExtra,
384 IN RECTL *prclOpaque,
385 IN BRUSHOBJ *pboFore,
386 IN BRUSHOBJ *pboOpaque,
387 IN POINTL *pptlOrg,
388 IN MIX mix
389 )
390{
391 DISPDBG((0,"DrvTextOut\n"));
392 return TRUE;
393}
394
395BOOL
396DrvStrokePath(SURFOBJ* pso,
397 PATHOBJ* ppo,
398 CLIPOBJ* pco,
399 XFORMOBJ* pxo,
400 BRUSHOBJ* pbo,
401 POINTL* pptlBrush,
402 LINEATTRS* pLineAttrs,
403 MIX mix)
404{
405 DISPDBG((0,"DrvStrokePath\n"));
406 return TRUE;
407}
408
409BOOL DrvAssertMode(DHPDEV dhpdev,
410 BOOL bEnable)
411{
412 DISPDBG((0,"DrvAssertMode\n"));
413 return TRUE;
414}
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