4 * Copyright 1999 Patrik Stridvall
15 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(ttydrv
);
19 /**********************************************************************/
21 static const DC_FUNCTIONS TTYDRV_DC_Driver
=
24 NULL
, /* pAbortPath */
26 TTYDRV_DC_Arc
, /* pArc */
28 NULL
, /* pBeginPath */
29 TTYDRV_DC_BitBlt
, /* pBitBlt */
30 TTYDRV_DC_BitmapBits
,/* pBitmapBits */
31 NULL
, /* pChoosePixelFormat */
32 TTYDRV_DC_Chord
, /* pChord */
33 NULL
, /* pCloseFigure */
34 TTYDRV_DC_CreateBitmap
, /* pCreateBitmap */
35 TTYDRV_DC_CreateDC
, /* pCreateDC */
36 NULL
, /* pCreateDIBSection */
37 NULL
, /* pCreateDIBSection16 */
38 TTYDRV_DC_DeleteDC
, /* pDeleteDC */
39 TTYDRV_DC_DeleteObject
, /* pDeleteObject */
40 NULL
, /* pDescribePixelFormat */
41 NULL
, /* pDeviceCapabilities */
42 TTYDRV_DC_Ellipse
, /* pEllipse */
46 NULL
, /* pEnumDeviceFonts */
47 TTYDRV_DC_Escape
, /* pEscape */
48 NULL
, /* pExcludeClipRect */
49 NULL
, /* pExtDeviceMode */
50 TTYDRV_DC_ExtFloodFill
, /* pExtFloodFill */
51 TTYDRV_DC_ExtTextOut
, /* pExtTextOut */
54 NULL
, /* pFlattenPath */
56 TTYDRV_DC_GetCharWidth
, /* pGetCharWidth */
57 NULL
, /* pGetDCOrgEx */
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 TTYDRV_DC_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
95 NULL
, /* pSetMapMode (optional) */
96 NULL
, /* pSetMapperFlags */
97 TTYDRV_DC_SetPixel
, /* pSetPixel */
98 NULL
, /* pSetPixelFormat */
99 NULL
, /* pSetPolyFillMode */
101 NULL
, /* pSetRelAbs */
102 NULL
, /* pSetStretchBltMode */
103 NULL
, /* pSetTextAlign */
104 NULL
, /* pSetTextCharacterExtra */
105 TTYDRV_DC_SetTextColor
, /* pSetTextColor */
106 NULL
, /* pSetTextJustification */
107 NULL
, /* pSetViewportExt (optional) */
108 NULL
, /* pSetViewportOrg (optional) */
109 NULL
, /* pSetWindowExt (optional) */
110 NULL
, /* pSetWindowOrg (optional) */
111 NULL
, /* pStartDoc */
112 NULL
, /* pStartPage */
113 TTYDRV_DC_StretchBlt
, /* pStretchBlt */
114 NULL
, /* pStretchDIBits */
115 NULL
, /* pStrokeAndFillPath */
116 NULL
, /* pStrokePath */
117 NULL
, /* pSwapBuffers */
118 NULL
/* pWidenPath */
122 BITMAP_DRIVER TTYDRV_BITMAP_Driver
=
124 TTYDRV_BITMAP_SetDIBits
,
125 TTYDRV_BITMAP_GetDIBits
,
126 TTYDRV_BITMAP_DeleteDIBSection
129 PALETTE_DRIVER TTYDRV_PALETTE_Driver
=
131 TTYDRV_PALETTE_SetMapping
,
132 TTYDRV_PALETTE_UpdateMapping
,
133 TTYDRV_PALETTE_IsDark
136 /* FIXME: Adapt to the TTY driver. Copied from the X11 driver */
138 DeviceCaps TTYDRV_DC_DevCaps
= {
140 /* technology */ DT_RASDISPLAY
,
141 /* size, resolution */ 0, 0, 0, 0, 0,
142 /* device objects */ 1, 16 + 6, 16, 0, 0, 100, 0,
143 /* curve caps */ CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
|
144 CC_WIDE
| CC_STYLED
| CC_WIDESTYLED
| CC_INTERIORS
| CC_ROUNDRECT
,
145 /* line caps */ LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
146 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
,
147 /* polygon caps */ PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
|
148 PC_SCANLINE
| PC_WIDE
| PC_STYLED
| PC_WIDESTYLED
| PC_INTERIORS
,
150 /* regions */ CP_REGION
,
151 /* raster caps */ RC_BITBLT
| RC_BANDING
| RC_SCALING
| RC_BITMAP64
|
152 RC_DI_BITMAP
| RC_DIBTODEV
| RC_BIGFONT
| RC_STRETCHBLT
| RC_STRETCHDIB
| RC_DEVBITS
,
153 /* aspects */ 36, 36, 51,
155 /* log pixels */ 0, 0,
157 /* palette size */ 0,
161 /**********************************************************************
162 * TTYDRV_GDI_Initialize
164 BOOL
TTYDRV_GDI_Initialize(void)
166 BITMAP_Driver
= &TTYDRV_BITMAP_Driver
;
167 PALETTE_Driver
= &TTYDRV_PALETTE_Driver
;
169 TTYDRV_DC_DevCaps
.version
= 0x300;
170 TTYDRV_DC_DevCaps
.horzSize
= 0; /* FIXME: Screen width in mm */
171 TTYDRV_DC_DevCaps
.vertSize
= 0; /* FIXME: Screen height in mm */
172 TTYDRV_DC_DevCaps
.horzRes
= 640; /* FIXME: Screen width in pixel */
173 TTYDRV_DC_DevCaps
.vertRes
= 480; /* FIXME: Screen height in pixel */
174 TTYDRV_DC_DevCaps
.bitsPixel
= 1; /* FIXME: Bits per pixel */
175 TTYDRV_DC_DevCaps
.sizePalette
= 256; /* FIXME: ??? */
177 /* Resolution will be adjusted during the font init */
179 TTYDRV_DC_DevCaps
.logPixelsX
= (int) (TTYDRV_DC_DevCaps
.horzRes
* 25.4 / TTYDRV_DC_DevCaps
.horzSize
);
180 TTYDRV_DC_DevCaps
.logPixelsY
= (int) (TTYDRV_DC_DevCaps
.vertRes
* 25.4 / TTYDRV_DC_DevCaps
.vertSize
);
182 if(!TTYDRV_PALETTE_Initialize())
185 return DRIVER_RegisterDriver( "DISPLAY", &TTYDRV_DC_Driver
);
188 /**********************************************************************
189 * TTYDRV_GDI_Finalize
191 void TTYDRV_GDI_Finalize(void)
193 TTYDRV_PALETTE_Finalize();
196 /***********************************************************************
199 BOOL
TTYDRV_DC_CreateDC(DC
*dc
, LPCSTR driver
, LPCSTR device
,
200 LPCSTR output
, const DEVMODEA
*initData
)
202 TTYDRV_PDEVICE
*physDev
;
205 TRACE("(%p, %s, %s, %s, %p)\n",
206 dc
, debugstr_a(driver
), debugstr_a(device
),
207 debugstr_a(output
), initData
);
209 dc
->physDev
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
210 sizeof(TTYDRV_PDEVICE
));
212 ERR("Can't allocate physDev\n");
215 physDev
= (TTYDRV_PDEVICE
*) dc
->physDev
;
217 dc
->w
.devCaps
= &TTYDRV_DC_DevCaps
;
219 if(dc
->w
.flags
& DC_MEMORY
){
220 physDev
->window
= NULL
;
221 physDev
->cellWidth
= 1;
222 physDev
->cellHeight
= 1;
224 TTYDRV_DC_CreateBitmap(dc
->w
.hBitmap
);
225 bmp
= (BITMAPOBJ
*) GDI_GetObjPtr(dc
->w
.hBitmap
, BITMAP_MAGIC
);
227 dc
->w
.bitsPerPixel
= bmp
->bitmap
.bmBitsPixel
;
229 dc
->w
.totalExtent
.left
= 0;
230 dc
->w
.totalExtent
.top
= 0;
231 dc
->w
.totalExtent
.right
= bmp
->bitmap
.bmWidth
;
232 dc
->w
.totalExtent
.bottom
= bmp
->bitmap
.bmHeight
;
233 dc
->w
.hVisRgn
= CreateRectRgnIndirect( &dc
->w
.totalExtent
);
235 GDI_HEAP_UNLOCK( dc
->w
.hBitmap
);
237 physDev
->window
= TTYDRV_GetRootWindow();
238 physDev
->cellWidth
= cell_width
;
239 physDev
->cellHeight
= cell_height
;
241 dc
->w
.bitsPerPixel
= 1;
242 dc
->w
.totalExtent
.left
= 0;
243 dc
->w
.totalExtent
.top
= 0;
244 dc
->w
.totalExtent
.right
= cell_width
* screen_cols
;
245 dc
->w
.totalExtent
.bottom
= cell_height
* screen_rows
;
246 dc
->w
.hVisRgn
= CreateRectRgnIndirect( &dc
->w
.totalExtent
);
252 /***********************************************************************
255 BOOL
TTYDRV_DC_DeleteDC(DC
*dc
)
259 HeapFree( GetProcessHeap(), 0, dc
->physDev
);
265 /***********************************************************************
268 INT
TTYDRV_DC_Escape(DC
*dc
, INT nEscape
, INT cbInput
,
269 SEGPTR lpInData
, SEGPTR lpOutData
)
274 /***********************************************************************
275 * TTYDRV_DC_SetDeviceClipping
277 void TTYDRV_DC_SetDeviceClipping(DC
*dc
)