cursor-renderer/native: Skip hw cursor upload if we can't use it

If the CRTCs the cursor is visible on do not share a common scale
and transform, we can't use the cursor hardware plane as we only have one.
We therefore fall back to software / gl cursor.

The check for that currently happens after we tried to upload the cursor image
to the hardware plane though.
This is made worse by the fact that in the scaling step, where we scale the
cursor image to the desired size, until now we expected a valid common scale -
otherwise scaling the image by an uninitialized float.

Make sure we bail out early during the scale/upload step if we don't have common
scales and transforms - to avoid that bug and save some unnecessary work.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1125
This commit is contained in:
Robert Mader 2020-03-14 15:52:38 +01:00
parent 074f4974dd
commit 4133b73632

View File

@ -1393,6 +1393,26 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
MetaMonitorTransform relative_transform;
uint32_t gbm_format;
if (!get_common_crtc_sprite_scale_for_logical_monitors (renderer,
cursor_sprite,
&relative_scale))
{
unset_can_preprocess (cursor_sprite);
return;
}
if (!get_common_crtc_sprite_transform_for_logical_monitors (renderer,
cursor_sprite,
&relative_transform))
{
unset_can_preprocess (cursor_sprite);
return;
}
set_can_preprocess (cursor_sprite,
relative_scale,
relative_transform);
wl_shm_buffer_begin_access (shm_buffer);
buffer_data = wl_shm_buffer_get_data (shm_buffer);
@ -1412,18 +1432,6 @@ realize_cursor_sprite_from_wl_buffer_for_gpu (MetaCursorRenderer *renderer,
gbm_format = GBM_FORMAT_ARGB8888;
}
get_common_crtc_sprite_scale_for_logical_monitors (renderer,
cursor_sprite,
&relative_scale);
get_common_crtc_sprite_transform_for_logical_monitors (renderer,
cursor_sprite,
&relative_transform);
set_can_preprocess (cursor_sprite,
relative_scale,
relative_transform);
load_scaled_and_transformed_cursor_sprite (native,
gpu_kms,
cursor_sprite,
@ -1502,20 +1510,28 @@ realize_cursor_sprite_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
is_cursor_scale_and_transform_valid (renderer, cursor_sprite))
return;
xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
get_common_crtc_sprite_scale_for_logical_monitors (renderer,
if (!get_common_crtc_sprite_scale_for_logical_monitors (renderer,
cursor_sprite,
&relative_scale);
&relative_scale))
{
unset_can_preprocess (cursor_sprite);
return;
}
get_common_crtc_sprite_transform_for_logical_monitors (renderer,
if (!get_common_crtc_sprite_transform_for_logical_monitors (renderer,
cursor_sprite,
&relative_transform);
&relative_transform))
{
unset_can_preprocess (cursor_sprite);
return;
}
set_can_preprocess (cursor_sprite,
relative_scale,
relative_transform);
xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
load_scaled_and_transformed_cursor_sprite (native,
gpu_kms,
cursor_sprite,