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