liveBook · Manning

Paint layer

As explained in CSS in Depth, Second Edition

A paint layer is an independently rendered layer containing painted portions of a page.

A paint layer is a separately rendered portion of a page created during the paint stage of the rendering pipeline. Painting fills pixels with text, images, borders, shadows, and backgrounds after layout has determined element positions and sizes. section 16.3.1

Use the rendering pipeline to reason about paint layers:

  • Changing a background color usually requires repainting but not layout recalculation, because it does not change element size or position. section 16.3.1
  • Under suitable conditions, an element can be promoted to its own layer and rendered separately, potentially using the GPU. section 16.3.1
  • Additional layers may speed rendering but consume more memory; the browser later combines painted layers during compositing. section 16.3.1
Figure 16.12 The three stages of the rendering pipeline
figure

Follow the pipeline from layout through painting and compositing to see where paint layers fit. section 16.3.1

How CSS in Depth, Second Edition covers it

How deep it goes
Traces painting, layer promotion, GPU rendering, memory trade-offs, and compositing without detailing promotion rules.
Examples
Uses background-color changes and independently promoted elements to contrast repainting, layout work, and layer rendering.
What it assumes
Assumes familiarity with page elements and teaches the layout-to-paint-to-composite sequence directly.
What you can do after
Diagnose rendering costs by distinguishing layout changes, repainting, layer rendering, and compositing.
How it connects
Links paint layers to layout, reflow, repainting, compositing, opacity, transforms, and GPU rendering.

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.