mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
color-representation-v1: Add wlr enums + converters
Add wlr-internal enums for the properties specified in color-representation-v1 (encoding, range, chroma siting, alpha mode) so that other parts of wlroots can use these without depending on the protocol specifics and without needing to include the protocol headers. Also add conversion functions to convert the protocol enum values into the wlroots enum values.
This commit is contained in:
parent
eff620770c
commit
a4eb2cff46
3 changed files with 126 additions and 0 deletions
|
|
@ -30,6 +30,57 @@ enum wlr_color_transfer_function {
|
|||
WLR_COLOR_TRANSFER_FUNCTION_EXT_LINEAR = 1 << 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Specifies alpha blending modes. Note that premultiplied_electrical
|
||||
* is the default, so there is no "none" or "unset" value.
|
||||
*/
|
||||
enum wlr_alpha_mode {
|
||||
WLR_COLOR_ALPHA_MODE_PREMULTIPLIED_ELECTRICAL,
|
||||
WLR_COLOR_ALPHA_MODE_PREMULTIPLIED_OPTICAL,
|
||||
WLR_COLOR_ALPHA_MODE_STRAIGHT,
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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,
|
||||
};
|
||||
|
||||
/**
|
||||
* Specifies whether a particular color-encoding uses full- or limited-range
|
||||
* values. NONE means the value is unset or unknown.
|
||||
*/
|
||||
enum wlr_color_range {
|
||||
WLR_COLOR_RANGE_NONE,
|
||||
WLR_COLOR_RANGE_LIMITED,
|
||||
WLR_COLOR_RANGE_FULL,
|
||||
};
|
||||
|
||||
/**
|
||||
* Chroma sample locations, corresponding to Chroma420SampleLocType code
|
||||
* points in H.273. NONE means the value is unset or unknown.
|
||||
*/
|
||||
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,
|
||||
};
|
||||
|
||||
/**
|
||||
* CIE 1931 xy chromaticity coordinates.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -82,4 +82,13 @@ struct wlr_color_representation_v1_surface_state {
|
|||
const struct wlr_color_representation_v1_surface_state *wlr_color_representation_v1_get_surface_state(
|
||||
struct wlr_surface *surface);
|
||||
|
||||
enum wlr_alpha_mode wlr_color_representation_v1_alpha_mode_to_wlr(
|
||||
enum wp_color_representation_surface_v1_alpha_mode wp_val);
|
||||
enum wlr_color_encoding wlr_color_representation_v1_color_encoding_to_wlr(
|
||||
enum wp_color_representation_surface_v1_coefficients wp_val);
|
||||
enum wlr_color_range wlr_color_representation_v1_color_range_to_wlr(
|
||||
enum wp_color_representation_surface_v1_range wp_val);
|
||||
enum wlr_color_chroma_location wlr_color_representation_v1_chroma_location_to_wlr(
|
||||
enum wp_color_representation_surface_v1_chroma_location wp_val);
|
||||
|
||||
#endif // WLR_TYPES_WLR_COLOR_REPRESENTATION_V1_H
|
||||
|
|
|
|||
|
|
@ -11,6 +11,72 @@
|
|||
|
||||
#define WP_COLOR_REPRESENTATION_VERSION 1
|
||||
|
||||
enum wlr_alpha_mode wlr_color_representation_v1_alpha_mode_to_wlr(
|
||||
enum wp_color_representation_surface_v1_alpha_mode wp_val) {
|
||||
switch (wp_val) {
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_ALPHA_MODE_PREMULTIPLIED_ELECTRICAL:
|
||||
return WLR_COLOR_ALPHA_MODE_PREMULTIPLIED_ELECTRICAL;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_ALPHA_MODE_PREMULTIPLIED_OPTICAL:
|
||||
return WLR_COLOR_ALPHA_MODE_PREMULTIPLIED_OPTICAL;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_ALPHA_MODE_STRAIGHT:
|
||||
return WLR_COLOR_ALPHA_MODE_STRAIGHT;
|
||||
}
|
||||
abort(); // unreachable
|
||||
}
|
||||
|
||||
enum wlr_color_encoding wlr_color_representation_v1_color_encoding_to_wlr(
|
||||
enum wp_color_representation_surface_v1_coefficients wp_val) {
|
||||
switch (wp_val) {
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_IDENTITY:
|
||||
return WLR_COLOR_ENCODING_IDENTITY;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_BT709:
|
||||
return WLR_COLOR_ENCODING_BT709;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_FCC:
|
||||
return WLR_COLOR_ENCODING_FCC;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_BT601:
|
||||
return WLR_COLOR_ENCODING_BT601;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_SMPTE240:
|
||||
return WLR_COLOR_ENCODING_SMPTE240;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_BT2020:
|
||||
return WLR_COLOR_ENCODING_BT2020;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_BT2020_CL:
|
||||
return WLR_COLOR_ENCODING_BT2020_CL;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_COEFFICIENTS_ICTCP:
|
||||
return WLR_COLOR_ENCODING_ICTCP;
|
||||
}
|
||||
abort(); // unreachable
|
||||
}
|
||||
|
||||
enum wlr_color_range wlr_color_representation_v1_color_range_to_wlr(
|
||||
enum wp_color_representation_surface_v1_range wp_val) {
|
||||
switch (wp_val) {
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_RANGE_LIMITED:
|
||||
return WLR_COLOR_RANGE_LIMITED;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_RANGE_FULL:
|
||||
return WLR_COLOR_RANGE_FULL;
|
||||
}
|
||||
abort(); // unreachable
|
||||
}
|
||||
|
||||
enum wlr_color_chroma_location wlr_color_representation_v1_chroma_location_to_wlr(
|
||||
enum wp_color_representation_surface_v1_chroma_location wp_val) {
|
||||
switch (wp_val) {
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_CHROMA_LOCATION_TYPE_0:
|
||||
return WLR_COLOR_CHROMA_LOCATION_TYPE0;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_CHROMA_LOCATION_TYPE_1:
|
||||
return WLR_COLOR_CHROMA_LOCATION_TYPE1;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_CHROMA_LOCATION_TYPE_2:
|
||||
return WLR_COLOR_CHROMA_LOCATION_TYPE2;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_CHROMA_LOCATION_TYPE_3:
|
||||
return WLR_COLOR_CHROMA_LOCATION_TYPE3;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_CHROMA_LOCATION_TYPE_4:
|
||||
return WLR_COLOR_CHROMA_LOCATION_TYPE4;
|
||||
case WP_COLOR_REPRESENTATION_SURFACE_V1_CHROMA_LOCATION_TYPE_5:
|
||||
return WLR_COLOR_CHROMA_LOCATION_TYPE5;
|
||||
}
|
||||
abort(); // unreachable
|
||||
}
|
||||
|
||||
struct wlr_color_representation_v1 {
|
||||
struct wl_resource *resource;
|
||||
struct wlr_surface *surface;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue