[mutter] kms/crtc: Make MetaKmsCrtcGamma reusable



commit 7d8dd6cc75c3f21355a6eb529844db91299a6453
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Sat Oct 10 11:18:10 2020 +0200

    kms/crtc: Make MetaKmsCrtcGamma reusable
    
    Expose it outside the private realms of MetaKms* so that e.g.
    MetaMonitorManagerKms can use it too.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>

 src/backends/native/meta-kms-crtc.h           | 17 ++++++++++++++
 src/backends/native/meta-kms-update-private.h |  9 --------
 src/backends/native/meta-kms-update.c         | 32 +++++++++++++++++++--------
 3 files changed, 40 insertions(+), 18 deletions(-)
---
diff --git a/src/backends/native/meta-kms-crtc.h b/src/backends/native/meta-kms-crtc.h
index 1d9b791563..406ca3ac1e 100644
--- a/src/backends/native/meta-kms-crtc.h
+++ b/src/backends/native/meta-kms-crtc.h
@@ -44,6 +44,15 @@ typedef struct _MetaKmsCrtcState
   } gamma;
 } MetaKmsCrtcState;
 
+typedef struct _MetaKmsCrtcGamma
+{
+  MetaKmsCrtc *crtc;
+  int size;
+  uint16_t *red;
+  uint16_t *green;
+  uint16_t *blue;
+} MetaKmsCrtcGamma;
+
 #define META_TYPE_KMS_CRTC (meta_kms_crtc_get_type ())
 G_DECLARE_FINAL_TYPE (MetaKmsCrtc, meta_kms_crtc,
                       META, KMS_CRTC,
@@ -59,4 +68,12 @@ int meta_kms_crtc_get_idx (MetaKmsCrtc *crtc);
 
 gboolean meta_kms_crtc_is_active (MetaKmsCrtc *crtc);
 
+void meta_kms_crtc_gamma_free (MetaKmsCrtcGamma *gamma);
+
+MetaKmsCrtcGamma * meta_kms_crtc_gamma_new (MetaKmsCrtc    *crtc,
+                                            int             size,
+                                            const uint16_t *red,
+                                            const uint16_t *green,
+                                            const uint16_t *blue);
+
 #endif /* META_KMS_CRTC_H */
diff --git a/src/backends/native/meta-kms-update-private.h b/src/backends/native/meta-kms-update-private.h
index f5be87b970..02afdc9343 100644
--- a/src/backends/native/meta-kms-update-private.h
+++ b/src/backends/native/meta-kms-update-private.h
@@ -77,15 +77,6 @@ typedef struct _MetaKmsConnectorUpdate
   } dpms;
 } MetaKmsConnectorUpdate;
 
-typedef struct _MetaKmsCrtcGamma
-{
-  MetaKmsCrtc *crtc;
-  int size;
-  uint16_t *red;
-  uint16_t *green;
-  uint16_t *blue;
-} MetaKmsCrtcGamma;
-
 typedef struct _MetaKmsPageFlipListener
 {
   MetaKmsCrtc *crtc;
diff --git a/src/backends/native/meta-kms-update.c b/src/backends/native/meta-kms-update.c
index 9d32a0da29..4508838656 100644
--- a/src/backends/native/meta-kms-update.c
+++ b/src/backends/native/meta-kms-update.c
@@ -333,7 +333,7 @@ meta_kms_update_set_dpms_state (MetaKmsUpdate    *update,
   connector_update->dpms.state = state;
 }
 
-static void
+void
 meta_kms_crtc_gamma_free (MetaKmsCrtcGamma *gamma)
 {
   g_free (gamma->red);
@@ -342,6 +342,27 @@ meta_kms_crtc_gamma_free (MetaKmsCrtcGamma *gamma)
   g_free (gamma);
 }
 
+MetaKmsCrtcGamma *
+meta_kms_crtc_gamma_new (MetaKmsCrtc    *crtc,
+                         int             size,
+                         const uint16_t *red,
+                         const uint16_t *green,
+                         const uint16_t *blue)
+{
+  MetaKmsCrtcGamma *gamma;
+
+  gamma = g_new0 (MetaKmsCrtcGamma, 1);
+  *gamma = (MetaKmsCrtcGamma) {
+    .crtc = crtc,
+    .size = size,
+    .red = g_memdup (red, size * sizeof (*red)),
+    .green = g_memdup (green, size * sizeof (*green)),
+    .blue = g_memdup (blue, size * sizeof (*blue)),
+  };
+
+  return gamma;
+}
+
 void
 meta_kms_update_set_crtc_gamma (MetaKmsUpdate  *update,
                                 MetaKmsCrtc    *crtc,
@@ -355,14 +376,7 @@ meta_kms_update_set_crtc_gamma (MetaKmsUpdate  *update,
   g_assert (!meta_kms_update_is_locked (update));
   g_assert (meta_kms_crtc_get_device (crtc) == update->device);
 
-  gamma = g_new0 (MetaKmsCrtcGamma, 1);
-  *gamma = (MetaKmsCrtcGamma) {
-    .crtc = crtc,
-    .size = size,
-    .red = g_memdup (red, size * sizeof *red),
-    .green = g_memdup (green, size * sizeof *green),
-    .blue = g_memdup (blue, size * sizeof *blue),
-  };
+  gamma = meta_kms_crtc_gamma_new (crtc, size, red, green, blue);
 
   update->crtc_gammas = g_list_prepend (update->crtc_gammas, gamma);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]