PaintingContext class

A place to paint.

Rather than holding a canvas directly, RenderObjects paint using a painting
context. The painting context has a Canvas, which receives the
individual draw operations, and also has functions for painting child
render objects.

When painting a child render object, the canvas held by the painting context
can change because the draw operations issued before and after painting the
child might be recorded in separate compositing layers. For this reason, do
not hold a reference to the canvas across operations that might paint
child render objects.

Appends the given layer to the recording, and calls the painter callback
with that layer, providing the childPaintBounds as the estimated paint
bounds of the child. The childPaintBounds can be used for debugging but
have no effect on painting. [...]