4 * Copyright 1993 Alexandre Julliard
5 * Copyright 2021 Jacek Caban for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #ifndef __WINE_GDI_PRIVATE_H
23 #define __WINE_GDI_PRIVATE_H
32 void set_gdi_client_ptr( HGDIOBJ handle
, void *ptr
);
33 void *get_gdi_client_ptr( HGDIOBJ handle
, DWORD type
);
34 DC_ATTR
*get_dc_attr( HDC hdc
);
35 HGDIOBJ
get_full_gdi_handle( HGDIOBJ handle
);
36 void GDI_hdc_using_object( HGDIOBJ obj
, HDC hdc
, void (*delete)( HDC hdc
, HGDIOBJ handle
));
37 void GDI_hdc_not_using_object( HGDIOBJ obj
, HDC hdc
);
39 static inline DWORD
gdi_handle_type( HGDIOBJ obj
)
41 unsigned int handle
= HandleToULong( obj
);
42 return handle
& NTGDI_HANDLE_TYPE_MASK
;
45 /* metafile defines */
47 #define META_EOF 0x0000
49 #define METAFILE_MEMORY 1
50 #define METAFILE_DISK 2
52 #define MFVERSION 0x300
54 /* Undocumented value for DIB's iUsage: Indicates a mono DIB w/o pal entries */
55 #define DIB_PAL_INDICES 2
57 /* Format of comment record added by GetWinMetaFileBits */
61 DWORD comment_id
; /* WMFC */
62 DWORD comment_type
; /* Always 0x00000001 */
63 DWORD version
; /* Always 0x00010000 */
65 DWORD flags
; /* Always 0 */
74 static inline BOOL
is_meta_dc( HDC hdc
)
76 return gdi_handle_type( hdc
) == NTGDI_OBJ_METADC
;
79 BOOL
METADC_Arc( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
80 INT xstart
, INT ystart
, INT xend
, INT yend
);
81 BOOL
METADC_BitBlt( HDC hdc_dst
, INT x_dst
, INT y_dst
, INT width
, INT height
,
82 HDC hdc_src
, INT x_src
, INT y_src
, DWORD rop
);
83 BOOL
METADC_Chord( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
, INT xstart
,
84 INT ystart
, INT xend
, INT yend
);
85 BOOL
METADC_DeleteDC( HDC hdc
);
86 BOOL
METADC_Ellipse( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
);
87 BOOL
METADC_ExcludeClipRect( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
);
88 BOOL
METADC_ExtEscape( HDC hdc
, INT escape
, INT input_size
, const void *input
,
89 INT output_size
, void *output
);
90 BOOL
METADC_ExtFloodFill( HDC hdc
, INT x
, INT y
, COLORREF color
, UINT fill_type
);
91 BOOL
METADC_ExtSelectClipRgn( HDC hdc
, HRGN hrgn
, INT mode
);
92 BOOL
METADC_ExtTextOut( HDC hdc
, INT x
, INT y
, UINT flags
, const RECT
*rect
,
93 const WCHAR
*str
, UINT count
, const INT
*dx
);
94 BOOL
METADC_FillRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
);
95 BOOL
METADC_FrameRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
, INT x
, INT y
);
96 INT
METADC_GetDeviceCaps( HDC hdc
, INT cap
);
97 BOOL
METADC_IntersectClipRect( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
);
98 BOOL
METADC_InvertRgn( HDC hdc
, HRGN hrgn
);
99 BOOL
METADC_LineTo( HDC hdc
, INT x
, INT y
);
100 BOOL
METADC_MoveTo( HDC hdc
, INT x
, INT y
);
101 BOOL
METADC_OffsetClipRgn( HDC hdc
, INT x
, INT y
);
102 BOOL
METADC_OffsetViewportOrgEx( HDC hdc
, INT x
, INT y
);
103 BOOL
METADC_OffsetWindowOrgEx( HDC hdc
, INT x
, INT y
);
104 BOOL
METADC_PaintRgn( HDC hdc
, HRGN hrgn
);
105 BOOL
METADC_PatBlt( HDC hdc
, INT left
, INT top
, INT width
, INT height
, DWORD rop
);
106 BOOL
METADC_Pie( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
107 INT xstart
, INT ystart
, INT xend
, INT yend
);
108 BOOL
METADC_PolyPolygon( HDC hdc
, const POINT
*points
, const INT
*counts
, UINT polygons
);
109 BOOL
METADC_Polygon( HDC hdc
, const POINT
*points
, INT count
);
110 BOOL
METADC_Polyline( HDC hdc
, const POINT
*points
,INT count
);
111 BOOL
METADC_RealizePalette( HDC hdc
);
112 BOOL
METADC_Rectangle( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
);
113 BOOL
METADC_RestoreDC( HDC hdc
, INT level
);
114 BOOL
METADC_RoundRect( HDC hdc
, INT left
, INT top
, INT right
, INT bottom
,
115 INT ell_width
, INT ell_height
);
116 BOOL
METADC_SaveDC( HDC hdc
);
117 BOOL
METADC_ScaleViewportExtEx( HDC hdc
, INT x_num
, INT x_denom
, INT y_num
, INT y_denom
);
118 BOOL
METADC_ScaleWindowExtEx( HDC hdc
, INT x_num
, INT x_denom
, INT y_num
, INT y_denom
);
119 HGDIOBJ
METADC_SelectObject( HDC hdc
, HGDIOBJ obj
);
120 BOOL
METADC_SelectPalette( HDC hdc
, HPALETTE palette
);
121 BOOL
METADC_SetBkColor( HDC hdc
, COLORREF color
);
122 BOOL
METADC_SetBkMode( HDC hdc
, INT mode
);
123 INT
METADC_SetDIBitsToDevice( HDC hdc
, INT x_dest
, INT y_dest
, DWORD width
, DWORD height
,
124 INT x_src
, INT y_src
, UINT startscan
, UINT lines
,
125 const void *bits
, const BITMAPINFO
*info
, UINT coloruse
);
126 BOOL
METADC_SetLayout( HDC hdc
, DWORD layout
);
127 BOOL
METADC_SetTextCharacterExtra( HDC hdc
, INT extra
);
128 BOOL
METADC_SetMapMode( HDC hdc
, INT mode
);
129 BOOL
METADC_SetMapperFlags( HDC hdc
, DWORD flags
);
130 BOOL
METADC_SetPixel( HDC hdc
, INT x
, INT y
, COLORREF color
);
131 BOOL
METADC_SetPolyFillMode( HDC hdc
, INT mode
);
132 BOOL
METADC_SetRelAbs( HDC hdc
, INT mode
);
133 BOOL
METADC_SetROP2( HDC hdc
, INT rop
);
134 BOOL
METADC_SetStretchBltMode( HDC hdc
, INT mode
);
135 BOOL
METADC_SetTextAlign( HDC hdc
, UINT align
);
136 BOOL
METADC_SetTextColor( HDC hdc
, COLORREF color
);
137 BOOL
METADC_SetTextJustification( HDC hdc
, INT extra
, INT breaks
);
138 BOOL
METADC_SetViewportExtEx( HDC hdc
, INT x
, INT y
);
139 BOOL
METADC_SetViewportOrgEx( HDC hdc
, INT x
, INT y
);
140 BOOL
METADC_SetWindowExtEx( HDC hdc
, INT x
, INT y
);
141 BOOL
METADC_SetWindowOrgEx( HDC
, INT x
, INT y
);
142 BOOL
METADC_StretchBlt( HDC hdc_dst
, INT x_dst
, INT y_dst
, INT width_dst
, INT height_dst
,
143 HDC hdc_src
, INT x_src
, INT y_src
, INT width_src
, INT height_src
,
145 INT
METADC_StretchDIBits( HDC hdc
, INT x_dst
, INT y_dst
, INT width_dst
, INT height_dst
,
146 INT x_src
, INT y_src
, INT width_src
, INT height_src
,
147 const void *bits
, const BITMAPINFO
*info
, UINT coloruse
,
150 HMETAFILE
MF_Create_HMETAFILE( METAHEADER
*mh
);
152 /* enhanced metafiles */
154 #define WMFC_MAGIC 0x43464d57
161 } EMRSETTEXTJUSTIFICATION
, *PEMRSETTEXTJUSTIFICATION
;
163 /* Public structure EMRSETMITERLIMIT is using a float field,
164 that does not match serialized output or documentation,
165 which are both using unsigned integer. */
166 struct emr_set_miter_limit
172 BOOL
EMFDC_AbortPath( DC_ATTR
*dc_attr
);
173 BOOL
EMFDC_AlphaBlend( DC_ATTR
*dc_attr
, INT x_dst
, INT y_dst
, INT width_dst
, INT height_dst
,
174 HDC hdc_src
, INT x_src
, INT y_src
, INT width_src
, INT height_src
,
175 BLENDFUNCTION blend_function
);
176 BOOL
EMFDC_AngleArc( DC_ATTR
*dc_attr
, INT x
, INT y
, DWORD radius
, FLOAT start
, FLOAT sweep
);
177 BOOL
EMFDC_ArcChordPie( DC_ATTR
*dc_attr
, INT left
, INT top
, INT right
,
178 INT bottom
, INT xstart
, INT ystart
, INT xend
,
179 INT yend
, DWORD type
);
180 BOOL
EMFDC_BeginPath( DC_ATTR
*dc_attr
);
181 BOOL
EMFDC_BitBlt( DC_ATTR
*dc_attr
, INT x_dst
, INT y_dst
, INT width
, INT height
,
182 HDC hdc_src
, INT x_src
, INT y_src
, DWORD rop
);
183 BOOL
EMFDC_CloseFigure( DC_ATTR
*dc_attr
);
184 void EMFDC_DeleteDC( DC_ATTR
*dc_attr
);
185 BOOL
EMFDC_Ellipse( DC_ATTR
*dc_attr
, INT left
, INT top
, INT right
, INT bottom
);
186 BOOL
EMFDC_EndPath( DC_ATTR
*dc_attr
);
187 BOOL
EMFDC_ExcludeClipRect( DC_ATTR
*dc_attr
, INT left
, INT top
, INT right
, INT bottom
);
188 INT
EMFDC_ExtEscape( DC_ATTR
*dc_attr
, INT escape
, INT input_size
, const char *input
,
189 INT output_size
, char *output
);
190 BOOL
EMFDC_ExtFloodFill( DC_ATTR
*dc_attr
, INT x
, INT y
, COLORREF color
, UINT fill_type
);
191 BOOL
EMFDC_ExtSelectClipRgn( DC_ATTR
*dc_attr
, HRGN hrgn
, INT mode
);
192 BOOL
EMFDC_ExtTextOut( DC_ATTR
*dc_attr
, INT x
, INT y
, UINT flags
, const RECT
*rect
,
193 const WCHAR
*str
, UINT count
, const INT
*dx
);
194 BOOL
EMFDC_FillPath( DC_ATTR
*dc_attr
);
195 BOOL
EMFDC_FillRgn( DC_ATTR
*dc_attr
, HRGN hrgn
, HBRUSH hbrush
);
196 BOOL
EMFDC_FlattenPath( DC_ATTR
*dc_attr
);
197 BOOL
EMFDC_FrameRgn( DC_ATTR
*dc_attr
, HRGN hrgn
, HBRUSH hbrush
, INT width
, INT height
);
198 BOOL
EMFDC_GradientFill( DC_ATTR
*dc_attr
, TRIVERTEX
*vert_array
, ULONG nvert
,
199 void *grad_array
, ULONG ngrad
, ULONG mode
);
200 BOOL
EMFDC_IntersectClipRect( DC_ATTR
*dc_attr
, INT left
, INT top
, INT right
, INT bottom
);
201 BOOL
EMFDC_InvertRgn( DC_ATTR
*dc_attr
, HRGN hrgn
);
202 BOOL
EMFDC_LineTo( DC_ATTR
*dc_attr
, INT x
, INT y
);
203 BOOL
EMFDC_MaskBlt( DC_ATTR
*dc_attr
, INT x_dst
, INT y_dst
, INT width_dst
, INT height_dst
,
204 HDC hdc_src
, INT x_src
, INT y_src
, HBITMAP mask
,
205 INT x_mask
, INT y_mask
, DWORD rop
);
206 BOOL
EMFDC_ModifyWorldTransform( DC_ATTR
*dc_attr
, const XFORM
*xform
, DWORD mode
);
207 BOOL
EMFDC_MoveTo( DC_ATTR
*dc_attr
, INT x
, INT y
);
208 BOOL
EMFDC_OffsetClipRgn( DC_ATTR
*dc_attr
, INT x
, INT y
);
209 BOOL
EMFDC_PaintRgn( DC_ATTR
*dc_attr
, HRGN hrgn
);
210 BOOL
EMFDC_PatBlt( DC_ATTR
*dc_attr
, INT left
, INT top
, INT width
, INT height
, DWORD rop
);
211 BOOL
EMFDC_PlgBlt( DC_ATTR
*dc_attr
, const POINT
*point
, HDC hdc_src
, INT x_src
, INT y_src
,
212 INT width
, INT height
, HBITMAP mask
, INT x_mask
, INT y_mask
);
213 BOOL
EMFDC_PolyBezier( DC_ATTR
*dc_attr
, const POINT
*points
, DWORD count
);
214 BOOL
EMFDC_PolyBezierTo( DC_ATTR
*dc_attr
, const POINT
*points
, DWORD count
);
215 BOOL
EMFDC_PolyDraw( DC_ATTR
*dc_attr
, const POINT
*points
, const BYTE
*types
, DWORD count
);
216 BOOL
EMFDC_PolyPolyline( DC_ATTR
*dc_attr
, const POINT
*points
, const DWORD
*counts
, DWORD polys
);
217 BOOL
EMFDC_PolyPolygon( DC_ATTR
*dc_attr
, const POINT
*points
, const INT
*counts
, UINT polys
);
218 BOOL
EMFDC_Polygon( DC_ATTR
*dc_attr
, const POINT
*points
, INT count
);
219 BOOL
EMFDC_Polyline( DC_ATTR
*dc_attr
, const POINT
*points
, INT count
);
220 BOOL
EMFDC_PolylineTo( DC_ATTR
*dc_attr
, const POINT
*points
, INT count
);
221 BOOL
EMFDC_RealizePalette( DC_ATTR
*dc_attr
);
222 BOOL
EMFDC_Rectangle( DC_ATTR
*dc_attr
, INT left
, INT top
, INT right
, INT bottom
);
223 BOOL
EMFDC_RestoreDC( DC_ATTR
*dc_attr
, INT level
);
224 BOOL
EMFDC_RoundRect( DC_ATTR
*dc_attr
, INT left
, INT top
, INT right
, INT bottom
,
225 INT ell_width
, INT ell_height
);
226 BOOL
EMFDC_SaveDC( DC_ATTR
*dc_attr
);
227 BOOL
EMFDC_ScaleViewportExtEx( DC_ATTR
*dc_attr
, INT x_num
, INT x_denom
, INT y_num
, INT y_denom
);
228 BOOL
EMFDC_ScaleWindowExtEx( DC_ATTR
*dc_attr
, INT x_num
, INT x_denom
, INT y_num
,
230 BOOL
EMFDC_SelectClipPath( DC_ATTR
*dc_attr
, INT mode
);
231 BOOL
EMFDC_SelectObject( DC_ATTR
*dc_attr
, HGDIOBJ obj
);
232 BOOL
EMFDC_SelectPalette( DC_ATTR
*dc_attr
, HPALETTE palette
);
233 BOOL
EMFDC_SetArcDirection( DC_ATTR
*dc_attr
, INT dir
);
234 BOOL
EMFDC_SetBkColor( DC_ATTR
*dc_attr
, COLORREF color
);
235 BOOL
EMFDC_SetBkMode( DC_ATTR
*dc_attr
, INT mode
);
236 BOOL
EMFDC_SetBrushOrgEx( DC_ATTR
*dc_attr
, INT x
, INT y
);
237 BOOL
EMFDC_SetDCBrushColor( DC_ATTR
*dc_attr
, COLORREF color
);
238 BOOL
EMFDC_SetDCPenColor( DC_ATTR
*dc_attr
, COLORREF color
);
239 INT
EMFDC_SetDIBitsToDevice( DC_ATTR
*dc_attr
, INT x_dest
, INT y_dest
, DWORD width
, DWORD height
,
240 INT x_src
, INT y_src
, UINT startscan
, UINT lines
, const void *bits
,
241 const BITMAPINFO
*info
, UINT coloruse
);
242 BOOL
EMFDC_SetLayout( DC_ATTR
*dc_attr
, DWORD layout
);
243 BOOL
EMFDC_SetMapMode( DC_ATTR
*dc_attr
, INT mode
);
244 BOOL
EMFDC_SetMapperFlags( DC_ATTR
*dc_attr
, DWORD flags
);
245 BOOL
EMFDC_SetMetaRgn( DC_ATTR
*dc_attr
);
246 BOOL
EMFDC_SetMiterLimit( DC_ATTR
*dc_attr
, FLOAT limit
);
247 BOOL
EMFDC_SetPixel( DC_ATTR
*dc_attr
, INT x
, INT y
, COLORREF color
);
248 BOOL
EMFDC_SetPolyFillMode( DC_ATTR
*dc_attr
, INT mode
);
249 BOOL
EMFDC_SetROP2( DC_ATTR
*dc_attr
, INT rop
);
250 BOOL
EMFDC_SetStretchBltMode( DC_ATTR
*dc_attr
, INT mode
);
251 BOOL
EMFDC_SetTextAlign( DC_ATTR
*dc_attr
, UINT align
);
252 BOOL
EMFDC_SetTextColor( DC_ATTR
*dc_attr
, COLORREF color
);
253 BOOL
EMFDC_SetTextJustification( DC_ATTR
*dc_attr
, INT extra
, INT breaks
);
254 BOOL
EMFDC_SetViewportExtEx( DC_ATTR
*dc_attr
, INT x
, INT y
);
255 BOOL
EMFDC_SetViewportOrgEx( DC_ATTR
*dc_attr
, INT x
, INT y
);
256 BOOL
EMFDC_SetWindowExtEx( DC_ATTR
*dc_attr
, INT x
, INT y
);
257 BOOL
EMFDC_SetWindowOrgEx( DC_ATTR
*dc_attr
, INT x
, INT y
);
258 BOOL
EMFDC_SetWorldTransform( DC_ATTR
*dc_attr
, const XFORM
*xform
);
259 BOOL
EMFDC_StretchBlt( DC_ATTR
*dc_attr
, INT x_dst
, INT y_dst
, INT width_dst
, INT height_dst
,
260 HDC hdc_src
, INT x_src
, INT y_src
, INT width_src
, INT height_src
,
262 BOOL
EMFDC_StretchDIBits( DC_ATTR
*dc_attr
, INT x_dst
, INT y_dst
, INT width_dst
,
263 INT height_dst
, INT x_src
, INT y_src
, INT width_src
,
264 INT height_src
, const void *bits
, const BITMAPINFO
*info
,
265 UINT coloruse
, DWORD rop
);
266 BOOL
EMFDC_StrokeAndFillPath( DC_ATTR
*dc_attr
);
267 BOOL
EMFDC_StrokePath( DC_ATTR
*dc_attr
);
268 BOOL
EMFDC_TransparentBlt( DC_ATTR
*dc_attr
, int x_dst
, int y_dst
, int width_dst
,
269 int height_dst
, HDC hdc_src
, int x_src
, int y_src
, int width_src
,
270 int height_src
, UINT color
);
271 BOOL
EMFDC_WidenPath( DC_ATTR
*dc_attr
);
273 HENHMETAFILE
EMF_Create_HENHMETAFILE( ENHMETAHEADER
*emh
, DWORD filesize
, BOOL on_disk
);
275 BOOL
spool_start_doc( DC_ATTR
*dc_attr
, HANDLE hspool
, const DOCINFOW
*doc_info
);
276 int spool_start_page( DC_ATTR
*dc_attr
, HANDLE hspool
);
277 int spool_end_page( DC_ATTR
*dc_attr
, HANDLE hspool
, const DEVMODEW
*devmode
,
278 BOOL write_devmode
);
279 int spool_end_doc( DC_ATTR
*dc_attr
, HANDLE hspool
);
280 int spool_abort_doc( DC_ATTR
*dc_attr
, HANDLE hspool
);
282 void print_call_start_page( DC_ATTR
*dc_attr
);
284 static inline int get_dib_stride( int width
, int bpp
)
286 return ((width
* bpp
+ 31) >> 3) & ~3;
289 /* only for use on sanitized BITMAPINFO structures */
290 static inline int get_dib_info_size( const BITMAPINFO
*info
, UINT coloruse
)
292 if (info
->bmiHeader
.biCompression
== BI_BITFIELDS
)
293 return sizeof(BITMAPINFOHEADER
) + 3 * sizeof(DWORD
);
294 if (coloruse
== DIB_PAL_COLORS
)
295 return sizeof(BITMAPINFOHEADER
) + info
->bmiHeader
.biClrUsed
* sizeof(WORD
);
296 return FIELD_OFFSET( BITMAPINFO
, bmiColors
[info
->bmiHeader
.biClrUsed
] );
299 extern HMODULE gdi32_module
;
301 #endif /* __WINE_GDI_PRIVATE_H */