2 * DIB driver private definitions
4 * Copyright 2009 Massimo Del Fedele
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __WINE_DIBDRV_H
21 #define __WINE_DIBDRV_H
31 #include "wine/list.h"
32 #include "wine/library.h"
33 #include "wine/debug.h"
36 #include "wine/winbase16.h" /* GlobalLock16 */
40 /* data structures needed to access opaque pointers
41 * defined in gdi32.h */
42 #include "dibdrv_gdi32.h"
44 /* enable this if you want debugging (i.e. TRACEs) output */
45 #define DIBDRV_ENABLE_MAYBE
47 /* provide a way to make debugging output appear
48 only once. Usage example:
49 ONCE(FIXME("Some message\n")); */
52 static BOOL done = FALSE; \
60 /* provide a way to make debugging output appear
61 only if enabled here. Can speed up stuffs
62 avoiding long traces.Usage example:
63 MAYBE(TRACE("Some message\n")); */
64 #ifdef DIBDRV_ENABLE_MAYBE
71 /* extra stock object: default 1x1 bitmap for memory DCs
72 grabbed from gdi_private.h */
73 #define DEFAULT_BITMAP (STOCK_LAST+1)
76 struct _DIBDRVPHYSDEV
;
77 typedef struct _DIBDRV_PRIMITIVE_FUNCS
79 /* color to pixel data conversion */
80 DWORD (* ColorToPixel
) (const struct _DIBDRVBITMAP
*bmp
, COLORREF color
);
82 /* pixel primitives */
83 void* (* GetPixelPointer
) (const struct _DIBDRVBITMAP
*bmp
, int x
, int y
);
84 void (* SetPixel
) ( struct _DIBDRVBITMAP
*bmp
, int x
, int y
, DWORD
and, DWORD
xor);
85 DWORD (* GetPixel
) (const struct _DIBDRVBITMAP
*bmp
, int x
, int y
);
87 /* line drawing primitives */
88 void (* SolidHLine
) ( struct _DIBDRVBITMAP
*bmp
, int x1
, int x2
, int y
, DWORD
and, DWORD
xor);
89 void (* PatternHLine
) ( struct _DIBDRVBITMAP
*bmp
, int x1
, int x2
, int y
, const void *and, const void *xor, DWORD offset
, DWORD count
);
90 void (* SolidVLine
) ( struct _DIBDRVBITMAP
*bmp
, int x
, int y1
, int y2
, DWORD
and, DWORD
xor);
92 /* bitmap conversion helpers */
93 BOOL (* GetLine
) (const struct _DIBDRVBITMAP
*bmp
, int line
, int startx
, int width
, void *buf
);
94 BOOL (* PutLine
) ( struct _DIBDRVBITMAP
*bmp
, int line
, int startx
, int width
, void *buf
);
96 /* BitBlt primitives */
97 BOOL (* AlphaBlend
) ( struct _DIBDRVPHYSDEV
*physDevDst
, int xDst
, int yDst
, int widthDst
, int heightDst
,
98 const struct _DIBDRVPHYSDEV
*physDevSrc
, int xSrc
, int ySrc
, int widthSrc
, int heightSrc
, BLENDFUNCTION blendFn
);
99 BOOL (* BitBlt
) ( struct _DIBDRVPHYSDEV
*physDevDst
, int xDst
, int yDst
, int width
, int height
,
100 const struct _DIBDRVPHYSDEV
*physDevSrc
, int xSrc
, int ySrc
, DWORD rop
);
101 BOOL (* StretchBlt
) ( struct _DIBDRVPHYSDEV
*physDevDst
, int xDst
, int yDst
, int widthDst
, int heightDst
,
102 const struct _DIBDRVPHYSDEV
*physDevSrc
, int xSrc
, int ySrc
, int widthSrc
, int heightSrc
, DWORD rop
);
104 /* font drawing helper */
105 void (* FreetypeBlit
) ( struct _DIBDRVPHYSDEV
*physDev
, int x
, int y
, FT_Bitmap
*bmp
);
107 } DIBDRV_PRIMITIVE_FUNCS
;
109 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB32_RGB
;
110 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB32_BITFIELDS
;
111 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB24
;
112 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB16_RGB
;
113 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB16_BITFIELDS
;
114 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB8
;
115 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB4
;
116 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB1
;
118 /* DIB bitmaps formats */
119 typedef enum _DIBFORMAT
127 DIBFMT_DIB16_RGB
= 6,
128 DIBFMT_DIB16_BITFIELDS
= 7,
130 DIBFMT_DIB32_RGB
= 9,
131 DIBFMT_DIB32_BITFIELDS
= 10
134 /* DIB driver's generic bitmap structure */
135 typedef struct _DIBDRVBITMAP
137 /* bitmap format of dib */
140 /* pointer to top left corner of bitmap */
143 /* flags indicating if bits array is owned
147 /* bitmap dimensions */
151 /* bitmap stride (== width in bytes) of a bitmap line */
152 /* negative for a bottom-up bitmap */
155 /* number of bits/pixel in bitmap */
158 /* calculated numbers for bitfields */
160 /* bitfields masks */
161 DWORD redMask
, greenMask
, blueMask
;
162 /* shifting required within a COLORREF's BYTE */
163 int redShift
, greenShift
, blueShift
;
164 /* size of the fields */
165 int redLen
, greenLen
, blueLen
;
167 /* color table and its size */
169 DWORD colorTableSize
;
171 /* flag indicating that color table has been grabbed */
172 BOOL colorTableGrabbed
;
174 /* primitive function pointers */
175 DIBDRV_PRIMITIVE_FUNCS
*funcs
;
180 typedef struct _DASHPATTERN
187 /* DIB driver physical device */
188 typedef struct _DIBDRVPHYSDEV
190 /* X11 driver physical device */
193 /* HDC associated with physDev */
196 /* is a DIB selected into DC ? */
199 /* currently selected HBITMAP */
202 /* physical bitmap */
203 DIBDRVBITMAP physBitmap
;
208 /* background color and active ROP2 precalculated
209 AND and XOR values for it */
210 COLORREF backgroundColor
;
211 DWORD backgroundAnd
, backgroundXor
;
213 /* pen color and active ROP2 precalculated
214 AND and XOR values for it */
215 COLORREF penColorref
;
217 DWORD penAnd
, penXor
;
218 const DASHPATTERN
*penPattern
;
219 DWORD curDash
, leftInDash
;
220 enum MARKSPACE
{ mark
, space
} markSpace
;
222 /* pen drawing functions */
223 void (* penHLine
) (struct _DIBDRVPHYSDEV
*physDev
, int x1
, int x2
, int y
);
224 void (* penVLine
) (struct _DIBDRVPHYSDEV
*physDev
, int x
, int y1
, int y2
);
225 void (* penLine
) (struct _DIBDRVPHYSDEV
*physDev
, int x1
, int y1
, int x2
, int y2
);
226 void (* brushHLine
)(struct _DIBDRVPHYSDEV
*physDev
, int x1
, int x2
, int y
);
228 /* brush color and active ROP2 precalculated
229 AND and XOR values for it */
230 COLORREF brushColorref
;
232 DWORD brushAnd
, brushXor
;
233 DWORD
*brushAnds
, *brushXors
;
238 /* brush bitmap, if needed, and its converted/resized cache copy */
240 DIBDRVBITMAP brushBitmap
;
241 DIBDRVBITMAP brushBmpCache
;
245 COLORREF textBackground
;
247 /* text color table for antialiased fonts */
248 COLORREF textColorTable
[256];
250 /* freetype face associated to current DC HFONT */
256 /* *********************************************************************
257 * DISPLAY DRIVER ACCESS FUNCTIONS
258 * ********************************************************************/
261 * Loads display driver - partially grabbed from gdi32 */
262 DC_FUNCTIONS
*_DIBDRV_LoadDisplayDriver(void);
265 Frees resources allocated by Display driver */
266 void _DIBDRV_FreeDisplayDriver(void);
269 Gets a pointer to display drives'function table */
270 inline DC_FUNCTIONS
*_DIBDRV_GetDisplayDriver(void);
272 /* *********************************************************************
273 * ROP2 AND OTHER DRAWING RELATED FUNCTIONS
274 * ********************************************************************/
276 void _DIBDRV_CalcAndXorMasks(INT rop
, DWORD color
, DWORD
*and, DWORD
*xor);
278 inline void _DIBDRV_rop32(DWORD
*ptr
, DWORD
and, DWORD
xor);
279 inline void _DIBDRV_rop16(WORD
*ptr
, WORD
and, WORD
xor);
280 inline void _DIBDRV_rop8(BYTE
*ptr
, BYTE
and, BYTE
xor);
282 void _DIBDRV_ResetDashOrigin(DIBDRVPHYSDEV
*physDev
);
284 /* *********************************************************************
286 * ********************************************************************/
288 /* the ROP3 operations
289 this is a BIG case block; beware that some
290 commons ROP3 operations will be optimized
291 from inside blt routines */
292 DWORD
_DIBDRV_ROP3(DWORD p
, DWORD s
, DWORD d
, BYTE rop
);
294 /* *********************************************************************
295 * PHYSICAL BITMAP FUNCTIONS
296 * ********************************************************************/
298 /* gets human-readable dib format name */
299 const char *_DIBDRVBITMAP_GetFormatName(DIBDRVBITMAP
const *bmp
);
301 /* initializes dib from a bitmap :
302 dib dib being initialized
303 bi source BITMAPINFOHEADER with required DIB format info
304 bit_fields color masks
305 color_table color table, if any
306 bits pointer to image data array
307 NOTE : DIBDRVBITMAP doesn't owns bits, but do own color table */
308 BOOL
_DIBDRVBITMAP_InitFromBMIH(DIBDRVBITMAP
*dib
, const BITMAPINFOHEADER
*bi
, const DWORD
*bit_fields
,
309 const RGBQUAD
*color_table
, void *bits
);
311 BOOL
_DIBDRVBITMAP_InitFromBitmapinfo(DIBDRVBITMAP
*dib
, BITMAPINFO
*bmi
);
313 /* initializes a DIBRDVBITMAP copying it from a source one
315 dib destination DIBDRVBITMAP
316 src source DIBDRVBITMAP
317 copy TRUE->copy source pixel array FALSE->link to source pixel array */
318 BOOL
_DIBDRVBITMAP_InitFromDibdrvbitmap(DIBDRVBITMAP
*dib
, const DIBDRVBITMAP
*src
, BOOL copy
);
320 /* creates a DIBRDVBITMAP copying format info from a source one
322 dib destination DIBDRVBITMAP
323 src source DIBDRVBITMAP
324 widht, height sizes of newly created bitmap */
325 BOOL
_DIBDRVBITMAP_CreateFromDibdrvbitmap(DIBDRVBITMAP
*dib
, const DIBDRVBITMAP
*src
, int width
, int height
);
327 /* Clears a DIBDRVBITMAP structure data
328 WARNING : doesn't free anything */
329 void _DIBDRVBITMAP_Clear(DIBDRVBITMAP
*bmp
);
331 /* Frees a DIBDRVBITMAP structure data */
332 void _DIBDRVBITMAP_Free(DIBDRVBITMAP
*bmp
);
334 /* checks whether the format of 2 DIBs are identical
335 it checks the pixel bit count and the color table size
336 and content, if needed */
337 BOOL
_DIBDRVBITMAP_FormatMatch(const DIBDRVBITMAP
*d1
, const DIBDRVBITMAP
*d2
);
339 /* convert a given dib into another format given by 'format' parameter */
340 BOOL
_DIBDRVBITMAP_Convert(DIBDRVBITMAP
*dst
, const DIBDRVBITMAP
*src
, const DIBDRVBITMAP
*format
);
342 /* creates a solid-filled DIB of given color and format
343 DIB format is given by 'format' parameter */
344 BOOL
_DIBDRVBITMAP_CreateSolid(DIBDRVBITMAP
*bmp
, DIBDRVBITMAP
*format
, int width
, int height
, DWORD Color
);
346 /* expands horizontally a bitmap to reach a minimum size,
347 keeping its width as a multiple of a base width
348 Used to widen brushes in order to optimize blitting */
349 BOOL
_DIBDRVBITMAP_ExpandHoriz(DIBDRVBITMAP
*dib
, int baseWidth
, int minWidth
);
351 /* *********************************************************************
352 * DIB <--> DDB CONVERSION ROUTINES
353 * ********************************************************************/
355 /***********************************************************************
356 * Creates DDB that is compatible with source hdc.
357 * hdc is the HDC on where the DIB MUST be selected in
358 * srcBmp is the source DIB
359 * startScan and scanLines specify the portion of DIB to convert
360 * in order to avoid unneeded conversion of large DIBs on blitting
362 * NOTE : the srcBmp DIB MUST NOT be selected in any DC */
363 HBITMAP
_DIBDRV_ConvertDIBtoDDB( HDC hdc
, HBITMAP srcBmp
, int startScan
, int scanLines
);
365 /***********************************************************************
366 * Creates DIB that is compatible with the target hdc.
367 * startScan and scanLines specify the portion of DDB to convert
368 * in order to avoid unneeded conversion of large DDBs on blitting
370 * NOTE : the srcBmp DDB MUST NOT be selected in any DC */
371 HBITMAP
_DIBDRV_ConvertDDBtoDIB( HDC hdc
, HBITMAP srcBmp
, int startScan
, int scanLines
);
373 /***********************************************************************
374 * Creates DIB that is compatible with the target hdc for a device (non memory) source DC */
375 HBITMAP
_DIBDRV_ConvertDevDDBtoDIB( HDC hdcSrc
, HDC hdcDst
, int xSrc
, int ySrc
, int width
, int height
);
377 /* *********************************************************************
379 * ********************************************************************/
381 /***********************************************************************
382 * DIBDRV_GetDeviceCaps */
383 INT
DIBDRV_GetDeviceCaps( DIBDRVPHYSDEV
*physDev
, INT cap
);