gl: check a surface->device first before checking others

a surface's device is NULL indicates the surface is not a true GL surface.
Instead, it is casted from _source_to_pattern ().