From: Kristian Høgsberg Date: Wed, 18 Jul 2012 16:09:58 +0000 (-0400) Subject: compositor-drm: Only update hw cursor contents when it changes X-Git-Tag: 0.95.0~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f5de35482ea1b416a054273fd7319c0ed66f928;p=profile%2Fivi%2Fweston.git compositor-drm: Only update hw cursor contents when it changes We avoid the memcpy, gbm_bo_write and the drmModeSetCursor ioctl per frame. --- diff --git a/src/compositor-drm.c b/src/compositor-drm.c index ada4a03..7cec446 100644 --- a/src/compositor-drm.c +++ b/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) return; - output->current_cursor ^= 1; - bo = output->cursor_bo[output->current_cursor]; - memset(buf, 0, sizeof buf); - stride = wl_shm_buffer_get_stride(es->buffer); - s = wl_shm_buffer_get_data(es->buffer); - for (i = 0; i < es->geometry.height; i++) - memcpy(buf + i * 64, s + i * stride, es->geometry.width * 4); - - if (gbm_bo_write(bo, buf, sizeof buf) < 0) - return; + if (es->buffer && pixman_region32_not_empty(&es->damage)) { + output->current_cursor ^= 1; + bo = output->cursor_bo[output->current_cursor]; + memset(buf, 0, sizeof buf); + stride = wl_shm_buffer_get_stride(es->buffer); + s = wl_shm_buffer_get_data(es->buffer); + for (i = 0; i < es->geometry.height; i++) + memcpy(buf + i * 64, s + i * stride, + es->geometry.width * 4); + + weston_log("bo_write now\n"); + if (gbm_bo_write(bo, buf, sizeof buf) < 0) + return; - handle = gbm_bo_get_handle(bo).s32; - if (drmModeSetCursor(c->drm.fd, output->crtc_id, handle, 64, 64)) { - weston_log("failed to set cursor: %n\n"); - return; + handle = gbm_bo_get_handle(bo).s32; + if (drmModeSetCursor(c->drm.fd, + output->crtc_id, handle, 64, 64)) { + weston_log("failed to set cursor: %n\n"); + return; + } } x = es->geometry.x - output->base.x;