Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /** -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | %{C++ |
michael@0 | 10 | #include "gfxImageSurface.h" |
michael@0 | 11 | #include "gfxContext.h" |
michael@0 | 12 | #include "gfxMatrix.h" |
michael@0 | 13 | #include "gfxRect.h" |
michael@0 | 14 | #include "GraphicsFilter.h" |
michael@0 | 15 | #include "gfxASurface.h" |
michael@0 | 16 | #include "mozilla/gfx/2D.h" |
michael@0 | 17 | #include "mozilla/RefPtr.h" |
michael@0 | 18 | #include "nsRect.h" |
michael@0 | 19 | #include "nsSize.h" |
michael@0 | 20 | #include "limits.h" |
michael@0 | 21 | |
michael@0 | 22 | namespace mozilla { |
michael@0 | 23 | namespace layers { |
michael@0 | 24 | class LayerManager; |
michael@0 | 25 | class ImageContainer; |
michael@0 | 26 | } |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | class nsIFrame; |
michael@0 | 30 | |
michael@0 | 31 | namespace mozilla { |
michael@0 | 32 | class TimeStamp; |
michael@0 | 33 | class SVGImageContext; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | namespace mozilla { |
michael@0 | 37 | namespace image { |
michael@0 | 38 | class Orientation; |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | %} |
michael@0 | 43 | |
michael@0 | 44 | [ptr] native gfxImageSurface(gfxImageSurface); |
michael@0 | 45 | [ptr] native gfxASurface(gfxASurface); |
michael@0 | 46 | native gfxImageFormat(gfxASurface::gfxImageFormat); |
michael@0 | 47 | [ptr] native gfxContext(gfxContext); |
michael@0 | 48 | [ref] native gfxMatrix(gfxMatrix); |
michael@0 | 49 | [ref] native gfxRect(gfxRect); |
michael@0 | 50 | native gfxGraphicsFilter(GraphicsFilter); |
michael@0 | 51 | [ref] native nsIntRect(nsIntRect); |
michael@0 | 52 | [ref] native nsIntSize(nsIntSize); |
michael@0 | 53 | native nsSize(nsSize); |
michael@0 | 54 | [ptr] native nsIFrame(nsIFrame); |
michael@0 | 55 | [ptr] native ImageContainer(mozilla::layers::ImageContainer); |
michael@0 | 56 | [ptr] native LayerManager(mozilla::layers::LayerManager); |
michael@0 | 57 | native Orientation(mozilla::image::Orientation); |
michael@0 | 58 | [ref] native TimeStamp(mozilla::TimeStamp); |
michael@0 | 59 | [ptr] native SVGImageContext(mozilla::SVGImageContext); |
michael@0 | 60 | native TempRefSourceSurface(mozilla::TemporaryRef<mozilla::gfx::SourceSurface>); |
michael@0 | 61 | |
michael@0 | 62 | |
michael@0 | 63 | /** |
michael@0 | 64 | * imgIContainer is the interface that represents an image. It allows |
michael@0 | 65 | * access to frames as Thebes surfaces. It also allows drawing of images |
michael@0 | 66 | * onto Thebes contexts. |
michael@0 | 67 | * |
michael@0 | 68 | * Internally, imgIContainer also manages animation of images. |
michael@0 | 69 | */ |
michael@0 | 70 | [scriptable, builtinclass, uuid(503a830c-734d-4362-91f6-73f83ac59646)] |
michael@0 | 71 | interface imgIContainer : nsISupports |
michael@0 | 72 | { |
michael@0 | 73 | /** |
michael@0 | 74 | * The width of the container rectangle. In the case of any error, |
michael@0 | 75 | * zero is returned, and an exception will be thrown. |
michael@0 | 76 | */ |
michael@0 | 77 | readonly attribute int32_t width; |
michael@0 | 78 | |
michael@0 | 79 | /** |
michael@0 | 80 | * The height of the container rectangle. In the case of any error, |
michael@0 | 81 | * zero is returned, and an exception will be thrown. |
michael@0 | 82 | */ |
michael@0 | 83 | readonly attribute int32_t height; |
michael@0 | 84 | |
michael@0 | 85 | /** |
michael@0 | 86 | * The intrinsic size of this image in appunits. If the image has no intrinsic |
michael@0 | 87 | * size in a dimension, -1 will be returned for that dimension. In the case of |
michael@0 | 88 | * any error, an exception will be thrown. |
michael@0 | 89 | */ |
michael@0 | 90 | [noscript] readonly attribute nsSize intrinsicSize; |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * The (dimensionless) intrinsic ratio of this image. In the case of any error, |
michael@0 | 94 | * an exception will be thrown. |
michael@0 | 95 | */ |
michael@0 | 96 | [noscript] readonly attribute nsSize intrinsicRatio; |
michael@0 | 97 | |
michael@0 | 98 | /** |
michael@0 | 99 | * Enumerated values for the 'type' attribute (below). |
michael@0 | 100 | */ |
michael@0 | 101 | const unsigned short TYPE_RASTER = 0; |
michael@0 | 102 | const unsigned short TYPE_VECTOR = 1; |
michael@0 | 103 | |
michael@0 | 104 | /** |
michael@0 | 105 | * The type of this image (one of the TYPE_* values above). |
michael@0 | 106 | */ |
michael@0 | 107 | readonly attribute unsigned short type; |
michael@0 | 108 | |
michael@0 | 109 | /** |
michael@0 | 110 | * Direct C++ accessor for 'type' attribute, for convenience. |
michael@0 | 111 | */ |
michael@0 | 112 | [noscript, notxpcom] uint16_t GetType(); |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Whether this image is animated. You can only be guaranteed that querying |
michael@0 | 116 | * this will not throw if STATUS_DECODE_COMPLETE is set on the imgIRequest. |
michael@0 | 117 | * |
michael@0 | 118 | * @throws NS_ERROR_NOT_AVAILABLE if the animated state cannot be determined. |
michael@0 | 119 | */ |
michael@0 | 120 | readonly attribute boolean animated; |
michael@0 | 121 | |
michael@0 | 122 | /** |
michael@0 | 123 | * Flags for imgIContainer operations. |
michael@0 | 124 | * |
michael@0 | 125 | * Meanings: |
michael@0 | 126 | * |
michael@0 | 127 | * FLAG_NONE: Lack of flags |
michael@0 | 128 | * |
michael@0 | 129 | * FLAG_SYNC_DECODE: Forces synchronous/non-progressive decode of all |
michael@0 | 130 | * available data before the call returns. It is an error to pass this flag |
michael@0 | 131 | * from a call stack that originates in a decoder (ie, from a decoder |
michael@0 | 132 | * observer event). |
michael@0 | 133 | * |
michael@0 | 134 | * FLAG_DECODE_NO_PREMULTIPLY_ALPHA: Do not premultiply alpha if |
michael@0 | 135 | * it's not already premultiplied in the image data. |
michael@0 | 136 | * |
michael@0 | 137 | * FLAG_DECODE_NO_COLORSPACE_CONVERSION: Do not do any colorspace conversion; |
michael@0 | 138 | * ignore any embedded profiles, and don't convert to any particular destination |
michael@0 | 139 | * space. |
michael@0 | 140 | * |
michael@0 | 141 | * FLAG_CLAMP: Extend the image to the fill area by clamping image sample |
michael@0 | 142 | * coordinates instead of by tiling. This only affects 'draw'. |
michael@0 | 143 | * |
michael@0 | 144 | * FLAG_HIGH_QUALITY_SCALING: A hint as to whether this image should be |
michael@0 | 145 | * scaled using the high quality scaler. Do not set this if not drawing to |
michael@0 | 146 | * a window or not listening to invalidations. |
michael@0 | 147 | */ |
michael@0 | 148 | |
michael@0 | 149 | const long FLAG_NONE = 0x0; |
michael@0 | 150 | const long FLAG_SYNC_DECODE = 0x1; |
michael@0 | 151 | const long FLAG_DECODE_NO_PREMULTIPLY_ALPHA = 0x2; |
michael@0 | 152 | const long FLAG_DECODE_NO_COLORSPACE_CONVERSION = 0x4; |
michael@0 | 153 | const long FLAG_CLAMP = 0x8; |
michael@0 | 154 | const long FLAG_HIGH_QUALITY_SCALING = 0x10; |
michael@0 | 155 | const long FLAG_WANT_DATA_SURFACE = 0x20; |
michael@0 | 156 | |
michael@0 | 157 | /** |
michael@0 | 158 | * Constants for specifying various "special" frames. |
michael@0 | 159 | * |
michael@0 | 160 | * FRAME_FIRST: The first frame |
michael@0 | 161 | * FRAME_CURRENT: The current frame |
michael@0 | 162 | * |
michael@0 | 163 | * FRAME_MAX_VALUE should be set to the value of the maximum constant above, |
michael@0 | 164 | * as it is used for ensuring that a valid value was passed in. |
michael@0 | 165 | */ |
michael@0 | 166 | const unsigned long FRAME_FIRST = 0; |
michael@0 | 167 | const unsigned long FRAME_CURRENT = 1; |
michael@0 | 168 | const unsigned long FRAME_MAX_VALUE = 1; |
michael@0 | 169 | |
michael@0 | 170 | /** |
michael@0 | 171 | * Get a surface for the given frame. This may be a platform-native, |
michael@0 | 172 | * optimized surface, so you cannot inspect its pixel data. If you |
michael@0 | 173 | * need that, use gfxASurface::GetAsReadableARGB32ImageSurface or |
michael@0 | 174 | * gfxASurface::CopyToARGB32ImageSurface. |
michael@0 | 175 | * |
michael@0 | 176 | * @param aWhichFrame Frame specifier of the FRAME_* variety. |
michael@0 | 177 | * @param aFlags Flags of the FLAG_* variety |
michael@0 | 178 | */ |
michael@0 | 179 | [noscript, notxpcom] TempRefSourceSurface getFrame(in uint32_t aWhichFrame, |
michael@0 | 180 | in uint32_t aFlags); |
michael@0 | 181 | |
michael@0 | 182 | /** |
michael@0 | 183 | * Whether the given frame is opaque; that is, needs the background painted |
michael@0 | 184 | * behind it. |
michael@0 | 185 | * |
michael@0 | 186 | * @param aWhichFrame Frame specifier of the FRAME_* variety. |
michael@0 | 187 | */ |
michael@0 | 188 | [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); |
michael@0 | 189 | |
michael@0 | 190 | /** |
michael@0 | 191 | * Attempts to create an ImageContainer (and Image) containing the current |
michael@0 | 192 | * frame. Only valid for RASTER type images. |
michael@0 | 193 | */ |
michael@0 | 194 | [noscript] ImageContainer getImageContainer(in LayerManager aManager); |
michael@0 | 195 | |
michael@0 | 196 | /** |
michael@0 | 197 | * Draw a frame onto the context specified. |
michael@0 | 198 | * |
michael@0 | 199 | * @param aContext The Thebes context to draw the image to. |
michael@0 | 200 | * @param aFilter The filter to be used if we're scaling the image. |
michael@0 | 201 | * @param aUserSpaceToImageSpace The transformation from user space (e.g., |
michael@0 | 202 | * appunits) to image space. |
michael@0 | 203 | * @param aFill The area in the context to draw pixels to. When aFlags includes |
michael@0 | 204 | * FLAG_CLAMP, the image will be extended to this area by clampling |
michael@0 | 205 | * image sample coordinates. Otherwise, the image will be |
michael@0 | 206 | * automatically tiled as necessary. |
michael@0 | 207 | * @param aSubimage The area of the image, in pixels, that we are allowed to |
michael@0 | 208 | * sample from. |
michael@0 | 209 | * @param aViewportSize |
michael@0 | 210 | * The size (in CSS pixels) of the viewport that would be available |
michael@0 | 211 | * for the full image to occupy, if we were drawing the full image. |
michael@0 | 212 | * (Note that we might not actually be drawing the full image -- we |
michael@0 | 213 | * might be restricted by aSubimage -- but we still need the full |
michael@0 | 214 | * image's viewport-size in order for SVG images with the "viewBox" |
michael@0 | 215 | * attribute to position their content correctly.) |
michael@0 | 216 | * @param aSVGContext If non-null, SVG-related rendering context such as |
michael@0 | 217 | * overridden attributes on the image document's root <svg> |
michael@0 | 218 | * node. Ignored for raster images. |
michael@0 | 219 | * @param aWhichFrame Frame specifier of the FRAME_* variety. |
michael@0 | 220 | * @param aFlags Flags of the FLAG_* variety |
michael@0 | 221 | */ |
michael@0 | 222 | [noscript] void draw(in gfxContext aContext, |
michael@0 | 223 | in gfxGraphicsFilter aFilter, |
michael@0 | 224 | [const] in gfxMatrix aUserSpaceToImageSpace, |
michael@0 | 225 | [const] in gfxRect aFill, |
michael@0 | 226 | [const] in nsIntRect aSubimage, |
michael@0 | 227 | [const] in nsIntSize aViewportSize, |
michael@0 | 228 | [const] in SVGImageContext aSVGContext, |
michael@0 | 229 | in uint32_t aWhichFrame, |
michael@0 | 230 | in uint32_t aFlags); |
michael@0 | 231 | |
michael@0 | 232 | /* |
michael@0 | 233 | * Ensures that an image is decoding. Calling this function guarantees that |
michael@0 | 234 | * the image will at some point fire off decode notifications. Calling draw() |
michael@0 | 235 | * or getFrame() triggers the same mechanism internally. Thus, if you want to |
michael@0 | 236 | * be sure that the image will be decoded but don't want to access it until |
michael@0 | 237 | * then, you must call requestDecode(). |
michael@0 | 238 | */ |
michael@0 | 239 | void requestDecode(); |
michael@0 | 240 | |
michael@0 | 241 | /* |
michael@0 | 242 | * This is equivalent to requestDecode() but it also decodes some of the image. |
michael@0 | 243 | */ |
michael@0 | 244 | [noscript] void startDecoding(); |
michael@0 | 245 | |
michael@0 | 246 | /* |
michael@0 | 247 | * Returns true if no more decoding can be performed on this image. Images |
michael@0 | 248 | * with errors return true since they cannot be decoded any further. Note that |
michael@0 | 249 | * because decoded images may be discarded, isDecoded() may return false even |
michael@0 | 250 | * if it has returned true in the past. |
michael@0 | 251 | */ |
michael@0 | 252 | [noscript, notxpcom, nostdcall] bool isDecoded(); |
michael@0 | 253 | |
michael@0 | 254 | /** |
michael@0 | 255 | * Increments the lock count on the image. An image will not be discarded |
michael@0 | 256 | * as long as the lock count is nonzero. Note that it is still possible for |
michael@0 | 257 | * the image to be undecoded if decode-on-draw is enabled and the image |
michael@0 | 258 | * was never drawn. |
michael@0 | 259 | * |
michael@0 | 260 | * Upon instantiation images have a lock count of zero. |
michael@0 | 261 | */ |
michael@0 | 262 | void lockImage(); |
michael@0 | 263 | |
michael@0 | 264 | /** |
michael@0 | 265 | * Decreases the lock count on the image. If the lock count drops to zero, |
michael@0 | 266 | * the image is allowed to discard its frame data to save memory. |
michael@0 | 267 | * |
michael@0 | 268 | * Upon instantiation images have a lock count of zero. It is an error to |
michael@0 | 269 | * call this method without first having made a matching lockImage() call. |
michael@0 | 270 | * In other words, the lock count is not allowed to be negative. |
michael@0 | 271 | */ |
michael@0 | 272 | void unlockImage(); |
michael@0 | 273 | |
michael@0 | 274 | /** |
michael@0 | 275 | * If this image is unlocked, discard its decoded data. If the image is |
michael@0 | 276 | * locked or has already been discarded, do nothing. |
michael@0 | 277 | */ |
michael@0 | 278 | void requestDiscard(); |
michael@0 | 279 | |
michael@0 | 280 | /** |
michael@0 | 281 | * Indicates that this imgIContainer has been triggered to update |
michael@0 | 282 | * its internal animation state. Likely this should only be called |
michael@0 | 283 | * from within nsImageFrame or objects of similar type. |
michael@0 | 284 | */ |
michael@0 | 285 | [notxpcom] void requestRefresh([const] in TimeStamp aTime); |
michael@0 | 286 | |
michael@0 | 287 | /** |
michael@0 | 288 | * Animation mode Constants |
michael@0 | 289 | * 0 = normal |
michael@0 | 290 | * 1 = don't animate |
michael@0 | 291 | * 2 = loop once |
michael@0 | 292 | */ |
michael@0 | 293 | const short kNormalAnimMode = 0; |
michael@0 | 294 | const short kDontAnimMode = 1; |
michael@0 | 295 | const short kLoopOnceAnimMode = 2; |
michael@0 | 296 | |
michael@0 | 297 | attribute unsigned short animationMode; |
michael@0 | 298 | |
michael@0 | 299 | /* Methods to control animation */ |
michael@0 | 300 | void resetAnimation(); |
michael@0 | 301 | |
michael@0 | 302 | /* |
michael@0 | 303 | * Returns an index for the requested animation frame (either FRAME_FIRST or |
michael@0 | 304 | * FRAME_CURRENT). |
michael@0 | 305 | * |
michael@0 | 306 | * The units of the index aren't specified, and may vary between different |
michael@0 | 307 | * types of images. What you can rely on is that on all occasions when |
michael@0 | 308 | * getFrameIndex(FRAME_CURRENT) returns a certain value, |
michael@0 | 309 | * draw(..FRAME_CURRENT..) will draw the same frame. The same holds for |
michael@0 | 310 | * FRAME_FIRST as well. |
michael@0 | 311 | * |
michael@0 | 312 | * @param aWhichFrame Frame specifier of the FRAME_* variety. |
michael@0 | 313 | */ |
michael@0 | 314 | [notxpcom] float getFrameIndex(in uint32_t aWhichFrame); |
michael@0 | 315 | |
michael@0 | 316 | /* |
michael@0 | 317 | * Returns the inherent orientation of the image, as described in the image's |
michael@0 | 318 | * metadata (e.g. EXIF). |
michael@0 | 319 | */ |
michael@0 | 320 | [notxpcom] Orientation getOrientation(); |
michael@0 | 321 | |
michael@0 | 322 | /* |
michael@0 | 323 | * Returns the delay, in ms, between the first and second frame. If this |
michael@0 | 324 | * returns 0, there is no delay between first and second frame (i.e., this |
michael@0 | 325 | * image could render differently whenever it draws). |
michael@0 | 326 | * |
michael@0 | 327 | * If this image is not animated, or not known to be animated (see attribute |
michael@0 | 328 | * animated), returns -1. |
michael@0 | 329 | */ |
michael@0 | 330 | [notxpcom] int32_t getFirstFrameDelay(); |
michael@0 | 331 | |
michael@0 | 332 | /* |
michael@0 | 333 | * If this is an animated image that hasn't started animating already, this |
michael@0 | 334 | * sets the animation's start time to the indicated time. |
michael@0 | 335 | * |
michael@0 | 336 | * This has no effect if the image isn't animated or it has started animating |
michael@0 | 337 | * already; it also has no effect if the image format doesn't care about |
michael@0 | 338 | * animation start time. |
michael@0 | 339 | * |
michael@0 | 340 | * In all cases, animation does not actually begin until startAnimation(), |
michael@0 | 341 | * resetAnimation(), or requestRefresh() is called for the first time. |
michael@0 | 342 | */ |
michael@0 | 343 | [notxpcom] void setAnimationStartTime([const] in TimeStamp aTime); |
michael@0 | 344 | }; |