Open-Source Wikis

/

Gecko

/

Systems

/

Image

mozilla/gecko-dev

Image

image/ is Gecko's image pipeline: format decoders, frame caching, animation handling, and the public API used by <img>, background-image, favicons, and CSS image() resources.

Pipeline

graph LR
    Net[Network channel<br/>(HTTP, file, etc.)] --> ImgLoader[imgLoader]
    ImgLoader --> Container[imgRequest + RasterImage / VectorImage]
    Container --> Decoder[Decoder<br/>(JPEG, PNG, GIF, WebP, AVIF, ICO, BMP, …)]
    Decoder --> Frames[DecodedFrame surfaces]
    Frames --> Painter[Layout painter / WebRender]

Decoders

image/decoders/ holds per-format decoders:

  • nsJPEGDecoder (libjpeg-turbo)
  • nsPNGDecoder (libpng)
  • nsGIFDecoder2
  • nsWebPDecoder
  • nsAVIFDecoder (rav1d / dav1d)
  • nsICODecoder, nsBMPDecoder
  • nsSVGDecoder (delegates to layout for SVG documents)

Decoding runs on a thread pool to avoid blocking the main thread.

Surface cache

Decoded frames live in the SurfaceCache (image/SurfaceCache.cpp), which evicts under memory pressure. Frames are keyed by (image, size, animation index) so a single source image can serve multiple sizes simultaneously.

Animation

GIF/APNG/WebP animations are managed by FrameAnimator and AnimationFrameRetainedBuffer. Frames are decoded lazily as the animation advances.

Embedded use

The public API is imgIRequest and imgIContainer (XPCOM interfaces). Layout consumes imgIContainer for paint; favicons go through mozIAsyncFavicons.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Image – Gecko wiki | Factory