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>
This commit is contained in:
Jonas Ådahl 2020-10-10 11:18:10 +02:00 committed by Marge Bot
parent 88e6400052
commit 7d8dd6cc75
3 changed files with 40 additions and 18 deletions

View File

@ -44,6 +44,15 @@ typedef struct _MetaKmsCrtcState
} gamma; } gamma;
} MetaKmsCrtcState; } 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 ()) #define META_TYPE_KMS_CRTC (meta_kms_crtc_get_type ())
G_DECLARE_FINAL_TYPE (MetaKmsCrtc, meta_kms_crtc, G_DECLARE_FINAL_TYPE (MetaKmsCrtc, meta_kms_crtc,
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); 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 */ #endif /* META_KMS_CRTC_H */

View File

@ -77,15 +77,6 @@ typedef struct _MetaKmsConnectorUpdate
} dpms; } dpms;
} MetaKmsConnectorUpdate; } MetaKmsConnectorUpdate;
typedef struct _MetaKmsCrtcGamma
{
MetaKmsCrtc *crtc;
int size;
uint16_t *red;
uint16_t *green;
uint16_t *blue;
} MetaKmsCrtcGamma;
typedef struct _MetaKmsPageFlipListener typedef struct _MetaKmsPageFlipListener
{ {
MetaKmsCrtc *crtc; MetaKmsCrtc *crtc;

View File

@ -333,7 +333,7 @@ meta_kms_update_set_dpms_state (MetaKmsUpdate *update,
connector_update->dpms.state = state; connector_update->dpms.state = state;
} }
static void void
meta_kms_crtc_gamma_free (MetaKmsCrtcGamma *gamma) meta_kms_crtc_gamma_free (MetaKmsCrtcGamma *gamma)
{ {
g_free (gamma->red); g_free (gamma->red);
@ -342,6 +342,27 @@ meta_kms_crtc_gamma_free (MetaKmsCrtcGamma *gamma)
g_free (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 void
meta_kms_update_set_crtc_gamma (MetaKmsUpdate *update, meta_kms_update_set_crtc_gamma (MetaKmsUpdate *update,
MetaKmsCrtc *crtc, 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_update_is_locked (update));
g_assert (meta_kms_crtc_get_device (crtc) == update->device); g_assert (meta_kms_crtc_get_device (crtc) == update->device);
gamma = g_new0 (MetaKmsCrtcGamma, 1); gamma = meta_kms_crtc_gamma_new (crtc, size, red, green, blue);
*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),
};
update->crtc_gammas = g_list_prepend (update->crtc_gammas, gamma); update->crtc_gammas = g_list_prepend (update->crtc_gammas, gamma);
} }