summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2021-04-03 19:54:05 +0300
committerDaniel Stone <daniels@collabora.com>2021-04-10 23:03:23 +0000
commit7a465d855e0c5bae359957023954b41f104848f7 (patch)
tree3a5f2a38b53c267551997d37b7e702fc38d7ffc9
parentf153c494301901f2bf6ffa14b06f730478b1f20b (diff)
downloadweston-7a465d855e0c5bae359957023954b41f104848f7.tar.gz
backend-drm/state-propose: Check the surface buffer dimensions for cursor case
In some situations, like positioning a sub-surface that exceeds the output's dimensions we would adjust the plane state dimensions to some lower values to that of the buffer. That would ultimately trip the cursor update function because the buffer itself actually exceeds the maximum size/dimension of the cursor. The plane state destination co-ordinates is the area of the view which is visible on the output, which in some situations, would actually be smaller than the original buffer dimensions (making it so that it will pass the cropping/scaling check), but depending on of how large is the surface buffer, it would tripping the assert wrt to cursor width/height dimensions. This hasn't been seen so far due to the fact that until recently we had a cursor surface that always reached the cursor plane and that was already being set-up by default (with desktop-shell, which is no longer the case), and also because kiosk-shell, which doesn't set-up a cursor surface, was not available. This adds a check to skip placing the view in the cursor plane if the buffer dimensions exceed the cursor permitted width/height. (Suggested-by Daniel Stone). Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
-rw-r--r--libweston/backend-drm/state-propose.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libweston/backend-drm/state-propose.c b/libweston/backend-drm/state-propose.c
index 87bc9db1..b2d881b4 100644
--- a/libweston/backend-drm/state-propose.c
+++ b/libweston/backend-drm/state-propose.c
@@ -306,6 +306,7 @@ drm_output_prepare_cursor_view(struct drm_output_state *output_state,
struct drm_plane *plane = output->cursor_plane;
struct drm_plane_state *plane_state;
bool needs_update = false;
+ struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
const char *p_name = drm_output_get_plane_type_name(plane);
assert(!b->cursors_are_broken);
@@ -337,6 +338,16 @@ drm_output_prepare_cursor_view(struct drm_output_state *output_state,
goto err;
}
+ if (buffer->width > b->cursor_width ||
+ buffer->height > b->cursor_height) {
+ drm_debug(b, "\t\t\t\t[%s] not assigning view %p to %s plane "
+ "(surface buffer (%dx%d) larger than permitted"
+ " (%dx%d))\n", p_name, ev, p_name,
+ buffer->width, buffer->height,
+ b->cursor_width, b->cursor_height);
+ goto err;
+ }
+
if (plane_state->src_x != 0 || plane_state->src_y != 0 ||
plane_state->src_w > (unsigned) b->cursor_width << 16 ||
plane_state->src_h > (unsigned) b->cursor_height << 16 ||