VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/Mirror/screen.c@ 16684

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

additional header updates

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