[PATCH weston v10 03/61] compositor-drm: Calculate more cursor state up front
Daniel Stone
daniels at collabora.com
Tue Apr 4 16:54:21 UTC 2017
Make drm_output_set_cursor more deterministic, by calculating more state
and performing more plane manipulation, inside
drm_output_prepare_cursor_view.
Signed-off-by: Daniel Stone <daniels at collabora.com>
Reviewed-by: Derek Foreman <derekf at osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
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 3f7e97e6..884d2e94 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -1241,6 +1241,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;
@@ -1279,6 +1280,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;
}
@@ -1324,24 +1328,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;
@@ -1356,22 +1353,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;
}
}
@@ -1400,6 +1389,10 @@ drm_assign_planes(struct weston_output *output_base, void *repaint_data)
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.12.2
More information about the wayland-devel
mailing list