When drawing in heavy files, there is a great lag since the previous stroke is completed before the system is able to receive new inputs.
In 2D, it is very common to draw a succession of strokes to have more gesture in the drawing. The current lag breaks that dynamic and affects artistic creation very negatively, since the system is unable to capture the artist's gesture.
The actual design is based on using the evaluated data in the draw engine, and the original data is used for the paint operator.
{F10765270}
As the geometry changes during the drawing process, copying the original data to evaluated data was very slow, so the current stroke buffer is updated manually to the runtime area of evaluated data avoiding any depsgraph tag.
When the paint operator ends, the original data is tagged in order to update evaluated data to make the new stroke visible in the draw engine. The current buffer is cleared also and ready for the next stroke.
Doing some test with very heavy files, the time to copy the full datablock is the following:
Test File: https://www.dropbox.com/s/0v2nb82zoedac9d/heavy_test_file.blend?dl=0
Note: Times recorded in debug mode using a Intel i9-9900K 32GB memory and NVIDIA RTX2080TI
```time start(deg_expand_copy_on_write_datablock)
Expanding datablock for GDMono_Datablock: id_orig=00000209ADB31EB8 id_cow=000002098322D9C8
time start(greasepencil_copy_data)
time end(greasepencil_copy_data): 0.569794
Remapping ID links for GDMono_Datablock: id_orig=00000209ADB31EB8 id_cow=000002098322D9C8
Remapping datablock for MARaw.001: id_orig=00000209C8E92B68 id_cow=00000209FF8FE9E8
Remapping datablock for MARaw: id_orig=00000209C8E924A8 id_cow=00000209FF8FB748
Remapping datablock for MAMaterial: id_orig=00000209C8E929B8 id_cow=00000209FF8FC4C8
time end(deg_expand_copy_on_write_datablock): 0.586778
time start(deg_expand_copy_on_write_datablock)
Expanding datablock for OBMono: id_orig=00000209C8121668 id_cow=000002098396C478
Remapping ID links for OBMono: id_orig=00000209C8121668 id_cow=000002098396C478
Remapping datablock for GDMono_Datablock: id_orig=00000209ADB31EB8 id_cow=000002098322D9C8
Remapping datablock for OBpeg: id_orig=00000209C81284D8 id_cow=0000020983966778
time start(BKE_gpencil_update_orig_pointers)
time end(BKE_gpencil_update_orig_pointers): 0.103322
time end(deg_expand_copy_on_write_datablock): 0.116978```
Total time is: 0.586778 + 0.116978, but checking the system there is still a delay of more than a second after this before the event system is available to receive new inputs.
This video shows that operator is completed and the cursor is set to change, but the cursor needs more than 2 seconds to back.
{F10765165}
If we try to draw before the cursor is restarted, the event is not captured as is showed in the next video.
{F10765179}
Capture the drawing events in the same stroke is not a problem because the eval data is updated directly without depsgraph evaluation.
{F10765248}
Possible solutions:
* Be able to tag only a layer or frame of grease pencil datablock to avoid the full copy of the datablock.
* Reduce the lag after the finish of the operator and make event system able to receive the new events.