xref: /reactos/win32ss/gdi/gdi32/wine/gdi_private.h (revision 1734f297)
1 /*
2  * GDI definitions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #ifndef __WINE_GDI_PRIVATE_H
22 #define __WINE_GDI_PRIVATE_H
23 
24 #include <limits.h>
25 #include <math.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 
30 #ifndef _NTGDITYP_
31 typedef enum GDILoObjType
32 {
33     GDILoObjType_LO_BRUSH_TYPE = 0x100000,
34     GDILoObjType_LO_DC_TYPE = 0x10000,
35     GDILoObjType_LO_BITMAP_TYPE = 0x50000,
36     GDILoObjType_LO_PALETTE_TYPE = 0x80000,
37     GDILoObjType_LO_FONT_TYPE = 0xa0000,
38     GDILoObjType_LO_REGION_TYPE = 0x40000,
39     GDILoObjType_LO_ICMLCS_TYPE = 0x90000,
40     GDILoObjType_LO_CLIENTOBJ_TYPE = 0x60000,
41     GDILoObjType_LO_UMPD_TYPE = 0x110000,
42     GDILoObjType_LO_META_TYPE = 0x150000,
43     GDILoObjType_LO_ALTDC_TYPE = 0x210000,
44     GDILoObjType_LO_PEN_TYPE = 0x300000,
45     GDILoObjType_LO_EXTPEN_TYPE = 0x500000,
46     GDILoObjType_LO_DIBSECTION_TYPE = 0x250000,
47     GDILoObjType_LO_METAFILE16_TYPE = 0x260000,
48     GDILoObjType_LO_METAFILE_TYPE = 0x460000,
49     GDILoObjType_LO_METADC16_TYPE = 0x660000
50 } GDILOOBJTYPE, *PGDILOOBJTYPE;
51 #endif
52 
53 #define GDI_HANDLE_TYPE_MASK  0x007f0000
54 #define GDI_HANDLE_GET_TYPE(h)     \
55     (((ULONG_PTR)(h)) & GDI_HANDLE_TYPE_MASK)
56 
57 HRGN APIENTRY NtGdiPathToRegion(_In_ HDC hdc);
58 HDC APIENTRY NtGdiCreateMetafileDC(_In_ HDC hdc);
59 #define GdiWorldSpaceToDeviceSpace  0x204
60 BOOL APIENTRY NtGdiGetTransform(_In_ HDC hdc,_In_ DWORD iXform, _Out_ LPXFORM pxf);
61 /* Get/SetBounds/Rect support. */
62 #define DCB_WINDOWMGR 0x8000 /* Queries the Windows bounding rectangle instead of the application's */
63 BOOL WINAPI GetBoundsRectAlt(HDC hdc,LPRECT prc,UINT flags);
64 BOOL WINAPI SetBoundsRectAlt(HDC hdc,LPRECT prc,UINT flags);
65 
66 HGDIOBJ WINAPI GdiCreateClientObj(_In_ PVOID pvObject, _In_ GDILOOBJTYPE eObjType);
67 PVOID WINAPI GdiGetClientObjLink(_In_ HGDIOBJ hobj);
68 PVOID WINAPI GdiDeleteClientObj(_In_ HGDIOBJ hobj);
69 
70 /* Metafile defines */
71 #define META_EOF 0x0000
72 /* values of mtType in METAHEADER.  Note however that the disk image of a disk
73    based metafile has mtType == 1 */
74 #define METAFILE_MEMORY 1
75 #define METAFILE_DISK   2
76 #define MFHEADERSIZE (sizeof(METAHEADER))
77 #define MFVERSION 0x300
78 
79 typedef struct {
80     EMR   emr;
81     INT   nBreakExtra;
82     INT   nBreakCount;
83 } EMRSETTEXTJUSTIFICATION, *PEMRSETTEXTJUSTIFICATION;
84 
85 typedef struct tagEMRESCAPE {
86         EMR emr;
87         INT iEsc;
88         INT cjIn;
89         BYTE Data[1];
90 } EMRESCAPE, *PEMRESCAPE, EMRNAMEDESCAPE, *PEMRNAMEDESCAPE;
91 
92 INT WINAPI NamedEscape(HDC,PWCHAR,INT,INT,LPSTR,INT,LPSTR);
93 
94 struct gdi_obj_funcs
95 {
96     HGDIOBJ (*pSelectObject)( HGDIOBJ handle, HDC hdc );
97     INT     (*pGetObjectA)( HGDIOBJ handle, INT count, LPVOID buffer );
98     INT     (*pGetObjectW)( HGDIOBJ handle, INT count, LPVOID buffer );
99     BOOL    (*pUnrealizeObject)( HGDIOBJ handle );
100     BOOL    (*pDeleteObject)( HGDIOBJ handle );
101 };
102 
103 /* DC_ATTR LCD Types */
104 #define LDC_LDC           0x00000001
105 #define LDC_EMFLDC        0x00000002
106 
107 typedef struct emf *PEMF;
108 
109 typedef struct tagWINEDC
110 {
111     HDC          hdc;
112     ULONG        Flags;
113     INT          iType;
114     PEMF         emf; /* Pointer to ENHMETAFILE structure */
115     LPWSTR       pwszPort;
116     ABORTPROC    pAbortProc;
117     DWORD        CallBackTick;
118     HANDLE       hPrinter;
119     PDEVMODEW    pdm;
120     PVOID        pUMPDev;
121     PVOID        pUMdhpdev;
122     PVOID        UFIHashTable[3];
123     ULONG        ufi[2];
124     PVOID        pvEMFSpoolData;
125     ULONG        cjSize;
126     LIST_ENTRY   leRecords;
127     ULONG        DevCaps[36];
128     HBRUSH       hBrush;
129     HPEN         hPen;
130     ////
131     INT          save_level;
132     RECTL        emf_bounds;
133 } WINEDC, DC;
134 
135 static inline BOOL is_meta_dc( HDC hdc )
136 {
137     return GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_METADC16_TYPE;
138 }
139 
140 
141 /* brush.c */
142 extern BOOL get_brush_bitmap_info( HBRUSH handle, BITMAPINFO *info, void *bits, UINT *usage ) DECLSPEC_HIDDEN;
143 
144 /* dc.c */
145 extern DC *alloc_dc_ptr( WORD magic ) DECLSPEC_HIDDEN;
146 extern void free_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
147 extern DC *get_dc_ptr( HDC hdc ) DECLSPEC_HIDDEN;
148 extern void release_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
149 
150 /* dib.c */
151 extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
152 
153 /* enhmetafile.c */
154 extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, DWORD filesize, BOOL on_disk ) DECLSPEC_HIDDEN;
155 
156 /* gdiobj.c */
157 extern HGDIOBJ alloc_gdi_handle( void *obj, WORD type, const struct gdi_obj_funcs *funcs ) DECLSPEC_HIDDEN;
158 extern void *free_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN;
159 extern HGDIOBJ get_full_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN;
160 extern void *GDI_GetObjPtr( HGDIOBJ, WORD ) DECLSPEC_HIDDEN;
161 extern void GDI_ReleaseObj( HGDIOBJ ) DECLSPEC_HIDDEN;
162 extern void GDI_hdc_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
163 extern void GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
164 
165 /* metafile.c */
166 extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh) DECLSPEC_HIDDEN;
167 extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCVOID filename, BOOL unicode ) DECLSPEC_HIDDEN;
168 
169 /* Format of comment record added by GetWinMetaFileBits */
170 #include <pshpack2.h>
171 typedef struct
172 {
173     DWORD magic;        /* WMFC */
174     DWORD comment_type; /* Always 0x00000001 */
175     DWORD version;      /* Always 0x00010000 */
176     WORD checksum;
177     DWORD flags;        /* Always 0 */
178     DWORD num_chunks;
179     DWORD chunk_size;
180     DWORD remaining_size;
181     DWORD emf_size;
182     BYTE emf_data[1];
183 } emf_in_wmf_comment;
184 #include <poppack.h>
185 
186 #define WMFC_MAGIC 0x43464d57
187 /* palette.c */
188 extern HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg) DECLSPEC_HIDDEN;
189 extern UINT WINAPI GDIRealizePalette( HDC hdc ) DECLSPEC_HIDDEN;
190 
191 DWORD WINAPI GetDCDWord(_In_ HDC hdc,_In_ UINT u,_In_ DWORD dwError);
192 
193 #define EMR_SETLINKEDUFI        119
194 
195 /* Undocumented value for DIB's iUsage: Indicates a mono DIB w/o pal entries */
196 #define DIB_PAL_MONO 2
197 
198 BOOL WINAPI SetVirtualResolution(HDC hdc, DWORD horz_res, DWORD vert_res, DWORD horz_size, DWORD vert_size);
199 
200 static inline int get_dib_stride( int width, int bpp )
201 {
202     return ((width * bpp + 31) >> 3) & ~3;
203 }
204 
205 static inline int get_dib_image_size( const BITMAPINFO *info )
206 {
207     return get_dib_stride( info->bmiHeader.biWidth, info->bmiHeader.biBitCount )
208         * abs( info->bmiHeader.biHeight );
209 }
210 
211 /* only for use on sanitized BITMAPINFO structures */
212 static inline int get_dib_info_size( const BITMAPINFO *info, UINT coloruse )
213 {
214     if (info->bmiHeader.biCompression == BI_BITFIELDS)
215         return sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD);
216     if (coloruse == DIB_PAL_COLORS)
217         return sizeof(BITMAPINFOHEADER) + info->bmiHeader.biClrUsed * sizeof(WORD);
218     return FIELD_OFFSET( BITMAPINFO, bmiColors[info->bmiHeader.biClrUsed] );
219 }
220 
221 #define GdiWorldSpaceToDeviceSpace  0x204
222 BOOL APIENTRY NtGdiGetTransform( _In_ HDC hdc, _In_ DWORD iXform, _Out_ LPXFORM pxf);
223 
224 /* Special sauce for reactos */
225 #define GDIRealizePalette RealizePalette
226 #define GDISelectPalette SelectPalette
227 
228 HGDIOBJ WINAPI GdiFixUpHandle(HGDIOBJ hGdiObj);
229 #define get_full_gdi_handle GdiFixUpHandle
230 
231 #if 0
232 BOOL WINAPI SetWorldTransformForMetafile(HDC hdc, const XFORM *pxform);
233 #define SetWorldTransform SetWorldTransformForMetafile
234 #endif
235 #ifdef _M_ARM
236 #define DbgRaiseAssertionFailure() __emit(0xdefc)
237 #else
238 #define DbgRaiseAssertionFailure() __int2c()
239 #endif // _M_ARM
240 
241 #undef ASSERT
242 #define ASSERT(x) if (!(x)) DbgRaiseAssertionFailure()
243 
244 BOOL EMFDRV_LineTo( WINEDC *dc, INT x, INT y );
245 BOOL EMFDRV_RoundRect( WINEDC *dc, INT left, INT top, INT right, INT bottom, INT ell_width, INT ell_height );
246 BOOL EMFDRV_ArcChordPie( WINEDC *dc, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend, DWORD type );
247 BOOL EMFDRV_Arc( WINEDC *dc, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend );
248 BOOL EMFDRV_ArcTo( WINEDC *dc, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend );
249 BOOL EMFDRV_Pie( WINEDC *dc, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend );
250 BOOL EMFDRV_Chord( WINEDC *dc, INT left, INT top, INT right, INT bottom, INT xstart, INT ystart, INT xend, INT yend );
251 BOOL EMFDRV_Ellipse( WINEDC *dc, INT left, INT top, INT right, INT bottom );
252 BOOL EMFDRV_Rectangle( WINEDC *dc, INT left, INT top, INT right, INT bottom );
253 COLORREF EMFDRV_SetPixel( WINEDC *dc, INT x, INT y, COLORREF color );
254 BOOL EMFDRV_PolylineTo( WINEDC *dc, const POINT *pt, INT count );
255 BOOL EMFDRV_PolyBezier( WINEDC *dc, const POINT *pts, DWORD count );
256 BOOL EMFDRV_PolyBezierTo( WINEDC *dc, const POINT *pts, DWORD count );
257 BOOL EMFDRV_PolyPolyline( WINEDC *dc, const POINT *pt, const DWORD *counts, UINT polys );
258 BOOL EMFDRV_PolyPolygon( WINEDC *dc, const POINT *pt, const INT *counts, UINT polys );
259 BOOL EMFDRV_PolyDraw( WINEDC *dc, const POINT *pts, const BYTE *types, DWORD count );
260 BOOL EMFDRV_FillRgn( WINEDC *dc, HRGN hrgn, HBRUSH hbrush );
261 BOOL EMFDRV_FrameRgn( WINEDC *dc, HRGN hrgn, HBRUSH hbrush, INT width, INT height );
262 BOOL EMFDRV_InvertRgn( WINEDC *dc, HRGN hrgn );
263 BOOL EMFDRV_ExtTextOut( WINEDC *dc, INT x, INT y, UINT flags, const RECT *lprect,LPCWSTR str, UINT count, const INT *lpDx );
264 BOOL EMFDRV_GradientFill( WINEDC *dc, TRIVERTEX *vert_array, ULONG nvert, void *grad_array, ULONG ngrad, ULONG mode );
265 BOOL EMFDRV_FillPath( WINEDC *dc );
266 BOOL EMFDRV_StrokeAndFillPath( WINEDC *dc );
267 BOOL EMFDRV_StrokePath( WINEDC *dc );
268 BOOL EMFDRV_AlphaBlend( WINEDC *dc_dst, INT x_dst, INT y_dst, INT width_dst, INT height_dst,HDC dc_src, INT x_src, INT y_src, INT width_src, INT height_src, BLENDFUNCTION func );
269 BOOL EMFDRV_PatBlt( WINEDC *dc, INT left, INT top, INT width, INT height, DWORD rop );
270 INT EMFDRV_StretchDIBits( WINEDC *dc, INT x_dst, INT y_dst, INT width_dst,INT height_dst, INT x_src, INT y_src, INT width_src, INT height_src, const void *bits, BITMAPINFO *info, UINT wUsage, DWORD dwRop );
271 INT EMFDRV_SetDIBitsToDevice( WINEDC *dc, INT x_dst, INT y_dst, DWORD width, DWORD height, INT x_src, INT y_src, UINT startscan, UINT lines, const void *bits, BITMAPINFO *info, UINT usage );
272 HBITMAP EMFDRV_SelectBitmap( WINEDC *dc, HBITMAP hbitmap );
273 
274 
275 #endif /* __WINE_GDI_PRIVATE_H */
276 
277