Should I create new Pens/Brushes per Paint request or keep them throughout the application lifecycle?

后端 未结 5 2179
北海茫月
北海茫月 2021-02-19 02:33

I have an application that does a lot of drawing, let\'s pretend it\'s a Viso-like application. It has objects that have multiple sub-objects that are drawn, things can

5条回答
  •  臣服心动
    2021-02-19 03:26

    Reusing the same Pen and Brush in operations that will require it many times over is going to be a lot faster than disposing of them each time with using.

    I would say for sure that it's a good idea to reuse these as much as possible (and I've seen code comparisons before, but I can't source them right now) but do remember to dispose of them when you are truly finished with them.

提交回复
热议问题