1 /* libwmf ("player/clip.h"): library for wmf conversion
2    Copyright (C) 2000 - various; see CREDITS, ChangeLog, and sources
3 
4    The libwmf Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8 
9    The libwmf 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    Library General Public License for more details.
13 
14    You should have received a copy of the GNU Library General Public
15    License along with the libwmf Library; see the file COPYING.  If not,
16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17    Boston, MA 02111-1307, USA.  */
18 
19 
20 #ifndef WMFPLAYER_CLIP_H
21 #define WMFPLAYER_CLIP_H
22 
Clipping(wmfAPI * API,wmfRegion * clip,wmfRegion * vis,wmfD_Rect * rect,U16 flags)23 static void Clipping (wmfAPI* API,wmfRegion* clip,wmfRegion* vis,wmfD_Rect* rect,U16 flags)
24 {	wmfRegion rgn;
25 
26 	rgn.rects = 0;
27 
28 	if (clip->numRects == 0)
29 	{	if (clip->rects)
30 		{	rgn.rects = clip->rects;
31 			rgn.size = clip->size;
32 
33 			clip->rects = 0;
34 			clip->size = 0;
35 		}
36 	}
37 
38 	if (rgn.rects == 0)
39 	{	rgn.rects = (wmfD_Rect*) wmf_malloc (API,8 * sizeof (wmfD_Rect));
40 		rgn.size = 8;
41 
42 		if (ERR (API))
43 		{	WMF_DEBUG (API,"bailing...");
44 			return;
45 		}
46 	}
47 
48 	WmfSetRectRgn (&rgn,rect);
49 
50 	if ((clip->numRects == 0) && (flags & CLIP_INTERSECT))
51 	{	(*clip) = rgn;
52 		return;
53 	}
54 /* else if (flags & CLIP_EXCLUDE) ...
55  */
56 	if (clip->numRects == 0)
57 	{	if (clip->rects == 0)
58 		{	clip->rects = (wmfD_Rect*) wmf_malloc (API,8 * sizeof (wmfD_Rect));
59 			clip->size = 8;
60 
61 			if (ERR (API))
62 			{	WMF_DEBUG (API,"bailing...");
63 				return;
64 			}
65 		}
66 
67 		WmfSetRectRgn (clip,0);
68 		WmfCombineRgn (API,clip,vis,0,RGN_COPY);
69 
70 		if (ERR (API))
71 		{	WMF_DEBUG (API,"bailing...");
72 			return;
73 		}
74 	}
75 
76 	WmfCombineRgn (API,&rgn,clip,&rgn,(U16)((flags & CLIP_EXCLUDE) ? RGN_DIFF : RGN_AND));
77 
78 	if (ERR (API))
79 	{	WMF_DEBUG (API,"bailing...");
80 		return;
81 	}
82 
83 	(*clip) = rgn; /* What about what *was* in clip ?? Check WmfCombineRgn */
84 }
85 
86 #endif /* ! WMFPLAYER_CLIP_H */
87