Forums > Dev

Creating Layers in JGraphics

November 9, 2009 | 11:40 pm

Hi there,

in what situation and what are the benefits of using layers when drawing an UI object?
I see at the end of the jgraphics.h file there are five functions defined:
jbox_invalidate_layer()
jbox_remove_layer()
jbox_start_layer()
jbox_end_layer()
jbox_paint_layer()

I understand that in situation when you want the same drawing tiled or repeated over and over layers are the way to go, but what does JGraphics do under the hood? Is it all transformed in a surface and then only the actual pixels of the surface are copied over and over ? I can see this being more efficient… But would layers be useful in situation other than tiling or repeating ? (i.e. for instance for drawing a button when you can have a "Button On" and a "Button Off" layer and alternate between the two? In this case I don’t see any performance gains, but are there other gains I cannot see?

This question arose from looking at the source code of the ICST objects which make frequent use of layers.

As far as I am concerned I always just create the old plain graphic context and then do all the drawing in there, but I was wondering if maybe the layer strategy is a better one.

Thanks for any comment, clarification, advice.

- Luigi


November 13, 2009 | 5:02 pm

The reason for layers in the ambimonitor external is that it prevents having to redraw static parts of the surface every time a redraw occurs — so it is much more efficient.


Viewing 2 posts - 1 through 2 (of 2 total)