Documentation for <wlr/render/color.h>

Back to index

Table of contents

enum wlr_alpha_mode

enum wlr_alpha_mode {
	WLR_COLOR_ALPHA_MODE_PREMULTIPLIED_ELECTRICAL,
	WLR_COLOR_ALPHA_MODE_PREMULTIPLIED_OPTICAL,
	WLR_COLOR_ALPHA_MODE_STRAIGHT,
};

Specifies alpha blending modes. Note that premultiplied_electrical is the default, so there is no "none" or "unset" value.

enum wlr_color_chroma_location

enum wlr_color_chroma_location {
	WLR_COLOR_CHROMA_LOCATION_NONE,
	WLR_COLOR_CHROMA_LOCATION_TYPE0,
	WLR_COLOR_CHROMA_LOCATION_TYPE1,
	WLR_COLOR_CHROMA_LOCATION_TYPE2,
	WLR_COLOR_CHROMA_LOCATION_TYPE3,
	WLR_COLOR_CHROMA_LOCATION_TYPE4,
	WLR_COLOR_CHROMA_LOCATION_TYPE5,
};

Chroma sample locations, corresponding to Chroma420SampleLocType code points in H.273. NONE means the value is unset or unknown.

struct wlr_color_cie1931_xy

struct wlr_color_cie1931_xy {
	float x, y;
};

CIE 1931 xy chromaticity coordinates.

enum wlr_color_encoding

enum wlr_color_encoding {
	WLR_COLOR_ENCODING_NONE,
	WLR_COLOR_ENCODING_IDENTITY,
	WLR_COLOR_ENCODING_BT709,
	WLR_COLOR_ENCODING_FCC,
	WLR_COLOR_ENCODING_BT601,
	WLR_COLOR_ENCODING_SMPTE240,
	WLR_COLOR_ENCODING_BT2020,
	WLR_COLOR_ENCODING_BT2020_CL,
	WLR_COLOR_ENCODING_ICTCP,
};

Well-known color encodings, each representing a set of matrix coefficients used to convert that particular YCbCr encoding to RGB. NONE means the value is unset or unknown.

struct wlr_color_luminances

struct wlr_color_luminances {
	float min, max, reference;
};

Luminance range and reference white luminance level, in cd/m².

enum wlr_color_named_primaries

enum wlr_color_named_primaries {
	WLR_COLOR_NAMED_PRIMARIES_SRGB,
	WLR_COLOR_NAMED_PRIMARIES_BT2020,
};

Well-known color primaries.

struct wlr_color_primaries

struct wlr_color_primaries {
	struct wlr_color_cie1931_xy red, green, blue, white;
};

Color primaries and white point describing a color volume.

wlr_color_primaries_from_named()

void wlr_color_primaries_from_named(​struct wlr_color_primaries *out, enum wlr_color_named_primaries named);

Obtain primaries values from a well-known primaries name.

wlr_color_primaries_transform_absolute_colorimetric()

void wlr_color_primaries_transform_absolute_colorimetric(​const struct wlr_color_primaries *source, const struct wlr_color_primaries *destination, float matrix[]);

Compute the matrix to convert between two linear RGB color spaces

enum wlr_color_range

enum wlr_color_range {
	WLR_COLOR_RANGE_NONE,
	WLR_COLOR_RANGE_LIMITED,
	WLR_COLOR_RANGE_FULL,
};

Specifies whether a particular color-encoding uses full- or limited-range values. NONE means the value is unset or unknown.

enum wlr_color_transfer_function

enum wlr_color_transfer_function {
	WLR_COLOR_TRANSFER_FUNCTION_SRGB,
	WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ,
	WLR_COLOR_TRANSFER_FUNCTION_EXT_LINEAR,
	WLR_COLOR_TRANSFER_FUNCTION_GAMMA22,
	WLR_COLOR_TRANSFER_FUNCTION_BT1886,
};

Well-known color transfer functions.

struct wlr_color_transform

struct wlr_color_transform {
	enum wlr_color_transform_type type;
	
	struct {
		int ref_count;
		struct wlr_addon_set addons; // per-renderer helper state
	} WLR_PRIVATE;
};

A color transformation formula, which maps a linear color space with sRGB primaries to an output color space.

For ease of use, this type is heap allocated and reference counted. Use wlr_color_transform_ref()/wlr_color_transform_unref(). The initial reference count after creation is 1.

Color transforms are immutable; their type/parameters should not be changed, and this API provides no functions to modify them after creation.

This formula may be implemented using a 3d look-up table, or some other means. Renderer implementations may inspect the type and the corresponding concrete transform structure below.

wlr_color_transform_eval()

