VirtualBox

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

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

Automated rebranding to Oracle copyright/license strings via filemuncher

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