wined3d: Check for SRV/RTV binding conflicts per wined3d_state.
[wine.git] / dlls / gdiplus / gdiplus_private.h
blob2b0f920473d0decba07992609b98a55047580a04
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
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.
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.
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
19 #ifndef __WINE_GP_PRIVATE_H_
20 #define __WINE_GP_PRIVATE_H_
22 #include <math.h>
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "wingdi.h"
27 #include "winbase.h"
28 #include "winuser.h"
30 #include "objbase.h"
31 #include "ocidl.h"
32 #include "wincodecsdk.h"
33 #include "wine/heap.h"
34 #include "wine/list.h"
36 #include "gdiplus.h"
38 #define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
39 #define MAX_ARC_PTS (13)
40 #define MAX_DASHLEN (16) /* this is a limitation of gdi */
41 #define INCH_HIMETRIC (2540)
43 #define VERSION_MAGIC 0xdbc01001
44 #define VERSION_MAGIC2 0xdbc01002
45 #define VALID_MAGIC(x) (((x) & 0xfffff000) == 0xdbc01000)
46 #define TENSION_CONST (0.3)
48 #define GIF_DISPOSE_UNSPECIFIED 0
49 #define GIF_DISPOSE_DO_NOT_DISPOSE 1
50 #define GIF_DISPOSE_RESTORE_TO_BKGND 2
51 #define GIF_DISPOSE_RESTORE_TO_PREV 3
54 COLORREF ARGB2COLORREF(ARGB color) DECLSPEC_HIDDEN;
55 HBITMAP ARGB2BMP(ARGB color) DECLSPEC_HIDDEN;
56 extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
57 REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN;
58 extern REAL gdiplus_atan2(REAL dy, REAL dx) DECLSPEC_HIDDEN;
59 extern GpStatus hresult_to_status(HRESULT res) DECLSPEC_HIDDEN;
60 extern REAL units_to_pixels(REAL units, GpUnit unit, REAL dpi, BOOL printer_display) DECLSPEC_HIDDEN;
61 extern REAL pixels_to_units(REAL pixels, GpUnit unit, REAL dpi, BOOL printer_display) DECLSPEC_HIDDEN;
62 extern REAL units_scale(GpUnit from, GpUnit to, REAL dpi, BOOL printer_display) DECLSPEC_HIDDEN;
64 #define WineCoordinateSpaceGdiDevice ((GpCoordinateSpace)4)
66 extern GpStatus gdi_transform_acquire(GpGraphics *graphics);
67 extern GpStatus gdi_transform_release(GpGraphics *graphics);
68 extern GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace dst_space,
69 GpCoordinateSpace src_space, GpMatrix *matrix) DECLSPEC_HIDDEN;
70 extern GpStatus gdip_transform_points(GpGraphics *graphics, GpCoordinateSpace dst_space,
71 GpCoordinateSpace src_space, GpPointF *points, INT count) DECLSPEC_HIDDEN;
73 extern GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics) DECLSPEC_HIDDEN;
74 extern GpStatus encode_image_png(GpImage *image, IStream* stream, GDIPCONST EncoderParameters* params) DECLSPEC_HIDDEN;
75 extern GpStatus terminate_encoder_wic(GpImage *image) DECLSPEC_HIDDEN;
77 extern GpStatus METAFILE_GetGraphicsContext(GpMetafile* metafile, GpGraphics **result) DECLSPEC_HIDDEN;
78 extern GpStatus METAFILE_GetDC(GpMetafile* metafile, HDC *hdc) DECLSPEC_HIDDEN;
79 extern GpStatus METAFILE_ReleaseDC(GpMetafile* metafile, HDC hdc) DECLSPEC_HIDDEN;
80 extern GpStatus METAFILE_GraphicsClear(GpMetafile* metafile, ARGB color) DECLSPEC_HIDDEN;
81 extern GpStatus METAFILE_FillRectangles(GpMetafile* metafile, GpBrush* brush,
82 GDIPCONST GpRectF* rects, INT count) DECLSPEC_HIDDEN;
83 extern GpStatus METAFILE_SetClipRect(GpMetafile* metafile,
84 REAL x, REAL y, REAL width, REAL height, CombineMode mode) DECLSPEC_HIDDEN;
85 extern GpStatus METAFILE_SetClipRegion(GpMetafile* metafile, GpRegion* region, CombineMode mode) DECLSPEC_HIDDEN;
86 extern GpStatus METAFILE_SetPageTransform(GpMetafile* metafile, GpUnit unit, REAL scale) DECLSPEC_HIDDEN;
87 extern GpStatus METAFILE_SetWorldTransform(GpMetafile* metafile, GDIPCONST GpMatrix* transform) DECLSPEC_HIDDEN;
88 extern GpStatus METAFILE_ScaleWorldTransform(GpMetafile* metafile, REAL sx, REAL sy, MatrixOrder order) DECLSPEC_HIDDEN;
89 extern GpStatus METAFILE_MultiplyWorldTransform(GpMetafile* metafile, GDIPCONST GpMatrix* matrix, MatrixOrder order) DECLSPEC_HIDDEN;
90 extern GpStatus METAFILE_RotateWorldTransform(GpMetafile* metafile, REAL angle, MatrixOrder order) DECLSPEC_HIDDEN;
91 extern GpStatus METAFILE_TranslateWorldTransform(GpMetafile* metafile, REAL dx, REAL dy, MatrixOrder order) DECLSPEC_HIDDEN;
92 extern GpStatus METAFILE_ResetWorldTransform(GpMetafile* metafile) DECLSPEC_HIDDEN;
93 extern GpStatus METAFILE_BeginContainer(GpMetafile* metafile, GDIPCONST GpRectF *dstrect,
94 GDIPCONST GpRectF *srcrect, GpUnit unit, DWORD StackIndex) DECLSPEC_HIDDEN;
95 extern GpStatus METAFILE_BeginContainerNoParams(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN;
96 extern GpStatus METAFILE_EndContainer(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN;
97 extern GpStatus METAFILE_SaveGraphics(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN;
98 extern GpStatus METAFILE_RestoreGraphics(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN;
99 extern GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile) DECLSPEC_HIDDEN;
100 extern GpStatus METAFILE_DrawImagePointsRect(GpMetafile* metafile, GpImage *image,
101 GDIPCONST GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth,
102 REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes* imageAttributes,
103 DrawImageAbort callback, VOID *callbackData) DECLSPEC_HIDDEN;
104 extern GpStatus METAFILE_AddSimpleProperty(GpMetafile *metafile, SHORT prop, SHORT val) DECLSPEC_HIDDEN;
105 extern GpStatus METAFILE_DrawPath(GpMetafile *metafile, GpPen *pen, GpPath *path) DECLSPEC_HIDDEN;
106 extern GpStatus METAFILE_FillPath(GpMetafile *metafile, GpBrush *brush, GpPath *path) DECLSPEC_HIDDEN;
107 extern GpStatus METAFILE_DrawDriverString(GpMetafile *metafile, GDIPCONST UINT16 *text, INT length,
108 GDIPCONST GpFont *font, GDIPCONST GpStringFormat *format, GDIPCONST GpBrush *brush,
109 GDIPCONST PointF *positions, INT flags, GDIPCONST GpMatrix *matrix) DECLSPEC_HIDDEN;
110 extern GpStatus METAFILE_FillRegion(GpMetafile* metafile, GpBrush* brush,
111 GpRegion* region) DECLSPEC_HIDDEN;
112 extern void METAFILE_Free(GpMetafile *metafile) DECLSPEC_HIDDEN;
113 extern GpStatus METAFILE_DrawEllipse(GpMetafile *metafile, GpPen *pen, GpRectF *rect) DECLSPEC_HIDDEN;
114 extern GpStatus METAFILE_FillEllipse(GpMetafile *metafile, GpBrush *brush, GpRectF *rect) DECLSPEC_HIDDEN;
115 extern GpStatus METAFILE_DrawRectangles(GpMetafile *metafile, GpPen *pen, const GpRectF *rects, INT count) DECLSPEC_HIDDEN;
116 extern GpStatus METAFILE_FillPie(GpMetafile *metafile, GpBrush *brush, const GpRectF *rect,
117 REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN;
118 extern GpStatus METAFILE_DrawArc(GpMetafile *metafile, GpPen *pen, const GpRectF *rect,
119 REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN;
120 extern GpStatus METAFILE_OffsetClip(GpMetafile *metafile, REAL dx, REAL dy) DECLSPEC_HIDDEN;
121 extern GpStatus METAFILE_ResetClip(GpMetafile *metafile) DECLSPEC_HIDDEN;
122 extern GpStatus METAFILE_SetClipPath(GpMetafile *metafile, GpPath *path, CombineMode mode) DECLSPEC_HIDDEN;
123 extern GpStatus METAFILE_SetRenderingOrigin(GpMetafile *metafile, INT x, INT y) DECLSPEC_HIDDEN;
125 extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1,
126 REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN;
127 extern void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
128 REAL tension, REAL *x, REAL *y) DECLSPEC_HIDDEN;
130 extern void free_installed_fonts(void) DECLSPEC_HIDDEN;
132 extern BOOL lengthen_path(GpPath *path, INT len) DECLSPEC_HIDDEN;
134 extern DWORD write_region_data(const GpRegion *region, void *data) DECLSPEC_HIDDEN;
135 extern DWORD write_path_data(GpPath *path, void *data) DECLSPEC_HIDDEN;
137 extern GpStatus trace_path(GpGraphics *graphics, GpPath *path) DECLSPEC_HIDDEN;
139 typedef struct region_element region_element;
140 extern void delete_element(region_element *element) DECLSPEC_HIDDEN;
142 extern GpStatus get_hatch_data(GpHatchStyle hatchstyle, const unsigned char **result) DECLSPEC_HIDDEN;
144 static inline INT gdip_round(REAL x)
146 return (INT) floorf(x + 0.5);
149 static inline INT ceilr(REAL x)
151 return (INT) ceilf(x);
154 static inline REAL deg2rad(REAL degrees)
156 return M_PI * degrees / 180.0;
159 static inline ARGB color_over(ARGB bg, ARGB fg)
161 BYTE b, g, r, a;
162 BYTE bg_alpha, fg_alpha;
164 fg_alpha = (fg>>24)&0xff;
166 if (fg_alpha == 0xff) return fg;
168 if (fg_alpha == 0) return bg;
170 bg_alpha = (((bg>>24)&0xff) * (0xff-fg_alpha)) / 0xff;
172 if (bg_alpha == 0) return fg;
174 a = bg_alpha + fg_alpha;
175 b = ((bg&0xff)*bg_alpha + (fg&0xff)*fg_alpha)/a;
176 g = (((bg>>8)&0xff)*bg_alpha + ((fg>>8)&0xff)*fg_alpha)/a;
177 r = (((bg>>16)&0xff)*bg_alpha + ((fg>>16)&0xff)*fg_alpha)/a;
179 return (a<<24)|(r<<16)|(g<<8)|b;
182 /* fg is premult, bg and return value are not */
183 static inline ARGB color_over_fgpremult(ARGB bg, ARGB fg)
185 BYTE b, g, r, a;
186 BYTE bg_alpha, fg_alpha;
188 fg_alpha = (fg>>24)&0xff;
190 if (fg_alpha == 0) return bg;
192 bg_alpha = (((bg>>24)&0xff) * (0xff-fg_alpha)) / 0xff;
194 a = bg_alpha + fg_alpha;
195 b = ((bg&0xff)*bg_alpha + (fg&0xff)*0xff)/a;
196 g = (((bg>>8)&0xff)*bg_alpha + ((fg>>8)&0xff)*0xff)/a;
197 r = (((bg>>16)&0xff)*bg_alpha + ((fg>>16)&0xff)*0xff)/a;
199 return (a<<24)|(r<<16)|(g<<8)|b;
202 extern const char *debugstr_rectf(const RectF* rc) DECLSPEC_HIDDEN;
204 extern const char *debugstr_pointf(const PointF* pt) DECLSPEC_HIDDEN;
206 extern void convert_32bppARGB_to_32bppPARGB(UINT width, UINT height,
207 BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride) DECLSPEC_HIDDEN;
209 extern GpStatus convert_pixels(INT width, INT height,
210 INT dst_stride, BYTE *dst_bits, PixelFormat dst_format,
211 INT src_stride, const BYTE *src_bits, PixelFormat src_format, ColorPalette *palette) DECLSPEC_HIDDEN;
213 extern PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE data,
214 UINT width, UINT height, INT stride, ColorAdjustType type, PixelFormat fmt) DECLSPEC_HIDDEN;
216 struct GpMatrix{
217 REAL matrix[6];
220 struct GpPen{
221 UINT style;
222 GpUnit unit;
223 REAL width;
224 GpLineCap endcap;
225 GpLineCap startcap;
226 GpDashCap dashcap;
227 GpCustomLineCap *customstart;
228 GpCustomLineCap *customend;
229 GpLineJoin join;
230 REAL miterlimit;
231 GpDashStyle dash;
232 REAL *dashes;
233 INT numdashes;
234 REAL offset; /* dash offset */
235 GpBrush *brush;
236 GpPenAlignment align;
237 GpMatrix transform;
240 struct GpGraphics{
241 HDC hdc;
242 HWND hwnd;
243 BOOL owndc;
244 BOOL alpha_hdc;
245 BOOL printer_display;
246 GpImage *image;
247 ImageType image_type;
248 SmoothingMode smoothing;
249 CompositingQuality compqual;
250 InterpolationMode interpolation;
251 PixelOffsetMode pixeloffset;
252 CompositingMode compmode;
253 TextRenderingHint texthint;
254 GpUnit unit; /* page unit */
255 REAL scale; /* page scale */
256 REAL xres, yres;
257 GpMatrix worldtrans; /* world transform */
258 BOOL busy; /* hdc handle obtained by GdipGetDC */
259 GpRegion *clip; /* in device coords */
260 UINT textcontrast; /* not used yet. get/set only */
261 struct list containers;
262 GraphicsContainer contid; /* last-issued container ID */
263 INT origin_x, origin_y;
264 INT gdi_transform_acquire_count, gdi_transform_save;
265 GpMatrix gdi_transform;
266 HRGN gdi_clip;
267 /* For giving the caller an HDC when we technically can't: */
268 HBITMAP temp_hbitmap;
269 int temp_hbitmap_width;
270 int temp_hbitmap_height;
271 BYTE *temp_bits;
272 HDC temp_hdc;
275 struct GpBrush{
276 GpBrushType bt;
279 struct GpHatch{
280 GpBrush brush;
281 GpHatchStyle hatchstyle;
282 ARGB forecol;
283 ARGB backcol;
286 struct GpSolidFill{
287 GpBrush brush;
288 ARGB color;
291 struct GpPathGradient{
292 GpBrush brush;
293 GpPath* path;
294 ARGB centercolor;
295 GpWrapMode wrap;
296 BOOL gamma;
297 GpPointF center;
298 GpPointF focus;
299 REAL* blendfac; /* blend factors */
300 REAL* blendpos; /* blend positions */
301 INT blendcount;
302 ARGB *surroundcolors;
303 INT surroundcolorcount;
304 ARGB* pblendcolor; /* preset blend colors */
305 REAL* pblendpos; /* preset blend positions */
306 INT pblendcount;
307 GpMatrix transform;
310 struct GpLineGradient{
311 GpBrush brush;
312 ARGB startcolor;
313 ARGB endcolor;
314 RectF rect;
315 GpWrapMode wrap;
316 BOOL gamma;
317 REAL* blendfac; /* blend factors */
318 REAL* blendpos; /* blend positions */
319 INT blendcount;
320 ARGB* pblendcolor; /* preset blend colors */
321 REAL* pblendpos; /* preset blend positions */
322 INT pblendcount;
323 GpMatrix transform;
326 struct GpTexture{
327 GpBrush brush;
328 GpMatrix transform;
329 GpImage *image;
330 GpImageAttributes *imageattributes;
331 BYTE *bitmap_bits; /* image bits converted to ARGB and run through imageattributes */
334 struct GpPath{
335 GpFillMode fill;
336 GpPathData pathdata;
337 BOOL newfigure; /* whether the next drawing action starts a new figure */
338 INT datalen; /* size of the arrays in pathdata */
341 struct GpPathIterator{
342 GpPathData pathdata;
343 INT subpath_pos; /* for NextSubpath methods */
344 INT marker_pos; /* for NextMarker methods */
345 INT pathtype_pos; /* for NextPathType methods */
348 struct GpCustomLineCap{
349 CustomLineCapType type;
350 GpPathData pathdata;
351 BOOL fill; /* TRUE for fill, FALSE for stroke */
352 GpLineCap cap; /* as far as I can tell, this value is ignored */
353 REAL inset; /* how much to adjust the end of the line */
354 GpLineJoin join;
355 REAL scale;
358 struct GpAdjustableArrowCap{
359 GpCustomLineCap cap;
360 REAL middle_inset;
361 REAL height;
362 REAL width;
365 struct GpImage{
366 IWICBitmapDecoder *decoder;
367 IWICBitmapEncoder *encoder;
368 ImageType type;
369 GUID format;
370 UINT flags;
371 UINT frame_count, current_frame;
372 ColorPalette *palette;
373 REAL xres, yres;
374 LONG busy;
377 #define EmfPlusObjectTableSize 64
379 typedef enum EmfPlusObjectType
381 ObjectTypeInvalid,
382 ObjectTypeBrush,
383 ObjectTypePen,
384 ObjectTypePath,
385 ObjectTypeRegion,
386 ObjectTypeImage,
387 ObjectTypeFont,
388 ObjectTypeStringFormat,
389 ObjectTypeImageAttributes,
390 ObjectTypeCustomLineCap,
391 ObjectTypeMax = ObjectTypeCustomLineCap,
392 } EmfPlusObjectType;
394 /* Deserialized EmfPlusObject record. */
395 struct emfplus_object {
396 EmfPlusObjectType type;
397 union {
398 GpBrush *brush;
399 GpPen *pen;
400 GpPath *path;
401 GpRegion *region;
402 GpImage *image;
403 GpFont *font;
404 GpImageAttributes *image_attributes;
405 void *object;
406 } u;
409 struct GpMetafile{
410 GpImage image;
411 GpRectF bounds;
412 GpUnit unit;
413 MetafileType metafile_type;
414 HENHMETAFILE hemf;
415 int preserve_hemf; /* if true, hemf belongs to the app and should not be deleted */
417 /* recording */
418 HDC record_dc;
419 GpGraphics *record_graphics;
420 BYTE *comment_data;
421 DWORD comment_data_size;
422 DWORD comment_data_length;
423 IStream *record_stream;
424 BOOL auto_frame; /* If true, determine the frame automatically */
425 GpPointF auto_frame_min, auto_frame_max;
426 DWORD next_object_id;
427 UINT limit_dpi;
428 BOOL printer_display;
429 REAL logical_dpix;
430 REAL logical_dpiy;
432 /* playback */
433 GpGraphics *playback_graphics;
434 HDC playback_dc;
435 GpPointF playback_points[3];
436 GpRectF src_rect;
437 HANDLETABLE *handle_table;
438 int handle_count;
439 GpMatrix *world_transform;
440 GpUnit page_unit;
441 REAL page_scale;
442 GpRegion *base_clip; /* clip region in device space for all metafile output */
443 GpRegion *clip; /* clip region within the metafile */
444 struct list containers;
445 struct emfplus_object objtable[EmfPlusObjectTableSize];
448 struct GpBitmap{
449 GpImage image;
450 INT width;
451 INT height;
452 PixelFormat format;
453 ImageLockMode lockmode;
454 BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */
455 HBITMAP hbitmap;
456 HDC hdc;
457 BYTE *bits; /* actual image bits if this is a DIB */
458 INT stride; /* stride of bits if this is a DIB */
459 BYTE *own_bits; /* image bits that need to be freed with this object */
460 INT lockx, locky; /* X and Y coordinates of the rect when a bitmap is locked for writing. */
461 IWICMetadataReader *metadata_reader; /* NULL if there is no metadata */
462 UINT prop_count;
463 PropertyItem *prop_item; /* cached image properties */
466 struct GpCachedBitmap{
467 GpImage *image;
470 struct color_key{
471 BOOL enabled;
472 ARGB low;
473 ARGB high;
476 struct color_matrix{
477 BOOL enabled;
478 ColorMatrixFlags flags;
479 ColorMatrix colormatrix;
480 ColorMatrix graymatrix;
483 struct color_remap_table{
484 BOOL enabled;
485 INT mapsize;
486 ColorMap *colormap;
489 enum imageattr_noop{
490 IMAGEATTR_NOOP_UNDEFINED,
491 IMAGEATTR_NOOP_SET,
492 IMAGEATTR_NOOP_CLEAR,
495 struct GpImageAttributes{
496 WrapMode wrap;
497 ARGB outside_color;
498 BOOL clamp;
499 struct color_key colorkeys[ColorAdjustTypeCount];
500 struct color_matrix colormatrices[ColorAdjustTypeCount];
501 struct color_remap_table colorremaptables[ColorAdjustTypeCount];
502 BOOL gamma_enabled[ColorAdjustTypeCount];
503 REAL gamma[ColorAdjustTypeCount];
504 enum imageattr_noop noop[ColorAdjustTypeCount];
507 struct GpFont{
508 GpFontFamily *family;
509 OUTLINETEXTMETRICW otm;
510 REAL emSize; /* in font units */
511 Unit unit;
514 extern const struct GpStringFormat default_drawstring_format DECLSPEC_HIDDEN;
516 struct GpStringFormat{
517 INT attr;
518 LANGID lang;
519 LANGID digitlang;
520 StringAlignment align;
521 StringTrimming trimming;
522 HotkeyPrefix hkprefix;
523 StringAlignment line_align;
524 StringDigitSubstitute digitsub;
525 INT tabcount;
526 REAL firsttab;
527 REAL *tabs;
528 CharacterRange *character_ranges;
529 INT range_count;
530 BOOL generic_typographic;
533 extern void init_generic_string_formats(void) DECLSPEC_HIDDEN;
534 extern void free_generic_string_formats(void) DECLSPEC_HIDDEN;
536 struct GpFontCollection{
537 GpFontFamily **FontFamilies;
538 INT count;
539 INT allocated;
542 struct GpFontFamily{
543 WCHAR FamilyName[LF_FACESIZE];
544 UINT16 em_height, ascent, descent, line_spacing; /* in font units */
545 int dpi;
548 /* internal use */
549 typedef enum RegionType
551 RegionDataRect = 0x10000000,
552 RegionDataPath = 0x10000001,
553 RegionDataEmptyRect = 0x10000002,
554 RegionDataInfiniteRect = 0x10000003,
555 } RegionType;
557 struct region_element
559 DWORD type; /* Rectangle, Path, SpecialRectangle, or CombineMode */
560 union
562 GpRectF rect;
563 GpPath *path;
564 struct
566 struct region_element *left; /* the original region */
567 struct region_element *right; /* what *left was combined with */
568 } combine;
569 } elementdata;
572 struct GpRegion{
573 DWORD num_children;
574 region_element node;
577 struct memory_buffer
579 const BYTE *buffer;
580 INT size, pos;
583 static inline void init_memory_buffer(struct memory_buffer *mbuf, const BYTE *buffer, INT size)
585 mbuf->buffer = buffer;
586 mbuf->size = size;
587 mbuf->pos = 0;
590 static inline const void *buffer_read(struct memory_buffer *mbuf, INT size)
592 if (mbuf->size - mbuf->pos >= size)
594 const void *data = mbuf->buffer + mbuf->pos;
595 mbuf->pos += size;
596 return data;
598 return NULL;
601 typedef GpStatus (*gdip_format_string_callback)(HDC hdc,
602 GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
603 GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
604 INT lineno, const RectF *bounds, INT *underlined_indexes,
605 INT underlined_index_count, void *user_data);
607 GpStatus gdip_format_string(HDC hdc,
608 GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
609 GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, int ignore_empty_clip,
610 gdip_format_string_callback callback, void *user_data) DECLSPEC_HIDDEN;
612 void get_log_fontW(const GpFont *, GpGraphics *, LOGFONTW *) DECLSPEC_HIDDEN;
614 static inline BOOL image_lock(GpImage *image, BOOL *unlock)
616 LONG tid = GetCurrentThreadId(), owner_tid;
617 owner_tid = InterlockedCompareExchange(&image->busy, tid, 0);
618 *unlock = !owner_tid;
619 return !owner_tid || owner_tid==tid;
622 static inline void image_unlock(GpImage *image, BOOL unlock)
624 if (unlock) image->busy = 0;
627 static inline void set_rect(GpRectF *rect, REAL x, REAL y, REAL width, REAL height)
629 rect->X = x;
630 rect->Y = y;
631 rect->Width = width;
632 rect->Height = height;
635 #endif