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