Split out backend-specific part to one function.
Make cairo dependency optional.
Kill dead code.