VirtualBox

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

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

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