Listen

Description

This detailed document explains the central painting method in the Blink rendering engine, PaintLayerPainter::Paint, which is responsible for generating visual output for stacking contexts. Historically part of the RenderLayer system, the function was overhauled by the Composite After Paint (CAP) architecture to transition from individual layer painting to recording a single, unified list of display commands called the Paint Artifact. The core routine orchestrates painting according to the strict CSS painting order, managing backgrounds, z-indexed children, and layer content across potentially fragmented layout outputs. Key performance relies heavily on CullRects to restrict drawing to damaged regions and subsequence caching to avoid repainting unchanged content. Furthermore, the painter integrates with pre-calculated Paint Property Trees to associate drawing commands with the correct transform, clip, and effect states for subsequent layer creation. This process converts Blink’s layout geometry into GPU-ready drawing chunks for the final compositing stage.