What graphics library are you using? If it supports alpha channels why not just draw the layers one over another using it? Layers are much like an undo stack otherwise. Each new action needs to be drawn and every change in the stack prompts a redraw.
There are things known (in
Qt) as Composition modes. Based on how the layers are to be ordered, you set the composition modes appropriately and draw the stack over the destination image area. The
QPainter class does this very well.
You can see an example here:
http://doc.trolltech.com/qq/qq17-compositionmodes.html
I don't know the low level implementation of this, if thats what you are asking.