Skip to main content
LibGfx is Ladybird’s 2D graphics library that handles everything from basic shapes and colors to image decoding, font rendering, and hardware-accelerated painting.

Core graphics primitives

LibGfx provides fundamental types for 2D graphics operations.

Geometric types

IntPoint / FloatPoint

2D coordinate positions with integer or floating-point precision

IntRect / FloatRect

Rectangles with position and dimensions, plus intersection/union operations

IntSize / FloatSize

Width and height dimensions

Quad

Arbitrary four-sided polygon

Color

Comprehensive color support with multiple representations:
LibGfx supports multiple color spaces including sRGB, Display P3, and custom ICC profiles through the ColorSpace class.

Bitmap handling

Bitmap creation and manipulation

Bitmap is the core image storage class:
Supported formats:
  • RGBA8888 - 32-bit with alpha
  • RGB888 - 24-bit without alpha
  • BGRx8888 - 32-bit BGR format
  • BGRA8888 - 32-bit BGRA with alpha

ImmutableBitmap

Read-only, shareable bitmap optimized for multi-process usage:

Image decoding

LibGfx includes decoders for common image formats:

PNG

Full PNG support with transparency

JPEG

Baseline and progressive JPEG

GIF

Including animations

WebP

Lossy and lossless

BMP

Windows bitmap format

ICO

Windows icon format

Font rendering

Font system

LibGfx provides font loading and text rendering:

Text layout

Complex text shaping and layout:

Painting

LibGfx uses Skia for high-performance 2D rendering.

Painter interface

Painter provides the main drawing API:

Advanced painting

Painting operations are not thread-safe. Each painter instance must only be used from a single thread.

Paths and vector graphics

Path construction

Transformations

AffineTransform provides 2D matrix transformations:

Hardware acceleration

LibGfx supports multiple rendering backends:

Skia backend

Default high-performance backend using Skia:

Vulkan and Metal

Platform-specific GPU acceleration:
  • Vulkan: Cross-platform GPU rendering (VulkanContext)
  • Metal: macOS/iOS GPU rendering (MetalContext)
LibGfx automatically selects the best available rendering backend based on platform and hardware capabilities.

Filters and effects

Image filtering and effects:

System theme integration

Source location

  • Repository: ~/workspace/source/Libraries/LibGfx/
  • Key headers: Bitmap.h, Color.h, Painter.h, Rect.h, Point.h, Font.h
  • Image formats: LibGfx/ImageFormats/
  • Fonts: LibGfx/Font/
LibGfx is designed to be backend-agnostic. While it currently uses Skia as the primary rendering engine, the API abstracts the underlying implementation.