Relatively basic and straightforward implementation.
Further optimizations are possible (and needed), especially regarding
the handling of caches.
Notes:
* All drawings are stored in each undo step. This is needed (also for
Reference drawings), in case some drawings are added, removed or
re-ordered between undo steps.
* The whole tree of layers is copied as-is, using the C++ classes copy
constructors, so they only handle what these constructors copy
(noticeably, the `Layer` copy constructor does not currently handles
masks?).
* The active layer pointer is stored and restored by its name.
* The layer customdata is also duplicated using standard `BKE_customdata`
API.
Pull Request: https://projects.blender.org/blender/blender/pulls/117072