gameux: Add stub of IGameStatisticsMgr implementation.
[wine] / dlls / gdiplus / gdiplus_private.h
1 /*
2  * Copyright (C) 2007 Google (Evan Stade)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #ifndef __WINE_GP_PRIVATE_H_
20 #define __WINE_GP_PRIVATE_H_
21
22 #include <math.h>
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "wingdi.h"
27 #include "winbase.h"
28 #include "winuser.h"
29
30 #include "objbase.h"
31 #include "ocidl.h"
32 #include "wine/list.h"
33
34 #include "gdiplus.h"
35
36 #define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
37 #define MAX_ARC_PTS (13)
38 #define MAX_DASHLEN (16) /* this is a limitation of gdi */
39 #define INCH_HIMETRIC (2540)
40
41 #define VERSION_MAGIC 0xdbc01001
42 #define TENSION_CONST (0.3)
43
44 COLORREF ARGB2COLORREF(ARGB color);
45 HBITMAP ARGB2BMP(ARGB color);
46 extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
47     REAL startAngle, REAL sweepAngle);
48 extern REAL gdiplus_atan2(REAL dy, REAL dx);
49 extern GpStatus hresult_to_status(HRESULT res);
50 extern REAL convert_unit(REAL logpixels, GpUnit unit);
51
52 extern GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics);
53
54 extern void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
55     REAL *y1, REAL *x2, REAL *y2);
56 extern void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
57     REAL tension, REAL *x, REAL *y);
58
59 extern void free_installed_fonts(void);
60
61 extern BOOL lengthen_path(GpPath *path, INT len);
62
63 extern GpStatus trace_path(GpGraphics *graphics, GpPath *path);
64
65 typedef struct region_element region_element;
66 extern void delete_element(region_element *element);
67
68 static inline INT roundr(REAL x)
69 {
70     return (INT) floorf(x + 0.5);
71 }
72
73 static inline INT ceilr(REAL x)
74 {
75     return (INT) ceilf(x);
76 }
77
78 static inline REAL deg2rad(REAL degrees)
79 {
80     return M_PI * degrees / 180.0;
81 }
82
83 static inline ARGB color_over(ARGB bg, ARGB fg)
84 {
85     BYTE b, g, r, a;
86     BYTE bg_alpha, fg_alpha;
87
88     fg_alpha = (fg>>24)&0xff;
89
90     if (fg_alpha == 0xff) return fg;
91
92     if (fg_alpha == 0) return bg;
93
94     bg_alpha = (((bg>>24)&0xff) * (0xff-fg_alpha)) / 0xff;
95
96     if (bg_alpha == 0) return fg;
97
98     a = bg_alpha + fg_alpha;
99     b = ((bg&0xff)*bg_alpha + (fg&0xff)*fg_alpha)/a;
100     g = (((bg>>8)&0xff)*bg_alpha + ((fg>>8)&0xff)*fg_alpha)/a;
101     r = (((bg>>16)&0xff)*bg_alpha + ((fg>>16)&0xff)*fg_alpha)/a;
102
103     return (a<<24)|(r<<16)|(g<<8)|b;
104 }
105
106 extern const char *debugstr_rectf(CONST RectF* rc);
107
108 extern const char *debugstr_pointf(CONST PointF* pt);
109
110 extern void convert_32bppARGB_to_32bppPARGB(UINT width, UINT height,
111     BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride);
112
113 extern GpStatus convert_pixels(UINT width, UINT height,
114     INT dst_stride, BYTE *dst_bits, PixelFormat dst_format,
115     INT src_stride, const BYTE *src_bits, PixelFormat src_format, ARGB *src_palette);
116
117 struct GpPen{
118     UINT style;
119     GpUnit unit;
120     REAL width;
121     GpLineCap endcap;
122     GpLineCap startcap;
123     GpDashCap dashcap;
124     GpCustomLineCap *customstart;
125     GpCustomLineCap *customend;
126     GpLineJoin join;
127     REAL miterlimit;
128     GpDashStyle dash;
129     REAL *dashes;
130     INT numdashes;
131     REAL offset;    /* dash offset */
132     GpBrush *brush;
133     GpPenAlignment align;
134 };
135
136 struct GpGraphics{
137     HDC hdc;
138     HWND hwnd;
139     BOOL owndc;
140     GpImage *image;
141     SmoothingMode smoothing;
142     CompositingQuality compqual;
143     InterpolationMode interpolation;
144     PixelOffsetMode pixeloffset;
145     CompositingMode compmode;
146     TextRenderingHint texthint;
147     GpUnit unit;    /* page unit */
148     REAL scale;     /* page scale */
149     GpMatrix * worldtrans; /* world transform */
150     BOOL busy;      /* hdc handle obtained by GdipGetDC */
151     GpRegion *clip;
152     UINT textcontrast; /* not used yet. get/set only */
153     struct list containers;
154     GraphicsContainer contid; /* last-issued container ID */
155 };
156
157 struct GpBrush{
158     HBRUSH gdibrush;
159     GpBrushType bt;
160     LOGBRUSH lb;
161 };
162
163 struct GpHatch{
164     GpBrush brush;
165     HatchStyle hatchstyle;
166     ARGB forecol;
167     ARGB backcol;
168 };
169
170 struct GpSolidFill{
171     GpBrush brush;
172     ARGB color;
173     HBITMAP bmp;
174 };
175
176 struct GpPathGradient{
177     GpBrush brush;
178     PathData pathdata;
179     ARGB centercolor;
180     GpWrapMode wrap;
181     BOOL gamma;
182     GpPointF center;
183     GpPointF focus;
184     REAL* blendfac;  /* blend factors */
185     REAL* blendpos;  /* blend positions */
186     INT blendcount;
187 };
188
189 struct GpLineGradient{
190     GpBrush brush;
191     GpPointF startpoint;
192     GpPointF endpoint;
193     ARGB startcolor;
194     ARGB endcolor;
195     RectF rect;
196     GpWrapMode wrap;
197     BOOL gamma;
198     REAL* blendfac;  /* blend factors */
199     REAL* blendpos;  /* blend positions */
200     INT blendcount;
201     ARGB* pblendcolor; /* preset blend colors */
202     REAL* pblendpos; /* preset blend positions */
203     INT pblendcount;
204 };
205
206 struct GpTexture{
207     GpBrush brush;
208     GpMatrix *transform;
209     GpImage *image;
210     WrapMode wrap;  /* not used yet */
211 };
212
213 struct GpPath{
214     GpFillMode fill;
215     GpPathData pathdata;
216     BOOL newfigure; /* whether the next drawing action starts a new figure */
217     INT datalen; /* size of the arrays in pathdata */
218 };
219
220 struct GpMatrix{
221     REAL matrix[6];
222 };
223
224 struct GpPathIterator{
225     GpPathData pathdata;
226     INT subpath_pos;    /* for NextSubpath methods */
227     INT marker_pos;     /* for NextMarker methods */
228     INT pathtype_pos;   /* for NextPathType methods */
229 };
230
231 struct GpCustomLineCap{
232     GpPathData pathdata;
233     BOOL fill;      /* TRUE for fill, FALSE for stroke */
234     GpLineCap cap;  /* as far as I can tell, this value is ignored */
235     REAL inset;     /* how much to adjust the end of the line */
236     GpLineJoin join;
237     REAL scale;
238 };
239
240 struct GpAdustableArrowCap{
241     GpCustomLineCap cap;
242 };
243
244 struct GpImage{
245     IPicture* picture;
246     ImageType type;
247     GUID format;
248     UINT flags;
249     UINT palette_flags;
250     UINT palette_count;
251     UINT palette_size;
252     ARGB *palette_entries;
253     REAL xres, yres;
254 };
255
256 struct GpMetafile{
257     GpImage image;
258     GpRectF bounds;
259     GpUnit unit;
260 };
261
262 struct GpBitmap{
263     GpImage image;
264     INT width;
265     INT height;
266     PixelFormat format;
267     ImageLockMode lockmode;
268     INT numlocks;
269     BYTE *bitmapbits;   /* pointer to the buffer we passed in BitmapLockBits */
270     HBITMAP hbitmap;
271     HDC hdc;
272     BYTE *bits; /* actual image bits if this is a DIB */
273     INT stride; /* stride of bits if this is a DIB */
274     BYTE *own_bits; /* image bits that need to be freed with this object */
275 };
276
277 struct GpCachedBitmap{
278     GpImage *image;
279 };
280
281 struct color_key{
282     BOOL enabled;
283     ARGB low;
284     ARGB high;
285 };
286
287 struct color_matrix{
288     BOOL enabled;
289     ColorMatrixFlags flags;
290     ColorMatrix colormatrix;
291     ColorMatrix graymatrix;
292 };
293
294 struct color_remap_table{
295     BOOL enabled;
296     INT mapsize;
297     GDIPCONST ColorMap *colormap;
298 };
299
300 struct GpImageAttributes{
301     WrapMode wrap;
302     ARGB outside_color;
303     BOOL clamp;
304     struct color_key colorkeys[ColorAdjustTypeCount];
305     struct color_matrix colormatrices[ColorAdjustTypeCount];
306     struct color_remap_table colorremaptables[ColorAdjustTypeCount];
307     BOOL gamma_enabled[ColorAdjustTypeCount];
308     REAL gamma[ColorAdjustTypeCount];
309 };
310
311 struct GpFont{
312     LOGFONTW lfw;
313     REAL emSize;
314     UINT height;
315     LONG line_spacing;
316     Unit unit;
317 };
318
319 struct GpStringFormat{
320     INT attr;
321     LANGID lang;
322     LANGID digitlang;
323     StringAlignment align;
324     StringTrimming trimming;
325     HotkeyPrefix hkprefix;
326     StringAlignment vertalign;
327     StringDigitSubstitute digitsub;
328     INT tabcount;
329     REAL firsttab;
330     REAL *tabs;
331     CharacterRange *character_ranges;
332     INT range_count;
333 };
334
335 struct GpFontCollection{
336     GpFontFamily **FontFamilies;
337     INT count;
338     INT allocated;
339 };
340
341 struct GpFontFamily{
342     NEWTEXTMETRICW tmw;
343     WCHAR FamilyName[LF_FACESIZE];
344 };
345
346 /* internal use */
347 typedef enum RegionType
348 {
349     RegionDataRect          = 0x10000000,
350     RegionDataPath          = 0x10000001,
351     RegionDataEmptyRect     = 0x10000002,
352     RegionDataInfiniteRect  = 0x10000003,
353 } RegionType;
354
355 struct region_element
356 {
357     DWORD type; /* Rectangle, Path, SpecialRectangle, or CombineMode */
358     union
359     {
360         GpRectF rect;
361         struct
362         {
363             GpPath* path;
364             struct
365             {
366                 DWORD size;
367                 DWORD magic;
368                 DWORD count;
369                 DWORD flags;
370             } pathheader;
371         } pathdata;
372         struct
373         {
374             struct region_element *left;  /* the original region */
375             struct region_element *right; /* what *left was combined with */
376         } combine;
377     } elementdata;
378 };
379
380 struct GpRegion{
381     struct
382     {
383         DWORD size;
384         DWORD checksum;
385         DWORD magic;
386         DWORD num_children;
387     } header;
388     region_element node;
389 };
390
391 #endif