timcreatedit / scribble

Scribble is a lightweight library for freehand drawing in Flutter supporting pressure, variable line width and more!
https://pub.dev/packages/scribble
MIT License
115 stars 39 forks source link

Optimize editing performance #28

Closed Dampfwalze closed 1 year ago

Dampfwalze commented 1 year ago

I have separated the drawing logic of the editing controls from the sketch drawing logic:

The Problem was, that the sketch got drawn every time the editing controls changed. These include information about the active tool, etc. and the most hurting of them: The active line and the pointer position. Since these change every frame, the user is editing the sketch, the hole sketch gets rendered every frame, making the repaint boundary useless, that is introduced in the Scribble widget!

Note that the user will instantly notice very slight frame drops, when actively drawing, but does not, if the last frame, in which he takes up the pen, takes way longer, because the screen does not change in this time anyways. That is why we should make the frames, in which the user is drawing very very fast, and shove every big operation to the end of the interaction!