Adds a mask layer of the specified type if not already present, or increments its reference count if it is. This function should be called from the main thread if it involves UI/map updates.