Paint & Rasterization
Paint does not draw pixels directly; it records ordered vector instructions (DisplayItem lists) on the main thread. Rasterization then splits layers into bitmap tiles and fills those pixels on worker threads or the GPU before compositing.
From DisplayItems to GPU Bitmap Tiles
Follow how vector paint commands become tiled GPU textures.
Main thread walks the box tree in stacking order and emits DisplayItems (fillRect, drawText, clip).
.card { background: #111; box-shadow: 0 8px 24px #0006; }- displayItems
- 24
- mainThreadMs
- 1.8
- pixelsDrawnYet
- 0
Under the Hood
Paint is an architect drafting blueprints; Rasterization is the print shop turning those blueprints into tiled posters.
- DisplayList Recording: The engine traverses boxes by CSS Stacking Context order and appends draw calls (backgrounds, borders, text glyphs).
- Tile Splitting: Layers are divided into square tiles so the engine only rasterizes regions near the viewport.
- Raster & Upload: Skia or GPU shaders fill tile bitmaps and upload them as textures for GPU Compositor Layers.
/* Triggers Paint only (skips Layout) when color changes */
.status-badge {
background-color: #16a34a;
contain: paint; /* Clips descendants and isolates invalidation */
}
/* Heavy blur multiplies rasterization time per tile */
.expensive-frost { backdrop-filter: blur(24px); }Problem Genealogy
- 2008–2013: Single-threaded software painting forced the main thread to rasterize every pixel synchronously, stalling input during scrolls.
- 2014+ (Impl-side Painting): Browsers decoupled DisplayList recording on the main thread from multi-threaded / GPU tile rasterization.
Production Pitfalls
- Giant
box-shadowandfilter: blur(): Large blur radii expand paint invalidation rects and force multi-pass shader sampling per tile. - Animating
background-coloron huge containers: Even without Layout, repaints re-rasterize every covered tile on each frame.
- When not to use heavy paint effects: Avoid animating
box-shadow,border-radius, orbackdrop-filterat 60fps; animateopacityon a pre-rendered pseudo-element instead.
Connections & Logical Next Steps
Paint containment clips descendants and bounds DisplayItem invalidation rects.
Rasterization maps floating-point CSS layout coordinates onto discrete physical device pixels.
View transitions capture rasterized GPU snapshots of old and new element states.
Paint requires resolved box coordinates from Layout to record drawing bounds.
Rasterized tiles are uploaded as GPU textures for the Compositor Thread.
Interpolated @property values drive smooth gradient and color repaints across frames.