forget worrying about if mat is thread safe, just do the floodfill
linearly