pastello-app

0005. In-house drawing engine with raster cache

Context

The drawing engine is the heart of Pastello. It must render the vector document model (ADR 0004), including per-stroke erasures and the lasso Select tool, at the display’s full frame rate (90 Hz on the reference Redmi Pad 2) with hundreds or thousands of strokes. Ready-made “drawing board” packages impose their own data model and depend on external maintainers.

Decision

The drawing engine is developed and owned by this project, on top of Flutter’s CustomPainter. This is not negotiable: if performance problems appear, we optimize our engine rather than switching to a third-party package.

Planned optimizations, if needed

  1. Incremental cache updates: paint a new stroke on top of the existing image.
  2. Point simplification when a stroke ends (e.g. Ramer–Douglas–Peucker).
  3. Tiled cache: repaint only the region that changed.
  4. Periodic cache snapshots for instant undo/redo.
  5. Serialization and saving in a separate isolate.

Lessons from the prototype

Consequences

Alternatives considered