2 * X11 graphics driver initialisation functions
4 * Copyright 1996 Alexandre Julliard
9 #ifndef X_DISPLAY_MISSING
17 #include "debugtools.h"
24 DEFAULT_DEBUG_CHANNEL(x11drv
)
26 static BOOL
X11DRV_CreateDC( DC
*dc
, LPCSTR driver
, LPCSTR device
,
27 LPCSTR output
, const DEVMODEA
* initData
);
28 static BOOL
X11DRV_DeleteDC( DC
*dc
);
30 static INT
X11DRV_Escape( DC
*dc
, INT nEscape
, INT cbInput
,
31 SEGPTR lpInData
, SEGPTR lpOutData
);
33 static const DC_FUNCTIONS X11DRV_Funcs
=
36 X11DRV_Arc
, /* pArc */
37 X11DRV_BitBlt
, /* pBitBlt */
38 X11DRV_BitmapBits
, /* pBitmapBits */
39 X11DRV_Chord
, /* pChord */
40 X11DRV_CreateBitmap
, /* pCreateBitmap */
41 X11DRV_CreateDC
, /* pCreateDC */
42 X11DRV_DIB_CreateDIBSection
, /* pCreateDIBSection */
43 X11DRV_DIB_CreateDIBSection16
, /* pCreateDIBSection16 */
44 X11DRV_DeleteDC
, /* pDeleteDC */
45 X11DRV_DeleteObject
, /* pDeleteObject */
46 NULL
, /* pDeviceCapabilities */
47 X11DRV_Ellipse
, /* pEllipse */
50 X11DRV_EnumDeviceFonts
, /* pEnumDeviceFonts */
51 X11DRV_Escape
, /* pEscape */
52 NULL
, /* pExcludeClipRect */
53 NULL
, /* pExtDeviceMode */
54 X11DRV_ExtFloodFill
, /* pExtFloodFill */
55 X11DRV_ExtTextOut
, /* pExtTextOut */
58 X11DRV_GetCharWidth
, /* pGetCharWidth */
59 X11DRV_GetPixel
, /* pGetPixel */
60 X11DRV_GetTextExtentPoint
, /* pGetTextExtentPoint */
61 X11DRV_GetTextMetrics
, /* pGetTextMetrics */
62 NULL
, /* pIntersectClipRect */
63 NULL
, /* pInvertRgn */
64 X11DRV_LineTo
, /* pLineTo */
65 X11DRV_LoadOEMResource
, /* pLoadOEMResource */
66 X11DRV_MoveToEx
, /* pMoveToEx */
67 NULL
, /* pOffsetClipRgn */
68 NULL
, /* pOffsetViewportOrg (optional) */
69 NULL
, /* pOffsetWindowOrg (optional) */
70 X11DRV_PaintRgn
, /* pPaintRgn */
71 X11DRV_PatBlt
, /* pPatBlt */
72 X11DRV_Pie
, /* pPie */
73 X11DRV_PolyPolygon
, /* pPolyPolygon */
74 X11DRV_PolyPolyline
, /* pPolyPolyline */
75 X11DRV_Polygon
, /* pPolygon */
76 X11DRV_Polyline
, /* pPolyline */
77 X11DRV_PolyBezier
, /* pPolyBezier */
78 NULL
, /* pRealizePalette */
79 X11DRV_Rectangle
, /* pRectangle */
80 NULL
, /* pRestoreDC */
81 X11DRV_RoundRect
, /* pRoundRect */
83 NULL
, /* pScaleViewportExt (optional) */
84 NULL
, /* pScaleWindowExt (optional) */
85 NULL
, /* pSelectClipRgn */
86 X11DRV_SelectObject
, /* pSelectObject */
87 NULL
, /* pSelectPalette */
88 X11DRV_SetBkColor
, /* pSetBkColor */
89 NULL
, /* pSetBkMode */
90 X11DRV_SetDeviceClipping
, /* pSetDeviceClipping */
91 X11DRV_SetDIBitsToDevice
, /* pSetDIBitsToDevice */
92 NULL
, /* pSetMapMode (optional) */
93 NULL
, /* pSetMapperFlags */
94 X11DRV_SetPixel
, /* pSetPixel */
95 NULL
, /* pSetPolyFillMode */
97 NULL
, /* pSetRelAbs */
98 NULL
, /* pSetStretchBltMode */
99 NULL
, /* pSetTextAlign */
100 NULL
, /* pSetTextCharacterExtra */
101 X11DRV_SetTextColor
, /* pSetTextColor */
102 NULL
, /* pSetTextJustification */
103 NULL
, /* pSetViewportExt (optional) */
104 NULL
, /* pSetViewportOrg (optional) */
105 NULL
, /* pSetWindowExt (optional) */
106 NULL
, /* pSetWindowOrg (optional) */
107 NULL
, /* pStartDoc */
108 NULL
, /* pStartPage */
109 X11DRV_StretchBlt
, /* pStretchBlt */
110 NULL
/* pStretchDIBits */
113 GDI_DRIVER X11DRV_GDI_Driver
=
115 X11DRV_GDI_Initialize
,
119 BITMAP_DRIVER X11DRV_BITMAP_Driver
=
121 X11DRV_DIB_SetDIBits
,
122 X11DRV_DIB_GetDIBits
,
123 X11DRV_DIB_DeleteDIBSection
126 PALETTE_DRIVER X11DRV_PALETTE_Driver
=
128 X11DRV_PALETTE_SetMapping
,
129 X11DRV_PALETTE_UpdateMapping
,
130 X11DRV_PALETTE_IsDark
133 DeviceCaps X11DRV_DevCaps
= {
135 /* technology */ DT_RASDISPLAY
,
136 /* size, resolution */ 0, 0, 0, 0, 0,
137 /* device objects */ 1, 16 + 6, 16, 0, 0, 100, 0,
138 /* curve caps */ CC_CIRCLES
| CC_PIE
| CC_CHORD
| CC_ELLIPSES
|
139 CC_WIDE
| CC_STYLED
| CC_WIDESTYLED
| CC_INTERIORS
| CC_ROUNDRECT
,
140 /* line caps */ LC_POLYLINE
| LC_MARKER
| LC_POLYMARKER
| LC_WIDE
|
141 LC_STYLED
| LC_WIDESTYLED
| LC_INTERIORS
,
142 /* polygon caps */ PC_POLYGON
| PC_RECTANGLE
| PC_WINDPOLYGON
|
143 PC_SCANLINE
| PC_WIDE
| PC_STYLED
| PC_WIDESTYLED
| PC_INTERIORS
,
145 /* regions */ CP_REGION
,
146 /* raster caps */ RC_BITBLT
| RC_BANDING
| RC_SCALING
| RC_BITMAP64
|
147 RC_DI_BITMAP
| RC_DIBTODEV
| RC_BIGFONT
| RC_STRETCHBLT
| RC_STRETCHDIB
| RC_DEVBITS
,
148 /* aspects */ 36, 36, 51,
150 /* log pixels */ 0, 0,
152 /* palette size */ 0,
155 /**********************************************************************
156 * X11DRV_GDI_Initialize
158 BOOL
X11DRV_GDI_Initialize(void)
160 BITMAP_Driver
= &X11DRV_BITMAP_Driver
;
161 PALETTE_Driver
= &X11DRV_PALETTE_Driver
;
163 /* FIXME: colormap management should be merged with the X11DRV */
165 if( !X11DRV_DIB_Init() ) return FALSE
;
167 if( !X11DRV_PALETTE_Init() ) return FALSE
;
169 if( !X11DRV_OBM_Init() ) return FALSE
;
171 /* Finish up device caps */
174 TRACE("Height = %-4i pxl, %-4i mm, Width = %-4i pxl, %-4i mm\n",
175 HeightOfScreen(X11DRV_GetXScreen()), HeightMMOfScreen(X11DRV_GetXScreen()),
176 WidthOfScreen(X11DRV_GetXScreen()), WidthMMOfScreen(X11DRV_GetXScreen()) );
179 X11DRV_DevCaps
.version
= 0x300;
180 X11DRV_DevCaps
.horzSize
= WidthMMOfScreen(X11DRV_GetXScreen()) * MONITOR_GetWidth(&MONITOR_PrimaryMonitor
) / WidthOfScreen(X11DRV_GetXScreen());
181 X11DRV_DevCaps
.vertSize
= HeightMMOfScreen(X11DRV_GetXScreen()) * MONITOR_GetHeight(&MONITOR_PrimaryMonitor
) / HeightOfScreen(X11DRV_GetXScreen());
182 X11DRV_DevCaps
.horzRes
= MONITOR_GetWidth(&MONITOR_PrimaryMonitor
);
183 X11DRV_DevCaps
.vertRes
= MONITOR_GetHeight(&MONITOR_PrimaryMonitor
);
184 X11DRV_DevCaps
.bitsPixel
= MONITOR_GetDepth(&MONITOR_PrimaryMonitor
);
186 /* Resolution will be adjusted during the font init */
188 X11DRV_DevCaps
.logPixelsX
= (int)(X11DRV_DevCaps
.horzRes
* 25.4 / X11DRV_DevCaps
.horzSize
);
189 X11DRV_DevCaps
.logPixelsY
= (int)(X11DRV_DevCaps
.vertRes
* 25.4 / X11DRV_DevCaps
.vertSize
);
191 /* Create default bitmap */
193 if (!X11DRV_BITMAP_Init()) return FALSE
;
195 /* Initialize brush dithering */
197 if (!X11DRV_BRUSH_Init()) return FALSE
;
199 /* Initialize fonts and text caps */
201 if (!X11DRV_FONT_Init( &X11DRV_DevCaps
)) return FALSE
;
203 return DRIVER_RegisterDriver( "DISPLAY", &X11DRV_Funcs
);
206 /**********************************************************************
207 * X11DRV_GDI_Finalize
209 void X11DRV_GDI_Finalize(void)
211 X11DRV_PALETTE_Cleanup();
214 /**********************************************************************
217 static BOOL
X11DRV_CreateDC( DC
*dc
, LPCSTR driver
, LPCSTR device
,
218 LPCSTR output
, const DEVMODEA
* initData
)
220 X11DRV_PDEVICE
*physDev
;
222 dc
->physDev
= physDev
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
225 ERR("Can't allocate physDev\n");
229 dc
->w
.devCaps
= &X11DRV_DevCaps
;
230 if (dc
->w
.flags
& DC_MEMORY
)
232 X11DRV_PHYSBITMAP
*pbitmap
;
233 BITMAPOBJ
*bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( dc
->w
.hBitmap
,
235 X11DRV_CreateBitmap( dc
->w
.hBitmap
);
236 pbitmap
= bmp
->DDBitmap
->physBitmap
;
237 physDev
->drawable
= pbitmap
->pixmap
;
238 physDev
->gc
= TSXCreateGC(display
, physDev
->drawable
, 0, NULL
);
239 dc
->w
.bitsPerPixel
= bmp
->bitmap
.bmBitsPixel
;
241 dc
->w
.totalExtent
.left
= 0;
242 dc
->w
.totalExtent
.top
= 0;
243 dc
->w
.totalExtent
.right
= bmp
->bitmap
.bmWidth
;
244 dc
->w
.totalExtent
.bottom
= bmp
->bitmap
.bmHeight
;
245 dc
->w
.hVisRgn
= CreateRectRgnIndirect( &dc
->w
.totalExtent
);
247 GDI_HEAP_UNLOCK( dc
->w
.hBitmap
);
251 physDev
->drawable
= X11DRV_GetXRootWindow();
252 physDev
->gc
= TSXCreateGC( display
, physDev
->drawable
, 0, NULL
);
253 dc
->w
.bitsPerPixel
= MONITOR_GetDepth(&MONITOR_PrimaryMonitor
);
255 dc
->w
.totalExtent
.left
= 0;
256 dc
->w
.totalExtent
.top
= 0;
257 dc
->w
.totalExtent
.right
= MONITOR_GetWidth(&MONITOR_PrimaryMonitor
);
258 dc
->w
.totalExtent
.bottom
= MONITOR_GetHeight(&MONITOR_PrimaryMonitor
);
259 dc
->w
.hVisRgn
= CreateRectRgnIndirect( &dc
->w
.totalExtent
);
264 TSXFreeGC( display
, physDev
->gc
);
268 TSXSetGraphicsExposures( display
, physDev
->gc
, False
);
269 TSXSetSubwindowMode( display
, physDev
->gc
, IncludeInferiors
);
275 /**********************************************************************
278 static BOOL
X11DRV_DeleteDC( DC
*dc
)
280 X11DRV_PDEVICE
*physDev
= (X11DRV_PDEVICE
*)dc
->physDev
;
281 TSXFreeGC( display
, physDev
->gc
);
282 HeapFree( GetProcessHeap(), 0, physDev
);
287 /**********************************************************************
290 static INT
X11DRV_Escape( DC
*dc
, INT nEscape
, INT cbInput
,
291 SEGPTR lpInData
, SEGPTR lpOutData
)
295 case GETSCALINGFACTOR
:
298 LPPOINT16 lppt
= (LPPOINT16
)PTR_SEG_TO_LIN(lpOutData
);
299 lppt
->x
= lppt
->y
= 0; /* no device scaling */
307 #endif /* !defined(X_DISPLAY_MISSING) */