Search guides and the APICtrl K
  1. API reference
  2. Native GUI

gfx/paint_diagnostics.h

ComponentPaintDiagnostics: how long each component takes to paint, and where the repaints land.

#include <sonore/gfx/paint_diagnostics.h>
On this page

Design notes

Why a plugin wants this, and when

An editor that stutters while a meter animates is almost always one of two things: a component whose paint() is far more expensive than it looks (a gradient per pixel, a path rebuilt every frame), or a repaint that covers far more than it should (a meter whose repaint() marks the whole editor). The first is a number per component; the second is a picture. This gives both, from the running editor, without a profiler.

How it hooks in

Through ComponentPaintObserver in component.h: one pointer, null unless this is installed, tested once per component per paint. Installing it is a debugging decision -- it reads a clock twice per component painted -- and nothing in the SDK installs one.

The flash

With flashing on, every region the window repaints is covered, after the tree has painted, with a translucent colour that changes every frame. A region that stays one colour across frames was not repainted; a region that keeps changing colour is being repainted, whether or not anything in it moved -- which is the bug this exists to find.

The clock is injectable, as everywhere else in this SDK, so the accounting is an exact test rather than a measurement of the machine.

Types 1

class ComponentPaintDiagnostics : public ComponentPaintObserver

Paint timings per component, and a flash over every repainted region -- a debugging aid, off unless install() is called. The file comment says what each finds and how it hooks in.

install() makes it THE observer for every paint in the process (a second install replaces the first) until uninstall() or destruction. It is called from inside painting, so it is used, read and reset on the message thread. Timing is on by default once installed; the flash is off until setFlashRepaints(true).

↑↓ to move↵ to openEvery public name in the headers, and every guide