compositor-drm: Only update hw cursor contents when it changes

We avoid the memcpy, gbm_bo_write and the drmModeSetCursor ioctl per frame.
dev
Kristian Høgsberg 13 years ago
parent 24e4275c30
commit 1f5de35482
  1. 33
      src/compositor-drm.c

@ -685,21 +685,26 @@ drm_output_set_cursor(struct weston_output *output_base,
es->geometry.width > 64 || es->geometry.height > 64) es->geometry.width > 64 || es->geometry.height > 64)
return; return;
output->current_cursor ^= 1; if (es->buffer && pixman_region32_not_empty(&es->damage)) {
bo = output->cursor_bo[output->current_cursor]; output->current_cursor ^= 1;
memset(buf, 0, sizeof buf); bo = output->cursor_bo[output->current_cursor];
stride = wl_shm_buffer_get_stride(es->buffer); memset(buf, 0, sizeof buf);
s = wl_shm_buffer_get_data(es->buffer); stride = wl_shm_buffer_get_stride(es->buffer);
for (i = 0; i < es->geometry.height; i++) s = wl_shm_buffer_get_data(es->buffer);
memcpy(buf + i * 64, s + i * stride, es->geometry.width * 4); for (i = 0; i < es->geometry.height; i++)
memcpy(buf + i * 64, s + i * stride,
if (gbm_bo_write(bo, buf, sizeof buf) < 0) es->geometry.width * 4);
return;
weston_log("bo_write now\n");
if (gbm_bo_write(bo, buf, sizeof buf) < 0)
return;
handle = gbm_bo_get_handle(bo).s32; handle = gbm_bo_get_handle(bo).s32;
if (drmModeSetCursor(c->drm.fd, output->crtc_id, handle, 64, 64)) { if (drmModeSetCursor(c->drm.fd,
weston_log("failed to set cursor: %n\n"); output->crtc_id, handle, 64, 64)) {
return; weston_log("failed to set cursor: %n\n");
return;
}
} }
x = es->geometry.x - output->base.x; x = es->geometry.x - output->base.x;

Loading…
Cancel
Save