The code in Blender changed a bit since last update by @Fabio Russo (ruesp83), and more work needs to done to port the patch to a usable state. Mainly, the image cache system was reworked as per rBce893552c359d11cfa93709f239a3c93f4cdb244 and this here patch should align with it.
Some quick notes:
- IMB_imbuf_types.h was moved to the DNA, I reverted the change. Apparently this was to be able to read/write the layers' imbufs from/to the blender file (which feels wrong to me, judging from other code)
- some logic here and there (e.g. getting the current layer) could be improved/simplified
- a fair amount of syle issues (naming convention essentially)
- the patch could be split up: e.g. one for the layer system, and one or two for the extra image filters/tools that it brings