backend-drm: Early-out for too-large SHM/cursor buffers

We know what our limit is for cursor planes, so don't try to assign a
view which is too large.

Signed-off-by: Daniel Stone <daniels@collabora.com>
dev
Daniel Stone 3 years ago
parent ca4c2865e9
commit 6aec64b2f7
  1. 20
      libweston/backend-drm/state-propose.c

@ -239,7 +239,6 @@ drm_output_prepare_cursor_view(struct drm_output_state *output_state,
struct drm_plane *plane = output->cursor_plane; struct drm_plane *plane = output->cursor_plane;
struct drm_plane_state *plane_state; struct drm_plane_state *plane_state;
bool needs_update = false; bool needs_update = false;
struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
const char *p_name = drm_output_get_plane_type_name(plane); const char *p_name = drm_output_get_plane_type_name(plane);
assert(!b->cursors_are_broken); assert(!b->cursors_are_broken);
@ -271,16 +270,6 @@ drm_output_prepare_cursor_view(struct drm_output_state *output_state,
goto err; 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 || if (plane_state->src_x != 0 || plane_state->src_y != 0 ||
plane_state->src_w > (unsigned) b->cursor_width << 16 || plane_state->src_w > (unsigned) b->cursor_width << 16 ||
plane_state->src_h > (unsigned) b->cursor_height << 16 || plane_state->src_h > (unsigned) b->cursor_height << 16 ||
@ -694,12 +683,21 @@ drm_output_prepare_plane_view(struct drm_output_state *state,
if (shmbuf) { if (shmbuf) {
if (!output->cursor_plane) if (!output->cursor_plane)
return NULL; return NULL;
if (wl_shm_buffer_get_format(shmbuf) != WL_SHM_FORMAT_ARGB8888) { if (wl_shm_buffer_get_format(shmbuf) != WL_SHM_FORMAT_ARGB8888) {
drm_debug(b, "\t\t\t\t[view] not placing view %p on " drm_debug(b, "\t\t\t\t[view] not placing view %p on "
"plane; SHM buffers must be ARGB8888 for " "plane; SHM buffers must be ARGB8888 for "
"cursor view", ev); "cursor view", ev);
return NULL; return NULL;
} }
if (buffer->width > b->cursor_width ||
buffer->height > b->cursor_height) {
drm_debug(b, "\t\t\t\t[view] not assigning view %p to plane "
"(buffer (%dx%d) too large for cursor plane)",
ev, buffer->width, buffer->height);
return NULL;
}
} else { } else {
fb = drm_fb_get_from_view(state, ev, try_view_on_plane_failure_reasons); fb = drm_fb_get_from_view(state, ev, try_view_on_plane_failure_reasons);
} }

Loading…
Cancel
Save