Added pBitmapBits and pCreateBitmap to the GDI function table and
[wine.git] / graphics / x11drv / init.c
blob0a395b03f7a11e6f02d921b158ee3b432c6568ab
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_BitmapBits, /* pBitmapBits */
25 X11DRV_Chord, /* pChord */
26 X11DRV_CreateBitmap, /* pCreateBitmap */
27 X11DRV_CreateDC, /* pCreateDC */
28 X11DRV_DeleteDC, /* pDeleteDC */
29 X11DRV_DeleteObject, /* pDeleteObject */
30 X11DRV_Ellipse, /* pEllipse */
31 X11DRV_EnumDeviceFonts, /* pEnumDeviceFonts */
32 X11DRV_Escape, /* pEscape */
33 NULL, /* pExcludeClipRect */
34 NULL, /* pExcludeVisRect */
35 X11DRV_ExtFloodFill, /* pExtFloodFill */
36 X11DRV_ExtTextOut, /* pExtTextOut */
37 X11DRV_GetCharWidth, /* pGetCharWidth */
38 X11DRV_GetPixel, /* pGetPixel */
39 X11DRV_GetTextExtentPoint, /* pGetTextExtentPoint */
40 X11DRV_GetTextMetrics, /* pGetTextMetrics */
41 NULL, /* pIntersectClipRect */
42 NULL, /* pIntersectVisRect */
43 X11DRV_LineTo, /* pLineTo */
44 X11DRV_MoveToEx, /* pMoveToEx */
45 NULL, /* pOffsetClipRgn */
46 NULL, /* pOffsetViewportOrg (optional) */
47 NULL, /* pOffsetWindowOrg (optional) */
48 X11DRV_PaintRgn, /* pPaintRgn */
49 X11DRV_PatBlt, /* pPatBlt */
50 X11DRV_Pie, /* pPie */
51 X11DRV_PolyPolygon, /* pPolyPolygon */
52 X11DRV_PolyPolyline, /* pPolyPolyline */
53 X11DRV_Polygon, /* pPolygon */
54 X11DRV_Polyline, /* pPolyline */
55 X11DRV_PolyBezier, /* pPolyBezier */
56 NULL, /* pRealizePalette */
57 X11DRV_Rectangle, /* pRectangle */
58 NULL, /* pRestoreDC */
59 X11DRV_RoundRect, /* pRoundRect */
60 NULL, /* pSaveDC */
61 NULL, /* pScaleViewportExt (optional) */
62 NULL, /* pScaleWindowExt (optional) */
63 NULL, /* pSelectClipRgn */
64 X11DRV_SelectObject, /* pSelectObject */
65 NULL, /* pSelectPalette */
66 X11DRV_SetBkColor, /* pSetBkColor */
67 NULL, /* pSetBkMode */
68 X11DRV_SetDeviceClipping, /* pSetDeviceClipping */
69 NULL, /* pSetDIBitsToDevice */
70 NULL, /* pSetMapMode (optional) */
71 NULL, /* pSetMapperFlags */
72 X11DRV_SetPixel, /* pSetPixel */
73 NULL, /* pSetPolyFillMode */
74 NULL, /* pSetROP2 */
75 NULL, /* pSetRelAbs */
76 NULL, /* pSetStretchBltMode */
77 NULL, /* pSetTextAlign */
78 NULL, /* pSetTextCharacterExtra */
79 X11DRV_SetTextColor, /* pSetTextColor */
80 NULL, /* pSetTextJustification */
81 NULL, /* pSetViewportExt (optional) */
82 NULL, /* pSetViewportOrg (optional) */
83 NULL, /* pSetWindowExt (optional) */
84 NULL, /* pSetWindowOrg (optional) */
85 X11DRV_StretchBlt, /* pStretchBlt */
86 NULL /* pStretchDIBits */
89 static DeviceCaps X11DRV_DevCaps = {
90 /* version */ 0,
91 /* technology */ DT_RASDISPLAY,
92 /* size, resolution */ 0, 0, 0, 0, 0,
93 /* device objects */ 1, 16 + 6, 16, 0, 0, 100, 0,
94 /* curve caps */ CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES |
95 CC_WIDE | CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT,
96 /* line caps */ LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
97 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS,
98 /* polygon caps */ PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
99 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS,
100 /* text caps */ 0,
101 /* regions */ CP_REGION,
102 /* raster caps */ RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 |
103 RC_DI_BITMAP | RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS,
104 /* aspects */ 36, 36, 51,
105 /* pad1 */ { 0 },
106 /* log pixels */ 0, 0,
107 /* pad2 */ { 0 },
108 /* palette size */ 0,
109 /* ..etc */ 0, 0 };
111 /**********************************************************************
112 * X11DRV_Init
114 BOOL32 X11DRV_Init(void)
116 /* FIXME: colormap management should be merged with the X11DRV */
118 if( !COLOR_Init() ) return FALSE;
120 /* Finish up device caps */
122 #if 0
123 TRACE(x11drv, "Height = %-4i pxl, %-4i mm, Width = %-4i pxl, %-4i mm\n",
124 HeightOfScreen(screen), HeightMMOfScreen(screen),
125 WidthOfScreen(screen), WidthMMOfScreen(screen) );
126 #endif
128 X11DRV_DevCaps.version = 0x300;
129 X11DRV_DevCaps.horzSize = WidthMMOfScreen(screen) * screenWidth / WidthOfScreen(screen);
130 X11DRV_DevCaps.vertSize = HeightMMOfScreen(screen) * screenHeight / HeightOfScreen(screen);
131 X11DRV_DevCaps.horzRes = screenWidth;
132 X11DRV_DevCaps.vertRes = screenHeight;
133 X11DRV_DevCaps.bitsPixel = screenDepth;
135 if( COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL )
136 X11DRV_DevCaps.sizePalette = 0;
137 else
139 X11DRV_DevCaps.rasterCaps |= RC_PALETTE;
140 X11DRV_DevCaps.sizePalette = DefaultVisual(display,DefaultScreen(display))->map_entries;
143 /* Resolution will be adjusted during the font init */
145 X11DRV_DevCaps.logPixelsX = (int)(X11DRV_DevCaps.horzRes * 25.4 / X11DRV_DevCaps.horzSize);
146 X11DRV_DevCaps.logPixelsY = (int)(X11DRV_DevCaps.vertRes * 25.4 / X11DRV_DevCaps.vertSize);
148 /* Create default bitmap */
150 if (!X11DRV_BITMAP_Init()) return FALSE;
152 /* Initialize brush dithering */
154 if (!X11DRV_BRUSH_Init()) return FALSE;
156 /* Initialize fonts and text caps */
158 if (!X11DRV_FONT_Init( &X11DRV_DevCaps )) return FALSE;
160 return DRIVER_RegisterDriver( "DISPLAY", &X11DRV_Funcs );
163 /**********************************************************************
164 * X11DRV_CreateDC
166 static BOOL32 X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
167 LPCSTR output, const DEVMODE16* initData )
169 X11DRV_PDEVICE *physDev;
171 physDev = &dc->u.x; /* for now */
173 memset( physDev, 0, sizeof(*physDev) );
174 dc->physDev = physDev;
175 dc->w.devCaps = &X11DRV_DevCaps;
176 if (dc->w.flags & DC_MEMORY)
178 X11DRV_PHYSBITMAP *pbitmap;
179 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap,
180 BITMAP_MAGIC );
181 X11DRV_CreateBitmap( dc->w.hBitmap );
182 pbitmap = bmp->DDBitmap->physBitmap;
183 physDev->drawable = pbitmap->pixmap;
184 physDev->gc = TSXCreateGC(display, physDev->drawable, 0, NULL);
185 dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
187 dc->w.totalExtent.left = 0;
188 dc->w.totalExtent.top = 0;
189 dc->w.totalExtent.right = bmp->bitmap.bmWidth;
190 dc->w.totalExtent.bottom = bmp->bitmap.bmHeight;
191 dc->w.hVisRgn = CreateRectRgnIndirect32( &dc->w.totalExtent );
193 GDI_HEAP_UNLOCK( dc->w.hBitmap );
195 else
197 physDev->drawable = rootWindow;
198 physDev->gc = TSXCreateGC( display, physDev->drawable, 0, NULL );
199 dc->w.bitsPerPixel = screenDepth;
201 dc->w.totalExtent.left = 0;
202 dc->w.totalExtent.top = 0;
203 dc->w.totalExtent.right = screenWidth;
204 dc->w.totalExtent.bottom = screenHeight;
205 dc->w.hVisRgn = CreateRectRgnIndirect32( &dc->w.totalExtent );
208 if (!dc->w.hVisRgn)
210 TSXFreeGC( display, physDev->gc );
211 return FALSE;
214 TSXSetGraphicsExposures( display, physDev->gc, False );
215 TSXSetSubwindowMode( display, physDev->gc, IncludeInferiors );
217 return TRUE;
221 /**********************************************************************
222 * X11DRV_DeleteDC
224 static BOOL32 X11DRV_DeleteDC( DC *dc )
226 X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
227 TSXFreeGC( display, physDev->gc );
228 return TRUE;
231 /**********************************************************************
232 * X11DRV_Escape
234 static INT32 X11DRV_Escape( DC *dc, INT32 nEscape, INT32 cbInput,
235 SEGPTR lpInData, SEGPTR lpOutData )
237 switch( nEscape )
239 case GETSCALINGFACTOR:
240 if( lpOutData )
242 LPPOINT16 lppt = (LPPOINT16)PTR_SEG_TO_LIN(lpOutData);
243 lppt->x = lppt->y = 0; /* no device scaling */
244 return 1;
246 break;
248 return 0;