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 (* BitBlt
) ( struct _DIBDRVPHYSDEV
*physDevDst
, int xDst
, int yDst
, int width
, int height
,
98 const struct _DIBDRVPHYSDEV
*physDevSrc
, int xSrc
, int ySrc
, DWORD rop
);
99 BOOL (* StretchBlt
) ( struct _DIBDRVPHYSDEV
*physDevDst
, int xDst
, int yDst
, int widthDst
, int heightDst
,
100 const struct _DIBDRVPHYSDEV
*physDevSrc
, int xSrc
, int ySrc
, int widthSrc
, int heightSrc
, DWORD rop
);
102 /* font drawing helper */
103 void (* FreetypeBlit
) ( struct _DIBDRVPHYSDEV
*physDev
, int x
, int y
, FT_Bitmap
*bmp
);
105 } DIBDRV_PRIMITIVE_FUNCS
;
107 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB32_RGB
;
108 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB32_BITFIELDS
;
109 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB24
;
110 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB16_RGB
;
111 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB16_BITFIELDS
;
112 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB8
;
113 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB4
;
114 extern DIBDRV_PRIMITIVE_FUNCS DIBDRV_funcs_DIB1
;
116 /* DIB bitmaps formats */
117 typedef enum _DIBFORMAT
125 DIBFMT_DIB16_RGB
= 6,
126 DIBFMT_DIB16_BITFIELDS
= 7,
128 DIBFMT_DIB32_RGB
= 9,
129 DIBFMT_DIB32_BITFIELDS
= 10
132 /* DIB driver's generic bitmap structure */
133 typedef struct _DIBDRVBITMAP
135 /* bitmap format of dib */
138 /* pointer to top left corner of bitmap */
141 /* flags indicating if bits array is owned
145 /* bitmap dimensions */
149 /* bitmap stride (== width in bytes) of a bitmap line */
150 /* negative for a bottom-up bitmap */
153 /* number of bits/pixel in bitmap */
156 /* calculated numbers for bitfields */
158 /* bitfields masks */
159 DWORD redMask
, greenMask
, blueMask
;
160 /* shifting required within a COLORREF's BYTE */
161 int redShift
, greenShift
, blueShift
;
162 /* size of the fields */
163 int redLen
, greenLen
, blueLen
;
165 /* color table and its size */
167 DWORD colorTableSize
;
169 /* flag indicating that color table has been grabbed */
170 BOOL colorTableGrabbed
;
172 /* primitive function pointers */
173 DIBDRV_PRIMITIVE_FUNCS
*funcs
;
178 typedef struct _DASHPATTERN
185 /* DIB driver physical device */
186 typedef struct _DIBDRVPHYSDEV
188 /* X11 driver physical device */
191 /* HDC associated with physDev */
194 /* is a DIB selected into DC ? */
197 /* currently selected HBITMAP */
200 /* physical bitmap */
201 DIBDRVBITMAP physBitmap
;
206 /* background color and active ROP2 precalculated
207 AND and XOR values for it */
208 COLORREF backgroundColor
;
209 DWORD backgroundAnd
, backgroundXor
;
211 /* pen color and active ROP2 precalculated
212 AND and XOR values for it */
213 COLORREF penColorref
;
215 DWORD penAnd
, penXor
;
216 const DASHPATTERN
*penPattern
;
217 DWORD curDash
, leftInDash
;
218 enum MARKSPACE
{ mark
, space
} markSpace
;
220 /* pen drawing functions */
221 void (* penHLine
) (struct _DIBDRVPHYSDEV
*physDev
, int x1
, int x2
, int y
);
222 void (* penVLine
) (struct _DIBDRVPHYSDEV
*physDev
, int x
, int y1
, int y2
);
223 void (* penLine
) (struct _DIBDRVPHYSDEV
*physDev
, int x1
, int y1
, int x2
, int y2
);
224 void (* brushHLine
)(struct _DIBDRVPHYSDEV
*physDev
, int x1
, int x2
, int y
);
226 /* brush color and active ROP2 precalculated
227 AND and XOR values for it */
228 COLORREF brushColorref
;
230 DWORD brushAnd
, brushXor
;
231 DWORD
*brushAnds
, *brushXors
;
236 /* brush bitmap, if needed, and its converted/resized cache copy */
238 DIBDRVBITMAP brushBitmap
;
239 DIBDRVBITMAP brushBmpCache
;
243 COLORREF textBackground
;
245 /* text color table for antialiased fonts */
246 COLORREF textColorTable
[256];
248 /* freetype face associated to current DC HFONT */
254 /* *********************************************************************
255 * DISPLAY DRIVER ACCESS FUNCTIONS
256 * ********************************************************************/
259 * Loads display driver - partially grabbed from gdi32 */
260 DC_FUNCTIONS
*_DIBDRV_LoadDisplayDriver(void);
263 Frees resources allocated by Display driver */
264 void _DIBDRV_FreeDisplayDriver(void);
267 Gets a pointer to display drives'function table */
268 inline DC_FUNCTIONS
*_DIBDRV_GetDisplayDriver(void);
270 /* *********************************************************************
271 * ROP2 AND OTHER DRAWING RELATED FUNCTIONS
272 * ********************************************************************/
274 void _DIBDRV_CalcAndXorMasks(INT rop
, DWORD color
, DWORD
*and, DWORD
*xor);
276 inline void _DIBDRV_rop32(DWORD
*ptr
, DWORD
and, DWORD
xor);
277 inline void _DIBDRV_rop16(WORD
*ptr
, WORD
and, WORD
xor);
278 inline void _DIBDRV_rop8(BYTE
*ptr
, BYTE
and, BYTE
xor);
280 void _DIBDRV_ResetDashOrigin(DIBDRVPHYSDEV
*physDev
);
282 /* *********************************************************************
284 * ********************************************************************/
286 /* the ROP3 operations
287 this is a BIG case block; beware that some
288 commons ROP3 operations will be optimized
289 from inside blt routines */
290 DWORD
_DIBDRV_ROP3(DWORD p
, DWORD s
, DWORD d
, BYTE rop
);
292 /* *********************************************************************
293 * PHYSICAL BITMAP FUNCTIONS
294 * ********************************************************************/
296 /* gets human-readable dib format name */
297 const char *_DIBDRVBITMAP_GetFormatName(DIBDRVBITMAP
const *bmp
);
299 /* initializes dib from a bitmap :
300 dib dib being initialized
301 bi source BITMAPINFOHEADER with required DIB format info
302 bit_fields color masks
303 color_table color table, if any
304 bits pointer to image data array
305 NOTE : DIBDRVBITMAP doesn't owns bits, but do own color table */
306 BOOL
_DIBDRVBITMAP_InitFromBMIH(DIBDRVBITMAP
*dib
, const BITMAPINFOHEADER
*bi
, const DWORD
*bit_fields
,
307 const RGBQUAD
*color_table
, void *bits
);
309 BOOL
_DIBDRVBITMAP_InitFromBitmapinfo(DIBDRVBITMAP
*dib
, BITMAPINFO
*bmi
);
311 /* initializes a DIBRDVBITMAP copying it from a source one
313 dib destination DIBDRVBITMAP
314 src source DIBDRVBITMAP
315 copy TRUE->copy source pixel array FALSE->link to source pixel array */
316 BOOL
_DIBDRVBITMAP_InitFromDibdrvbitmap(DIBDRVBITMAP
*dib
, const DIBDRVBITMAP
*src
, BOOL copy
);
318 /* creates a DIBRDVBITMAP copying format info from a source one
320 dib destination DIBDRVBITMAP
321 src source DIBDRVBITMAP
322 widht, height sizes of newly created bitmap */
323 BOOL
_DIBDRVBITMAP_CreateFromDibdrvbitmap(DIBDRVBITMAP
*dib
, const DIBDRVBITMAP
*src
, int width
, int height
);
325 /* Clears a DIBDRVBITMAP structure data
326 WARNING : doesn't free anything */
327 void _DIBDRVBITMAP_Clear(DIBDRVBITMAP
*bmp
);
329 /* Frees a DIBDRVBITMAP structure data */
330 void _DIBDRVBITMAP_Free(DIBDRVBITMAP
*bmp
);
332 /* checks whether the format of 2 DIBs are identical
333 it checks the pixel bit count and the color table size
334 and content, if needed */
335 BOOL
_DIBDRVBITMAP_FormatMatch(const DIBDRVBITMAP
*d1
, const DIBDRVBITMAP
*d2
);
337 /* convert a given dib into another format given by 'format' parameter */
338 BOOL
_DIBDRVBITMAP_Convert(DIBDRVBITMAP
*dst
, const DIBDRVBITMAP
*src
, const DIBDRVBITMAP
*format
);
340 /* creates a solid-filled DIB of given color and format
341 DIB format is given by 'format' parameter */
342 BOOL
_DIBDRVBITMAP_CreateSolid(DIBDRVBITMAP
*bmp
, DIBDRVBITMAP
*format
, int width
, int height
, DWORD Color
);
344 /* expands horizontally a bitmap to reach a minimum size,
345 keeping its width as a multiple of a base width
346 Used to widen brushes in order to optimize blitting */
347 BOOL
_DIBDRVBITMAP_ExpandHoriz(DIBDRVBITMAP
*dib
, int baseWidth
, int minWidth
);
349 /* *********************************************************************
350 * DIB <--> DDB CONVERSION ROUTINES
351 * ********************************************************************/
353 /***********************************************************************
354 * Creates DDB that is compatible with source hdc.
355 * hdc is the HDC on where the DIB MUST be selected in
356 * srcBmp is the source DIB
357 * startScan and scanLines specify the portion of DIB to convert
358 * in order to avoid unneeded conversion of large DIBs on blitting
360 * NOTE : the srcBmp DIB MUST NOT be selected in any DC */
361 HBITMAP
_DIBDRV_ConvertDIBtoDDB( HDC hdc
, HBITMAP srcBmp
, int startScan
, int scanLines
);
363 /***********************************************************************
364 * Creates DIB that is compatible with the target hdc.
365 * startScan and scanLines specify the portion of DDB to convert
366 * in order to avoid unneeded conversion of large DDBs on blitting
368 * NOTE : the srcBmp DDB MUST NOT be selected in any DC */
369 HBITMAP
_DIBDRV_ConvertDDBtoDIB( HDC hdc
, HBITMAP srcBmp
, int startScan
, int scanLines
);
371 /***********************************************************************
372 * Creates DIB that is compatible with the target hdc for a device (non memory) source DC */
373 HBITMAP
_DIBDRV_ConvertDevDDBtoDIB( HDC hdcSrc
, HDC hdcDst
, int xSrc
, int ySrc
, int width
, int height
);
375 /* *********************************************************************
377 * ********************************************************************/
379 /***********************************************************************
380 * DIBDRV_GetDeviceCaps */
381 INT
DIBDRV_GetDeviceCaps( DIBDRVPHYSDEV
*physDev
, INT cap
);