Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / gfx / public / nsIRegion.h
blob74cdbc48960ce36b27b44715ded2463c3cae0a1f
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsIRegion_h___
39 #define nsIRegion_h___
41 #include "nscore.h"
42 #include "nsISupports.h"
43 #include "nsRect.h"
45 enum nsRegionComplexity
47 eRegionComplexity_empty = 0,
48 eRegionComplexity_rect = 1,
49 eRegionComplexity_complex = 2
52 typedef struct
54 PRInt32 x;
55 PRInt32 y;
56 PRUint32 width;
57 PRUint32 height;
58 } nsRegionRect;
60 typedef struct
62 PRUint32 mNumRects; //number of actual rects in the mRects array
63 PRUint32 mRectsLen; //length, in rects, of the mRects array
64 PRUint32 mArea; //area of the covered portion of the region
65 nsRegionRect mRects[1];
66 } nsRegionRectSet;
68 // An implementation of a region primitive that can be used to
69 // represent arbitrary pixel areas. Probably implemented on top
70 // of the native region primitive. The assumption is that, at worst,
71 // it is a rectangle list.
73 #define NS_IREGION_IID \
74 { 0x8ef366e0, 0xee94, 0x11d1, \
75 { 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
77 class nsIRegion : public nsISupports
79 public:
80 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IREGION_IID)
82 virtual nsresult Init(void) = 0;
84 /**
85 * copy operator equivalent that takes another region
87 * @param region to copy
88 * @return void
90 **/
92 virtual void SetTo(const nsIRegion &aRegion) = 0;
94 /**
95 * copy operator equivalent that takes a rect
97 * @param aX xoffset of rect to set region to
98 * @param aY yoffset of rect to set region to
99 * @param aWidth width of rect to set region to
100 * @param aHeight height of rect to set region to
101 * @return void
105 virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
108 * destructively intersect another region with this one
110 * @param region to intersect
111 * @return void
115 virtual void Intersect(const nsIRegion &aRegion) = 0;
118 * destructively intersect a rect with this region
120 * @param aX xoffset of rect to intersect with region
121 * @param aY yoffset of rect to intersect with region
122 * @param aWidth width of rect to intersect with region
123 * @param aHeight height of rect to intersect with region
124 * @return void
128 virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
131 * destructively union another region with this one
133 * @param region to union
134 * @return void
138 virtual void Union(const nsIRegion &aRegion) = 0;
141 * destructively union a rect with this region
143 * @param aX xoffset of rect to union with region
144 * @param aY yoffset of rect to union with region
145 * @param aWidth width of rect to union with region
146 * @param aHeight height of rect to union with region
147 * @return void
151 virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
154 * destructively subtract another region with this one
156 * @param region to subtract
157 * @return void
161 virtual void Subtract(const nsIRegion &aRegion) = 0;
164 * destructively subtract a rect from this region
166 * @param aX xoffset of rect to subtract with region
167 * @param aY yoffset of rect to subtract with region
168 * @param aWidth width of rect to subtract with region
169 * @param aHeight height of rect to subtract with region
170 * @return void
174 virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
177 * is this region empty? i.e. does it contain any pixels
179 * @param none
180 * @return returns whether the region is empty
184 virtual PRBool IsEmpty(void) = 0;
187 * == operator equivalent i.e. do the regions contain exactly
188 * the same pixels
190 * @param region to compare
191 * @return whether the regions are identical
195 virtual PRBool IsEqual(const nsIRegion &aRegion) = 0;
198 * returns the bounding box of the region i.e. the smallest
199 * rectangle that completely contains the region.
201 * @param aX out parameter for xoffset of bounding rect for region
202 * @param aY out parameter for yoffset of bounding rect for region
203 * @param aWidth out parameter for width of bounding rect for region
204 * @param aHeight out parameter for height of bounding rect for region
205 * @return void
208 virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight) = 0;
211 * offsets the region in x and y
213 * @param xoffset pixel offset in x
214 * @param yoffset pixel offset in y
215 * @return void
218 virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset) = 0;
221 * does the region intersect the rectangle?
223 * @param rect to check for containment
224 * @return true if the region intersects the rect
228 virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
231 * get the set of rects which make up this region. the aRects
232 * parameter must be freed by calling FreeRects before the region
233 * is deleted. aRects may be passed in again when requesting
234 * the rect list as a recycling method.
236 * @param aRects out parameter containing set of rects
237 * comprising the region
238 * @return error status
241 NS_IMETHOD GetRects(nsRegionRectSet **aRects) = 0;
244 * Free a rect set returned by GetRects.
246 * @param aRects rects to free
247 * @return error status
250 NS_IMETHOD FreeRects(nsRegionRectSet *aRects) = 0;
253 * Get the native region that this nsIRegion represents.
254 * @param aRegion out parameter for native region handle
255 * @return error status
257 NS_IMETHOD GetNativeRegion(void *&aRegion) const = 0;
260 * Get the complexity of the region as defined by the
261 * nsRegionComplexity enum.
262 * @param aComplexity out parameter for region complexity
263 * @return error status
265 NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const = 0;
268 * get the number of rects which make up this region.
270 * @param aRects out parameter containing the number of rects
271 * comprising the region
272 * @return error status
275 NS_IMETHOD GetNumRects(PRUint32 *aRects) const = 0;
278 NS_DEFINE_STATIC_IID_ACCESSOR(nsIRegion, NS_IREGION_IID)
280 #endif // nsIRegion_h___