summaryrefslogtreecommitdiff
path: root/src/cairo-xcb-connection-shm.c
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2010-12-04 16:36:28 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-12-25 09:50:34 +0000
commit109fcb39502239ff87c70cc99f2baea6e46b36a5 (patch)
tree1763e250a56c4ed126b4be27ff65c81c43568be8 /src/cairo-xcb-connection-shm.c
parentcf0a4ed862d93b7e6d7d26942cfe98a50beccd4c (diff)
XCB: Stop taking the xcb socket
This makes the xcb backend use the auto-generated xcb API instead of hand-writing each request. This should also improve parallelism with non-cairo threads that use the same xcb connection. Big thanks to Andrea Canciani for taking a look at this and finding lots of good improvements (especially finding xcb_send_request was great). cairo-perf-trace and cairo-perf-diff-files between master (6732dbf2992891be4b1f08b14a5c449fd08b637c) and this change: $ ./cairo-perf-diff-files ../master_perf ../xcb_no_socket_perf old: master_perf new: xcb_no_socket_perf Speedups ======== xcb-rgba evolution-0 23558.86 (23558.86 0.00%) -> 19338.78 (19338.78 0.00%): 1.22x speedup ▎ xcb-rgba poppler-bug-12266-0 98.43 (98.43 0.00%) -> 82.36 (82.36 0.00%): 1.20x speedup ▎ xcb-rgba gnome-terminal-vim-0 5518.08 (5518.08 0.00%) -> 4905.92 (4905.92 0.00%): 1.12x speedup ▏ xcb-rgba gnome-terminal-20090601-0 45648.46 (45648.46 0.00%) -> 41231.25 (41231.25 0.00%): 1.11x speedup ▏ xcb-rgba evolution-20090607-0 71643.69 (71643.69 0.00%) -> 66314.95 (66314.95 0.00%): 1.08x speedup ▏ xcb-rgba poppler-0 3501.69 (3501.69 0.00%) -> 3322.26 (3322.26 0.00%): 1.05x speedup Slowdowns ========= xcb-rgba gnome-system-monitor-0 7500.01 (7500.01 0.00%) -> 7923.70 (7923.70 0.00%): 1.06x slowdown xcb-rgba swfdec-youtube-full-0 26409.89 (26409.89 0.00%) -> 28430.76 (28430.76 0.00%): 1.08x slowdown ▏ xcb-rgba gnome-system-monitor-20090821-0 34801.61 (34801.61 0.00%) -> 37891.14 (37891.14 0.00%): 1.09x slowdown Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'src/cairo-xcb-connection-shm.c')
-rw-r--r--src/cairo-xcb-connection-shm.c105
1 files changed, 11 insertions, 94 deletions
diff --git a/src/cairo-xcb-connection-shm.c b/src/cairo-xcb-connection-shm.c
index 060a03e3..3e76301d 100644
--- a/src/cairo-xcb-connection-shm.c
+++ b/src/cairo-xcb-connection-shm.c
@@ -41,35 +41,12 @@ _cairo_xcb_connection_shm_attach (cairo_xcb_connection_t *connection,
uint32_t id,
cairo_bool_t readonly)
{
- struct {
- uint8_t req;
- uint8_t shm_req;
- uint16_t length;
- uint32_t segment;
- uint32_t id;
- uint8_t readonly;
- uint8_t pad1;
- uint16_t pad2;
- } req;
- struct iovec vec[1];
-
- COMPILE_TIME_ASSERT (sizeof (req) == 16);
-
- req.req = connection->shm->major_opcode;
- req.shm_req = 1;
- req.length = sizeof (req) >> 2;
- req.segment = _cairo_xcb_connection_get_xid (connection);
- req.id = id;
- req.readonly = readonly;
-
- vec[0].iov_base = &req;
- vec[0].iov_len = sizeof (req);
-
- _cairo_xcb_connection_write (connection, vec, 1);
- return req.segment;
+ uint32_t segment = _cairo_xcb_connection_get_xid (connection);
+ xcb_shm_attach (connection->xcb_connection, segment, id, readonly);
+ return segment;
}
-uint64_t
+unsigned int
_cairo_xcb_connection_shm_put_image (cairo_xcb_connection_t *connection,
xcb_drawable_t dst,
xcb_gcontext_t gc,
@@ -85,53 +62,11 @@ _cairo_xcb_connection_shm_put_image (cairo_xcb_connection_t *connection,
uint32_t shm,
uint32_t offset)
{
- struct {
- uint8_t req;
- uint8_t shm_req;
- uint16_t len;
- uint32_t dst;
- uint32_t gc;
- uint16_t total_width;
- uint16_t total_height;
- int16_t src_x;
- int16_t src_y;
- uint16_t src_width;
- uint16_t src_height;
- int16_t dst_x;
- int16_t dst_y;
- uint8_t depth;
- uint8_t format;
- uint8_t send_event;
- uint8_t pad;
- uint32_t shm;
- uint32_t offset;
- } req;
- struct iovec vec[2];
-
- req.req = connection->shm->major_opcode;
- req.shm_req = 3;
- req.len = sizeof (req) >> 2;
- req.dst = dst;
- req.gc = gc;
- req.total_width = total_width;
- req.total_height = total_height;
- req.src_x = src_x;
- req.src_y = src_y;
- req.src_width = width;
- req.src_height = height;
- req.dst_x = dst_x;
- req.dst_y = dst_y;
- req.depth = depth;
- req.format = XCB_IMAGE_FORMAT_Z_PIXMAP;
- req.send_event = 0;
- req.shm = shm;
- req.offset = offset;
-
- vec[0].iov_base = &req;
- vec[0].iov_len = sizeof (req);
-
- _cairo_xcb_connection_write (connection, vec, 1);
- return connection->seqno;
+ xcb_void_cookie_t cookie;
+ cookie = xcb_shm_put_image (connection->xcb_connection, dst, gc, total_width, total_height,
+ src_x, src_y, width, height, dst_x, dst_y, depth,
+ XCB_IMAGE_FORMAT_Z_PIXMAP, 0, shm, offset);
+ return cookie.sequence;
}
cairo_status_t
@@ -164,31 +99,13 @@ _cairo_xcb_connection_shm_get_image (cairo_xcb_connection_t *connection,
return _cairo_error (CAIRO_STATUS_READ_ERROR);
}
- return _cairo_xcb_connection_take_socket (connection);
+ return CAIRO_STATUS_SUCCESS;
}
void
_cairo_xcb_connection_shm_detach (cairo_xcb_connection_t *connection,
uint32_t segment)
{
- struct {
- uint8_t req;
- uint8_t shm_req;
- uint16_t length;
- uint32_t segment;
- } req;
- struct iovec vec[1];
-
- COMPILE_TIME_ASSERT (sizeof (req) == 8);
-
- req.req = connection->shm->major_opcode;
- req.shm_req = 2;
- req.length = sizeof (req) >> 2;
- req.segment = segment;
-
- vec[0].iov_base = &req;
- vec[0].iov_len = sizeof (req);
-
- _cairo_xcb_connection_write (connection, vec, 1);
+ xcb_shm_detach (connection->xcb_connection, segment);
_cairo_xcb_connection_put_xid (connection, segment);
}