4 * Copyright 1999 Patrik Stridvall
14 #include "debugtools.h"
16 DEFAULT_DEBUG_CHANNEL(ttydrv);
18 /**********************************************************************/
20 static const DC_FUNCTIONS TTYDRV_DC_Driver =
23 NULL, /* pAbortPath */
25 TTYDRV_DC_Arc, /* pArc */
27 NULL, /* pBeginPath */
28 TTYDRV_DC_BitBlt, /* pBitBlt */
29 TTYDRV_DC_BitmapBits,/* pBitmapBits */
30 NULL, /* pChoosePixelFormat */
31 TTYDRV_DC_Chord, /* pChord */
32 NULL, /* pCloseFigure */
33 TTYDRV_DC_CreateBitmap, /* pCreateBitmap */
34 TTYDRV_DC_CreateDC, /* pCreateDC */
35 NULL, /* pCreateDIBSection */
36 NULL, /* pCreateDIBSection16 */
37 TTYDRV_DC_DeleteDC, /* pDeleteDC */
38 TTYDRV_DC_DeleteObject, /* pDeleteObject */
39 NULL, /* pDescribePixelFormat */
40 NULL, /* pDeviceCapabilities */
41 TTYDRV_DC_Ellipse, /* pEllipse */
45 NULL, /* pEnumDeviceFonts */
46 TTYDRV_DC_Escape, /* pEscape */
47 NULL, /* pExcludeClipRect */
48 NULL, /* pExtDeviceMode */
49 TTYDRV_DC_ExtFloodFill, /* pExtFloodFill */
50 TTYDRV_DC_ExtTextOut, /* pExtTextOut */
53 NULL, /* pFlattenPath */
55 TTYDRV_DC_GetCharWidth, /* pGetCharWidth */
56 NULL, /* pGetDCOrgEx */
57 NULL, /* pGetDeviceGammaRamp */
58 TTYDRV_DC_GetPixel, /* pGetPixel */
59 NULL, /* pGetPixelFormat */
60 TTYDRV_DC_GetTextExtentPoint, /* pGetTextExtentPoint */
61 TTYDRV_DC_GetTextMetrics, /* pGetTextMetrics */
62 NULL, /* pIntersectClipRect */
63 NULL, /* pIntersectVisRect */
64 TTYDRV_DC_LineTo, /* pLineTo */
66 NULL, /* pOffsetClipRgn */
67 NULL, /* pOffsetViewportOrg (optional) */
68 NULL, /* pOffsetWindowOrg (optional) */
69 TTYDRV_DC_PaintRgn, /* pPaintRgn */
70 TTYDRV_DC_PatBlt, /* pPatBlt */
71 TTYDRV_DC_Pie, /* pPie */
72 NULL, /* pPolyBezier */
73 NULL, /* pPolyBezierTo */
75 TTYDRV_DC_PolyPolygon, /* pPolyPolygon */
76 TTYDRV_DC_PolyPolyline, /* pPolyPolyline */
77 TTYDRV_DC_Polygon, /* pPolygon */
78 TTYDRV_DC_Polyline, /* pPolyline */
79 NULL, /* pPolylineTo */
80 NULL, /* pRealizePalette */
81 TTYDRV_DC_Rectangle, /* pRectangle */
82 NULL, /* pRestoreDC */
83 TTYDRV_DC_RoundRect, /* pRoundRect */
85 NULL, /* pScaleViewportExt (optional) */
86 NULL, /* pScaleWindowExt (optional) */
87 NULL, /* pSelectClipPath */
88 NULL, /* pSelectClipRgn */
89 TTYDRV_DC_SelectObject, /* pSelectObject */
90 NULL, /* pSelectPalette */
91 TTYDRV_DC_SetBkColor, /* pSetBkColor */
92 NULL, /* pSetBkMode */
93 TTYDRV_DC_SetDeviceClipping, /* pSetDeviceClipping */
94 NULL, /* pSetDeviceGammaRamp */
95 TTYDRV_DC_SetDIBitsToDevice, /* pSetDIBitsToDevice */
96 NULL, /* pSetMapMode (optional) */
97 NULL, /* pSetMapperFlags */
98 TTYDRV_DC_SetPixel, /* pSetPixel */
99 NULL, /* pSetPixelFormat */
100 NULL, /* pSetPolyFillMode */
102 NULL, /* pSetRelAbs */
103 NULL, /* pSetStretchBltMode */
104 NULL, /* pSetTextAlign */
105 NULL, /* pSetTextCharacterExtra */
106 TTYDRV_DC_SetTextColor, /* pSetTextColor */
107 NULL, /* pSetTextJustification */
108 NULL, /* pSetViewportExt (optional) */
109 NULL, /* pSetViewportOrg (optional) */
110 NULL, /* pSetWindowExt (optional) */
111 NULL, /* pSetWindowOrg (optional) */
112 NULL, /* pStartDoc */
113 NULL, /* pStartPage */
114 TTYDRV_DC_StretchBlt, /* pStretchBlt */
115 NULL, /* pStretchDIBits */
116 NULL, /* pStrokeAndFillPath */
117 NULL, /* pStrokePath */
118 NULL, /* pSwapBuffers */
119 NULL /* pWidenPath */
123 BITMAP_DRIVER TTYDRV_BITMAP_Driver =
125 TTYDRV_BITMAP_SetDIBits,
126 TTYDRV_BITMAP_GetDIBits,
127 TTYDRV_BITMAP_DeleteDIBSection,
128 TTYDRV_BITMAP_SetDIBColorTable,
129 TTYDRV_BITMAP_GetDIBColorTable,
134 PALETTE_DRIVER TTYDRV_PALETTE_Driver =
136 TTYDRV_PALETTE_SetMapping,
137 TTYDRV_PALETTE_UpdateMapping,
138 TTYDRV_PALETTE_IsDark
141 /* FIXME: Adapt to the TTY driver. Copied from the X11 driver */
143 DeviceCaps TTYDRV_DC_DevCaps = {
145 /* technology */ DT_RASDISPLAY,
146 /* size, resolution */ 0, 0, 0, 0, 0,
147 /* device objects */ 1, 16 + 6, 16, 0, 0, 100, 0,
148 /* curve caps */ CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES |
149 CC_WIDE | CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT,
150 /* line caps */ LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
151 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS,
152 /* polygon caps */ PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
153 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS,
155 /* regions */ CP_REGION,
156 /* raster caps */ RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 |
157 RC_DI_BITMAP | RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS,
158 /* aspects */ 36, 36, 51,
160 /* log pixels */ 0, 0,
162 /* palette size */ 0,
166 /**********************************************************************
167 * TTYDRV_GDI_Initialize
169 BOOL TTYDRV_GDI_Initialize(void)
171 BITMAP_Driver = &TTYDRV_BITMAP_Driver;
172 PALETTE_Driver = &TTYDRV_PALETTE_Driver;
174 TTYDRV_DC_DevCaps.version = 0x300;
175 TTYDRV_DC_DevCaps.horzSize = 0; /* FIXME: Screen width in mm */
176 TTYDRV_DC_DevCaps.vertSize = 0; /* FIXME: Screen height in mm */
177 TTYDRV_DC_DevCaps.horzRes = 640; /* FIXME: Screen width in pixel */
178 TTYDRV_DC_DevCaps.vertRes = 480; /* FIXME: Screen height in pixel */
179 TTYDRV_DC_DevCaps.bitsPixel = 1; /* FIXME: Bits per pixel */
180 TTYDRV_DC_DevCaps.sizePalette = 256; /* FIXME: ??? */
182 /* Resolution will be adjusted during the font init */
184 TTYDRV_DC_DevCaps.logPixelsX = (int) (TTYDRV_DC_DevCaps.horzRes * 25.4 / TTYDRV_DC_DevCaps.horzSize);
185 TTYDRV_DC_DevCaps.logPixelsY = (int) (TTYDRV_DC_DevCaps.vertRes * 25.4 / TTYDRV_DC_DevCaps.vertSize);
187 if(!TTYDRV_PALETTE_Initialize())
190 return DRIVER_RegisterDriver( "DISPLAY", &TTYDRV_DC_Driver );
193 /**********************************************************************
194 * TTYDRV_GDI_Finalize
196 void TTYDRV_GDI_Finalize(void)
198 TTYDRV_PALETTE_Finalize();
201 /***********************************************************************
204 BOOL TTYDRV_DC_CreateDC(DC *dc, LPCSTR driver, LPCSTR device,
205 LPCSTR output, const DEVMODEA *initData)
207 TTYDRV_PDEVICE *physDev;
210 TRACE("(%p, %s, %s, %s, %p)\n",
211 dc, debugstr_a(driver), debugstr_a(device),
212 debugstr_a(output), initData);
214 dc->physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
215 sizeof(TTYDRV_PDEVICE));
217 ERR("Can't allocate physDev\n");
220 physDev = (TTYDRV_PDEVICE *) dc->physDev;
222 dc->devCaps = &TTYDRV_DC_DevCaps;
224 if(dc->flags & DC_MEMORY){
225 physDev->window = NULL;
226 physDev->cellWidth = 1;
227 physDev->cellHeight = 1;
229 TTYDRV_DC_CreateBitmap(dc->hBitmap);
230 bmp = (BITMAPOBJ *) GDI_GetObjPtr(dc->hBitmap, BITMAP_MAGIC);
232 dc->bitsPerPixel = bmp->bitmap.bmBitsPixel;
234 dc->totalExtent.left = 0;
235 dc->totalExtent.top = 0;
236 dc->totalExtent.right = bmp->bitmap.bmWidth;
237 dc->totalExtent.bottom = bmp->bitmap.bmHeight;
238 dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
240 GDI_ReleaseObj( dc->hBitmap );
242 physDev->window = root_window;
243 physDev->cellWidth = cell_width;
244 physDev->cellHeight = cell_height;
246 dc->bitsPerPixel = 1;
247 dc->totalExtent.left = 0;
248 dc->totalExtent.top = 0;
249 dc->totalExtent.right = cell_width * screen_cols;
250 dc->totalExtent.bottom = cell_height * screen_rows;
251 dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
257 /***********************************************************************
260 BOOL TTYDRV_DC_DeleteDC(DC *dc)
264 HeapFree( GetProcessHeap(), 0, dc->physDev );
270 /***********************************************************************
273 INT TTYDRV_DC_Escape(DC *dc, INT nEscape, INT cbInput,
274 SEGPTR lpInData, SEGPTR lpOutData)
279 /***********************************************************************
280 * TTYDRV_DC_SetDeviceClipping
282 void TTYDRV_DC_SetDeviceClipping(DC *dc)