diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c index 77c984a6a..0d8c01b23 100644 --- a/src/backends/meta-monitor-manager-dummy.c +++ b/src/backends/meta-monitor-manager-dummy.c @@ -521,6 +521,14 @@ meta_monitor_manager_dummy_apply_config (MetaMonitorManager *manager, meta_monitor_manager_rebuild_derived (manager); } +static gboolean +meta_monitor_manager_dummy_is_transform_handled (MetaMonitorManager *manager, + MetaCrtc *crtc, + MetaMonitorTransform transform) +{ + return TRUE; +} + static void meta_monitor_manager_dummy_class_init (MetaMonitorManagerDummyClass *klass) { @@ -530,6 +538,7 @@ meta_monitor_manager_dummy_class_init (MetaMonitorManagerDummyClass *klass) manager_class->ensure_initial_config = meta_monitor_manager_dummy_ensure_initial_config; manager_class->apply_monitors_config = meta_monitor_manager_dummy_apply_monitors_config; manager_class->apply_configuration = meta_monitor_manager_dummy_apply_config; + manager_class->is_transform_handled = meta_monitor_manager_dummy_is_transform_handled; } static void diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index 1c2bb262d..3c27bc8bb 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -345,6 +345,9 @@ struct _MetaMonitorManagerClass void (*tiled_monitor_removed) (MetaMonitorManager *, MetaMonitor *); + gboolean (*is_transform_handled) (MetaMonitorManager *, + MetaCrtc *, + MetaMonitorTransform); }; void meta_monitor_manager_rebuild (MetaMonitorManager *manager, @@ -428,6 +431,10 @@ void meta_monitor_manager_tiled_monitor_added (MetaMonitorManager void meta_monitor_manager_tiled_monitor_removed (MetaMonitorManager *manager, MetaMonitor *monitor); +gboolean meta_monitor_manager_is_transform_handled (MetaMonitorManager *manager, + MetaCrtc *crtc, + MetaMonitorTransform transform); + MetaMonitorsConfig * meta_monitor_manager_ensure_configured (MetaMonitorManager *manager); void meta_monitor_manager_update_logical_state (MetaMonitorManager *manager, diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 04e5cb6e8..4400b71db 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -1725,6 +1725,17 @@ meta_monitor_manager_tiled_monitor_removed (MetaMonitorManager *manager, manager_class->tiled_monitor_removed (manager, monitor); } +gboolean +meta_monitor_manager_is_transform_handled (MetaMonitorManager *manager, + MetaCrtc *crtc, + MetaMonitorTransform transform) +{ + MetaMonitorManagerClass *manager_class = + META_MONITOR_MANAGER_GET_CLASS (manager); + + return manager_class->is_transform_handled (manager, crtc, transform); +} + void meta_monitor_manager_read_current_state (MetaMonitorManager *manager) { diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c index 25c1b77ea..1d9bdfdf2 100644 --- a/src/backends/native/meta-monitor-manager-kms.c +++ b/src/backends/native/meta-monitor-manager-kms.c @@ -1968,6 +1968,19 @@ meta_monitor_manager_kms_wait_for_flip (MetaMonitorManagerKms *manager_kms) drmHandleEvent (manager_kms->fd, &evctx); } +static gboolean +meta_monitor_manager_kms_is_transform_handled (MetaMonitorManager *manager, + MetaCrtc *crtc, + MetaMonitorTransform transform) +{ + MetaCrtcKms *crtc_kms = crtc->driver_private; + + if ((1 << crtc->transform) & crtc_kms->all_hw_transforms) + return TRUE; + else + return FALSE; +} + static void meta_monitor_manager_kms_dispose (GObject *object) { @@ -2007,20 +2020,5 @@ meta_monitor_manager_kms_class_init (MetaMonitorManagerKmsClass *klass) manager_class->set_power_save_mode = meta_monitor_manager_kms_set_power_save_mode; manager_class->get_crtc_gamma = meta_monitor_manager_kms_get_crtc_gamma; manager_class->set_crtc_gamma = meta_monitor_manager_kms_set_crtc_gamma; -} - -MetaMonitorTransform -meta_monitor_manager_kms_get_view_transform (MetaMonitorManagerKms *manager, - MetaCrtc *crtc) -{ - MetaCrtcKms *crtc_kms; - - crtc_kms = crtc->driver_private; - if ((1 << crtc->transform) & crtc_kms->all_hw_transforms) - { - /* Transform is managed by the hardware, the view is untransformed */ - return META_MONITOR_TRANSFORM_NORMAL; - } - - return crtc->transform; + manager_class->is_transform_handled = meta_monitor_manager_kms_is_transform_handled; } diff --git a/src/backends/native/meta-monitor-manager-kms.h b/src/backends/native/meta-monitor-manager-kms.h index 59d6e7211..d4978b802 100644 --- a/src/backends/native/meta-monitor-manager-kms.h +++ b/src/backends/native/meta-monitor-manager-kms.h @@ -58,9 +58,4 @@ gboolean meta_monitor_manager_kms_flip_crtc (MetaMonitorManagerKms *manager_kms, void meta_monitor_manager_kms_wait_for_flip (MetaMonitorManagerKms *manager_kms); -MetaMonitorTransform -meta_monitor_manager_kms_get_view_transform (MetaMonitorManagerKms *manager, - MetaCrtc *crtc); - - #endif /* META_MONITOR_MANAGER_KMS_H */ diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index c69068805..8dba7276f 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -1398,25 +1398,6 @@ meta_renderer_native_queue_modes_reset (MetaRendererNative *renderer_native) } } -static MetaMonitorTransform -meta_renderer_native_get_logical_monitor_transform (MetaRenderer *renderer, - MetaLogicalMonitor *logical_monitor) -{ - MetaBackend *backend = meta_get_backend (); - MetaMonitorManager *monitor_manager = - meta_backend_get_monitor_manager (backend); - MetaMonitorManagerKms *monitor_manager_kms = - META_MONITOR_MANAGER_KMS (monitor_manager); - MetaMonitor *monitor; - MetaOutput *output; - - monitor = meta_logical_monitor_get_monitors (logical_monitor)->data; - output = meta_monitor_get_main_output (monitor); - - return meta_monitor_manager_kms_get_view_transform (monitor_manager_kms, - output->crtc); -} - static CoglOnscreen * meta_renderer_native_create_onscreen (MetaRendererNative *renderer, CoglContext *context, @@ -1689,38 +1670,61 @@ meta_renderer_native_create_legacy_view (MetaRendererNative *renderer_native) return view; } +static MetaMonitorTransform +calculate_view_transform (MetaMonitorManager *monitor_manager, + MetaLogicalMonitor *logical_monitor) +{ + MetaMonitor *main_monitor; + MetaOutput *main_output; + main_monitor = meta_logical_monitor_get_monitors (logical_monitor)->data; + main_output = meta_monitor_get_main_output (main_monitor); + + /* + * Pick any monitor and output and check; all CRTCs of a logical monitor will + * always have the same transform assigned to them. + */ + + if (meta_monitor_manager_is_transform_handled (monitor_manager, + main_output->crtc, + main_output->crtc->transform)) + return META_MONITOR_TRANSFORM_NORMAL; + else + return main_output->crtc->transform; +} + static MetaRendererView * meta_renderer_native_create_view (MetaRenderer *renderer, MetaLogicalMonitor *logical_monitor) { MetaBackend *backend = meta_get_backend (); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); CoglDisplay *cogl_display = cogl_context_get_display (cogl_context); CoglDisplayEGL *egl_display = cogl_display->winsys; CoglOnscreenEGL *egl_onscreen; - MetaMonitorTransform transform; + MetaMonitorTransform view_transform; CoglOnscreen *onscreen = NULL; CoglOffscreen *offscreen = NULL; MetaRendererView *view; GError *error = NULL; - transform = meta_renderer_native_get_logical_monitor_transform (renderer, - logical_monitor); + view_transform = calculate_view_transform (monitor_manager, logical_monitor); onscreen = meta_renderer_native_create_onscreen (META_RENDERER_NATIVE (renderer), cogl_context, - transform, + view_transform, logical_monitor->rect.width, logical_monitor->rect.height); if (!onscreen) meta_fatal ("Failed to allocate onscreen framebuffer\n"); - if (transform != META_MONITOR_TRANSFORM_NORMAL) + if (view_transform != META_MONITOR_TRANSFORM_NORMAL) { offscreen = meta_renderer_native_create_offscreen (META_RENDERER_NATIVE (renderer), cogl_context, - transform, + view_transform, logical_monitor->rect.width, logical_monitor->rect.height); if (!offscreen) @@ -1732,7 +1736,7 @@ meta_renderer_native_create_view (MetaRenderer *renderer, "framebuffer", onscreen, "offscreen", offscreen, "logical-monitor", logical_monitor, - "transform", transform, + "transform", view_transform, NULL); g_clear_pointer (&offscreen, cogl_object_unref); diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index df608a3da..cc7a4440a 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -1558,6 +1558,16 @@ meta_monitor_manager_xrandr_init_monitors (MetaMonitorManagerXrandr *manager_xra } #endif +static gboolean +meta_monitor_manager_xrandr_is_transform_handled (MetaMonitorManager *manager, + MetaCrtc *crtc, + MetaMonitorTransform transform) +{ + g_warn_if_fail (crtc->all_transforms & transform); + + return TRUE; +} + static void meta_monitor_manager_xrandr_init (MetaMonitorManagerXrandr *manager_xrandr) { @@ -1633,6 +1643,7 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass) manager_class->tiled_monitor_added = meta_monitor_manager_xrandr_tiled_monitor_added; manager_class->tiled_monitor_removed = meta_monitor_manager_xrandr_tiled_monitor_removed; #endif + manager_class->is_transform_handled = meta_monitor_manager_xrandr_is_transform_handled; quark_meta_monitor_xrandr_data = g_quark_from_static_string ("-meta-monitor-xrandr-data"); diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c index d7b01fa69..2d862d5b1 100644 --- a/src/tests/meta-monitor-manager-test.c +++ b/src/tests/meta-monitor-manager-test.c @@ -327,6 +327,14 @@ meta_monitor_manager_test_tiled_monitor_removed (MetaMonitorManager *manager, manager_test->tiled_monitor_count--; } +static gboolean +meta_monitor_manager_test_is_transform_handled (MetaMonitorManager *manager, + MetaCrtc *crtc, + MetaMonitorTransform transform) +{ + return TRUE; +} + static void meta_monitor_manager_test_dispose (GObject *object) { @@ -358,4 +366,5 @@ meta_monitor_manager_test_class_init (MetaMonitorManagerTestClass *klass) manager_class->apply_configuration = meta_monitor_manager_test_apply_configuration; manager_class->tiled_monitor_added = meta_monitor_manager_test_tiled_monitor_added; manager_class->tiled_monitor_removed = meta_monitor_manager_test_tiled_monitor_removed; + manager_class->is_transform_handled = meta_monitor_manager_test_is_transform_handled; }