2 * X11 graphics driver initialisation functions
4 * Copyright 1996 Alexandre Julliard
15 #include "debugtools.h"
22 DEFAULT_DEBUG_CHANNEL(x11drv
)
24 static BOOL
X11DRV_CreateDC( DC
*dc
, LPCSTR driver
, LPCSTR device
,
25 LPCSTR output
, const DEVMODEA
* initData
);
26 static BOOL
X11DRV_DeleteDC( DC
*dc
);
28 static INT
X11DRV_Escape( DC
*dc
, INT nEscape
, INT cbInput
,
29 SEGPTR lpInData
, SEGPTR lpOutData
);
31 const DC_FUNCTIONS X11DRV_DC_Funcs
=
34 NULL
, /* pAbortPath */
36 X11DRV_Arc
, /* pArc */
38 NULL
, /* pBeginPath */
39 X11DRV_BitBlt
, /* pBitBlt */
40 X11DRV_BitmapBits
, /* pBitmapBits */
41 X11DRV_ChoosePixelFormat
, /* pChoosePixelFormat */
42 X11DRV_Chord
, /* pChord */
43 NULL
, /* pCloseFigure */
44 X11DRV_CreateBitmap
, /* pCreateBitmap */
45 X11DRV_CreateDC
, /* pCreateDC */
46 X11DRV_DIB_CreateDIBSection
, /* pCreateDIBSection */
47 X11DRV_DIB_CreateDIBSection16
, /* pCreateDIBSection16 */
48 X11DRV_DeleteDC
, /* pDeleteDC */
49 X11DRV_DeleteObject
, /* pDeleteObject */
50 X11DRV_DescribePixelFormat
, /* pDescribePixelFormat */
51 NULL
, /* pDeviceCapabilities */
52 X11DRV_Ellipse
, /* pEllipse */
56 X11DRV_EnumDeviceFonts
, /* pEnumDeviceFonts */
57 X11DRV_Escape
, /* pEscape */
58 NULL
, /* pExcludeClipRect */
59 NULL
, /* pExtDeviceMode */
60 X11DRV_ExtFloodFill
, /* pExtFloodFill */
61 X11DRV_ExtTextOut
, /* pExtTextOut */
64 NULL
, /* pFlattenPath */
66 X11DRV_GetCharWidth
, /* pGetCharWidth */
67 X11DRV_GetDCOrgEx
, /* pGetDCOrgEx */
68 X11DRV_GetPixel
, /* pGetPixel */
69 X11DRV_GetPixelFormat
, /* pGetPixelFormat */
70 X11DRV_GetTextExtentPoint
, /* pGetTextExtentPoint */
71 X11DRV_GetTextMetrics
, /* pGetTextMetrics */
72 NULL
, /* pIntersectClipRect */
73 NULL
, /* pInvertRgn */
74 X11DRV_LineTo
, /* pLineTo */
75 X11DRV_LoadOEMResource
, /* pLoadOEMResource */
77 NULL
, /* pOffsetClipRgn */
78 NULL
, /* pOffsetViewportOrg (optional) */
79 NULL
, /* pOffsetWindowOrg (optional) */
80 X11DRV_PaintRgn
, /* pPaintRgn */
81 X11DRV_PatBlt
, /* pPatBlt */
82 X11DRV_Pie
, /* pPie */
83 NULL
, /* pPolyBezier */
84 NULL
, /* pPolyBezierTo */
86 X11DRV_PolyPolygon
, /* pPolyPolygon */
87 X11DRV_PolyPolyline
, /* pPolyPolyline */
88 X11DRV_Polygon
, /* pPolygon */
89 X11DRV_Polyline
, /* pPolyline */
90 NULL
, /* pPolylineTo */
91 NULL
, /* pRealizePalette */
92 X11DRV_Rectangle
, /* pRectangle */
93 NULL
, /* pRestoreDC */
94 X11DRV_RoundRect
, /* pRoundRect */
96 NULL
, /* pScaleViewportExt (optional) */
97 NULL
, /* pScaleWindowExt (optional) */
98 NULL
, /* pSelectClipPath */
99 NULL
, /* pSelectClipRgn */
100 X11DRV_SelectObject
, /* pSelectObject */
101 NULL
, /* pSelectPalette */
102 X11DRV_SetBkColor
, /* pSetBkColor */
103 NULL
, /* pSetBkMode */
104 X11DRV_SetDeviceClipping
, /* pSetDeviceClipping */
105 X11DRV_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
106 NULL
, /* pSetMapMode (optional) */
107 NULL
, /* pSetMapperFlags */
108 X11DRV_SetPixel
, /* pSetPixel */
109 X11DRV_SetPixelFormat
, /* pSetPixelFormat */
110 NULL
, /* pSetPolyFillMode */
112 NULL
, /* pSetRelAbs */
113 NULL
, /* pSetStretchBltMode */
114 NULL
, /* pSetTextAlign */
115 NULL
, /* pSetTextCharacterExtra */
116 X11DRV_SetTextColor
, /* pSetTextColor */
117 NULL
, /* pSetTextJustification */
118 NULL
, /* pSetViewportExt (optional) */
119 NULL
, /* pSetViewportOrg (optional) */
120 NULL
, /* pSetWindowExt (optional) */
121 NULL
, /* pSetWindowOrg (optional) */
122 NULL
, /* pStartDoc */
123 NULL
, /* pStartPage */
124 X11DRV_StretchBlt
, /* pStretchBlt */
125 NULL
, /* pStretchDIBits */
126 NULL
, /* pStrokeAndFillPath */
127 NULL
, /* pStrokePath */
128 X11DRV_SwapBuffers
, /* pSwapBuffers */
129 NULL
/* pWidenPath */
132 BITMAP_DRIVER X11DRV_BITMAP_Driver
=
134 X11DRV_DIB_SetDIBits
,
135 X11DRV_DIB_GetDIBits
,
136 X11DRV_DIB_DeleteDIBSection
139 PALETTE_DRIVER X11DRV_PALETTE_Driver
=
141 X11DRV_PALETTE_SetMapping
,
142 X11DRV_PALETTE_UpdateMapping
,
143 X11DRV_PALETTE_IsDark
146 DeviceCaps X11DRV_DevCaps
= {
148 /* technology */ DT_RASDISPLAY
,
149 /* size, resolution */ 0, 0, 0, 0, 0,
150 /* device objects */ 1, 16 + 6, 16, 0, 0, 100, 0,
151 /* curve caps */ CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
|
152 CC_WIDE
| CC_STYLED
| CC_WIDESTYLED
| CC_INTERIORS
| CC_ROUNDRECT
,
153 /* line caps */ LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
154 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
,
155 /* polygon caps */ PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
|
156 PC_SCANLINE
| PC_WIDE
| PC_STYLED
| PC_WIDESTYLED
| PC_INTERIORS
,
158 /* regions */ CP_REGION
,
159 /* raster caps */ RC_BITBLT
| RC_BANDING
| RC_SCALING
| RC_BITMAP64
|
160 RC_DI_BITMAP
| RC_DIBTODEV
| RC_BIGFONT
| RC_STRETCHBLT
| RC_STRETCHDIB
| RC_DEVBITS
,
161 /* aspects */ 36, 36, 51,
163 /* log pixels */ 0, 0,
165 /* palette size */ 0,
168 /**********************************************************************
169 * X11DRV_GDI_Initialize
171 BOOL
X11DRV_GDI_Initialize(void)
173 BITMAP_Driver
= &X11DRV_BITMAP_Driver
;
174 PALETTE_Driver
= &X11DRV_PALETTE_Driver
;
176 /* FIXME: colormap management should be merged with the X11DRV */
178 if( !X11DRV_DIB_Init() ) return FALSE
;
180 if( !X11DRV_PALETTE_Init() ) return FALSE
;
182 if( !X11DRV_OBM_Init() ) return FALSE
;
184 /* Finish up device caps */
187 TRACE("Height = %-4i pxl, %-4i mm, Width = %-4i pxl, %-4i mm\n",
188 HeightOfScreen(X11DRV_GetXScreen()), HeightMMOfScreen(X11DRV_GetXScreen()),
189 WidthOfScreen(X11DRV_GetXScreen()), WidthMMOfScreen(X11DRV_GetXScreen()) );
192 X11DRV_DevCaps
.version
= 0x300;
193 X11DRV_DevCaps
.horzSize
= WidthMMOfScreen(X11DRV_GetXScreen()) * MONITOR_GetWidth(&MONITOR_PrimaryMonitor
) / WidthOfScreen(X11DRV_GetXScreen());
194 X11DRV_DevCaps
.vertSize
= HeightMMOfScreen(X11DRV_GetXScreen()) * MONITOR_GetHeight(&MONITOR_PrimaryMonitor
) / HeightOfScreen(X11DRV_GetXScreen());
195 X11DRV_DevCaps
.horzRes
= MONITOR_GetWidth(&MONITOR_PrimaryMonitor
);
196 X11DRV_DevCaps
.vertRes
= MONITOR_GetHeight(&MONITOR_PrimaryMonitor
);
197 X11DRV_DevCaps
.bitsPixel
= X11DRV_GetDepth();
199 /* Resolution will be adjusted during the font init */
201 X11DRV_DevCaps
.logPixelsX
= (int)(X11DRV_DevCaps
.horzRes
* 25.4 / X11DRV_DevCaps
.horzSize
);
202 X11DRV_DevCaps
.logPixelsY
= (int)(X11DRV_DevCaps
.vertRes
* 25.4 / X11DRV_DevCaps
.vertSize
);
204 /* Create default bitmap */
206 if (!X11DRV_BITMAP_Init()) return FALSE
;
208 /* Initialize brush dithering */
210 if (!X11DRV_BRUSH_Init()) return FALSE
;
212 /* Initialize fonts and text caps */
214 if (!X11DRV_FONT_Init( &X11DRV_DevCaps
)) return FALSE
;
216 return DRIVER_RegisterDriver( "DISPLAY", &X11DRV_DC_Funcs
);
219 /**********************************************************************
220 * X11DRV_GDI_Finalize
222 void X11DRV_GDI_Finalize(void)
224 X11DRV_PALETTE_Cleanup();
227 /**********************************************************************
230 static BOOL
X11DRV_CreateDC( DC
*dc
, LPCSTR driver
, LPCSTR device
,
231 LPCSTR output
, const DEVMODEA
* initData
)
233 X11DRV_PDEVICE
*physDev
;
235 dc
->physDev
= physDev
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
238 ERR("Can't allocate physDev\n");
242 dc
->w
.devCaps
= &X11DRV_DevCaps
;
243 if (dc
->w
.flags
& DC_MEMORY
)
245 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( dc
->w
.hBitmap
,
247 if (!bmp
->physBitmap
) X11DRV_CreateBitmap( dc
->w
.hBitmap
);
248 physDev
->drawable
= (Pixmap
)bmp
->physBitmap
;
249 physDev
->gc
= TSXCreateGC(display
, physDev
->drawable
, 0, NULL
);
250 dc
->w
.bitsPerPixel
= bmp
->bitmap
.bmBitsPixel
;
252 dc
->w
.totalExtent
.left
= 0;
253 dc
->w
.totalExtent
.top
= 0;
254 dc
->w
.totalExtent
.right
= bmp
->bitmap
.bmWidth
;
255 dc
->w
.totalExtent
.bottom
= bmp
->bitmap
.bmHeight
;
256 dc
->w
.hVisRgn
= CreateRectRgnIndirect( &dc
->w
.totalExtent
);
258 GDI_HEAP_UNLOCK( dc
->w
.hBitmap
);
262 physDev
->drawable
= X11DRV_GetXRootWindow();
263 physDev
->gc
= TSXCreateGC( display
, physDev
->drawable
, 0, NULL
);
264 dc
->w
.bitsPerPixel
= X11DRV_GetDepth();
266 dc
->w
.totalExtent
.left
= 0;
267 dc
->w
.totalExtent
.top
= 0;
268 dc
->w
.totalExtent
.right
= MONITOR_GetWidth(&MONITOR_PrimaryMonitor
);
269 dc
->w
.totalExtent
.bottom
= MONITOR_GetHeight(&MONITOR_PrimaryMonitor
);
270 dc
->w
.hVisRgn
= CreateRectRgnIndirect( &dc
->w
.totalExtent
);
273 physDev
->current_pf
= 0;
274 physDev
->used_visuals
= 0;
278 TSXFreeGC( display
, physDev
->gc
);
282 TSXSetGraphicsExposures( display
, physDev
->gc
, False
);
283 TSXSetSubwindowMode( display
, physDev
->gc
, IncludeInferiors
);
289 /**********************************************************************
292 static BOOL
X11DRV_DeleteDC( DC
*dc
)
294 X11DRV_PDEVICE
*physDev
= (X11DRV_PDEVICE
*)dc
->physDev
;
295 TSXFreeGC( display
, physDev
->gc
);
296 while (physDev
->used_visuals
-- > 0)
297 TSXFree(physDev
->visuals
[physDev
->used_visuals
]);
298 HeapFree( GetProcessHeap(), 0, physDev
);
303 /**********************************************************************
306 static INT
X11DRV_Escape( DC
*dc
, INT nEscape
, INT cbInput
,
307 SEGPTR lpInData
, SEGPTR lpOutData
)
311 case GETSCALINGFACTOR
:
314 LPPOINT16 lppt
= (LPPOINT16
)PTR_SEG_TO_LIN(lpOutData
);
315 lppt
->x
= lppt
->y
= 0; /* no device scaling */