backends: Make the SDL backend thread safe.
backends: Make the SDL backend thread safe.

The SDL_Flip, SDL_UpdateRect, SDL_Poll and SDL_Quit
are not thread safe. If these clash while running on
xserver, asynchronous communication is detected and
the connection is aborted. Fix that by guarding these
by a mutex.

gfxprim/gfxprim,gfxprim/gfxprim,gfxprim/gfxprim,gfxprim/gfxprim,gfxprim/gfxprim