Optimizing Gridviews and Nineslices


I'm looking for advice on getting better performance when running multiple gridviews at the same time. I'm having significant framerate drops when two are on the screen at the same time. In particular, when both are using a nineslice background, there are serious drops of 20FPS or more when running on a device.

I did eventually figure out that I need to make a different nineslice object for each gridview-- trying to share the same nineslice between two gridviews made the situation much worse. But that alone isn't helping enough.

I have sprites being drawn/animated underneath the gridviews, and I am animating the positions of the gridviews themselves. As far as I can tell, I will need to draw them each frame.

Currently, each gridview only has 3 or 4 cells, and each cell has is 2-4 draw calls each. Is this too many?

I have tried making the gridviews smaller, but it only helps a little.

So far, I have been running everything at 50 FPS without any real issues. Are gridviews/nineslices inherently expensive to draw? If it's just that I will need to expect a lower framerate when using them, I suppose I can accept that. But it feels like I'm not asking too much of the hardware. Any thoughts?

EDIT: I should mention that I am aware of some performance issue with drawTextInRect(). I have significant framerate drops even without using this call.

Do you have a drawing/screen capture of what you want to do? Can not it be done with just one grid instead of two ?

It might be worthwhile implementing your own grid system. The Corelibs one is highly inefficient because it draws all the cells for every frame.

It would save a lot time drawing just the cells that changed for a given frame (because they got selected / deselected for example).

You would do this by keeping a bunch of cell-sized images in a table. On every frame, you draw the images for the cells as a whole, rather than all the elements of the cell. You redraw the cell image when needed.

Instead of building from scratch, you could modify the existing file. All the Corelibs are regular Lua files, located in the sdk installation folder

1 Like