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: screen.c
|
---|
24 | *
|
---|
25 | * Initializes the GDIINFO and DEVINFO structures for DrvEnablePDEV.
|
---|
26 | *
|
---|
27 | * Copyright (c) 1992-1998 Microsoft Corporation
|
---|
28 | \**************************************************************************/
|
---|
29 |
|
---|
30 | #include "driver.h"
|
---|
31 |
|
---|
32 | #define SYSTM_LOGFONT {16,7,0,0,700,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"System"}
|
---|
33 | #define HELVE_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,VARIABLE_PITCH | FF_DONTCARE,L"MS Sans Serif"}
|
---|
34 | #define COURI_LOGFONT {12,9,0,0,400,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_STROKE_PRECIS,PROOF_QUALITY,FIXED_PITCH | FF_DONTCARE, L"Courier"}
|
---|
35 |
|
---|
36 | // This is the basic devinfo for a default driver. This is used as a base and customized based
|
---|
37 | // on information passed back from the miniport driver.
|
---|
38 |
|
---|
39 | const DEVINFO gDevInfoFrameBuffer = {
|
---|
40 | ( GCAPS_OPAQUERECT
|
---|
41 | | GCAPS_ASYNCMOVE
|
---|
42 | | GCAPS_LAYERED
|
---|
43 | ), /* Graphics capabilities */
|
---|
44 | SYSTM_LOGFONT, /* Default font description */
|
---|
45 | HELVE_LOGFONT, /* ANSI variable font description */
|
---|
46 | COURI_LOGFONT, /* ANSI fixed font description */
|
---|
47 | 0, /* Count of device fonts */
|
---|
48 | 0, /* Preferred DIB format */
|
---|
49 | 8, /* Width of color dither */
|
---|
50 | 8, /* Height of color dither */
|
---|
51 | 0 /* Default palette to use for this device */
|
---|
52 | };
|
---|
53 |
|
---|
54 | // This is default palette from Win 3.1
|
---|
55 |
|
---|
56 | #define NUMPALCOLORS 256
|
---|
57 | #define NUMPALRESERVED 20
|
---|
58 |
|
---|
59 | ULONG palColors[NUMPALCOLORS][4] =
|
---|
60 | {
|
---|
61 | { 0, 0, 0, 0 }, // 0
|
---|
62 | { 0x80,0, 0, 0 }, // 1
|
---|
63 | { 0, 0x80,0, 0 }, // 2
|
---|
64 | { 0x80,0x80,0, 0 }, // 3
|
---|
65 | { 0, 0, 0x80,0 }, // 4
|
---|
66 | { 0x80,0, 0x80,0 }, // 5
|
---|
67 | { 0, 0x80,0x80,0 }, // 6
|
---|
68 | { 0xC0,0xC0,0xC0,0 }, // 7
|
---|
69 |
|
---|
70 | { 192, 220, 192, 0 }, // 8
|
---|
71 | { 166, 202, 240, 0 }, // 9
|
---|
72 | { 255, 251, 240, 0 }, // 10
|
---|
73 | { 160, 160, 164, 0 }, // 11
|
---|
74 |
|
---|
75 | { 0x80,0x80,0x80,0 }, // 12
|
---|
76 | { 0xFF,0, 0, 0 }, // 13
|
---|
77 | { 0, 0xFF,0, 0 }, // 14
|
---|
78 | { 0xFF,0xFF,0, 0 }, // 15
|
---|
79 | { 0, 0, 0xFF,0 }, // 16
|
---|
80 | { 0xFF,0, 0xFF,0 }, // 17
|
---|
81 | { 0, 0xFF,0xFF,0 }, // 18
|
---|
82 | { 0xFF,0xFF,0xFF,0 } // 19
|
---|
83 | };
|
---|
84 |
|
---|
85 | /******************************Public*Routine******************************\
|
---|
86 | * bInitPDEV
|
---|
87 | *
|
---|
88 | * Determine the mode we should be in based on the DEVMODE passed in.
|
---|
89 | * For mirrored devices we don't bother querying the miniport.
|
---|
90 | *
|
---|
91 | \**************************************************************************/
|
---|
92 |
|
---|
93 | BOOL bInitPDEV(
|
---|
94 | PPDEV ppdev,
|
---|
95 | DEVMODEW *pDevMode,
|
---|
96 | GDIINFO *pGdiInfo,
|
---|
97 | DEVINFO *pDevInfo)
|
---|
98 | {
|
---|
99 | ULONG cModes;
|
---|
100 | PVIDEO_MODE_INFORMATION pVideoBuffer, pVideoModeSelected, pVideoTemp;
|
---|
101 | VIDEO_COLOR_CAPABILITIES colorCapabilities;
|
---|
102 | ULONG ulTemp;
|
---|
103 | BOOL bSelectDefault;
|
---|
104 | ULONG cbModeSize;
|
---|
105 | ULONG red, green, blue;
|
---|
106 | INT i;
|
---|
107 |
|
---|
108 | //
|
---|
109 | // Fill in the GDIINFO data structure with the information returned from
|
---|
110 | // the kernel driver.
|
---|
111 | //
|
---|
112 |
|
---|
113 | ppdev->ulMode = 0;
|
---|
114 | ppdev->cxScreen = pDevMode->dmPelsWidth;
|
---|
115 | ppdev->cyScreen = pDevMode->dmPelsHeight;
|
---|
116 | ppdev->ulBitCount = pDevMode->dmBitsPerPel;
|
---|
117 | ppdev->lDeltaScreen = 0;
|
---|
118 |
|
---|
119 | ppdev->flRed = 0x00FF0000;
|
---|
120 | ppdev->flGreen = 0x000FF00;
|
---|
121 | ppdev->flBlue = 0x00000FF;
|
---|
122 |
|
---|
123 | pGdiInfo->ulVersion = GDI_DRIVER_VERSION;
|
---|
124 | pGdiInfo->ulTechnology = DT_RASDISPLAY;
|
---|
125 | pGdiInfo->ulHorzSize = 0;
|
---|
126 | pGdiInfo->ulVertSize = 0;
|
---|
127 |
|
---|
128 | pGdiInfo->ulHorzRes = ppdev->cxScreen;
|
---|
129 | pGdiInfo->ulVertRes = ppdev->cyScreen;
|
---|
130 | pGdiInfo->ulPanningHorzRes = 0;
|
---|
131 | pGdiInfo->ulPanningVertRes = 0;
|
---|
132 | pGdiInfo->cBitsPixel = 8;
|
---|
133 | pGdiInfo->cPlanes = 1;
|
---|
134 | pGdiInfo->ulVRefresh = 1; // not used
|
---|
135 | pGdiInfo->ulBltAlignment = 1; // We don't have accelerated screen-
|
---|
136 | // to-screen blts, and any
|
---|
137 | // window alignment is okay
|
---|
138 |
|
---|
139 | pGdiInfo->ulLogPixelsX = pDevMode->dmLogPixels;
|
---|
140 | pGdiInfo->ulLogPixelsY = pDevMode->dmLogPixels;
|
---|
141 |
|
---|
142 | pGdiInfo->flTextCaps = TC_RA_ABLE;
|
---|
143 |
|
---|
144 | pGdiInfo->flRaster = 0; // flRaster is reserved by DDI
|
---|
145 |
|
---|
146 | pGdiInfo->ulDACRed = 8;
|
---|
147 | pGdiInfo->ulDACGreen = 8;
|
---|
148 | pGdiInfo->ulDACBlue = 8;
|
---|
149 |
|
---|
150 | pGdiInfo->ulAspectX = 0x24; // One-to-one aspect ratio
|
---|
151 | pGdiInfo->ulAspectY = 0x24;
|
---|
152 | pGdiInfo->ulAspectXY = 0x33;
|
---|
153 |
|
---|
154 | pGdiInfo->xStyleStep = 1; // A style unit is 3 pels
|
---|
155 | pGdiInfo->yStyleStep = 1;
|
---|
156 | pGdiInfo->denStyleStep = 3;
|
---|
157 |
|
---|
158 | pGdiInfo->ptlPhysOffset.x = 0;
|
---|
159 | pGdiInfo->ptlPhysOffset.y = 0;
|
---|
160 | pGdiInfo->szlPhysSize.cx = 0;
|
---|
161 | pGdiInfo->szlPhysSize.cy = 0;
|
---|
162 |
|
---|
163 | // RGB and CMY color info.
|
---|
164 |
|
---|
165 | pGdiInfo->ciDevice.Red.x = 6700;
|
---|
166 | pGdiInfo->ciDevice.Red.y = 3300;
|
---|
167 | pGdiInfo->ciDevice.Red.Y = 0;
|
---|
168 | pGdiInfo->ciDevice.Green.x = 2100;
|
---|
169 | pGdiInfo->ciDevice.Green.y = 7100;
|
---|
170 | pGdiInfo->ciDevice.Green.Y = 0;
|
---|
171 | pGdiInfo->ciDevice.Blue.x = 1400;
|
---|
172 | pGdiInfo->ciDevice.Blue.y = 800;
|
---|
173 | pGdiInfo->ciDevice.Blue.Y = 0;
|
---|
174 | pGdiInfo->ciDevice.AlignmentWhite.x = 3127;
|
---|
175 | pGdiInfo->ciDevice.AlignmentWhite.y = 3290;
|
---|
176 | pGdiInfo->ciDevice.AlignmentWhite.Y = 0;
|
---|
177 |
|
---|
178 | pGdiInfo->ciDevice.RedGamma = 20000;
|
---|
179 | pGdiInfo->ciDevice.GreenGamma = 20000;
|
---|
180 | pGdiInfo->ciDevice.BlueGamma = 20000;
|
---|
181 |
|
---|
182 | pGdiInfo->ciDevice.Cyan.x = 0;
|
---|
183 | pGdiInfo->ciDevice.Cyan.y = 0;
|
---|
184 | pGdiInfo->ciDevice.Cyan.Y = 0;
|
---|
185 | pGdiInfo->ciDevice.Magenta.x = 0;
|
---|
186 | pGdiInfo->ciDevice.Magenta.y = 0;
|
---|
187 | pGdiInfo->ciDevice.Magenta.Y = 0;
|
---|
188 | pGdiInfo->ciDevice.Yellow.x = 0;
|
---|
189 | pGdiInfo->ciDevice.Yellow.y = 0;
|
---|
190 | pGdiInfo->ciDevice.Yellow.Y = 0;
|
---|
191 |
|
---|
192 | // No dye correction for raster displays.
|
---|
193 |
|
---|
194 | pGdiInfo->ciDevice.MagentaInCyanDye = 0;
|
---|
195 | pGdiInfo->ciDevice.YellowInCyanDye = 0;
|
---|
196 | pGdiInfo->ciDevice.CyanInMagentaDye = 0;
|
---|
197 | pGdiInfo->ciDevice.YellowInMagentaDye = 0;
|
---|
198 | pGdiInfo->ciDevice.CyanInYellowDye = 0;
|
---|
199 | pGdiInfo->ciDevice.MagentaInYellowDye = 0;
|
---|
200 |
|
---|
201 | pGdiInfo->ulDevicePelsDPI = 0; // For printers only
|
---|
202 | pGdiInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA;
|
---|
203 |
|
---|
204 | // Note: this should be modified later to take into account the size
|
---|
205 | // of the display and the resolution.
|
---|
206 |
|
---|
207 | pGdiInfo->ulHTPatternSize = HT_PATSIZE_4x4_M;
|
---|
208 |
|
---|
209 | pGdiInfo->flHTFlags = HT_FLAG_ADDITIVE_PRIMS;
|
---|
210 |
|
---|
211 | // Fill in the basic devinfo structure
|
---|
212 |
|
---|
213 | *pDevInfo = gDevInfoFrameBuffer;
|
---|
214 |
|
---|
215 | // Fill in the rest of the devinfo and GdiInfo structures.
|
---|
216 |
|
---|
217 | if (ppdev->ulBitCount == 8)
|
---|
218 | {
|
---|
219 | // It is Palette Managed.
|
---|
220 |
|
---|
221 | pGdiInfo->ulNumColors = 20;
|
---|
222 | pGdiInfo->ulNumPalReg = 1 << ppdev->ulBitCount;
|
---|
223 |
|
---|
224 | pDevInfo->flGraphicsCaps |= (GCAPS_PALMANAGED | GCAPS_COLOR_DITHER);
|
---|
225 |
|
---|
226 | pGdiInfo->ulHTOutputFormat = HT_FORMAT_8BPP;
|
---|
227 | pDevInfo->iDitherFormat = BMF_8BPP;
|
---|
228 |
|
---|
229 | // Assuming palette is orthogonal - all colors are same size.
|
---|
230 |
|
---|
231 | ppdev->cPaletteShift = 8 - pGdiInfo->ulDACRed;
|
---|
232 | }
|
---|
233 | else
|
---|
234 | {
|
---|
235 | pGdiInfo->ulNumColors = (ULONG) (-1);
|
---|
236 | pGdiInfo->ulNumPalReg = 0;
|
---|
237 |
|
---|
238 | if (ppdev->ulBitCount == 16)
|
---|
239 | {
|
---|
240 | pGdiInfo->ulHTOutputFormat = HT_FORMAT_16BPP;
|
---|
241 | pDevInfo->iDitherFormat = BMF_16BPP;
|
---|
242 | }
|
---|
243 | else if (ppdev->ulBitCount == 24)
|
---|
244 | {
|
---|
245 | pGdiInfo->ulHTOutputFormat = HT_FORMAT_24BPP;
|
---|
246 | pDevInfo->iDitherFormat = BMF_24BPP;
|
---|
247 | }
|
---|
248 | else
|
---|
249 | {
|
---|
250 | pGdiInfo->ulHTOutputFormat = HT_FORMAT_32BPP;
|
---|
251 | pDevInfo->iDitherFormat = BMF_32BPP;
|
---|
252 | }
|
---|
253 | }
|
---|
254 |
|
---|
255 | // create remaining palette entries, simple loop to create uniformly
|
---|
256 | // distributed color values.
|
---|
257 |
|
---|
258 | red = 0, green = 0, blue = 0;
|
---|
259 |
|
---|
260 | for (i = NUMPALRESERVED; i < NUMPALCOLORS; i++) {
|
---|
261 | palColors[i][0] = red;
|
---|
262 | palColors[i][1] = green;
|
---|
263 | palColors[i][2] = blue;
|
---|
264 | palColors[i][3] = 0;
|
---|
265 |
|
---|
266 | if (!(red += 32))
|
---|
267 | if (!(green += 32))
|
---|
268 | blue += 64;
|
---|
269 | }
|
---|
270 |
|
---|
271 | if (ppdev->ulBitCount == 8)
|
---|
272 | {
|
---|
273 | pDevInfo->hpalDefault = ppdev->hpalDefault =
|
---|
274 |
|
---|
275 | EngCreatePalette(PAL_INDEXED,
|
---|
276 | NUMPALCOLORS, // cColors
|
---|
277 | (ULONG*)&palColors[0], // pulColors
|
---|
278 | 0,
|
---|
279 | 0,
|
---|
280 | 0); // flRed, flGreen, flBlue [not used]
|
---|
281 | }
|
---|
282 | else
|
---|
283 | {
|
---|
284 | pDevInfo->hpalDefault = ppdev->hpalDefault =
|
---|
285 | EngCreatePalette(PAL_BITFIELDS, 0,NULL,
|
---|
286 | ppdev->flRed,ppdev->flBlue,ppdev->flGreen);
|
---|
287 | }
|
---|
288 |
|
---|
289 | DISPDBG((0,"bInitPDEV OK\n"));
|
---|
290 |
|
---|
291 | return(TRUE);
|
---|
292 | }
|
---|
293 |
|
---|
294 |
|
---|
295 |
|
---|