Blame SOURCES/0002-onscreen-native-Pass-damage-rectangles-when-page-fli.patch

1e895f
From b328c8cc8b0b31a4afe2bfc857c6ea5a2b837ef2 Mon Sep 17 00:00:00 2001
1e895f
From: Piotr Lopatka <piotr.lopatka@gmail.com>
1e895f
Date: Fri, 3 Sep 2021 20:01:59 +0100
1e895f
Subject: [PATCH 2/2] onscreen/native: Pass damage rectangles when page
1e895f
 flipping
1e895f
1e895f
This commit passes damage rectangles metadata to the (KMS) primary
1e895f
plane.
1e895f
1e895f
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
1e895f
---
1e895f
 src/backends/native/meta-crtc-kms.c        |  4 +++-
1e895f
 src/backends/native/meta-crtc-kms.h        |  6 +++---
1e895f
 src/backends/native/meta-onscreen-native.c | 22 ++++++++++++++++++----
1e895f
 3 files changed, 24 insertions(+), 8 deletions(-)
1e895f
1e895f
diff --git a/src/backends/native/meta-crtc-kms.c b/src/backends/native/meta-crtc-kms.c
1e895f
index f1bc79146af..fde64817532 100644
1e895f
--- a/src/backends/native/meta-crtc-kms.c
1e895f
+++ b/src/backends/native/meta-crtc-kms.c
1e895f
@@ -115,7 +115,7 @@ meta_crtc_kms_apply_transform (MetaCrtcKms            *crtc_kms,
1e895f
                                       hw_transform);
1e895f
 }
1e895f
 
1e895f
-void
1e895f
+MetaKmsPlaneAssignment *
1e895f
 meta_crtc_kms_assign_primary_plane (MetaCrtcKms   *crtc_kms,
1e895f
                                     MetaDrmBuffer *buffer,
1e895f
                                     MetaKmsUpdate *kms_update)
1e895f
@@ -161,6 +161,8 @@ meta_crtc_kms_assign_primary_plane (MetaCrtcKms   *crtc_kms,
1e895f
                                                    dst_rect,
1e895f
                                                    flags);
1e895f
   meta_crtc_kms_apply_transform (crtc_kms, plane_assignment);
1e895f
+
1e895f
+  return plane_assignment;
1e895f
 }
1e895f
 
1e895f
 static GList *
