Bug 1643896 - Convert sync onMessage listener exceptions into async rejections r...
[gecko.git] / image / imgIContainer.idl
blob6267662206db8e995ecbbdc76797e6d5ae06a9b4
1 /** -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsISupports.idl"
9 webidl Document;
11 %{C++
12 #include "ImgDrawResult.h"
13 #include "gfxContext.h"
14 #include "gfxMatrix.h"
15 #include "gfxRect.h"
16 #include "mozilla/gfx/2D.h"
17 #include "mozilla/AspectRatio.h"
18 #include "mozilla/Maybe.h"
19 #include "mozilla/RefPtr.h"
20 #include "nsRect.h"
21 #include "nsSize.h"
22 #include "limits.h"
24 namespace mozilla {
25 namespace layers {
26 class LayerManager;
27 class ImageContainer;
31 class nsIFrame;
33 namespace mozilla {
34 class TimeStamp;
35 class SVGImageContext;
36 struct MediaFeatureChange;
39 namespace mozilla {
40 namespace image {
42 class ImageRegion;
43 struct Orientation;
50 native MaybeAspectRatio(mozilla::Maybe<mozilla::AspectRatio>);
51 native ImgDrawResult(mozilla::image::ImgDrawResult);
52 [ptr] native gfxContext(gfxContext);
53 [ref] native gfxMatrix(gfxMatrix);
54 [ref] native gfxRect(gfxRect);
55 [ref] native gfxSize(gfxSize);
56 native SamplingFilter(mozilla::gfx::SamplingFilter);
57 [ref] native nsIntRect(nsIntRect);
58 native nsIntRectByVal(nsIntRect);
59 [ref] native nsIntSize(nsIntSize);
60 native nsSize(nsSize);
61 [ptr] native nsIFrame(nsIFrame);
62 native TempRefImageContainer(already_AddRefed<mozilla::layers::ImageContainer>);
63 [ptr] native ImageContainer(mozilla::layers::ImageContainer);
64 [ref] native ImageRegion(mozilla::image::ImageRegion);
65 [ptr] native LayerManager(mozilla::layers::LayerManager);
66 native Orientation(mozilla::image::Orientation);
67 [ref] native TimeStamp(mozilla::TimeStamp);
68 [ref] native MaybeSVGImageContext(mozilla::Maybe<mozilla::SVGImageContext>);
69 native TempRefSourceSurface(already_AddRefed<mozilla::gfx::SourceSurface>);
70 native TempRefImgIContainer(already_AddRefed<imgIContainer>);
71 native nsIntSizeByVal(nsIntSize);
74 /**
75 * imgIContainer is the interface that represents an image. It allows
76 * access to frames as Thebes surfaces. It also allows drawing of images
77 * onto Thebes contexts.
79 * Internally, imgIContainer also manages animation of images.
81 [scriptable, builtinclass, uuid(a8dbee24-ff86-4755-b40e-51175caf31af)]
82 interface imgIContainer : nsISupports
84 /**
85 * The width of the container rectangle. In the case of any error,
86 * zero is returned, and an exception will be thrown.
88 readonly attribute int32_t width;
90 /**
91 * The height of the container rectangle. In the case of any error,
92 * zero is returned, and an exception will be thrown.
94 readonly attribute int32_t height;
96 /**
97 * The intrinsic size of this image in appunits. If the image has no intrinsic
98 * size in a dimension, -1 will be returned for that dimension. In the case of
99 * any error, an exception will be thrown.
101 [noscript] readonly attribute nsSize intrinsicSize;
104 * The (dimensionless) intrinsic ratio of this image. In the case of any
105 * error, Nothing() will be returned.
107 [notxpcom, nostdcall] readonly attribute MaybeAspectRatio intrinsicRatio;
110 * The x coordinate of the image's hotspot, or 0 if there is no hotspot.
112 readonly attribute int32_t hotspotX;
115 * The y coordinate of the image's hotspot, or 0 if there is no hotspot.
117 readonly attribute int32_t hotspotY;
120 * Given a size at which this image will be displayed, and the drawing
121 * parameters affecting how it will be drawn, returns the image size which
122 * should be used to draw to produce the highest quality result. This is the
123 * appropriate size, for example, to use as an input to the pixel snapping
124 * algorithm.
126 * For best results the size returned by this method should not be cached. It
127 * can change over time due to changes in the internal state of the image.
129 * @param aDest The size of the destination rect into which this image will be
130 * drawn, in device pixels.
131 * @param aWhichFrame Frame specifier of the FRAME_* variety.
132 * @param aSamplingFilter The filter to be used if we're scaling the image.
133 * @param aFlags Flags of the FLAG_* variety
135 [notxpcom, nostdcall] nsIntSizeByVal
136 optimalImageSizeForDest([const] in gfxSize aDest, in uint32_t aWhichFrame,
137 in SamplingFilter aSamplingFilter, in uint32_t aFlags);
140 * Enumerated values for the 'type' attribute (below).
142 const unsigned short TYPE_RASTER = 0;
143 const unsigned short TYPE_VECTOR = 1;
144 const unsigned short TYPE_REQUEST = 2;
147 * The type of this image (one of the TYPE_* values above).
149 [infallible] readonly attribute unsigned short type;
152 * Whether this image is animated. You can only be guaranteed that querying
153 * this will not throw if STATUS_DECODE_COMPLETE is set on the imgIRequest.
155 * @throws NS_ERROR_NOT_AVAILABLE if the animated state cannot be determined.
157 readonly attribute boolean animated;
160 * Producer ID for image containers created by this image.
162 [infallible] readonly attribute unsigned long producerId;
165 * Flags for imgIContainer operations.
167 * Meanings:
169 * FLAG_NONE: Lack of flags.
171 * FLAG_SYNC_DECODE: Forces synchronous/non-progressive decode of all
172 * available data before the call returns.
174 * FLAG_SYNC_DECODE_IF_FAST: Like FLAG_SYNC_DECODE, but requests a sync decode
175 * be performed only if ImageLib estimates it can be completed very quickly.
177 * FLAG_ASYNC_NOTIFY: Send notifications asynchronously, even if we decode
178 * synchronously because of FLAG_SYNC_DECODE or FLAG_SYNC_DECODE_IF_FAST.
180 * FLAG_DECODE_NO_PREMULTIPLY_ALPHA: Do not premultiply alpha if
181 * it's not already premultiplied in the image data.
183 * FLAG_DECODE_NO_COLORSPACE_CONVERSION: Do not do any colorspace conversion;
184 * ignore any embedded profiles, and don't convert to any particular
185 * destination space.
187 * FLAG_CLAMP: Extend the image to the fill area by clamping image sample
188 * coordinates instead of by tiling. This only affects 'draw'.
190 * FLAG_HIGH_QUALITY_SCALING: A hint as to whether this image should be
191 * scaled using the high quality scaler. Do not set this if not drawing to
192 * a window or not listening to invalidations. Passing this flag will do two
193 * things: 1) request a decode of the image at the size asked for by the
194 * caller if one isn't already started or complete, and 2) allows a decoded
195 * frame of any size (it could be neither the requested size, nor the
196 * intrinsic size) to be substituted.
198 * FLAG_WANT_DATA_SURFACE: Can be passed to GetFrame when the caller wants a
199 * DataSourceSurface instead of a hardware accelerated surface. This can be
200 * important for performance (by avoiding an upload to/readback from the GPU)
201 * when the caller knows they want a SourceSurface of type DATA.
203 * FLAG_BYPASS_SURFACE_CACHE: Forces drawing to happen rather than taking
204 * cached rendering from the surface cache. This is used when we are printing,
205 * for example, where we want the vector commands from VectorImages to end up
206 * in the PDF output rather than a cached rendering at screen resolution.
208 * FLAG_FORCE_PRESERVEASPECTRATIO_NONE: Force scaling this image
209 * non-uniformly if necessary. This flag is for vector image only. A raster
210 * image should ignore this flag. While drawing a vector image with this
211 * flag, do not force uniform scaling even if its root <svg> node has a
212 * preserveAspectRatio attribute that would otherwise require uniform
213 * scaling , such as xMinYMin/ xMidYMin. Always scale the graphic content of
214 * the given image non-uniformly if necessary such that the image's
215 * viewBox (if specified or implied by height/width attributes) exactly
216 * matches the viewport rectangle.
218 * FLAG_FORCE_UNIFORM_SCALING: Signal to ClippedImage::OptimalSizeForDest that
219 * its returned size can only scale the image's size *uniformly* (by the same
220 * factor in each dimension). We need this flag when painting border-image
221 * section with SVG image source-data, if the SVG image has no viewBox and no
222 * intrinsic size. In such a case, we synthesize a viewport for the SVG image
223 * (a "window into SVG space") based on the border image area, and we need to
224 * be sure we don't subsequently scale that viewport in a way that distorts
225 * its contents by stretching them more in one dimension than the other.
227 * FLAG_AVOID_REDECODE_FOR_SIZE: If there is already a raster surface
228 * available for this image, but it is not the same size as requested, skip
229 * starting a new decode for said size.
231 * FLAG_DECODE_TO_SRGB_COLORSPACE: Instead of converting the colorspace to
232 * the display's colorspace, use sRGB.
234 const unsigned long FLAG_NONE = 0x0;
235 const unsigned long FLAG_SYNC_DECODE = 0x1;
236 const unsigned long FLAG_SYNC_DECODE_IF_FAST = 0x2;
237 const unsigned long FLAG_ASYNC_NOTIFY = 0x4;
238 const unsigned long FLAG_DECODE_NO_PREMULTIPLY_ALPHA = 0x8;
239 const unsigned long FLAG_DECODE_NO_COLORSPACE_CONVERSION = 0x10;
240 const unsigned long FLAG_CLAMP = 0x20;
241 const unsigned long FLAG_HIGH_QUALITY_SCALING = 0x40;
242 const unsigned long FLAG_WANT_DATA_SURFACE = 0x80;
243 const unsigned long FLAG_BYPASS_SURFACE_CACHE = 0x100;
244 const unsigned long FLAG_FORCE_PRESERVEASPECTRATIO_NONE = 0x200;
245 const unsigned long FLAG_FORCE_UNIFORM_SCALING = 0x400;
246 const unsigned long FLAG_AVOID_REDECODE_FOR_SIZE = 0x800;
247 const unsigned long FLAG_DECODE_TO_SRGB_COLORSPACE = 0x1000;
250 * A constant specifying the default set of decode flags (i.e., the default
251 * values for FLAG_DECODE_*).
253 const unsigned long DECODE_FLAGS_DEFAULT = 0;
256 * A constant specifying the decode flags recommended to be used when
257 * re-encoding an image, or with the clipboard.
259 const unsigned long DECODE_FLAGS_FOR_REENCODE =
260 FLAG_DECODE_NO_PREMULTIPLY_ALPHA | FLAG_DECODE_TO_SRGB_COLORSPACE;
263 * Constants for specifying various "special" frames.
265 * FRAME_FIRST: The first frame
266 * FRAME_CURRENT: The current frame
268 * FRAME_MAX_VALUE should be set to the value of the maximum constant above,
269 * as it is used for ensuring that a valid value was passed in.
271 const unsigned long FRAME_FIRST = 0;
272 const unsigned long FRAME_CURRENT = 1;
273 const unsigned long FRAME_MAX_VALUE = 1;
276 * Get a surface for the given frame. This may be a platform-native,
277 * optimized surface, so you cannot inspect its pixel data. If you
278 * need that, use SourceSurface::GetDataSurface.
280 * @param aWhichFrame Frame specifier of the FRAME_* variety.
281 * @param aFlags Flags of the FLAG_* variety
283 [noscript, notxpcom] TempRefSourceSurface getFrame(in uint32_t aWhichFrame,
284 in uint32_t aFlags);
287 * Get a surface for the given frame at the specified size. Matching the
288 * requested size is best effort; it's not guaranteed that the surface you get
289 * will be a perfect match. (Some reasons you may get a surface of a different
290 * size include: if you requested upscaling, if downscale-during-decode is
291 * disabled, or if you didn't request the first frame.)
293 * @param aSize The desired size.
294 * @param aWhichFrame Frame specifier of the FRAME_* variety.
295 * @param aFlags Flags of the FLAG_* variety
297 [noscript, notxpcom] TempRefSourceSurface getFrameAtSize([const] in nsIntSize aSize,
298 in uint32_t aWhichFrame,
299 in uint32_t aFlags);
302 * Returns true if this image will draw opaquely right now if asked to draw
303 * with FLAG_HIGH_QUALITY_SCALING and otherwise default flags. If this image
304 * (when decoded) is opaque but no decoded frames are available then
305 * willDrawOpaqueNow will return false.
307 [noscript, notxpcom] boolean willDrawOpaqueNow();
310 * @return true if getImageContainer() is expected to return a valid
311 * ImageContainer when passed the given @Manager and @Flags
312 * parameters.
314 [noscript, notxpcom] boolean isImageContainerAvailable(in LayerManager aManager,
315 in uint32_t aFlags);
317 * Attempts to create an ImageContainer (and Image) containing the current
318 * frame at its native size.
320 * Avoid calling this unless you're actually going to layerize this image.
322 * @param aManager The LayerManager which will be used to create the
323 * ImageContainer.
324 * @param aFlags Decoding / drawing flags (in other words, FLAG_* flags).
325 * Currently only FLAG_SYNC_DECODE and FLAG_SYNC_DECODE_IF_FAST
326 * are supported.
327 * @return An ImageContainer for the current frame, or nullptr if one could
328 * not be created.
330 [noscript, notxpcom] TempRefImageContainer getImageContainer(in LayerManager aManager,
331 in uint32_t aFlags);
334 * Attempts to create an ImageContainer (and Image) containing the current
335 * frame at the given size. Match the requested size is best effort; it's
336 * not guaranteed that the surface you get will be a perfect match. (Some
337 * reasons you may get a surface of a different size include: if you
338 * requested upscaling, or if downscale-during-decode is disabled.)
340 * Avoid calling this unless you're actually going to layerize this image.
342 * @param aManager The LayerManager which will be used to create the
343 * ImageContainer.
344 * @param aSVGContext If specified, SVG-related rendering context, such as
345 * overridden attributes on the image document's root <svg>
346 * node, and the size of the viewport that the full image
347 * would occupy. Ignored for raster images.
348 * @param aFlags Decoding / drawing flags (in other words, FLAG_* flags).
349 * Currently only FLAG_SYNC_DECODE and FLAG_SYNC_DECODE_IF_FAST
350 * are supported.
351 * @param aContainer Return value for ImageContainer for the current frame.
352 * May be null depending on the draw result.
353 * @return The draw result for the current frame.
355 [noscript, notxpcom] ImgDrawResult getImageContainerAtSize(in LayerManager aManager,
356 [const] in nsIntSize aSize,
357 [const] in MaybeSVGImageContext aSVGContext,
358 in uint32_t aFlags,
359 out ImageContainer aOutContainer);
362 * @return true if getImageContainer() is expected to return a valid
363 * ImageContainer when passed the given @Manager, @Size and @Flags
364 * parameters.
366 [noscript, notxpcom] boolean isImageContainerAvailableAtSize(in LayerManager aManager,
367 [const] in nsIntSize aSize,
368 in uint32_t aFlags);
371 * Draw the requested frame of this image onto the context specified.
373 * Drawing an image involves scaling it to a certain size (which may be
374 * implemented as a "smart" scale by substituting an HQ-scaled frame or
375 * rendering at a high DPI), and then selecting a region of that image to
376 * draw. That region is drawn onto the graphics context and in the process
377 * transformed by the context matrix, which determines the final area that is
378 * filled. The basic process looks like this:
380 * +------------------+
381 * | Image |
382 * | |
383 * | intrinsic width |
384 * | X |
385 * | intrinsic height |
386 * +------------------+
387 * / \
388 * / \
389 * / (scale to aSize) \
390 * / \
391 * +----------------------------+
392 * | |
393 * | Scaled Image |
394 * | aSize.width X aSize.height |
395 * | |
396 * | +---------+ |
397 * | | aRegion | |
398 * | +---------+ |
399 * +-------(---------(----------+
400 * | |
401 * / \
402 * | (transform |
403 * / by aContext \
404 * | matrix) |
405 * / \
406 * +---------------------+
407 * | |
408 * | Fill Rect |
409 * | |
410 * +---------------------+
412 * The region may extend outside of the scaled image's boundaries. It's
413 * actually a region in tiled image space, which is formed by tiling the
414 * scaled image infinitely in every direction. Drawing with a region larger
415 * than the scaled image thus causes the filled area to contain multiple tiled
416 * copies of the image, which looks like this:
418 * ....................................................
419 * : : : :
420 * : Tile : Tile : Tile :
421 * : +------------[aRegion]------------+ :
422 * :........|.......:................:........|.......:
423 * : | : : | :
424 * : Ti|le : Scaled Image : Ti|le :
425 * : | : : | :
426 * :........|.......:................:........|.......:
427 * : +---------------------------------+ :
428 * : Ti|le : Tile : Ti|le :
429 * : / : : \ :
430 * :......(.........:................:..........).....:
431 * | |
432 * / \
433 * | (transform by aContext matrix) |
434 * / \
435 * +---------------------------------------------+
436 * | : : |
437 * |.....:.................................:.....|
438 * | : : |
439 * | : Tiled Fill : |
440 * | : : |
441 * |.....:.................................:.....|
442 * | : : |
443 * +---------------------------------------------+
446 * @param aContext The Thebes context to draw the image to.
447 * @param aSize The size to which the image should be scaled before drawing.
448 * This requirement may be satisfied using HQ scaled frames,
449 * selecting from different resolution layers, drawing at a
450 * higher DPI, or just performing additional scaling on the
451 * graphics context. Callers can use optimalImageSizeForDest()
452 * to determine the best choice for this parameter if they have
453 * no special size requirements.
454 * @param aRegion The region in tiled image space which will be drawn onto the
455 * graphics context. aRegion is in the coordinate space of the
456 * image after it has been scaled to aSize - that is, the image
457 * is scaled first, and then aRegion is applied. When aFlags
458 * includes FLAG_CLAMP, the image will be extended to this area
459 * by clamping image sample coordinates. Otherwise, the image
460 * will be automatically tiled as necessary. aRegion can also
461 * optionally contain a second region which restricts the set
462 * of pixels we're allowed to sample from when drawing; this
463 * is only of use to callers which need to draw with pixel
464 * snapping.
465 * @param aWhichFrame Frame specifier of the FRAME_* variety.
466 * @param aSamplingFilter The filter to be used if we're scaling the image.
467 * @param aSVGContext If specified, SVG-related rendering context, such as
468 * overridden attributes on the image document's root <svg>
469 * node, and the size of the viewport that the full image
470 * would occupy. Ignored for raster images.
471 * @param aFlags Flags of the FLAG_* variety
472 * @return A ImgDrawResult value indicating whether and to what degree the
473 * drawing operation was successful.
475 [noscript, notxpcom] ImgDrawResult
476 draw(in gfxContext aContext,
477 [const] in nsIntSize aSize,
478 [const] in ImageRegion aRegion,
479 in uint32_t aWhichFrame,
480 in SamplingFilter aSamplingFilter,
481 [const] in MaybeSVGImageContext aSVGContext,
482 in uint32_t aFlags,
483 in float aOpacity);
486 * Ensures that an image is decoding. Calling this function guarantees that
487 * the image will at some point fire off decode notifications. Images that
488 * can be decoded "quickly" according to some heuristic will be decoded
489 * synchronously.
491 * @param aFlags Flags of the FLAG_* variety. Only FLAG_ASYNC_NOTIFY
492 * is accepted; all others are ignored.
493 * @param aWhichFrame Frame specifier of the FRAME_* variety.
495 [noscript] void startDecoding(in uint32_t aFlags, in uint32_t aWhichFrame);
497 %{C++
498 nsresult StartDecoding(uint32_t aFlags) {
499 return StartDecoding(aFlags, FRAME_CURRENT);
504 * Exactly like startDecoding above except returns whether the current frame
505 * of the image is complete or not.
507 * @param aFlags Flags of the FLAG_* variety. Only FLAG_ASYNC_NOTIFY
508 * is accepted; all others are ignored.
509 * @param aWhichFrame Frame specifier of the FRAME_* variety.
511 [noscript, notxpcom] boolean startDecodingWithResult(in uint32_t aFlags, in uint32_t aWhichFrame);
513 %{C++
514 bool StartDecodingWithResult(uint32_t aFlags) {
515 return StartDecodingWithResult(aFlags, FRAME_CURRENT);
520 * This method triggers decoding for an image, but unlike startDecoding() it
521 * enables the caller to provide more detailed information about the decode
522 * request.
524 * @param aFlags Flags of the FLAG_* variety.
525 * @param aWhichFrame Frame specifier of the FRAME_* variety.
526 * @return DECODE_SURFACE_AVAILABLE if is a surface that satisfies the
527 * request and it is fully decoded.
528 * DECODE_REQUESTED if we requested a decode.
529 * DECODE_REQUEST_FAILED if we failed to request a decode. This means
530 * that either there is an error in the image or we cannot allocate a
531 * surface that big.
533 cenum DecodeResult : 8 {
534 DECODE_SURFACE_AVAILABLE = 0,
535 DECODE_REQUESTED = 1,
536 DECODE_REQUEST_FAILED = 2
538 [noscript, notxpcom] imgIContainer_DecodeResult requestDecodeWithResult(in uint32_t aFlags, in uint32_t aWhichFrame);
540 %{C++
541 DecodeResult RequestDecodeWithResult(uint32_t aFlags) {
542 return RequestDecodeWithResult(aFlags, FRAME_CURRENT);
547 * This method triggers decoding for an image, but unlike startDecoding() it
548 * enables the caller to provide more detailed information about the decode
549 * request.
551 * @param aSize The size to which the image should be scaled while decoding,
552 * if possible. If the image cannot be scaled to this size while
553 * being decoded, it will be decoded at its intrinsic size.
554 * @param aFlags Flags of the FLAG_* variety.
555 * @param aWhichFrame Frame specifier of the FRAME_* variety.
557 [noscript] void requestDecodeForSize([const] in nsIntSize aSize,
558 in uint32_t aFlags,
559 in uint32_t aWhichFrame);
561 %{C++
562 nsresult RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags) {
563 return RequestDecodeForSize(aSize, aFlags, FRAME_CURRENT);
568 * Increments the lock count on the image. An image will not be discarded
569 * as long as the lock count is nonzero. Note that it is still possible for
570 * the image to be undecoded if decode-on-draw is enabled and the image
571 * was never drawn.
573 * Upon instantiation images have a lock count of zero.
575 void lockImage();
578 * Decreases the lock count on the image. If the lock count drops to zero,
579 * the image is allowed to discard its frame data to save memory.
581 * Upon instantiation images have a lock count of zero. It is an error to
582 * call this method without first having made a matching lockImage() call.
583 * In other words, the lock count is not allowed to be negative.
585 void unlockImage();
588 * If this image is unlocked, discard its decoded data. If the image is
589 * locked or has already been discarded, do nothing.
591 void requestDiscard();
594 * Indicates that this imgIContainer has been triggered to update
595 * its internal animation state. Likely this should only be called
596 * from within nsImageFrame or objects of similar type.
598 [notxpcom] void requestRefresh([const] in TimeStamp aTime);
601 * Animation mode Constants
602 * 0 = normal
603 * 1 = don't animate
604 * 2 = loop once
606 const short kNormalAnimMode = 0;
607 const short kDontAnimMode = 1;
608 const short kLoopOnceAnimMode = 2;
610 attribute unsigned short animationMode;
612 /* Methods to control animation */
613 void resetAnimation();
616 * Returns an index for the requested animation frame (either FRAME_FIRST or
617 * FRAME_CURRENT).
619 * The units of the index aren't specified, and may vary between different
620 * types of images. What you can rely on is that on all occasions when
621 * getFrameIndex(FRAME_CURRENT) returns a certain value,
622 * draw(..FRAME_CURRENT..) will draw the same frame. The same holds for
623 * FRAME_FIRST as well.
625 * @param aWhichFrame Frame specifier of the FRAME_* variety.
627 [notxpcom] float getFrameIndex(in uint32_t aWhichFrame);
630 * Returns the inherent orientation of the image, as described in the image's
631 * metadata (e.g. EXIF).
633 [notxpcom] Orientation getOrientation();
636 * Returns whether the image handles the orientation returned by
637 * getOrientation() itself.
639 [notxpcom] bool handledOrientation();
642 * Returns the delay, in ms, between the first and second frame. If this
643 * returns 0, there is no delay between first and second frame (i.e., this
644 * image could render differently whenever it draws).
646 * If this image is not animated, or not known to be animated (see attribute
647 * animated), returns -1.
649 [notxpcom] int32_t getFirstFrameDelay();
652 * If this is an animated image that hasn't started animating already, this
653 * sets the animation's start time to the indicated time.
655 * This has no effect if the image isn't animated or it has started animating
656 * already; it also has no effect if the image format doesn't care about
657 * animation start time.
659 * In all cases, animation does not actually begin until startAnimation(),
660 * resetAnimation(), or requestRefresh() is called for the first time.
662 [notxpcom] void setAnimationStartTime([const] in TimeStamp aTime);
665 * Given an invalidation rect in the coordinate system used by the decoder,
666 * returns an invalidation rect in image space.
668 * This is the identity transformation in most cases, but the result can
669 * differ if the image is wrapped by an ImageWrapper that changes its size
670 * or orientation.
672 [notxpcom] nsIntRectByVal
673 getImageSpaceInvalidationRect([const] in nsIntRect aRect);
676 * Removes any ImageWrappers and returns the unwrapped base image.
678 [notxpcom, nostdcall] TempRefImgIContainer unwrap();
681 * Propagate the use counters (if any) from this container to the passed in
682 * document.
684 [noscript, notxpcom] void propagateUseCounters(in Document aDocument);
686 %{C++
688 * Called when media feature values that apply to all documents (such as
689 * those based on system metrics) have changed. If this image is a type
690 * that can respond to media queries (i.e., an SVG image), this function
691 * is overridden to handle restyling and invalidating the image.
693 virtual void MediaFeatureValuesChangedAllDocuments(const mozilla::MediaFeatureChange& aChange) {}
696 * Get the set of sizes the image can decode to natively.
698 virtual nsresult GetNativeSizes(nsTArray<nsIntSize>& aNativeSizes) const = 0;
700 virtual size_t GetNativeSizesLength() const = 0;