Re: [PATCH 2/2] xcb: Use SHM FD-passing if possible

Chris Wilson <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Quoting Alexander Volkov (2018-04-06 13:33:37)
> +    if (connection->flags & CAIRO_XCB_HAS_SHM_FD) {
> +       xcb_shm_create_segment_cookie_t cookie;
> +       xcb_shm_create_segment_reply_t *reply;
> +       xcb_generic_error_t *error;
> +       int *fds;
> +       int err;
> +
> +       if (unlikely (size > UINT32_MAX))
> +           return CAIRO_STATUS_NO_MEMORY;

That's not the protocol limit, surely? It may well be, just a bit
surprising if it was.

> +       shm->shmseg = _cairo_xcb_connection_get_xid (connection);
> +       cookie = xcb_shm_create_segment (connection->xcb_connection, shm->shmseg, size, FALSE);
> +       reply = xcb_shm_create_segment_reply (connection->xcb_connection, cookie, &error);
> +       if (error) {
> +           free (error);
> +           _cairo_xcb_connection_put_xid (connection, shm->shmseg);
> +           return CAIRO_INT_STATUS_UNSUPPORTED;
> +       }
> +
> +       fds = xcb_shm_create_segment_reply_fds (connection->xcb_connection, reply);
> +       if (reply->nfd != 1) {
> +           for (int i = 0; i < reply->nfd; i++)
> +               close (fds[i]);
> +
> +           free (reply);
> +           xcb_shm_detach (connection->xcb_connection, shm->shmseg);
> +           _cairo_xcb_connection_put_xid (connection, shm->shmseg);
> +           return CAIRO_INT_STATUS_UNSUPPORTED;
> +       }
> +
> +       shm->shm = mmap (NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fds[0], 0);

A roundtrip on allocation. That doesn't seem like something we would want
in a frequent path? And creating temporary surfaces is frequent enough.
That would suggest to me that we want an allocation cache... And packing
into a larger object?
-Chris
-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.