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 TTYDRV_DC_GetPixel, /* pGetPixel */
58 NULL, /* pGetPixelFormat */
59 TTYDRV_DC_GetTextExtentPoint, /* pGetTextExtentPoint */
60 TTYDRV_DC_GetTextMetrics, /* pGetTextMetrics */
61 NULL, /* pIntersectClipRect */
62 NULL, /* pIntersectVisRect */
63 TTYDRV_DC_LineTo, /* pLineTo */
65 NULL, /* pOffsetClipRgn */
66 NULL, /* pOffsetViewportOrg (optional) */
67 NULL, /* pOffsetWindowOrg (optional) */
68 TTYDRV_DC_PaintRgn, /* pPaintRgn */
69 TTYDRV_DC_PatBlt, /* pPatBlt */
70 TTYDRV_DC_Pie, /* pPie */
71 NULL, /* pPolyBezier */
72 NULL, /* pPolyBezierTo */
74 TTYDRV_DC_PolyPolygon, /* pPolyPolygon */
75 TTYDRV_DC_PolyPolyline, /* pPolyPolyline */
76 TTYDRV_DC_Polygon, /* pPolygon */
77 TTYDRV_DC_Polyline, /* pPolyline */
78 NULL, /* pPolylineTo */
79 NULL, /* pRealizePalette */
80 TTYDRV_DC_Rectangle, /* pRectangle */
81 NULL, /* pRestoreDC */
82 TTYDRV_DC_RoundRect, /* pRoundRect */
84 NULL, /* pScaleViewportExt (optional) */
85 NULL, /* pScaleWindowExt (optional) */
86 NULL, /* pSelectClipPath */
87 NULL, /* pSelectClipRgn */
88 TTYDRV_DC_SelectObject, /* pSelectObject */
89 NULL, /* pSelectPalette */
90 TTYDRV_DC_SetBkColor, /* pSetBkColor */
91 NULL, /* pSetBkMode */
92 TTYDRV_DC_SetDeviceClipping, /* pSetDeviceClipping */
93 TTYDRV_DC_SetDIBitsToDevice, /* pSetDIBitsToDevice */
94 NULL, /* pSetMapMode (optional) */
95 NULL, /* pSetMapperFlags */
96 TTYDRV_DC_SetPixel, /* pSetPixel */
97 NULL, /* pSetPixelFormat */
98 NULL, /* pSetPolyFillMode */
100 NULL, /* pSetRelAbs */
101 NULL, /* pSetStretchBltMode */
102 NULL, /* pSetTextAlign */
103 NULL, /* pSetTextCharacterExtra */
104 TTYDRV_DC_SetTextColor, /* pSetTextColor */
105 NULL, /* pSetTextJustification */
106 NULL, /* pSetViewportExt (optional) */
107 NULL, /* pSetViewportOrg (optional) */
108 NULL, /* pSetWindowExt (optional) */
109 NULL, /* pSetWindowOrg (optional) */
110 NULL, /* pStartDoc */
111 NULL, /* pStartPage */
112 TTYDRV_DC_StretchBlt, /* pStretchBlt */
113 NULL, /* pStretchDIBits */
114 NULL, /* pStrokeAndFillPath */
115 NULL, /* pStrokePath */
116 NULL, /* pSwapBuffers */
117 NULL /* pWidenPath */
121 BITMAP_DRIVER TTYDRV_BITMAP_Driver =
123 TTYDRV_BITMAP_SetDIBits,
124 TTYDRV_BITMAP_GetDIBits,
125 TTYDRV_BITMAP_DeleteDIBSection,
126 TTYDRV_BITMAP_SetDIBColorTable,
127 TTYDRV_BITMAP_GetDIBColorTable,
132 PALETTE_DRIVER TTYDRV_PALETTE_Driver =
134 TTYDRV_PALETTE_SetMapping,
135 TTYDRV_PALETTE_UpdateMapping,
136 TTYDRV_PALETTE_IsDark
139 /* FIXME: Adapt to the TTY driver. Copied from the X11 driver */
141 DeviceCaps TTYDRV_DC_DevCaps = {
143 /* technology */ DT_RASDISPLAY,
144 /* size, resolution */ 0, 0, 0, 0, 0,
145 /* device objects */ 1, 16 + 6, 16, 0, 0, 100, 0,
146 /* curve caps */ CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES |
147 CC_WIDE | CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT,
148 /* line caps */ LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
149 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS,
150 /* polygon caps */ PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
151 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS,
153 /* regions */ CP_REGION,
154 /* raster caps */ RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 |
155 RC_DI_BITMAP | RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS,
156 /* aspects */ 36, 36, 51,
158 /* log pixels */ 0, 0,
160 /* palette size */ 0,
164 /**********************************************************************
165 * TTYDRV_GDI_Initialize
167 BOOL TTYDRV_GDI_Initialize(void)
169 BITMAP_Driver = &TTYDRV_BITMAP_Driver;
170 PALETTE_Driver = &TTYDRV_PALETTE_Driver;
172 TTYDRV_DC_DevCaps.version = 0x300;
173 TTYDRV_DC_DevCaps.horzSize = 0; /* FIXME: Screen width in mm */
174 TTYDRV_DC_DevCaps.vertSize = 0; /* FIXME: Screen height in mm */
175 TTYDRV_DC_DevCaps.horzRes = 640; /* FIXME: Screen width in pixel */
176 TTYDRV_DC_DevCaps.vertRes = 480; /* FIXME: Screen height in pixel */
177 TTYDRV_DC_DevCaps.bitsPixel = 1; /* FIXME: Bits per pixel */
178 TTYDRV_DC_DevCaps.sizePalette = 256; /* FIXME: ??? */
180 /* Resolution will be adjusted during the font init */
182 TTYDRV_DC_DevCaps.logPixelsX = (int) (TTYDRV_DC_DevCaps.horzRes * 25.4 / TTYDRV_DC_DevCaps.horzSize);
183 TTYDRV_DC_DevCaps.logPixelsY = (int) (TTYDRV_DC_DevCaps.vertRes * 25.4 / TTYDRV_DC_DevCaps.vertSize);
185 if(!TTYDRV_PALETTE_Initialize())
188 return DRIVER_RegisterDriver( "DISPLAY", &TTYDRV_DC_Driver );
191 /**********************************************************************
192 * TTYDRV_GDI_Finalize
194 void TTYDRV_GDI_Finalize(void)
196 TTYDRV_PALETTE_Finalize();
199 /***********************************************************************
202 BOOL TTYDRV_DC_CreateDC(DC *dc, LPCSTR driver, LPCSTR device,
203 LPCSTR output, const DEVMODEA *initData)
205 TTYDRV_PDEVICE *physDev;
208 TRACE("(%p, %s, %s, %s, %p)\n",
209 dc, debugstr_a(driver), debugstr_a(device),
210 debugstr_a(output), initData);
212 dc->physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
213 sizeof(TTYDRV_PDEVICE));
215 ERR("Can't allocate physDev\n");
218 physDev = (TTYDRV_PDEVICE *) dc->physDev;
220 dc->devCaps = &TTYDRV_DC_DevCaps;
222 if(dc->flags & DC_MEMORY){
223 physDev->window = NULL;
224 physDev->cellWidth = 1;
225 physDev->cellHeight = 1;
227 TTYDRV_DC_CreateBitmap(dc->hBitmap);
228 bmp = (BITMAPOBJ *) GDI_GetObjPtr(dc->hBitmap, BITMAP_MAGIC);
230 dc->bitsPerPixel = bmp->bitmap.bmBitsPixel;
232 dc->totalExtent.left = 0;
233 dc->totalExtent.top = 0;
234 dc->totalExtent.right = bmp->bitmap.bmWidth;
235 dc->totalExtent.bottom = bmp->bitmap.bmHeight;
236 dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
238 GDI_ReleaseObj( dc->hBitmap );
240 physDev->window = TTYDRV_GetRootWindow();
241 physDev->cellWidth = cell_width;
242 physDev->cellHeight = cell_height;
244 dc->bitsPerPixel = 1;
245 dc->totalExtent.left = 0;
246 dc->totalExtent.top = 0;
247 dc->totalExtent.right = cell_width * screen_cols;
248 dc->totalExtent.bottom = cell_height * screen_rows;
249 dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
255 /***********************************************************************
258 BOOL TTYDRV_DC_DeleteDC(DC *dc)
262 HeapFree( GetProcessHeap(), 0, dc->physDev );
268 /***********************************************************************
271 INT TTYDRV_DC_Escape(DC *dc, INT nEscape, INT cbInput,
272 SEGPTR lpInData, SEGPTR lpOutData)
277 /***********************************************************************
278 * TTYDRV_DC_SetDeviceClipping
280 void TTYDRV_DC_SetDeviceClipping(DC *dc)