void wlr_color_transform_eval(​struct wlr_color_transform *tr, float out[], const float in[]);

Evaluate a color transform for a given RGB triplet.

wlr_color_transform_init_linear_to_icc()

struct wlr_color_transform *wlr_color_transform_init_linear_to_icc(​const void *data, size_t size);

Initialize a color transformation to convert linear (with sRGB(?) primaries) to an ICC profile. Returns NULL on failure.

wlr_color_transform_init_linear_to_inverse_eotf()

struct wlr_color_transform *wlr_color_transform_init_linear_to_inverse_eotf(​enum wlr_color_transfer_function tf);

Initialize a color transformation to apply EOTF⁻¹ encoding. Returns NULL on failure.

wlr_color_transform_init_lut_3x1d()

struct wlr_color_transform *wlr_color_transform_init_lut_3x1d(​size_t dim, const uint16_t *r, const uint16_t *g, const uint16_t *b);

Initialize a color transformation to apply three 1D look-up tables. dim is the number of elements in each individual LUT. Returns NULL on failure.

wlr_color_transform_init_matrix()

struct wlr_color_transform *wlr_color_transform_init_matrix(​const float matrix[]);

Initialize a color transformation to apply a 3×3 matrix. Returns NULL on failure.

wlr_color_transform_init_pipeline()

struct wlr_color_transform *wlr_color_transform_init_pipeline(​struct wlr_color_transform **transforms, size_t len);

Initialize a color transformation to apply a sequence of color transforms one after another.

struct wlr_color_transform_inverse_eotf

struct wlr_color_transform_inverse_eotf {
	struct wlr_color_transform base;
	
	enum wlr_color_transfer_function tf;
};

wlr_color_transform_inverse_eotf_from_base()

struct wlr_color_transform_inverse_eotf *wlr_color_transform_inverse_eotf_from_base(​struct wlr_color_transform *tr);

Get a struct wlr_color_transform_inverse_eotf from a generic struct wlr_color_transform. Asserts that the base type is WLR_COLOR_TRANSFORM_INVERSE_EOTF.

struct wlr_color_transform_lut_3x1d

struct wlr_color_transform_lut_3x1d {
	struct wlr_color_transform base;
	
	uint16_t *lut_3x1d;
	size_t dim;
};

The formula is approximated via three 1D look-up tables. The flat lut_3x1d array has a length of 3 * dim.

The offset of a color value for a given channel and color index is:

offset = channel_index * dim + color_index

wlr_color_transform_lut_3x1d_from_base()

struct wlr_color_transform_lut_3x1d *wlr_color_transform_lut_3x1d_from_base(​struct wlr_color_transform *tr);

Get a struct wlr_color_transform_lut_3x1d from a generic struct wlr_color_transform. Asserts that the base type is WLR_COLOR_TRANSFORM_LUT_3X1D.

struct wlr_color_transform_matrix

struct wlr_color_transform_matrix {
	struct wlr_color_transform base;
	
	float matrix[];
};

wlr_color_transform_matrix_from_base()

struct wlr_color_transform_matrix *wlr_color_transform_matrix_from_base(​struct wlr_color_transform *tr);

Get a struct wlr_color_transform_matrix from a generic struct wlr_color_transform. Asserts that the base type is WLR_COLOR_TRANSFORM_MATRIX.

struct wlr_color_transform_pipeline

struct wlr_color_transform_pipeline {
	struct wlr_color_transform base;
	
	struct wlr_color_transform **transforms;
	size_t len;
};

wlr_color_transform_pipeline_from_base()

struct wlr_color_transform_pipeline *wlr_color_transform_pipeline_from_base(​struct wlr_color_transform *tr);

Get a struct wlr_color_transform_pipeline from a generic struct wlr_color_transform. Asserts that the base type is WLR_COLOR_TRANSFORM_PIPELINE.

wlr_color_transform_ref()

struct wlr_color_transform *wlr_color_transform_ref(​struct wlr_color_transform *tr);

Increase the reference count of the color transform by 1.

enum wlr_color_transform_type

enum wlr_color_transform_type {
	WLR_COLOR_TRANSFORM_INVERSE_EOTF,
	WLR_COLOR_TRANSFORM_LCMS2,
	WLR_COLOR_TRANSFORM_LUT_3X1D,
	WLR_COLOR_TRANSFORM_MATRIX,
	WLR_COLOR_TRANSFORM_PIPELINE,
};

The representation used by a color transform.

wlr_color_transform_unref()

void wlr_color_transform_unref(​struct wlr_color_transform *tr);

Reduce the reference count of the color transform by 1; freeing it and all associated resources when the reference count hits zero.