diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 053460e00..91f213ad8 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -1892,6 +1892,48 @@ ensure_crtc_modes (CoglOnscreen *onscreen, } } +static MetaKmsUpdate * +unset_disabled_crtcs (MetaBackend *backend, + MetaKms *kms) +{ + MetaKmsUpdate *kms_update = NULL; + GList *l; + + for (l = meta_backend_get_gpus (backend); l; l = l->next) + { + MetaGpu *gpu = l->data; + GList *k; + + for (k = meta_gpu_get_crtcs (gpu); k; k = k->next) + { + MetaCrtc *crtc = k->data; + + if (meta_crtc_get_config (crtc)) + continue; + + kms_update = meta_kms_ensure_pending_update (kms); + meta_crtc_kms_set_mode (META_CRTC_KMS (crtc), kms_update); + } + } + + return kms_update; +} + +static void +post_pending_update (MetaKms *kms) +{ + g_autoptr (MetaKmsFeedback) kms_feedback = NULL; + + kms_feedback = meta_kms_post_pending_update_sync (kms); + if (meta_kms_feedback_get_result (kms_feedback) != META_KMS_FEEDBACK_PASSED) + { + const GError *error = meta_kms_feedback_get_error (kms_feedback); + + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED)) + g_warning ("Failed to post KMS update: %s", error->message); + } +} + static void meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen, const int *rectangles, @@ -1977,14 +2019,7 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen, COGL_TRACE_BEGIN (MetaRendererNativePostKmsUpdate, "Onscreen (post pending update)"); - kms_feedback = meta_kms_post_pending_update_sync (kms); - if (meta_kms_feedback_get_result (kms_feedback) != META_KMS_FEEDBACK_PASSED) - { - const GError *error = meta_kms_feedback_get_error (kms_feedback); - - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED)) - g_warning ("Failed to post KMS update: %s", error->message); - } + post_pending_update (kms); COGL_TRACE_END (MetaRendererNativePostKmsUpdate); } @@ -3128,41 +3163,12 @@ meta_renderer_native_finish_frame (MetaRendererNative *renderer_native) if (renderer_native->pending_unset_disabled_crtcs) { - GList *l; - - for (l = meta_backend_get_gpus (backend); l; l = l->next) - { - MetaGpu *gpu = l->data; - GList *k; - - for (k = meta_gpu_get_crtcs (gpu); k; k = k->next) - { - MetaCrtc *crtc = k->data; - - if (meta_crtc_get_config (crtc)) - continue; - - kms_update = meta_kms_ensure_pending_update (kms); - meta_crtc_kms_set_mode (META_CRTC_KMS (crtc), kms_update); - } - } - + kms_update = unset_disabled_crtcs (backend, kms); renderer_native->pending_unset_disabled_crtcs = FALSE; } if (kms_update) - { - g_autoptr (MetaKmsFeedback) kms_feedback = NULL; - - kms_feedback = meta_kms_post_pending_update_sync (kms); - if (meta_kms_feedback_get_result (kms_feedback) != META_KMS_FEEDBACK_PASSED) - { - const GError *error = meta_kms_feedback_get_error (kms_feedback); - - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED)) - g_warning ("Failed to post KMS update: %s", error->message); - } - } + post_pending_update (kms); } static gboolean