Make drm_output_set_cursor more deterministic, by calculating more state
and performing more plane manipulation, inside
drm_output_prepare_cursor_view.

Differential Revision: https://phabricator.freedesktop.org/D1485

Signed-off-by: Daniel Stone <dani...@collabora.com>
---
 libweston/compositor-drm.c | 39 ++++++++++++++++-----------------------
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index e22d792..3276ed0 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -1135,6 +1135,7 @@ drm_output_prepare_cursor_view(struct drm_output *output,
        struct drm_backend *b = to_drm_backend(output->base.compositor);
        struct weston_buffer_viewport *viewport = &ev->surface->buffer_viewport;
        struct wl_shm_buffer *shmbuf;
+       float x, y;
 
        if (b->cursors_are_broken)
                return NULL;
@@ -1173,6 +1174,9 @@ drm_output_prepare_cursor_view(struct drm_output *output,
                return NULL;
 
        output->cursor_view = ev;
+       weston_view_to_global_float(ev, 0, 0, &x, &y);
+       output->cursor_plane.x = x;
+       output->cursor_plane.y = y;
 
        return &output->cursor_plane;
 }
@@ -1218,24 +1222,17 @@ static void
 drm_output_set_cursor(struct drm_output *output)
 {
        struct weston_view *ev = output->cursor_view;
-       struct weston_buffer *buffer;
        struct drm_backend *b = to_drm_backend(output->base.compositor);
        EGLint handle;
        struct gbm_bo *bo;
        float x, y;
 
-       output->cursor_view = NULL;
        if (ev == NULL) {
                drmModeSetCursor(b->drm.fd, output->crtc_id, 0, 0, 0);
-               output->cursor_plane.x = INT32_MIN;
-               output->cursor_plane.y = INT32_MIN;
                return;
        }
 
-       buffer = ev->surface->buffer_ref.buffer;
-
-       if (buffer &&
-           pixman_region32_not_empty(&output->cursor_plane.damage)) {
+       if (pixman_region32_not_empty(&output->cursor_plane.damage)) {
                pixman_region32_fini(&output->cursor_plane.damage);
                pixman_region32_init(&output->cursor_plane.damage);
                output->current_cursor ^= 1;
@@ -1250,22 +1247,14 @@ drm_output_set_cursor(struct drm_output *output)
                }
        }
 
-       weston_view_to_global_float(ev, 0, 0, &x, &y);
-
-       /* From global to output space, output transform is guaranteed to be
-        * NORMAL by drm_output_prepare_cursor_view().
-        */
-       x = (x - output->base.x) * output->base.current_scale;
-       y = (y - output->base.y) * output->base.current_scale;
+       x = (output->cursor_plane.x - output->base.x) *
+               output->base.current_scale;
+       y = (output->cursor_plane.y - output->base.y) *
+               output->base.current_scale;
 
-       if (output->cursor_plane.x != x || output->cursor_plane.y != y) {
-               if (drmModeMoveCursor(b->drm.fd, output->crtc_id, x, y)) {
-                       weston_log("failed to move cursor: %m\n");
-                       b->cursors_are_broken = 1;
-               }
-
-               output->cursor_plane.x = x;
-               output->cursor_plane.y = y;
+       if (drmModeMoveCursor(b->drm.fd, output->crtc_id, x, y)) {
+               weston_log("failed to move cursor: %m\n");
+               b->cursors_are_broken = 1;
        }
 }
 
@@ -1294,6 +1283,10 @@ drm_assign_planes(struct weston_output *output_base)
        pixman_region32_init(&overlap);
        primary = &output_base->compositor->primary_plane;
 
+       output->cursor_view = NULL;
+       output->cursor_plane.x = INT32_MIN;
+       output->cursor_plane.y = INT32_MIN;
+
        wl_list_for_each_safe(ev, next, &output_base->compositor->view_list, 
link) {
                struct weston_surface *es = ev->surface;
 
-- 
2.9.3

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to