Improve framerate of stabilizer
ClosedPublic

Authored by alvinhochun on Jul 6 2017, 5:50 PM.

Details

Summary
This change aims to improve the framerate of the stabilizer visual feedback.

- Perform delayed paint during `KisToolFreehandHelper::paint` (pointer event) and use a timer for backup.
- Removed the `stabilizerDelayedPaintInterval` config option.
- Added the `stabilizerDelayedPaint` config option for disabling the delayed painting,

Moved the paint code to be called during `KisToolFreehandHelper::paint` since this is how it's done for other smoothing methods and no smoothing. This shouldn't perform any worse than those. Removing the timer event dispatching might've caused some improvement too, but I haven't profiled for that.

Calling requestExplicitUpdateOutline during delayed paint is not needed anymore, but still needed during the timer. (It was needed because a delayed paint timer trigger can be after a pointer event, and not calling it would cause the outline to detach from the cursor if using a mouse.)

Diff Detail

Repository
R37 Krita
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
alvinhochun updated this revision to Diff 16281.EditedJul 7 2017, 7:10 AM
alvinhochun edited the summary of this revision. (Show Details)

Updated the diff to remove the delayed paint timer completely. Will still need to change the config options, but function-wise it is ready for testing.

alvinhochun edited the summary of this revision. (Show Details)Jul 7 2017, 7:18 AM

Hold on a second... I didn't think this through.

There still has to be something to trigger the delayed painting after pointer events, because if the mouse doesn't move, the delayed painting and brush outline would be pause at an earlier state.

alvinhochun planned changes to this revision.Jul 7 2017, 11:03 AM
alvinhochun updated this revision to Diff 16304.Jul 7 2017, 1:48 PM
alvinhochun edited the summary of this revision. (Show Details)
  • Reverted the stabilizer event sampling back to Qt::CoarseTimer.
  • Reverted to call requestExplicitUpdateOutline again.

TODO: Replace the stabilizerDelayedPaintInterval config with another.

alvinhochun updated this revision to Diff 16308.Jul 7 2017, 2:41 PM
alvinhochun edited the summary of this revision. (Show Details)

Removed the config stabilizerDelayedPaintInterval. Replaced with stabilizerDelayedPaint, true (default) to enable stabilizer delayed painting, false to disable (I don't think anyone would need this to be disabled).

alvinhochun retitled this revision from Refactor KisStabilizerDelayedPaintHelper and adjust code flow to Improve framerate of stabilizer.Jul 7 2017, 2:54 PM
alvinhochun edited the summary of this revision. (Show Details)

From the IRC log:

11:42 < dmitryK|log> windragon: so the plan is: 1) remove QBasicTimer; 2) Add a comment that the call in freehand helper is just a "tricky" source of stable time events for every 7ms, 3) don't restart the 20ms timer every time.
libs/ui/kis_config.h
501

return value should also be bool

alvinhochun updated this revision to Diff 16376.Jul 9 2017, 9:48 AM
alvinhochun edited the summary of this revision. (Show Details)

Need to add a time check during the timer event. If I don't do this I get weird visual stuttering.

alvinhochun marked an inline comment as done.Jul 9 2017, 11:01 AM
dkazakov accepted this revision.Jul 10 2017, 8:46 AM

Hi, @alvinhochun!

The patch looks perfect now! :)

This revision is now accepted and ready to land.Jul 10 2017, 8:46 AM
This revision was automatically updated to reflect the committed changes.