source: trunk/src/gui/painting/qrasterdefs_p.h@ 811

Last change on this file since 811 was 651, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 79.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/***************************************************************************/
43/* */
44/* ftimage.h */
45/* */
46/* FreeType glyph image formats and default raster interface */
47/* (specification). */
48/* */
49/* Copyright 1996-2001, 2002, 2003, 2004 by */
50/* David Turner, Robert Wilhelm, and Werner Lemberg. */
51/* */
52/* This file is part of the FreeType project, and may only be used, */
53/* modified, and distributed under the terms of the FreeType project */
54/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
55/* this file you indicate that you have read the license and */
56/* understand and accept it fully. */
57/* */
58/***************************************************************************/
59
60 /*************************************************************************/
61 /* */
62 /* Note: A `raster' is simply a scan-line converter, used to render */
63 /* QT_FT_Outlines into QT_FT_Bitmaps. */
64 /* */
65 /*************************************************************************/
66
67
68#ifndef __QT_FTIMAGE_H__
69#define __QT_FTIMAGE_H__
70
71/*
72// W A R N I N G
73// -------------
74//
75// This file is not part of the Qt API. It exists purely as an
76// implementation detail. This header file may change from version to
77// version without notice, or even be removed.
78//
79// We mean it.
80*/
81
82QT_FT_BEGIN_HEADER
83
84
85 /*************************************************************************/
86 /* */
87 /* <Section> */
88 /* basic_types */
89 /* */
90 /*************************************************************************/
91
92
93 /*************************************************************************/
94 /* */
95 /* <Type> */
96 /* QT_FT_Pos */
97 /* */
98 /* <Description> */
99 /* The type QT_FT_Pos is a 32-bit integer used to store vectorial */
100 /* coordinates. Depending on the context, these can represent */
101 /* distances in integer font units, or 16,16, or 26.6 fixed float */
102 /* pixel coordinates. */
103 /* */
104 typedef signed long QT_FT_Pos;
105
106
107 /*************************************************************************/
108 /* */
109 /* <Struct> */
110 /* QT_FT_Vector */
111 /* */
112 /* <Description> */
113 /* A simple structure used to store a 2D vector; coordinates are of */
114 /* the QT_FT_Pos type. */
115 /* */
116 /* <Fields> */
117 /* x :: The horizontal coordinate. */
118 /* y :: The vertical coordinate. */
119 /* */
120 typedef struct QT_FT_Vector_
121 {
122 QT_FT_Pos x;
123 QT_FT_Pos y;
124
125 } QT_FT_Vector;
126
127
128 /*************************************************************************/
129 /* */
130 /* <Struct> */
131 /* QT_FT_BBox */
132 /* */
133 /* <Description> */
134 /* A structure used to hold an outline's bounding box, i.e., the */
135 /* coordinates of its extrema in the horizontal and vertical */
136 /* directions. */
137 /* */
138 /* <Fields> */
139 /* xMin :: The horizontal minimum (left-most). */
140 /* */
141 /* yMin :: The vertical minimum (bottom-most). */
142 /* */
143 /* xMax :: The horizontal maximum (right-most). */
144 /* */
145 /* yMax :: The vertical maximum (top-most). */
146 /* */
147 typedef struct QT_FT_BBox_
148 {
149 QT_FT_Pos xMin, yMin;
150 QT_FT_Pos xMax, yMax;
151
152 } QT_FT_BBox;
153
154
155 /*************************************************************************/
156 /* */
157 /* <Enum> */
158 /* QT_FT_Pixel_Mode */
159 /* */
160 /* <Description> */
161 /* An enumeration type used to describe the format of pixels in a */
162 /* given bitmap. Note that additional formats may be added in the */
163 /* future. */
164 /* */
165 /* <Values> */
166 /* QT_FT_PIXEL_MODE_NONE :: */
167 /* Value 0 is reserved. */
168 /* */
169 /* QT_FT_PIXEL_MODE_MONO :: */
170 /* A monochrome bitmap, using 1 bit per pixel. Note that pixels */
171 /* are stored in most-significant order (MSB), which means that */
172 /* the left-most pixel in a byte has value 128. */
173 /* */
174 /* QT_FT_PIXEL_MODE_GRAY :: */
175 /* An 8-bit bitmap, generally used to represent anti-aliased glyph */
176 /* images. Each pixel is stored in one byte. Note that the number */
177 /* of value "gray" levels is stored in the `num_bytes' field of */
178 /* the @QT_FT_Bitmap structure (it generally is 256). */
179 /* */
180 /* QT_FT_PIXEL_MODE_GRAY2 :: */
181 /* A 2-bit/pixel bitmap, used to represent embedded anti-aliased */
182 /* bitmaps in font files according to the OpenType specification. */
183 /* We haven't found a single font using this format, however. */
184 /* */
185 /* QT_FT_PIXEL_MODE_GRAY4 :: */
186 /* A 4-bit/pixel bitmap, used to represent embedded anti-aliased */
187 /* bitmaps in font files according to the OpenType specification. */
188 /* We haven't found a single font using this format, however. */
189 /* */
190 /* QT_FT_PIXEL_MODE_LCD :: */
191 /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
192 /* images used for display on LCD displays; the bitmap's width is */
193 /* three times wider than the original glyph image. See also */
194 /* @QT_FT_RENDER_MODE_LCD. */
195 /* */
196 /* QT_FT_PIXEL_MODE_LCD_V :: */
197 /* An 8-bit bitmap, used to represent RGB or BGR decimated glyph */
198 /* images used for display on rotated LCD displays; the bitmap's */
199 /* height is three times taller than the original glyph image. */
200 /* See also @QT_FT_RENDER_MODE_LCD_V. */
201 /* */
202 typedef enum QT_FT_Pixel_Mode_
203 {
204 QT_FT_PIXEL_MODE_NONE = 0,
205 QT_FT_PIXEL_MODE_MONO,
206 QT_FT_PIXEL_MODE_GRAY,
207 QT_FT_PIXEL_MODE_GRAY2,
208 QT_FT_PIXEL_MODE_GRAY4,
209 QT_FT_PIXEL_MODE_LCD,
210 QT_FT_PIXEL_MODE_LCD_V,
211
212 QT_FT_PIXEL_MODE_MAX /* do not remove */
213
214 } QT_FT_Pixel_Mode;
215
216
217 /*************************************************************************/
218 /* */
219 /* <Enum> */
220 /* qt_ft_pixel_mode_xxx */
221 /* */
222 /* <Description> */
223 /* A list of deprecated constants. Use the corresponding */
224 /* @QT_FT_Pixel_Mode values instead. */
225 /* */
226 /* <Values> */
227 /* qt_ft_pixel_mode_none :: see @QT_FT_PIXEL_MODE_NONE */
228 /* qt_ft_pixel_mode_mono :: see @QT_FT_PIXEL_MODE_MONO */
229 /* qt_ft_pixel_mode_grays :: see @QT_FT_PIXEL_MODE_GRAY */
230 /* qt_ft_pixel_mode_pal2 :: see @QT_FT_PIXEL_MODE_GRAY2 */
231 /* qt_ft_pixel_mode_pal4 :: see @QT_FT_PIXEL_MODE_GRAY4 */
232 /* */
233#define qt_ft_pixel_mode_none QT_FT_PIXEL_MODE_NONE
234#define qt_ft_pixel_mode_mono QT_FT_PIXEL_MODE_MONO
235#define qt_ft_pixel_mode_grays QT_FT_PIXEL_MODE_GRAY
236#define qt_ft_pixel_mode_pal2 QT_FT_PIXEL_MODE_GRAY2
237#define qt_ft_pixel_mode_pal4 QT_FT_PIXEL_MODE_GRAY4
238
239 /* */
240
241#if 0
242
243 /*************************************************************************/
244 /* */
245 /* <Enum> */
246 /* QT_FT_Palette_Mode */
247 /* */
248 /* <Description> */
249 /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */
250 /* */
251 /* An enumeration type used to describe the format of a bitmap */
252 /* palette, used with qt_ft_pixel_mode_pal4 and qt_ft_pixel_mode_pal8. */
253 /* */
254 /* <Fields> */
255 /* qt_ft_palette_mode_rgb :: The palette is an array of 3-bytes RGB */
256 /* records. */
257 /* */
258 /* qt_ft_palette_mode_rgba :: The palette is an array of 4-bytes RGBA */
259 /* records. */
260 /* */
261 /* <Note> */
262 /* As qt_ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */
263 /* FreeType, these types are not handled by the library itself. */
264 /* */
265 typedef enum QT_FT_Palette_Mode_
266 {
267 qt_ft_palette_mode_rgb = 0,
268 qt_ft_palette_mode_rgba,
269
270 qt_ft_palettte_mode_max /* do not remove */
271
272 } QT_FT_Palette_Mode;
273
274 /* */
275
276#endif
277
278
279 /*************************************************************************/
280 /* */
281 /* <Struct> */
282 /* QT_FT_Bitmap */
283 /* */
284 /* <Description> */
285 /* A structure used to describe a bitmap or pixmap to the raster. */
286 /* Note that we now manage pixmaps of various depths through the */
287 /* `pixel_mode' field. */
288 /* */
289 /* <Fields> */
290 /* rows :: The number of bitmap rows. */
291 /* */
292 /* width :: The number of pixels in bitmap row. */
293 /* */
294 /* pitch :: The pitch's absolute value is the number of bytes */
295 /* taken by one bitmap row, including padding. */
296 /* However, the pitch is positive when the bitmap has */
297 /* a `down' flow, and negative when it has an `up' */
298 /* flow. In all cases, the pitch is an offset to add */
299 /* to a bitmap pointer in order to go down one row. */
300 /* */
301 /* buffer :: A typeless pointer to the bitmap buffer. This */
302 /* value should be aligned on 32-bit boundaries in */
303 /* most cases. */
304 /* */
305 /* num_grays :: This field is only used with */
306 /* `QT_FT_PIXEL_MODE_GRAY'; it gives the number of gray */
307 /* levels used in the bitmap. */
308 /* */
309 /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
310 /* See @QT_FT_Pixel_Mode for possible values. */
311 /* */
312 /* palette_mode :: This field is only used with paletted pixel modes; */
313 /* it indicates how the palette is stored. */
314 /* */
315 /* palette :: A typeless pointer to the bitmap palette; only */
316 /* used for paletted pixel modes. */
317 /* */
318 /* <Note> */
319 /* For now, the only pixel mode supported by FreeType are mono and */
320 /* grays. However, drivers might be added in the future to support */
321 /* more `colorful' options. */
322 /* */
323 /* When using pixel modes pal2, pal4 and pal8 with a void `palette' */
324 /* field, a gray pixmap with respectively 4, 16, and 256 levels of */
325 /* gray is assumed. This, in order to be compatible with some */
326 /* embedded bitmap formats defined in the TrueType specification. */
327 /* */
328 /* Note that no font was found presenting such embedded bitmaps, so */
329 /* this is currently completely unhandled by the library. */
330 /* */
331 typedef struct QT_FT_Bitmap_
332 {
333 int rows;
334 int width;
335 int pitch;
336 unsigned char* buffer;
337 short num_grays;
338 char pixel_mode;
339 char palette_mode;
340 void* palette;
341
342 } QT_FT_Bitmap;
343
344
345 /*************************************************************************/
346 /* */
347 /* <Section> */
348 /* outline_processing */
349 /* */
350 /*************************************************************************/
351
352
353 /*************************************************************************/
354 /* */
355 /* <Struct> */
356 /* QT_FT_Outline */
357 /* */
358 /* <Description> */
359 /* This structure is used to describe an outline to the scan-line */
360 /* converter. */
361 /* */
362 /* <Fields> */
363 /* n_contours :: The number of contours in the outline. */
364 /* */
365 /* n_points :: The number of points in the outline. */
366 /* */
367 /* points :: A pointer to an array of `n_points' QT_FT_Vector */
368 /* elements, giving the outline's point coordinates. */
369 /* */
370 /* tags :: A pointer to an array of `n_points' chars, giving */
371 /* each outline point's type. If bit 0 is unset, the */
372 /* point is `off' the curve, i.e. a Bezier control */
373 /* point, while it is `on' when set. */
374 /* */
375 /* Bit 1 is meaningful for `off' points only. If set, */
376 /* it indicates a third-order Bezier arc control point; */
377 /* and a second-order control point if unset. */
378 /* */
379 /* contours :: An array of `n_contours' shorts, giving the end */
380 /* point of each contour within the outline. For */
381 /* example, the first contour is defined by the points */
382 /* `0' to `contours[0]', the second one is defined by */
383 /* the points `contours[0]+1' to `contours[1]', etc. */
384 /* */
385 /* flags :: A set of bit flags used to characterize the outline */
386 /* and give hints to the scan-converter and hinter on */
387 /* how to convert/grid-fit it. See QT_FT_Outline_Flags. */
388 /* */
389 typedef struct QT_FT_Outline_
390 {
391 int n_contours; /* number of contours in glyph */
392 int n_points; /* number of points in the glyph */
393
394 QT_FT_Vector* points; /* the outline's points */
395 char* tags; /* the points flags */
396 int* contours; /* the contour end points */
397
398 int flags; /* outline masks */
399
400 } QT_FT_Outline;
401
402
403 /*************************************************************************/
404 /* */
405 /* <Enum> */
406 /* QT_FT_OUTLINE_FLAGS */
407 /* */
408 /* <Description> */
409 /* A list of bit-field constants use for the flags in an outline's */
410 /* `flags' field. */
411 /* */
412 /* <Values> */
413 /* QT_FT_OUTLINE_NONE :: Value 0 is reserved. */
414 /* */
415 /* QT_FT_OUTLINE_OWNER :: If set, this flag indicates that the */
416 /* outline's field arrays (i.e. */
417 /* `points', `flags' & `contours') are */
418 /* `owned' by the outline object, and */
419 /* should thus be freed when it is */
420 /* destroyed. */
421 /* */
422 /* QT_FT_OUTLINE_EVEN_ODD_FILL :: By default, outlines are filled using */
423 /* the non-zero winding rule. If set to */
424 /* 1, the outline will be filled using */
425 /* the even-odd fill rule (only works */
426 /* with the smooth raster). */
427 /* */
428 /* QT_FT_OUTLINE_REVERSE_FILL :: By default, outside contours of an */
429 /* outline are oriented in clock-wise */
430 /* direction, as defined in the TrueType */