Texture Renderer / Bitmap Caching

I’m trying to make a painting app that uses brushes but notice a massive performance decrease one the number of brush items crosses certain limit.  Is there a similar functionality like “CCRenderTexture” or bitmap caching as in AS3 that will treat the object group as a single image?

Cheers

You could use snapshot objects which essentially does that:

http://docs.coronalabs.com/tachyon/guide/graphics/snapshot.html

Already using them, I’m dynamically creating a snapshot for every brush stroke, but eventually it ends up with the same performance issue. Will try to remove all the objects without calling the invalidate method at the end of each stroke and will let you know how it goes.

Ah, yes, if you’re calling invalidate on every frame, then it will actually be slower to use snapshots (same problem that plagued bitmap caching in AS3).

When you invalidate right now, you are redrawing all strokes. but what you need is a way to accumulate strokes in the snapshot. Let me think about how we could add this to snapshots.

Also, we have not begun optimizing the engine, so that may make this whole issue go away.

Someone else brought up this issue earlier in the beta.

His suggestion (and I mention it here because it is a great idea!) is to add in a .noClear flag to the snapshot object or something equivalent, so that when you :invalidate() it, it doesn’t clear the area first.

Having said that, I got a solution working then, and in fact I intend to do a demo demonstrating exactly how to go about painting into snapshots (the only reason I won’t link to my previous solution is because it was buggy then and I believe it doesn’t work in the latest versions).

If you can wait a day or two, I’ll post some source up.

If you want to have a stab at it yourself though, the idea is to use 2 snapshot objects, toggling between them every update, with the previous snapshot’s image being the background to the ‘live’ snapshot. It is a form of double buffering that you can use for a great deal of effects (I use it to get motion blur in my racey demo, for example).

You could use snapshot objects which essentially does that:

http://docs.coronalabs.com/tachyon/guide/graphics/snapshot.html

Already using them, I’m dynamically creating a snapshot for every brush stroke, but eventually it ends up with the same performance issue. Will try to remove all the objects without calling the invalidate method at the end of each stroke and will let you know how it goes.

Ah, yes, if you’re calling invalidate on every frame, then it will actually be slower to use snapshots (same problem that plagued bitmap caching in AS3).

When you invalidate right now, you are redrawing all strokes. but what you need is a way to accumulate strokes in the snapshot. Let me think about how we could add this to snapshots.

Also, we have not begun optimizing the engine, so that may make this whole issue go away.

Someone else brought up this issue earlier in the beta.

His suggestion (and I mention it here because it is a great idea!) is to add in a .noClear flag to the snapshot object or something equivalent, so that when you :invalidate() it, it doesn’t clear the area first.

Having said that, I got a solution working then, and in fact I intend to do a demo demonstrating exactly how to go about painting into snapshots (the only reason I won’t link to my previous solution is because it was buggy then and I believe it doesn’t work in the latest versions).

If you can wait a day or two, I’ll post some source up.

If you want to have a stab at it yourself though, the idea is to use 2 snapshot objects, toggling between them every update, with the previous snapshot’s image being the background to the ‘live’ snapshot. It is a form of double buffering that you can use for a great deal of effects (I use it to get motion blur in my racey demo, for example).