1e895f
diff --git a/src/backends/native/meta-crtc-kms.h b/src/backends/native/meta-crtc-kms.h
1e895f
index f8d241bbb51..bd80835f986 100644
1e895f
--- a/src/backends/native/meta-crtc-kms.h
1e895f
+++ b/src/backends/native/meta-crtc-kms.h
1e895f
@@ -48,9 +48,9 @@ void meta_crtc_kms_set_cursor_renderer_private (MetaCrtcKms    *crtc_kms,
1e895f
 void meta_crtc_kms_apply_transform (MetaCrtcKms            *crtc_kms,
1e895f
                                     MetaKmsPlaneAssignment *kms_plane_assignment);
1e895f
 
1e895f
-void meta_crtc_kms_assign_primary_plane (MetaCrtcKms   *crtc_kms,
1e895f
-                                         MetaDrmBuffer *buffer,
1e895f
-                                         MetaKmsUpdate *kms_update);
1e895f
+MetaKmsPlaneAssignment * meta_crtc_kms_assign_primary_plane (MetaCrtcKms   *crtc_kms,
1e895f
+                                                             MetaDrmBuffer *buffer,
1e895f
+                                                             MetaKmsUpdate *kms_update);
1e895f
 
1e895f
 void meta_crtc_kms_set_mode (MetaCrtcKms   *crtc_kms,
1e895f
                              MetaKmsUpdate *kms_update);
1e895f
diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c
1e895f
index 112bd0d438b..00b2d9f89cc 100644
1e895f
--- a/src/backends/native/meta-onscreen-native.c
1e895f
+++ b/src/backends/native/meta-onscreen-native.c
1e895f
@@ -416,7 +416,9 @@ static void
1e895f
 meta_onscreen_native_flip_crtc (CoglOnscreen                *onscreen,
1e895f
                                 MetaRendererView            *view,
1e895f
                                 MetaCrtc                    *crtc,
1e895f
-                                MetaKmsPageFlipListenerFlag  flags)
1e895f
+                                MetaKmsPageFlipListenerFlag  flags,
1e895f
+                                const int                   *rectangles,
1e895f
+                                int                          n_rectangles)
1e895f
 {
1e895f
   MetaOnscreenNative *onscreen_native = META_ONSCREEN_NATIVE (onscreen);
1e895f
   MetaRendererNative *renderer_native = onscreen_native->renderer_native;
1e895f
@@ -430,6 +432,7 @@ meta_onscreen_native_flip_crtc (CoglOnscreen                *onscreen,
1e895f
   MetaKmsUpdate *kms_update;
1e895f
   MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state = NULL;
1e895f
   MetaDrmBuffer *buffer;
1e895f
+  MetaKmsPlaneAssignment *plane_assignment;
1e895f
 
1e895f
   COGL_TRACE_BEGIN_SCOPED (MetaOnscreenNativeFlipCrtcs,
1e895f
                            "Onscreen (flip CRTCs)");
1e895f
@@ -456,8 +459,15 @@ meta_onscreen_native_flip_crtc (CoglOnscreen                *onscreen,
1e895f
           buffer = secondary_gpu_state->gbm.next_fb;
1e895f
         }
1e895f
 
1e895f
-      meta_crtc_kms_assign_primary_plane (crtc_kms, buffer, kms_update);
1e895f
+      plane_assignment = meta_crtc_kms_assign_primary_plane (crtc_kms,
1e895f
+                                                             buffer,
1e895f
+                                                             kms_update);
1e895f
 
1e895f
+      if (rectangles != NULL && n_rectangles != 0)
1e895f
+        {
1e895f
+          meta_kms_plane_assignment_set_fb_damage (plane_assignment,
1e895f
+                                                   rectangles, n_rectangles);
1e895f
+        }
1e895f
       break;
1e895f
     case META_RENDERER_NATIVE_MODE_SURFACELESS:
1e895f
       g_assert_not_reached ();
1e895f
@@ -1081,7 +1091,9 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen  *onscreen,
1e895f
       meta_onscreen_native_flip_crtc (onscreen,
1e895f
                                       onscreen_native->view,
1e895f
                                       onscreen_native->crtc,
1e895f
-                                      META_KMS_PAGE_FLIP_LISTENER_FLAG_NONE);
1e895f
+                                      META_KMS_PAGE_FLIP_LISTENER_FLAG_NONE,
1e895f
+                                      rectangles,
1e895f
+                                      n_rectangles);
1e895f
     }
1e895f
   else
1e895f
     {
1e895f
@@ -1299,7 +1311,9 @@ meta_onscreen_native_direct_scanout (CoglOnscreen   *onscreen,
1e895f
   meta_onscreen_native_flip_crtc (onscreen,
1e895f
                                   onscreen_native->view,
1e895f
                                   onscreen_native->crtc,
1e895f
-                                  META_KMS_PAGE_FLIP_LISTENER_FLAG_DROP_ON_ERROR);
1e895f
+                                  META_KMS_PAGE_FLIP_LISTENER_FLAG_DROP_ON_ERROR,
1e895f
+                                  NULL,
1e895f
+                                  0);
1e895f
 
1e895f
   kms_crtc = meta_crtc_kms_get_kms_crtc (META_CRTC_KMS (onscreen_native->crtc));
1e895f
   kms_device = meta_kms_crtc_get_device (kms_crtc);
1e895f
-- 
1e895f
2.36.1
1e895f