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
130 PALETTE_DRIVER TTYDRV_PALETTE_Driver =
132 TTYDRV_PALETTE_SetMapping,
133 TTYDRV_PALETTE_UpdateMapping,
134 TTYDRV_PALETTE_IsDark
137 /* FIXME: Adapt to the TTY driver. Copied from the X11 driver */
139 DeviceCaps TTYDRV_DC_DevCaps = {
141 /* technology */ DT_RASDISPLAY,
142 /* size, resolution */ 0, 0, 0, 0, 0,
143 /* device objects */ 1, 16 + 6, 16, 0, 0, 100, 0,
144 /* curve caps */ CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES |
145 CC_WIDE | CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT,
146 /* line caps */ LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
147 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS,
148 /* polygon caps */ PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
149 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS,
151 /* regions */ CP_REGION,
152 /* raster caps */ RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 |
153 RC_DI_BITMAP | RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS,
154 /* aspects */ 36, 36, 51,
156 /* log pixels */ 0, 0,
158 /* palette size */ 0,
162 /**********************************************************************
163 * TTYDRV_GDI_Initialize
165 BOOL TTYDRV_GDI_Initialize(void)
167 BITMAP_Driver = &TTYDRV_BITMAP_Driver;
168 PALETTE_Driver = &TTYDRV_PALETTE_Driver;
170 TTYDRV_DC_DevCaps.version = 0x300;
171 TTYDRV_DC_DevCaps.horzSize = 0; /* FIXME: Screen width in mm */
172 TTYDRV_DC_DevCaps.vertSize = 0; /* FIXME: Screen height in mm */
173 TTYDRV_DC_DevCaps.horzRes = 640; /* FIXME: Screen width in pixel */
174 TTYDRV_DC_DevCaps.vertRes = 480; /* FIXME: Screen height in pixel */
175 TTYDRV_DC_DevCaps.bitsPixel = 1; /* FIXME: Bits per pixel */
176 TTYDRV_DC_DevCaps.sizePalette = 256; /* FIXME: ??? */
178 /* Resolution will be adjusted during the font init */
180 TTYDRV_DC_DevCaps.logPixelsX = (int) (TTYDRV_DC_DevCaps.horzRes * 25.4 / TTYDRV_DC_DevCaps.horzSize);
181 TTYDRV_DC_DevCaps.logPixelsY = (int) (TTYDRV_DC_DevCaps.vertRes * 25.4 / TTYDRV_DC_DevCaps.vertSize);
183 if(!TTYDRV_PALETTE_Initialize())
186 return DRIVER_RegisterDriver( "DISPLAY", &TTYDRV_DC_Driver );
189 /**********************************************************************
190 * TTYDRV_GDI_Finalize
192 void TTYDRV_GDI_Finalize(void)
194 TTYDRV_PALETTE_Finalize();
197 /***********************************************************************
200 BOOL TTYDRV_DC_CreateDC(DC *dc, LPCSTR driver, LPCSTR device,
201 LPCSTR output, const DEVMODEA *initData)
203 TTYDRV_PDEVICE *physDev;
206 TRACE("(%p, %s, %s, %s, %p)\n",
207 dc, debugstr_a(driver), debugstr_a(device),
208 debugstr_a(output), initData);
210 dc->physDev = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
211 sizeof(TTYDRV_PDEVICE));
213 ERR("Can't allocate physDev\n");
216 physDev = (TTYDRV_PDEVICE *) dc->physDev;
218 dc->devCaps = &TTYDRV_DC_DevCaps;
220 if(dc->flags & DC_MEMORY){
221 physDev->window = NULL;
222 physDev->cellWidth = 1;
223 physDev->cellHeight = 1;
225 TTYDRV_DC_CreateBitmap(dc->hBitmap);
226 bmp = (BITMAPOBJ *) GDI_GetObjPtr(dc->hBitmap, BITMAP_MAGIC);
228 dc->bitsPerPixel = bmp->bitmap.bmBitsPixel;
230 dc->totalExtent.left = 0;
231 dc->totalExtent.top = 0;
232 dc->totalExtent.right = bmp->bitmap.bmWidth;
233 dc->totalExtent.bottom = bmp->bitmap.bmHeight;
234 dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
236 GDI_ReleaseObj( dc->hBitmap );
238 physDev->window = TTYDRV_GetRootWindow();
239 physDev->cellWidth = cell_width;
240 physDev->cellHeight = cell_height;
242 dc->bitsPerPixel = 1;
243 dc->totalExtent.left = 0;
244 dc->totalExtent.top = 0;
245 dc->totalExtent.right = cell_width * screen_cols;
246 dc->totalExtent.bottom = cell_height * screen_rows;
247 dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
253 /***********************************************************************
256 BOOL TTYDRV_DC_DeleteDC(DC *dc)
260 HeapFree( GetProcessHeap(), 0, dc->physDev );
266 /***********************************************************************
269 INT TTYDRV_DC_Escape(DC *dc, INT nEscape, INT cbInput,
270 SEGPTR lpInData, SEGPTR lpOutData)
275 /***********************************************************************
276 * TTYDRV_DC_SetDeviceClipping
278 void TTYDRV_DC_SetDeviceClipping(DC *dc)