From 0c34908132bc53908c20475a6f8e70d7567c076f Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Tue, 14 Jun 2022 18:47:10 +0200 Subject: [PATCH] cursor-renderer/native: Various fixes for rotated cursors - Drop bogus `meta_monitor_transform_invert()`. It papered over wrong `meta_rectangle_transform()` behaviour for non-flipped output transforms. - Update `scale_and_transform_cursor_sprite_cpu` to match the GL pipeline matrix in `MetaShapedTexture`, fixing several of the flipped cases. Note: the rotation applied is the one a client would need to apply to the buffer for a given monitor transform. - While on it, drop a redundant `return`. Part-of: --- src/backends/native/meta-cursor-renderer-native.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c index 9e852e82a..9dcaec1a2 100644 --- a/src/backends/native/meta-cursor-renderer-native.c +++ b/src/backends/native/meta-cursor-renderer-native.c @@ -410,7 +410,6 @@ set_crtc_cursor (MetaCursorRendererNative *cursor_renderer_native, float cursor_crtc_scale; MetaRectangle cursor_rect; MetaMonitorTransform transform; - MetaMonitorTransform inverted_transform; MetaMonitorMode *monitor_mode; MetaMonitorCrtcMode *monitor_crtc_mode; const MetaCrtcModeInfo *crtc_mode_info; @@ -452,15 +451,13 @@ set_crtc_cursor (MetaCursorRendererNative *cursor_renderer_native, transform = meta_logical_monitor_get_transform (logical_monitor); transform = meta_monitor_logical_to_crtc_transform (monitor, transform); - inverted_transform = meta_monitor_transform_invert (transform); - monitor_mode = meta_monitor_get_current_mode (monitor); monitor_crtc_mode = meta_monitor_get_crtc_mode_for_output (monitor, monitor_mode, output); crtc_mode_info = meta_crtc_mode_get_info (monitor_crtc_mode->crtc_mode); meta_rectangle_transform (&cursor_rect, - inverted_transform, + transform, crtc_mode_info->width, crtc_mode_info->height, &cursor_rect); @@ -898,8 +895,6 @@ should_have_hw_cursor (MetaCursorRenderer *renderer, return TRUE; else return get_can_preprocess (cursor_sprite); - - return TRUE; } static gboolean @@ -1494,19 +1489,19 @@ scale_and_transform_cursor_sprite_cpu (uint8_t *pixels, cairo_rotate (cr, M_PI * 0.5); break; case META_MONITOR_TRANSFORM_FLIPPED: - cairo_scale (cr, 1, -1); + cairo_scale (cr, -1, 1); break; case META_MONITOR_TRANSFORM_FLIPPED_90: - cairo_rotate (cr, M_PI * 1.5); cairo_scale (cr, -1, 1); + cairo_rotate (cr, M_PI * 0.5); break; case META_MONITOR_TRANSFORM_FLIPPED_180: + cairo_scale (cr, -1, 1); cairo_rotate (cr, M_PI); - cairo_scale (cr, 1, -1); break; case META_MONITOR_TRANSFORM_FLIPPED_270: - cairo_rotate (cr, M_PI * 0.5); cairo_scale (cr, -1, 1); + cairo_rotate (cr, M_PI * 1.5); break; case META_MONITOR_TRANSFORM_NORMAL: g_assert_not_reached ();