The SVG painting process

Main classes involved (in a somewhat "chronological" order):

Painting to screen

The journey begins

The paint is (regularly) initiated by a call to SVGImage::PaintToScreen [PTS] (from SVGContent::Paint). The SVGImage reference has been acquired through a call to the global SVGManager object. PTS does little besides dispatching the render operation further down the line, and handling the actual painting of the result on the visual device.

The paint call proceeds by:

The above is the flow unless there is a rendering job currently in-progress. In that case, the current paint area is queued, and will be submitted after the current job has finished.

Painting traversal

The SVGRenderer class is tasked with keeping track of what parts of the SVG that has an up-to-date state. This is achieved through the use of a region data structure (OpRegion), which represents the (total) area covered by a number of rectangles. When updating renderstate (in SVGRenderer::Update), the region is used together with the area of interest, that was passed into the SVGRenderer through the Setup-call, to determine what parts of the SVGCanvas that needs to be updated. A scheme is used that results in 1 to 4 rectangular areas. Each one of these areas are updated through a call to SVGRenderer::UpdateSingleRect [internal].

SVGRenderer::UpdateSingleRect sets up a SVGTraverser in an appropriate manner for the rectangle specified, and traverses the tree.

Painting to a buffer (intermediate)

The process described above mostly applies to the case where the results end up on the visual device. There are however another case worth mentioning - painting to an intermediate surface (currently used for cases such as CSS background-image / list-item, Save as (PNG) and svgtest).

The painting of an SVG to an intermediate buffer is achieved through a call to the SVGImage::PaintToBuffer-method. This call does things similar in nature to a PTS -> SVGRenderer::Update chain, but makes sure that any current renderstate is destroyed. It also has provisions for handling the setting of specific dimensions and animation times.