Release 980614
[wine/multimedia.git] / graphics / x11drv / init.c
blobd5f11aa7063293e80686282d3e1366326ac40439
1 /*
2 * X11 graphics driver initialisation functions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #include <string.h>
8 #include "x11drv.h"
9 #include "color.h"
10 #include "bitmap.h"
13 static BOOL32 X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
14 LPCSTR output, const DEVMODE16* initData );
15 static BOOL32 X11DRV_DeleteDC( DC *dc );
17 static INT32 X11DRV_Escape( DC *dc, INT32 nEscape, INT32 cbInput,
18 SEGPTR lpInData, SEGPTR lpOutData );
20 static const DC_FUNCTIONS X11DRV_Funcs =
22 X11DRV_Arc, /* pArc */
23 X11DRV_BitBlt, /* pBitBlt */
24 X11DRV_Chord, /* pChord */
25 X11DRV_CreateDC, /* pCreateDC */
26 X11DRV_DeleteDC, /* pDeleteDC */
27 NULL, /* pDeleteObject */
28 X11DRV_Ellipse, /* pEllipse */
29 X11DRV_EnumDeviceFonts, /* pEnumDeviceFonts */
30 X11DRV_Escape, /* pEscape */
31 NULL, /* pExcludeClipRect */
32 NULL, /* pExcludeVisRect */
33 X11DRV_ExtFloodFill, /* pExtFloodFill */
34 X11DRV_ExtTextOut, /* pExtTextOut */
35 X11DRV_GetCharWidth, /* pGetCharWidth */
36 X11DRV_GetPixel, /* pGetPixel */
37 X11DRV_GetTextExtentPoint, /* pGetTextExtentPoint */
38 X11DRV_GetTextMetrics, /* pGetTextMetrics */
39 NULL, /* pIntersectClipRect */
40 NULL, /* pIntersectVisRect */
41 X11DRV_LineTo, /* pLineTo */
42 X11DRV_MoveToEx, /* pMoveToEx */
43 NULL, /* pOffsetClipRgn */
44 NULL, /* pOffsetViewportOrg (optional) */
45 NULL, /* pOffsetWindowOrg (optional) */
46 X11DRV_PaintRgn, /* pPaintRgn */
47 X11DRV_PatBlt, /* pPatBlt */
48 X11DRV_Pie, /* pPie */
49 X11DRV_PolyPolygon, /* pPolyPolygon */
50 X11DRV_PolyPolyline, /* pPolyPolyline */
51 X11DRV_Polygon, /* pPolygon */
52 X11DRV_Polyline, /* pPolyline */
53 NULL, /* pRealizePalette */
54 X11DRV_Rectangle, /* pRectangle */
55 NULL, /* pRestoreDC */
56 X11DRV_RoundRect, /* pRoundRect */
57 NULL, /* pSaveDC */
58 NULL, /* pScaleViewportExt (optional) */
59 NULL, /* pScaleWindowExt (optional) */
60 NULL, /* pSelectClipRgn */
61 X11DRV_SelectObject, /* pSelectObject */
62 NULL, /* pSelectPalette */
63 NULL, /* pSetBkColor */
64 NULL, /* pSetBkMode */
65 X11DRV_SetDeviceClipping, /* pSetDeviceClipping */
66 NULL, /* pSetDIBitsToDevice */
67 NULL, /* pSetMapMode (optional) */
68 NULL, /* pSetMapperFlags */
69 X11DRV_SetPixel, /* pSetPixel */
70 NULL, /* pSetPolyFillMode */
71 NULL, /* pSetROP2 */
72 NULL, /* pSetRelAbs */
73 NULL, /* pSetStretchBltMode */
74 NULL, /* pSetTextAlign */
75 NULL, /* pSetTextCharacterExtra */
76 NULL, /* pSetTextColor */
77 NULL, /* pSetTextJustification */
78 NULL, /* pSetViewportExt (optional) */
79 NULL, /* pSetViewportOrg (optional) */
80 NULL, /* pSetWindowExt (optional) */
81 NULL, /* pSetWindowOrg (optional) */
82 X11DRV_StretchBlt, /* pStretchBlt */
83 NULL /* pStretchDIBits */
86 static DeviceCaps X11DRV_DevCaps = {
87 /* version */ 0,
88 /* technology */ DT_RASDISPLAY,
89 /* size, resolution */ 0, 0, 0, 0, 0,
90 /* device objects */ 1, 16 + 6, 16, 0, 0, 100, 0,
91 /* curve caps */ CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES |
92 CC_WIDE | CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT,
93 /* line caps */ LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
94 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS,
95 /* polygon caps */ PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
96 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS,
97 /* text caps */ 0,
98 /* regions */ CP_REGION,
99 /* raster caps */ RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 |
100 RC_DI_BITMAP | RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS,
101 /* aspects */ 36, 36, 51,
102 /* pad1 */ { 0 },
103 /* log pixels */ 0, 0,
104 /* pad2 */ { 0 },
105 /* palette size */ 0,
106 /* ..etc */ 0, 0 };
108 /**********************************************************************
109 * X11DRV_Init
111 BOOL32 X11DRV_Init(void)
113 /* FIXME: colormap management should be merged with the X11DRV */
115 if( !COLOR_Init() ) return FALSE;
117 /* Finish up device caps */
119 #if 0
120 TRACE(x11drv, "Height = %-4i pxl, %-4i mm, Width = %-4i pxl, %-4i mm\n",
121 HeightOfScreen(screen), HeightMMOfScreen(screen),
122 WidthOfScreen(screen), WidthMMOfScreen(screen) );
123 #endif
125 X11DRV_DevCaps.version = 0x300;
126 X11DRV_DevCaps.horzSize = WidthMMOfScreen(screen) * screenWidth / WidthOfScreen(screen);
127 X11DRV_DevCaps.vertSize = HeightMMOfScreen(screen) * screenHeight / HeightOfScreen(screen);
128 X11DRV_DevCaps.horzRes = screenWidth;
129 X11DRV_DevCaps.vertRes = screenHeight;
130 X11DRV_DevCaps.bitsPixel = screenDepth;
132 if( COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL )
133 X11DRV_DevCaps.sizePalette = 0;
134 else
136 X11DRV_DevCaps.rasterCaps |= RC_PALETTE;
137 X11DRV_DevCaps.sizePalette = DefaultVisual(display,DefaultScreen(display))->map_entries;
140 /* Resolution will be adjusted during the font init */
142 X11DRV_DevCaps.logPixelsX = (int)(X11DRV_DevCaps.horzRes * 25.4 / X11DRV_DevCaps.horzSize);
143 X11DRV_DevCaps.logPixelsY = (int)(X11DRV_DevCaps.vertRes * 25.4 / X11DRV_DevCaps.vertSize);
145 /* Create default bitmap */
147 if (!X11DRV_BITMAP_Init()) return FALSE;
149 /* Initialize brush dithering */
151 if (!X11DRV_BRUSH_Init()) return FALSE;
153 /* Initialize fonts and text caps */
155 if (!X11DRV_FONT_Init( &X11DRV_DevCaps )) return FALSE;
157 return DRIVER_RegisterDriver( "DISPLAY", &X11DRV_Funcs );
160 /**********************************************************************
161 * X11DRV_CreateDC
163 static BOOL32 X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
164 LPCSTR output, const DEVMODE16* initData )
166 X11DRV_PDEVICE *physDev;
168 physDev = &dc->u.x; /* for now */
170 memset( physDev, 0, sizeof(*physDev) );
171 dc->physDev = physDev;
172 dc->w.devCaps = &X11DRV_DevCaps;
173 if (dc->w.flags & DC_MEMORY)
175 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap,
176 BITMAP_MAGIC );
177 physDev->drawable = bmp->pixmap;
178 physDev->gc = TSXCreateGC( display, physDev->drawable, 0, NULL );
179 dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
180 dc->w.hVisRgn = CreateRectRgn32( 0, 0, bmp->bitmap.bmWidth,
181 bmp->bitmap.bmHeight );
182 GDI_HEAP_UNLOCK( dc->w.hBitmap );
184 else
186 physDev->drawable = rootWindow;
187 physDev->gc = TSXCreateGC( display, physDev->drawable, 0, NULL );
188 dc->w.bitsPerPixel = screenDepth;
189 dc->w.hVisRgn = CreateRectRgn32( 0, 0, screenWidth, screenHeight);
192 if (!dc->w.hVisRgn)
194 TSXFreeGC( display, physDev->gc );
195 return FALSE;
198 TSXSetGraphicsExposures( display, physDev->gc, False );
199 TSXSetSubwindowMode( display, physDev->gc, IncludeInferiors );
201 return TRUE;
205 /**********************************************************************
206 * X11DRV_DeleteDC
208 static BOOL32 X11DRV_DeleteDC( DC *dc )
210 X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
211 TSXFreeGC( display, physDev->gc );
212 return TRUE;
215 /**********************************************************************
216 * X11DRV_Escape
218 static INT32 X11DRV_Escape( DC *dc, INT32 nEscape, INT32 cbInput,
219 SEGPTR lpInData, SEGPTR lpOutData )
221 switch( nEscape )
223 case GETSCALINGFACTOR:
224 if( lpOutData )
226 LPPOINT16 lppt = (LPPOINT16)PTR_SEG_TO_LIN(lpOutData);
227 lppt->x = lppt->y = 0; /* no device scaling */
228 return 1;
230 break;
232 return 0;