Merge common parts of bitmap_surface and output_surface into rgba_surface
Only draw/clear dirty area of output_surface
Only flush cache of rgba_surface data when needed

Flushing cache after each draw isn't necessary and only costs performance.
Now cache gets flushed right before data is needed by hardware engines.
Ignore zero-sized surfaces in rgba_render_surface

This also avoids triggering a g2d driver bug.
Only clear rgba_surface if it won't get overwritten anyway
Link to -lm and -lX11

fixes #22
Fix missing reference frames in h264 decoder

When decoding doesn't start with a keyframe there would be
uninitialized surfaces in the reference list.
Fix h264 default reference picture list generation
Don't overwrite VideoSurface data while it is still needed for OutputSurface

We use hardware overlays instead of copying the VideoSurface to the
OutputSurface, so the VideoSurface must not be overwritten while it
is still used for an OutputSurface. This is now ensured by reference
counting and allocating new memory if the old is still in use, which
might not be the best way to solve this, but the performance impact
is negligible for now.