Interface imgIContainerType

imgIContainer is the interface that represents an image. It allows access to frames as Thebes surfaces. It also allows drawing of images onto Thebes contexts.

Internally, imgIContainer also manages animation of images.

Hierarchy

Properties

animated: boolean

Whether this image is animated. You can only be guaranteed that querying this will not throw if STATUS_DECODE_COMPLETE is set on the imgIRequest.

Throws

NS_ERROR_NOT_AVAILABLE if the animated state cannot be determined.

animationMode: number
height: int32_t

The height of the container rectangle. In the case of any error, zero is returned, and an exception will be thrown.

hotspotX: int32_t

The x coordinate of the image's hotspot, or 0 if there is no hotspot.

hotspotY: int32_t

The y coordinate of the image's hotspot, or 0 if there is no hotspot.

intrinsicRatio: MaybeAspectRatio

The (dimensionless) intrinsic ratio of this image. In the case of any error, Nothing() will be returned.

intrinsicSize: nsSize

The intrinsic size of this image in appunits. If the image has no intrinsic size in a dimension, -1 will be returned for that dimension. In the case of any error, an exception will be thrown.

providerId: number

Provider ID for image providers created by this image.

type: number

The type of this image (one of the TYPE_* values above).

width: int32_t

The width of the container rectangle. In the case of any error, zero is returned, and an exception will be thrown.

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • Draw the requested frame of this image onto the context specified.

    Drawing an image involves scaling it to a certain size (which may be implemented as a "smart" scale by substituting an HQ-scaled frame or rendering at a high DPI), and then selecting a region of that image to draw. That region is drawn onto the graphics context and in the process transformed by the context matrix, which determines the final area that is filled. The basic process looks like this:

    +------------------+ | Image | | | | intrinsic width | | X | | intrinsic height | +------------------+ /
    /
    / (scale to aSize)
    /
    +----------------------------+ | | | Scaled Image | | aSize.width X aSize.height | | | | +---------+ | | | aRegion | | | +---------+ | +-------(---------(----------+ | | /
    | (transform | / by aContext
    | matrix) | /
    +---------------------+ | | | Fill Rect | | | +---------------------+

    The region may extend outside of the scaled image's boundaries. It's actually a region in tiled image space, which is formed by tiling the scaled image infinitely in every direction. Drawing with a region larger than the scaled image thus causes the filled area to contain multiple tiled copies of the image, which looks like this:

    .................................................... : : : : : Tile : Tile : Tile : : +------------[aRegion]------------+ : :........|.......:................:........|.......: : | : : | : : Ti|le : Scaled Image : Ti|le : : | : : | : :........|.......:................:........|.......: : +---------------------------------+ : : Ti|le : Tile : Ti|le : : / : : \ : :......(.........:................:..........).....: | | /
    | (transform by aContext matrix) | /
    +---------------------------------------------+ | : : | |.....:.................................:.....| | : : | | : Tiled Fill : | | : : | |.....:.................................:.....| | : : | +---------------------------------------------+

    Returns

    A ImgDrawResult value indicating whether and to what degree the drawing operation was successful.

    Parameters

    • aContext: gfxContext

      The Thebes context to draw the image to.

    • aSize: nsIntSize

      The size to which the image should be scaled before drawing. This requirement may be satisfied using HQ scaled frames, selecting from different resolution layers, drawing at a higher DPI, or just performing additional scaling on the graphics context. Callers can use optimalImageSizeForDest() to determine the best choice for this parameter if they have no special size requirements.

    • aRegion: ImageRegion

      The region in tiled image space which will be drawn onto the graphics context. aRegion is in the coordinate space of the image after it has been scaled to aSize - that is, the image is scaled first, and then aRegion is applied. When aFlags includes FLAG_CLAMP, the image will be extended to this area by clamping image sample coordinates. Otherwise, the image will be automatically tiled as necessary. aRegion can also optionally contain a second region which restricts the set of pixels we're allowed to sample from when drawing; this is only of use to callers which need to draw with pixel snapping.

    • aWhichFrame: uint32_t

      Frame specifier of the FRAME_* variety.

    • aSamplingFilter: SamplingFilter

      The filter to be used if we're scaling the image.

    • aSVGContext: SVGImageContext

      If specified, SVG-related rendering context, such as overridden attributes on the image document's root node, and the size of the viewport that the full image would occupy. Ignored for raster images.

    • aFlags: uint32_t

      Flags of the FLAG_* variety

    • aOpacity: number

    Returns ImgDrawResult

  • Returns the delay, in ms, between the first and second frame. If this returns 0, there is no delay between first and second frame (i.e., this image could render differently whenever it draws).

    If this image is not animated, or not known to be animated (see attribute animated), returns -1.

    Returns int32_t

  • Get a surface for the given frame. This may be a platform-native, optimized surface, so you cannot inspect its pixel data. If you need that, use SourceSurface::GetDataSurface.

    Parameters

    • aWhichFrame: uint32_t

      Frame specifier of the FRAME_* variety.

    • aFlags: uint32_t

      Flags of the FLAG_* variety

    Returns TempRefSourceSurface

  • Get a surface for the given frame at the specified size. Matching the requested size is best effort; it's not guaranteed that the surface you get will be a perfect match. (Some reasons you may get a surface of a different size include: if you requested upscaling, if downscale-during-decode is disabled, or if you didn't request the first frame.)

    Parameters

    • aSize: nsIntSize

      The desired size.

    • aWhichFrame: uint32_t

      Frame specifier of the FRAME_* variety.

    • aFlags: uint32_t

      Flags of the FLAG_* variety

    Returns TempRefSourceSurface

  • Returns an index for the requested animation frame (either FRAME_FIRST or FRAME_CURRENT).

    The units of the index aren't specified, and may vary between different types of images. What you can rely on is that on all occasions when getFrameIndex(FRAME_CURRENT) returns a certain value, draw(..FRAME_CURRENT..) will draw the same frame. The same holds for FRAME_FIRST as well.

    Parameters

    • aWhichFrame: uint32_t

      Frame specifier of the FRAME_* variety.

    Returns number

  • Attempts to find a WebRenderImageProvider containing the current frame at the given size. Match the requested size is best effort; it's not guaranteed that the surface you get will be a perfect match. (Some reasons you may get a surface of a different size include: if you requested upscaling, or if downscale-during-decode is disabled.)

    Returns

    The draw result for the current frame.

    Parameters

    • aRenderer: WindowRenderer

      The WindowRenderer which will be used to render the ImageContainer.

    • aSize: nsIntSize
    • aSVGContext: SVGImageContext

      If specified, SVG-related rendering context, such as overridden attributes on the image document's root node, and the size of the viewport that the full image would occupy. Ignored for raster images.

    • aRegion: MaybeImageIntRegion
    • aFlags: uint32_t

      Decoding / drawing flags (in other words, FLAG_* flags). Currently only FLAG_SYNC_DECODE and FLAG_SYNC_DECODE_IF_FAST are supported.

    • aProvider: WebRenderImageProvider

      Return value for WebRenderImageProvider for the current frame. May be null depending on the draw result.

    Returns ImgDrawResult

  • Given an invalidation rect in the coordinate system used by the decoder, returns an invalidation rect in image space.

    This is the identity transformation in most cases, but the result can differ if the image is wrapped by an ImageWrapper that changes its size or orientation.

    Parameters

    • aRect: nsIntRect

    Returns nsIntRectByVal

  • Returns number

  • Returns the inherent orientation of the image, as described in the image's metadata (e.g. EXIF).

    Returns Orientation

  • Returns the intrinsic resolution of the image, or 1.0 if the image doesn't declare any.

    Returns ImageResolution

  • Returns true if this image has a frame and the frame currently has a least 1 decoded pixel. Only valid for raster images.

    Returns boolean

  • Returns

    true if getImageContainer() is expected to return a valid ImageContainer when passed the given

    Renderer

    and

    Flags

    parameters.

    Parameters

    • aRenderer: WindowRenderer
    • aFlags: uint32_t

    Returns boolean

  • Increments the lock count on the image. An image will not be discarded as long as the lock count is nonzero. Note that it is still possible for the image to be undecoded if decode-on-draw is enabled and the image was never drawn.

    Upon instantiation images have a lock count of zero.

    Returns void

  • Called when media feature values that apply to all documents (such as those based on system metrics) have changed. If this image is a type that can respond to media queries (i.e., an SVG image), this function is overridden to handle restyling and invalidating the image.

    Parameters

    • aChange: MediaFeatureChange

    Returns void

  • Given a size at which this image will be displayed, and the drawing parameters affecting how it will be drawn, returns the image size which should be used to draw to produce the highest quality result. This is the appropriate size, for example, to use as an input to the pixel snapping algorithm.

    For best results the size returned by this method should not be cached. It can change over time due to changes in the internal state of the image.

    Parameters

    • aDest: gfxSize

      The size of the destination rect into which this image will be drawn, in device pixels.

    • aWhichFrame: uint32_t

      Frame specifier of the FRAME_* variety.

    • aSamplingFilter: SamplingFilter

      The filter to be used if we're scaling the image.

    • aFlags: uint32_t

      Flags of the FLAG_* variety

    Returns nsIntSizeByVal

  • Propagate the use counters (if any) from this container to the passed in document.

    Parameters

    • aReferencingDocument: Document

    Returns void

  • This method triggers decoding for an image, but unlike startDecoding() it enables the caller to provide more detailed information about the decode request.

    Parameters

    • aSize: nsIntSize

      The size to which the image should be scaled while decoding, if possible. If the image cannot be scaled to this size while being decoded, it will be decoded at its intrinsic size.

    • aFlags: uint32_t

      Flags of the FLAG_* variety.

    • aWhichFrame: uint32_t

      Frame specifier of the FRAME_* variety.

    Returns void

  • Parameters

    • aFlags: uint32_t
    • aWhichFrame: uint32_t

    Returns imgIContainer_DecodeResult

  • If this image is unlocked, discard its decoded data. If the image is locked or has already been discarded, do nothing.

    Returns void

  • Indicates that this imgIContainer has been triggered to update its internal animation state. Likely this should only be called from within nsImageFrame or objects of similar type.

    Parameters

    • aTime: TimeStamp

    Returns void

  • Methods to control animation

    Returns void

  • If this is an animated image that hasn't started animating already, this sets the animation's start time to the indicated time.

    This has no effect if the image isn't animated or it has started animating already; it also has no effect if the image format doesn't care about animation start time.

    In all cases, animation does not actually begin until startAnimation(), resetAnimation(), or requestRefresh() is called for the first time.

    Parameters

    • aTime: TimeStamp

    Returns void

  • Ensures that an image is decoding. Calling this function guarantees that the image will at some point fire off decode notifications. Images that can be decoded "quickly" according to some heuristic will be decoded synchronously.

    Parameters

    • aFlags: uint32_t

      Flags of the FLAG_* variety. Only FLAG_ASYNC_NOTIFY is accepted; all others are ignored.

    • aWhichFrame: uint32_t

      Frame specifier of the FRAME_* variety.

    Returns void

  • Exactly like startDecoding above except returns whether the current frame of the image is complete or not.

    Parameters

    • aFlags: uint32_t

      Flags of the FLAG_* variety. Only FLAG_ASYNC_NOTIFY is accepted; all others are ignored.

    • aWhichFrame: uint32_t

      Frame specifier of the FRAME_* variety.

    Returns boolean

  • Decreases the lock count on the image. If the lock count drops to zero, the image is allowed to discard its frame data to save memory.

    Upon instantiation images have a lock count of zero. It is an error to call this method without first having made a matching lockImage() call. In other words, the lock count is not allowed to be negative.

    Returns void

  • Removes any ImageWrappers and returns the unwrapped base image.

    Returns TempRefImgIContainer

  • Returns true if this image will draw opaquely right now if asked to draw with FLAG_HIGH_QUALITY_SCALING and otherwise default flags. If this image (when decoded) is opaque but no decoded frames are available then willDrawOpaqueNow will return false.

    Returns boolean

Generated using TypeDoc