mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-01 22:58:38 -04:00
backend/drm: add support for SIZE_HINTS property
This property allows the driver to advertise support for multiple cursor sizes. On Intel, using a smaller buffer size reduces power consumption. References: https://lore.kernel.org/dri-devel/20240227193523.5601-2-ville.syrjala@linux.intel.com/
This commit is contained in:
parent
6f63f55ace
commit
a35b4f059d
7 changed files with 106 additions and 17 deletions
|
|
@ -196,13 +196,27 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
|
|||
|
||||
int width = cursor->width;
|
||||
int height = cursor->height;
|
||||
if (output->impl->get_cursor_size) {
|
||||
if (output->impl->get_cursor_sizes) {
|
||||
// Apply hardware limitations on buffer size
|
||||
output->impl->get_cursor_size(cursor->output, &width, &height);
|
||||
if ((int)texture->width > width || (int)texture->height > height) {
|
||||
size_t sizes_len = 0;
|
||||
const struct wlr_output_cursor_size *sizes =
|
||||
output->impl->get_cursor_sizes(cursor->output, &sizes_len);
|
||||
|
||||
bool found = false;
|
||||
for (size_t i = 0; i < sizes_len; i++) {
|
||||
struct wlr_output_cursor_size size = sizes[i];
|
||||
if ((int)texture->width <= size.width && (int)texture->height <= size.height) {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
wlr_log(WLR_DEBUG, "Cursor texture too large (%dx%d), "
|
||||
"exceeds hardware limitations (%dx%d)", texture->width,
|
||||
texture->height, width, height);
|
||||
"exceeds hardware limitations", texture->width,
|
||||
texture->height);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue