cairo: fixed corrupted drawing

Cherry-picked from upstream (fdo#61876). Also, added a few windows
related fixes.