I have been doing research on what the best way to achieve undo/redo functionality is for a painting app. I am using OpenGL ES 2.0 on iOS. The most popular approach seems to be to save a list of commands and VBOs to re-generate the painting to its previous state (Memento design structure). The other approach is to take graphical snapshots after each drawing action and revert to these snapshots on undo.
I have a problem with both approaches:
1) Memento - after a long list of actions, especially computationally intensive flood fill algorithms, the undo/redo functionally will get very slow and intensive.
2) Snapshots - after a long list of actions these snapshot will start to take up a lot of memory, especially if in raw state.
I was wondering if anybody has found a solution that works well for this situation, or perhaps somebody here has an idea how to optimize the above approaches.
Thanks.
I have decided to try a hybrid approach, where I save a bitmap snapshot every 10-15 actions, and use command lines to restore individual actions past the snapshots. A more in depth answer is offered here: https://stackoverflow.com/a/3944758/2303367