Add copy of .ttf font with .eot extension for testing
[wine-gecko.git] / gfx / public / nsIImage.h
blob0c7d992def27032148ebbcc781ae53a092190045
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 nsIImage_h___
39 #define nsIImage_h___
41 #include "nsISupports.h"
42 #include "nsMargin.h"
43 #include "nsRect.h"
45 class gfxASurface;
46 class gfxPattern;
47 class gfxMatrix;
48 class gfxRect;
49 class gfxContext;
51 class nsIDeviceContext;
53 struct nsColorMap
55 //I lifted this from the image lib. The difference is that
56 //this uses nscolor instead of NI_RGB. Multiple color pollution
57 //is a bad thing. MMP
58 PRInt32 NumColors; // Number of colors in the colormap.
59 // A negative value can be used to denote a
60 // possibly non-unique set.
61 //nscolor *Map; // Colormap colors.
62 PRUint8 *Index; // NULL, if map is in index order, otherwise
63 // specifies the indices of the map entries. */
66 typedef enum {
67 nsMaskRequirements_kNoMask,
68 nsMaskRequirements_kNeeds1Bit,
69 nsMaskRequirements_kNeeds8Bit
70 } nsMaskRequirements;
73 #define nsImageUpdateFlags_kColorMapChanged 0x1
74 #define nsImageUpdateFlags_kBitsChanged 0x2
76 // IID for the nsIImage interface
77 // 455fc276-01de-488f-9f8f-19b85a6b112d
78 #define NS_IIMAGE_IID \
79 { 0x455fc276, 0x01de, 0x488f, \
80 { 0x9f, 0x8f, 0x19, 0xb8, 0x5a, 0x6b, 0x11, 0x2d } }
82 // Interface to Images
83 class nsIImage : public nsISupports
86 public:
87 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIMAGE_IID)
89 /**
90 * Build and initialize the nsIImage
91 * @param aWidth The width in pixels of the desired pixelmap
92 * @param aHeight The height in pixels of the desired pixelmap
93 * @param aDepth The number of bits per pixel for the pixelmap
94 * @param aMaskRequirements A flag indicating if a alpha mask should be allocated
96 virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements) = 0;
98 /**
99 * Get the number of bytes per pixel for this image
100 * @update - dwc 2/3/99
101 * @return - the number of bytes per pixel
103 virtual PRInt32 GetBytesPix() = 0;
106 * Get whether rows are organized top to bottom, or bottom to top
107 * @update - syd 3/29/99
108 * @return PR_TRUE if top to bottom, else PR_FALSE
110 virtual PRBool GetIsRowOrderTopToBottom() = 0;
113 * Get the width for the pixelmap
114 * @update - dwc 2/1/99
115 * @return The width in pixels for the pixelmap
117 virtual PRInt32 GetWidth() = 0;
120 * Get the height for the pixelmap
121 * @update - dwc 2/1/99
122 * @return The height in pixels for the pixelmap
124 virtual PRInt32 GetHeight() = 0;
127 * Get a pointer to the bits for the pixelmap, only if it is not optimized
128 * @update - dwc 2/1/99
129 * @return address of the DIB pixel array
131 virtual PRUint8 * GetBits() = 0;
134 * Get the number of bytes needed to get to the next scanline for the pixelmap
135 * @update - dwc 2/1/99
136 * @return The number of bytes in each scanline
138 virtual PRInt32 GetLineStride() = 0;
141 * Get whether this image has an alpha mask. Preferable to testing
142 * if GetAlphaBits() is non-null.
143 * @update - sfraser 10/19/99
144 * @return PR_TRUE if the image has an alpha mask, PR_FALSE otherwise
146 virtual PRBool GetHasAlphaMask() = 0;
149 * Get a pointer to the bits for the alpha mask
150 * @update - dwc 2/1/99
151 * @return address of the alpha mask pixel array
153 virtual PRUint8 * GetAlphaBits() = 0;
156 * Get the number of bytes per scanline for the alpha mask
157 * @update - dwc 2/1/99
158 * @return The number of bytes in each scanline
160 virtual PRInt32 GetAlphaLineStride() = 0;
163 * Update the nsIImage color table
164 * @update - dougt 9/9/08
165 * @param aFlags Used to pass in parameters for the update
166 * @param aUpdateRect The rectangle to update
167 * @return success code. failure means stop decoding
169 virtual nsresult ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsIntRect *aUpdateRect) = 0;
172 * Get whether this image's region is completely filled with data.
173 * @return PR_TRUE if image is complete, PR_FALSE if image is not yet
174 * complete or broken
176 virtual PRBool GetIsImageComplete() = 0;
179 * Converted this pixelmap to an optimized pixelmap for the device
180 * @update - dwc 2/1/99
181 * @param aContext The device to optimize for
182 * @return the result of the operation, if NS_OK, then the pixelmap is optimized
184 virtual nsresult Optimize(nsIDeviceContext* aContext) = 0;
187 * Get the colormap for the nsIImage
188 * @update - dwc 2/1/99
189 * @return if non null, the colormap for the pixelmap,otherwise the image is not color mapped
191 virtual nsColorMap * GetColorMap() = 0;
194 * BitBlit the nsIImage to a device, the source and dest can be scaled.
195 * @param aContext the destination
196 * @param aUserSpaceToImageSpace the transform that maps user-space
197 * coordinates to coordinates in (tiled, post-padding) image pixels
198 * @param aFill the area to fill with tiled images
199 * @param aPadding the padding to be added to this image before tiling,
200 * in image pixels
201 * @param aSubimage the subimage in padded+tiled image space that we're
202 * extracting the contents from. Pixels outside this rectangle must not
203 * be sampled.
205 * So this is supposed to
206 * -- add aPadding transparent pixels around the image
207 * -- use that image to tile the plane
208 * -- replace everything outside the aSubimage region with the nearest
209 * border pixel of that region (like EXTEND_PAD)
210 * -- fill aFill with the image, using aImageSpaceToDeviceSpace as the
211 * image-space-to-device-space transform
213 virtual void Draw(gfxContext* aContext,
214 const gfxMatrix& aUserSpaceToImageSpace,
215 const gfxRect& aFill,
216 const nsIntMargin& aPadding,
217 const nsIntRect& aSubimage) = 0;
219 /**
220 * Get the alpha depth for the image mask
221 * @update - lordpixel 2001/05/16
222 * @return the alpha mask depth for the image, ie, 0, 1 or 8
224 virtual PRInt8 GetAlphaDepth() = 0;
227 * Return information about the bits for this structure
228 * @update - dwc 2/1/99
229 * @return a bitmap info structure for the Device Dependent Bits
231 virtual void* GetBitInfo() = 0;
235 * LockImagePixels
236 * Lock the image pixels so that we can access them directly,
237 * with safety. May be a noop on some platforms.
239 * If you want to be able to call GetSurface(), wrap the call in
240 * LockImagePixels()/UnlockImagePixels(). This also allows you to write to
241 * the surface returned by GetSurface().
243 * aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image
245 * Must be balanced by a call to UnlockImagePixels().
247 * @update - sfraser 10/18/99
248 * @return error result
250 NS_IMETHOD LockImagePixels(PRBool aMaskPixels) = 0;
253 * UnlockImagePixels
254 * Unlock the image pixels. May be a noop on some platforms.
256 * Should balance an earlier call to LockImagePixels().
258 * aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image
260 * @update - sfraser 10/18/99
261 * @return error result
263 NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels) = 0;
266 * GetSurface
267 * Return the Thebes gfxASurface in aSurface, if there is one. Should be
268 * wrapped by LockImagePixels()/UnlockImagePixels().
270 * aSurface will be AddRef'd (as with most getters), so
271 * getter_AddRefs should be used.
273 NS_IMETHOD GetSurface(gfxASurface **aSurface) = 0;
276 * GetSurface
277 * Return the Thebes gfxPattern in aPattern. It is always possible to get a
278 * gfxPattern (unlike the gfxASurface from GetSurface()).
280 * aPattern will be AddRef'd (as with most getters), so
281 * getter_AddRefs should be used.
283 NS_IMETHOD GetPattern(gfxPattern **aPattern) = 0;
286 * SetHasNoAlpha
288 * Hint to the image that all the pixels are fully opaque, even if
289 * the original format requested a 1-bit or 8-bit alpha mask
291 virtual void SetHasNoAlpha() = 0;
294 NS_DEFINE_STATIC_IID_ACCESSOR(nsIImage, NS_IIMAGE_IID)
296 #endif