在Penultimate和iDraft等绘画应用程序中撤消操作 [英] Undo in painting apps like Penultimate and iDraft

查看:110
本文介绍了在Penultimate和iDraft等绘画应用程序中撤消操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iDraft和Penultimate等应用中,它们执行撤消和重做的性能非常好,没有任何延迟.

In apps like iDraft and Penultimate, they perform undos and redos very well without any delay.

我尝试了许多方法.目前,我的测试应用在每次撤消后都使用[NSData writeToFile:atomically:]将原始像素数据直接写到文件中,但是我得到了0.6s的延迟.

I tried many approaches. Currently, my testing app writes raw pixel data directly to a file after each undo using [NSData writeToFile:atomically:] but I am getting 0.6s delay.

有人可以给它一些提示吗?

Can anyone give some hints on it?

推荐答案

将撤消堆栈保留在内存中.不要为每个操作写入磁盘.无论您是位图还是矢量,文件操作都不应该在每次绘制操作的关键路径上.

Keep your undo stack in memory. Don't write to disk for every operation. Whether you keep around bitmaps or vectors, your file ops shouldn't be on the critical path for every paint operation you do.

如果您的数据模型是完整的位图,则仅保留更改后的矩形以进行撤消/重做.

If your data model is full bitmaps, keep just the changed rect for undo/redo.

这篇关于在Penultimate和iDraft等绘画应用程序中撤消操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