The ro_anonymous_file is a abstraction around anonymous read-only files. os_create_ro_anonymous_file creates such a file with the contents passed in data. Subsequent calls to os_ro_anonymous_file_get_ref get a reference to a fd that's ready to be send over the socket. If support_shared is not set the socket is only guaranteed to be mmap-able readonly with MAP_PRIVATE but does not require duplicating the file for each resource when memfd_create is available.
Having to duplicate the files all the time might become a problem with the color management work I'm doing. Feedback appreciated.