[RFC weston 05/14] compositor-drm: Refactor code into cursor_bo_update()
Pekka Paalanen
ppaalanen at gmail.com
Thu May 21 02:14:45 PDT 2015
On Thu, 21 May 2015 08:29:02 +0100
Daniel Stone <daniels at collabora.com> wrote:
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
>
> Cut a chunk of code out from drm_output_set_cursor() and form a new
> function for writing a cursor bo data from a weston_view with a wl_shm
> buffer.
>
> Add more asserts to verify the assumptions in there.
>
> Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> ---
> src/compositor-drm.c | 46 +++++++++++++++++++++++++++++++---------------
> 1 file changed, 31 insertions(+), 15 deletions(-)
>
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index d47bbd9..038bafc 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -1016,17 +1016,43 @@ drm_output_prepare_cursor_view(struct drm_output *output,
> }
>
> static void
> +cursor_bo_update(struct gbm_bo *bo, struct weston_view *ev)
> +{
> + struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
> + uint32_t buf[64 * 64];
> + int32_t stride;
> + uint8_t *s;
> + int i;
> +
> + assert(buffer && buffer->shm_buffer);
> + assert(buffer->shm_buffer == wl_shm_buffer_get(buffer->resource));
> + assert(ev->surface->width <= 64);
> + assert(ev->surface->height <= 64);
> +
> + memset(buf, 0, sizeof buf);
> + stride = wl_shm_buffer_get_stride(buffer->shm_buffer);
> + s = wl_shm_buffer_get_data(buffer->shm_buffer);
> +
> + wl_shm_buffer_begin_access(buffer->shm_buffer);
> + for (i = 0; i < ev->surface->height; i++)
> + memcpy(buf + i * 64, s + i * stride,
> + ev->surface->width * 4);
> + wl_shm_buffer_end_access(buffer->shm_buffer);
> +
> + if (gbm_bo_write(bo, buf, sizeof buf) < 0)
> + weston_log("failed update cursor: %m\n");
> +}
This is no longer good as is, the code below was using cursor_width
and cursor_height introduced in
http://cgit.freedesktop.org/wayland/weston/commit/?id=dce7c6e5a2fb2e639e1e96ec0eaaf0f6551bc7b6
Thanks,
pq
> +
> +static void
> drm_output_set_cursor(struct drm_output *output)
> {
> struct weston_view *ev = output->cursor_view;
> struct weston_buffer *buffer;
> struct drm_compositor *c =
> (struct drm_compositor *) output->base.compositor;
> - EGLint handle, stride;
> + EGLint handle;
> struct gbm_bo *bo;
> - uint32_t buf[c->cursor_width * c->cursor_height];
> - unsigned char *s;
> - int i, x, y;
> + int x, y;
>
> output->cursor_view = NULL;
> if (ev == NULL) {
> @@ -1042,18 +1068,8 @@ drm_output_set_cursor(struct drm_output *output)
> pixman_region32_init(&output->cursor_plane.damage);
> output->current_cursor ^= 1;
> bo = output->cursor_bo[output->current_cursor];
> - memset(buf, 0, sizeof buf);
> - stride = wl_shm_buffer_get_stride(buffer->shm_buffer);
> - s = wl_shm_buffer_get_data(buffer->shm_buffer);
> - wl_shm_buffer_begin_access(buffer->shm_buffer);
> - for (i = 0; i < ev->surface->height; i++)
> - memcpy(buf + i * c->cursor_width, s + i * stride,
> - ev->surface->width * 4);
> - wl_shm_buffer_end_access(buffer->shm_buffer);
> -
> - if (gbm_bo_write(bo, buf, sizeof buf) < 0)
> - weston_log("failed update cursor: %m\n");
>
> + cursor_bo_update(bo, ev);
> handle = gbm_bo_get_handle(bo).s32;
> if (drmModeSetCursor(c->drm.fd, output->crtc_id, handle,
> c->cursor_width, c->cursor_height)) {
More information about the wayland-devel
mailing list