mirror of
https://github.com/brl/mutter.git
synced 2025-02-02 06:42:28 +00:00
crtc: Add identity gamma LUT helpers
One to create a identity LUT of a certain size, one to check if a LUT represents identity. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
This commit is contained in:
parent
6876b51875
commit
a55e2e5af2
@ -219,6 +219,48 @@ meta_gamma_lut_new_sized (int size)
|
|||||||
return gamma;
|
return gamma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaGammaLut *
|
||||||
|
meta_gamma_lut_new_identity (int size)
|
||||||
|
{
|
||||||
|
MetaGammaLut *lut = meta_gamma_lut_new_sized (size);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (size < 2)
|
||||||
|
return lut;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
double value = (i / (double) (size - 1));
|
||||||
|
|
||||||
|
lut->red[i] = value * UINT16_MAX;
|
||||||
|
lut->green[i] = value * UINT16_MAX;
|
||||||
|
lut->blue[i] = value * UINT16_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lut;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_gamma_lut_is_identity (const MetaGammaLut *lut)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!lut)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
for (i = 0; i < lut->size; i++)
|
||||||
|
{
|
||||||
|
uint16_t value = (i / (double) (lut->size - 1)) * UINT16_MAX;
|
||||||
|
|
||||||
|
if (ABS (lut->red[i] - value) > 1 ||
|
||||||
|
ABS (lut->green[i] - value) > 1 ||
|
||||||
|
ABS (lut->blue[i] - value) > 1)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
MetaGammaLut *
|
MetaGammaLut *
|
||||||
meta_gamma_lut_copy (const MetaGammaLut *gamma)
|
meta_gamma_lut_copy (const MetaGammaLut *gamma)
|
||||||
{
|
{
|
||||||
|
@ -110,8 +110,13 @@ MetaGammaLut * meta_gamma_lut_new (int size,
|
|||||||
const uint16_t *green,
|
const uint16_t *green,
|
||||||
const uint16_t *blue);
|
const uint16_t *blue);
|
||||||
|
|
||||||
|
META_EXPORT_TEST
|
||||||
MetaGammaLut * meta_gamma_lut_new_sized (int size);
|
MetaGammaLut * meta_gamma_lut_new_sized (int size);
|
||||||
|
|
||||||
|
MetaGammaLut *meta_gamma_lut_new_identity (int size);
|
||||||
|
|
||||||
|
gboolean meta_gamma_lut_is_identity (const MetaGammaLut *lut);
|
||||||
|
|
||||||
META_EXPORT_TEST
|
META_EXPORT_TEST
|
||||||
MetaGammaLut * meta_gamma_lut_copy (const MetaGammaLut *gamma);
|
MetaGammaLut * meta_gamma_lut_copy (const MetaGammaLut *gamma);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user