gdiplus/metafile: Implement EmfPlusRegion deserialization.
[wine.git] / dlls / gdiplus / gdiplus_private.h
blobca2c022d9378ca44f12e6ad4ce2490b796f33b7c
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/list.h"
35 #include "gdiplus.h"
37 #define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
38 #define MAX_ARC_PTS (13)
39 #define MAX_DASHLEN (16) /* this is a limitation of gdi */
40 #define INCH_HIMETRIC (2540)
42 #define VERSION_MAGIC 0xdbc01001
43 #define VERSION_MAGIC2 0xdbc01002
44 #define VALID_MAGIC(x) (((x) & 0xfffff000) == 0xdbc01000)
45 #define TENSION_CONST (0.3)
47 #define GIF_DISPOSE_UNSPECIFIED 0
48 #define GIF_DISPOSE_DO_NOT_DISPOSE 1
49 #define GIF_DISPOSE_RESTORE_TO_BKGND 2
50 #define GIF_DISPOSE_RESTORE_TO_PREV 3
52 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
54 return HeapAlloc(GetProcessHeap(), 0, size);
57 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size)
59 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
62 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size)
64 return HeapReAlloc(GetProcessHeap(), 0, mem, size);
67 static inline BOOL heap_free(void *mem)
69 return HeapFree(GetProcessHeap(), 0, mem);
72 COLORREF ARGB2COLORREF(ARGB color) DECLSPEC_HIDDEN;
73 HBITMAP ARGB2BMP(ARGB color) DECLSPEC_HIDDEN;
74 extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
75 REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN;
76 extern REAL gdiplus_atan2(REAL dy, REAL dx) DECLSPEC_HIDDEN;
77 extern GpStatus hresult_to_status(HRESULT res) DECLSPEC_HIDDEN;
78 extern REAL units_to_pixels(REAL units, GpUnit unit, REAL dpi) DECLSPEC_HIDDEN;
79 extern REAL pixels_to_units(REAL pixels, GpUnit unit, REAL dpi) DECLSPEC_HIDDEN;
80 extern REAL units_scale(GpUnit from, GpUnit to, REAL dpi) DECLSPEC_HIDDEN;
82 #define WineCoordinateSpaceGdiDevice ((GpCoordinateSpace)4)
84 extern GpStatus gdi_transform_acquire(GpGraphics *graphics);
85 extern GpStatus gdi_transform_release(GpGraphics *graphics);
86 extern GpStatus get_graphics_transform(GpGraphics *graphics, GpCoordinateSpace dst_space,
87 GpCoordinateSpace src_space, GpMatrix *matrix) DECLSPEC_HIDDEN;
88 extern GpStatus gdip_transform_points(GpGraphics *graphics, GpCoordinateSpace dst_space,
89 GpCoordinateSpace src_space, GpPointF *points, INT count) DECLSPEC_HIDDEN;
91 extern GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics) DECLSPEC_HIDDEN;
92 extern GpStatus encode_image_png(GpImage *image, IStream* stream, GDIPCONST EncoderParameters* params) DECLSPEC_HIDDEN;
94 extern GpStatus METAFILE_GetGraphicsContext(GpMetafile* metafile, GpGraphics **result) DECLSPEC_HIDDEN;
95 extern GpStatus METAFILE_GetDC(GpMetafile* metafile, HDC *hdc) DECLSPEC_HIDDEN;
96 extern GpStatus METAFILE_ReleaseDC(GpMetafile* metafile, HDC hdc) DECLSPEC_HIDDEN;
97 extern GpStatus METAFILE_GraphicsClear(GpMetafile* metafile, ARGB color) DECLSPEC_HIDDEN;
98 extern GpStatus METAFILE_FillRectangles(GpMetafile* metafile, GpBrush* brush,
99 GDIPCONST GpRectF* rects, INT count) DECLSPEC_HIDDEN;
100 extern GpStatus METAFILE_SetClipRect(GpMetafile* metafile,
101 REAL x, REAL y, REAL width, REAL height, CombineMode mode) DECLSPEC_HIDDEN;
102 extern GpStatus METAFILE_SetClipRegion(GpMetafile* metafile, GpRegion* region, CombineMode mode) DECLSPEC_HIDDEN;
103 extern GpStatus METAFILE_SetPageTransform(GpMetafile* metafile, GpUnit unit, REAL scale) DECLSPEC_HIDDEN;
104 extern GpStatus METAFILE_SetWorldTransform(GpMetafile* metafile, GDIPCONST GpMatrix* transform) DECLSPEC_HIDDEN;
105 extern GpStatus METAFILE_ScaleWorldTransform(GpMetafile* metafile, REAL sx, REAL sy, MatrixOrder order) DECLSPEC_HIDDEN;
106 extern GpStatus METAFILE_MultiplyWorldTransform(GpMetafile* metafile, GDIPCONST GpMatrix* matrix, MatrixOrder order) DECLSPEC_HIDDEN;
107 extern GpStatus METAFILE_RotateWorldTransform(GpMetafile* metafile, REAL angle, MatrixOrder order) DECLSPEC_HIDDEN;
108 extern GpStatus METAFILE_TranslateWorldTransform(GpMetafile* metafile, REAL dx, REAL dy, MatrixOrder order) DECLSPEC_HIDDEN;
109 extern GpStatus METAFILE_ResetWorldTransform(GpMetafile* metafile) DECLSPEC_HIDDEN;
110 extern GpStatus METAFILE_BeginContainer(GpMetafile* metafile, GDIPCONST GpRectF *dstrect,
111 GDIPCONST GpRectF *srcrect, GpUnit unit, DWORD StackIndex) DECLSPEC_HIDDEN;
112 extern GpStatus METAFILE_BeginContainerNoParams(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN;
113 extern GpStatus METAFILE_EndContainer(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN;
114 extern GpStatus METAFILE_SaveGraphics(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN;
115 extern GpStatus METAFILE_RestoreGraphics(GpMetafile* metafile, DWORD StackIndex) DECLSPEC_HIDDEN;
116 extern GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile) DECLSPEC_HIDDEN;
117 extern GpStatus METAFILE_DrawImagePointsRect(GpMetafile* metafile, GpImage *image,
118 GDIPCONST GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth,
119 REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes* imageAttributes,
120 DrawImageAbort callback, VOID *callbackData) DECLSPEC_HIDDEN;
121 extern GpStatus METAFILE_AddSimpleProperty(GpMetafile *metafile, SHORT prop, SHORT val) DECLSPEC_HIDDEN;
122 extern GpStatus METAFILE_DrawPath(GpMetafile *metafile, GpPen *pen, GpPath *path) DECLSPEC_HIDDEN;
123 extern GpStatus METAFILE_FillPath(GpMetafile *metafile, GpBrush *brush, GpPath *path) DECLSPEC_HIDDEN;
124 extern void METAFILE_Free(GpMetafile *metafile) DECLSPEC_HIDDEN;
126 extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1,
127 REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN;
128 extern void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
129 REAL tension, REAL *x, REAL *y) DECLSPEC_HIDDEN;
131 extern void free_installed_fonts(void) DECLSPEC_HIDDEN;
133 extern BOOL lengthen_path(GpPath *path, INT len) DECLSPEC_HIDDEN;
135 extern DWORD write_region_data(const GpRegion *region, void *data) DECLSPEC_HIDDEN;
136 extern DWORD write_path_data(GpPath *path, void *data) DECLSPEC_HIDDEN;
138 extern GpStatus trace_path(GpGraphics *graphics, GpPath *path) DECLSPEC_HIDDEN;
140 typedef struct region_element region_element;
141 extern void delete_element(region_element *element) DECLSPEC_HIDDEN;
143 extern GpStatus get_hatch_data(GpHatchStyle hatchstyle, const char **result) DECLSPEC_HIDDEN;
145 static inline INT gdip_round(REAL x)
147 return (INT) floorf(x + 0.5);
150 static inline INT ceilr(REAL x)
152 return (INT) ceilf(x);
155 static inline REAL deg2rad(REAL degrees)
157 return M_PI * degrees / 180.0;
160 static inline ARGB color_over(ARGB bg, ARGB fg)
162 BYTE b, g, r, a;
163 BYTE bg_alpha, fg_alpha;
165 fg_alpha = (fg>>24)&0xff;
167 if (fg_alpha == 0xff) return fg;
169 if (fg_alpha == 0) return bg;
171 bg_alpha = (((bg>>24)&0xff) * (0xff-fg_alpha)) / 0xff;
173 if (bg_alpha == 0) return fg;
175 a = bg_alpha + fg_alpha;
176 b = ((bg&0xff)*bg_alpha + (fg&0xff)*fg_alpha)/a;
177 g = (((bg>>8)&0xff)*bg_alpha + ((fg>>8)&0xff)*fg_alpha)/a;
178 r = (((bg>>16)&0xff)*bg_alpha + ((fg>>16)&0xff)*fg_alpha)/a;
180 return (a<<24)|(r<<16)|(g<<8)|b;
183 /* fg is premult, bg and return value are not */
184 static inline ARGB color_over_fgpremult(ARGB bg, ARGB fg)
186 BYTE b, g, r, a;
187 BYTE bg_alpha, fg_alpha;
189 fg_alpha = (fg>>24)&0xff;
191 if (fg_alpha == 0) return bg;
193 bg_alpha = (((bg>>24)&0xff) * (0xff-fg_alpha)) / 0xff;
195 a = bg_alpha + fg_alpha;
196 b = ((bg&0xff)*bg_alpha + (fg&0xff)*0xff)/a;
197 g = (((bg>>8)&0xff)*bg_alpha + ((fg>>8)&0xff)*0xff)/a;
198 r = (((bg>>16)&0xff)*bg_alpha + ((fg>>16)&0xff)*0xff)/a;
200 return (a<<24)|(r<<16)|(g<<8)|b;
203 extern const char *debugstr_rectf(const RectF* rc) DECLSPEC_HIDDEN;
205 extern const char *debugstr_pointf(const PointF* pt) DECLSPEC_HIDDEN;
207 extern void convert_32bppARGB_to_32bppPARGB(UINT width, UINT height,
208 BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride) DECLSPEC_HIDDEN;
210 extern GpStatus convert_pixels(INT width, INT height,
211 INT dst_stride, BYTE *dst_bits, PixelFormat dst_format,
212 INT src_stride, const BYTE *src_bits, PixelFormat src_format, ColorPalette *palette) DECLSPEC_HIDDEN;
214 extern PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE data,
215 UINT width, UINT height, INT stride, ColorAdjustType type, PixelFormat fmt) DECLSPEC_HIDDEN;
217 struct GpMatrix{
218 REAL matrix[6];
221 struct GpPen{
222 UINT style;
223 GpUnit unit;
224 REAL width;
225 GpLineCap endcap;
226 GpLineCap startcap;
227 GpDashCap dashcap;
228 GpCustomLineCap *customstart;
229 GpCustomLineCap *customend;
230 GpLineJoin join;
231 REAL miterlimit;
232 GpDashStyle dash;
233 REAL *dashes;
234 INT numdashes;
235 REAL offset; /* dash offset */
236 GpBrush *brush;
237 GpPenAlignment align;
238 GpMatrix transform;
241 struct GpGraphics{
242 HDC hdc;
243 HWND hwnd;
244 BOOL owndc;
245 BOOL alpha_hdc;
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 GpPointF startpoint;
313 GpPointF endpoint;
314 ARGB startcolor;
315 ARGB endcolor;
316 RectF rect;
317 GpWrapMode wrap;
318 BOOL gamma;
319 REAL* blendfac; /* blend factors */
320 REAL* blendpos; /* blend positions */
321 INT blendcount;
322 ARGB* pblendcolor; /* preset blend colors */
323 REAL* pblendpos; /* preset blend positions */
324 INT pblendcount;
325 GpMatrix transform;
328 struct GpTexture{
329 GpBrush brush;
330 GpMatrix transform;
331 GpImage *image;
332 GpImageAttributes *imageattributes;
333 BYTE *bitmap_bits; /* image bits converted to ARGB and run through imageattributes */
336 struct GpPath{
337 GpFillMode fill;
338 GpPathData pathdata;
339 BOOL newfigure; /* whether the next drawing action starts a new figure */
340 INT datalen; /* size of the arrays in pathdata */
343 struct GpPathIterator{
344 GpPathData pathdata;
345 INT subpath_pos; /* for NextSubpath methods */
346 INT marker_pos; /* for NextMarker methods */
347 INT pathtype_pos; /* for NextPathType methods */
350 struct GpCustomLineCap{
351 CustomLineCapType type;
352 GpPathData pathdata;
353 BOOL fill; /* TRUE for fill, FALSE for stroke */
354 GpLineCap cap; /* as far as I can tell, this value is ignored */
355 REAL inset; /* how much to adjust the end of the line */
356 GpLineJoin join;
357 REAL scale;
360 struct GpAdjustableArrowCap{
361 GpCustomLineCap cap;
364 struct GpImage{
365 IWICBitmapDecoder *decoder;
366 ImageType type;
367 GUID format;
368 UINT flags;
369 UINT frame_count, current_frame;
370 ColorPalette *palette;
371 REAL xres, yres;
372 LONG busy;
375 #define EmfPlusObjectTableSize 64
377 typedef enum EmfPlusObjectType
379 ObjectTypeInvalid,
380 ObjectTypeBrush,
381 ObjectTypePen,
382 ObjectTypePath,
383 ObjectTypeRegion,
384 ObjectTypeImage,
385 ObjectTypeFont,
386 ObjectTypeStringFormat,
387 ObjectTypeImageAttributes,
388 ObjectTypeCustomLineCap,
389 ObjectTypeMax = ObjectTypeCustomLineCap,
390 } EmfPlusObjectType;
392 /* Deserialized EmfPlusObject record. */
393 struct emfplus_object {
394 EmfPlusObjectType type;
395 union {
396 GpBrush *brush;
397 GpPen *pen;
398 GpPath *path;
399 GpRegion *region;
400 GpImage *image;
401 GpFont *font;
402 GpImageAttributes *image_attributes;
403 void *object;
404 } u;
407 struct GpMetafile{
408 GpImage image;
409 GpRectF bounds;
410 GpUnit unit;
411 MetafileType metafile_type;
412 HENHMETAFILE hemf;
413 int preserve_hemf; /* if true, hemf belongs to the app and should not be deleted */
415 /* recording */
416 HDC record_dc;
417 GpGraphics *record_graphics;
418 BYTE *comment_data;
419 DWORD comment_data_size;
420 DWORD comment_data_length;
421 IStream *record_stream;
422 BOOL auto_frame; /* If true, determine the frame automatically */
423 GpPointF auto_frame_min, auto_frame_max;
424 DWORD next_object_id;
426 /* playback */
427 GpGraphics *playback_graphics;
428 HDC playback_dc;
429 GpPointF playback_points[3];
430 GpRectF src_rect;
431 HANDLETABLE *handle_table;
432 int handle_count;
433 XFORM gdiworldtransform;
434 GpMatrix *world_transform;
435 GpUnit page_unit;
436 REAL page_scale;
437 GpRegion *base_clip; /* clip region in device space for all metafile output */
438 GpRegion *clip; /* clip region within the metafile */
439 struct list containers;
440 struct emfplus_object objtable[EmfPlusObjectTableSize];
443 struct GpBitmap{
444 GpImage image;
445 INT width;
446 INT height;
447 PixelFormat format;
448 ImageLockMode lockmode;
449 BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */
450 HBITMAP hbitmap;
451 HDC hdc;
452 BYTE *bits; /* actual image bits if this is a DIB */
453 INT stride; /* stride of bits if this is a DIB */
454 BYTE *own_bits; /* image bits that need to be freed with this object */
455 INT lockx, locky; /* X and Y coordinates of the rect when a bitmap is locked for writing. */
456 IWICMetadataReader *metadata_reader; /* NULL if there is no metadata */
457 UINT prop_count;
458 PropertyItem *prop_item; /* cached image properties */
461 struct GpCachedBitmap{
462 GpImage *image;
465 struct color_key{
466 BOOL enabled;
467 ARGB low;
468 ARGB high;
471 struct color_matrix{
472 BOOL enabled;
473 ColorMatrixFlags flags;
474 ColorMatrix colormatrix;
475 ColorMatrix graymatrix;
478 struct color_remap_table{
479 BOOL enabled;
480 INT mapsize;
481 ColorMap *colormap;
484 struct GpImageAttributes{
485 WrapMode wrap;
486 ARGB outside_color;
487 BOOL clamp;
488 struct color_key colorkeys[ColorAdjustTypeCount];
489 struct color_matrix colormatrices[ColorAdjustTypeCount];
490 struct color_remap_table colorremaptables[ColorAdjustTypeCount];
491 BOOL gamma_enabled[ColorAdjustTypeCount];
492 REAL gamma[ColorAdjustTypeCount];
495 struct GpFont{
496 GpFontFamily *family;
497 OUTLINETEXTMETRICW otm;
498 REAL emSize; /* in font units */
499 Unit unit;
502 extern const struct GpStringFormat default_drawstring_format DECLSPEC_HIDDEN;
504 struct GpStringFormat{
505 INT attr;
506 LANGID lang;
507 LANGID digitlang;
508 StringAlignment align;
509 StringTrimming trimming;
510 HotkeyPrefix hkprefix;
511 StringAlignment line_align;
512 StringDigitSubstitute digitsub;
513 INT tabcount;
514 REAL firsttab;
515 REAL *tabs;
516 CharacterRange *character_ranges;
517 INT range_count;
518 BOOL generic_typographic;
521 extern void init_generic_string_formats(void) DECLSPEC_HIDDEN;
522 extern void free_generic_string_formats(void) DECLSPEC_HIDDEN;
524 struct GpFontCollection{
525 GpFontFamily **FontFamilies;
526 INT count;
527 INT allocated;
530 struct GpFontFamily{
531 WCHAR FamilyName[LF_FACESIZE];
532 UINT16 em_height, ascent, descent, line_spacing; /* in font units */
533 int dpi;
536 /* internal use */
537 typedef enum RegionType
539 RegionDataRect = 0x10000000,
540 RegionDataPath = 0x10000001,
541 RegionDataEmptyRect = 0x10000002,
542 RegionDataInfiniteRect = 0x10000003,
543 } RegionType;
545 struct region_element
547 DWORD type; /* Rectangle, Path, SpecialRectangle, or CombineMode */
548 union
550 GpRectF rect;
551 GpPath *path;
552 struct
554 struct region_element *left; /* the original region */
555 struct region_element *right; /* what *left was combined with */
556 } combine;
557 } elementdata;
560 struct GpRegion{
561 DWORD num_children;
562 region_element node;
565 struct memory_buffer
567 const BYTE *buffer;
568 INT size, pos;
571 static inline void init_memory_buffer(struct memory_buffer *mbuf, const BYTE *buffer, INT size)
573 mbuf->buffer = buffer;
574 mbuf->size = size;
575 mbuf->pos = 0;
578 static inline const void *buffer_read(struct memory_buffer *mbuf, INT size)
580 if (mbuf->size - mbuf->pos >= size)
582 const void *data = mbuf->buffer + mbuf->pos;
583 mbuf->pos += size;
584 return data;
586 return NULL;
589 typedef GpStatus (*gdip_format_string_callback)(HDC hdc,
590 GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
591 GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
592 INT lineno, const RectF *bounds, INT *underlined_indexes,
593 INT underlined_index_count, void *user_data);
595 GpStatus gdip_format_string(HDC hdc,
596 GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
597 GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, int ignore_empty_clip,
598 gdip_format_string_callback callback, void *user_data) DECLSPEC_HIDDEN;
600 void get_log_fontW(const GpFont *, GpGraphics *, LOGFONTW *) DECLSPEC_HIDDEN;
602 static inline BOOL image_lock(GpImage *image, BOOL *unlock)
604 LONG tid = GetCurrentThreadId(), owner_tid;
605 owner_tid = InterlockedCompareExchange(&image->busy, tid, 0);
606 *unlock = !owner_tid;
607 return !owner_tid || owner_tid==tid;
610 static inline void image_unlock(GpImage *image, BOOL unlock)
612 if (unlock) image->busy = 0;
615 #endif