mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-17 06:46:39 -04:00
render/color: Add COLOR_TRANSFORM_LUT_3x1D type
This commit is contained in:
parent
75cf7ceec9
commit
3a5dd80d20
2 changed files with 50 additions and 0 deletions
|
|
@ -7,6 +7,7 @@
|
|||
enum wlr_color_transform_type {
|
||||
COLOR_TRANSFORM_SRGB,
|
||||
COLOR_TRANSFORM_LUT_3D,
|
||||
COLOR_TRANSFORM_LUT_3x1D,
|
||||
};
|
||||
|
||||
struct wlr_color_transform {
|
||||
|
|
@ -37,6 +38,36 @@ struct wlr_color_transform_lut3d {
|
|||
size_t dim_len;
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a color transform that is specified by three seperate ramps that
|
||||
* modify the RGB values individually. This means that this color transform type
|
||||
* cannot be used to create a transform that can infruence color channels
|
||||
* depending on the values of other color channels.
|
||||
*
|
||||
* This color transform is modeled off of the wlr-gamma-control-unstable-v1
|
||||
* wayland protocol.
|
||||
*
|
||||
* The memory layout of this type requires that the r, g, b color channel ramps
|
||||
* are inline in memory. A ramp value can be retrieved from memory:
|
||||
*
|
||||
* offset = dim_len * rgb_channel_index + ramp_index
|
||||
*
|
||||
* This is an offset into the `r` pointer and can be used to retrieve the ramps
|
||||
* from the other channels as the ramps are linear in memory. The three pointers
|
||||
* are given for convenience.
|
||||
*
|
||||
* Note that when freeing the color transform, only the `r` channel is freed as
|
||||
* a it's expected that a single malloc will allocate all three channels at once.
|
||||
*/
|
||||
struct wlr_color_transform_lut3x1d {
|
||||
struct wlr_color_transform base;
|
||||
|
||||
uint16_t *r;
|
||||
uint16_t *g;
|
||||
uint16_t *b;
|
||||
size_t ramp_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a wlr_color_transform_lut3d from a generic wlr_color_transform.
|
||||
* Asserts that the base type is COLOR_TRANSFORM_LUT_3D
|
||||
|
|
@ -44,4 +75,11 @@ struct wlr_color_transform_lut3d {
|
|||
struct wlr_color_transform_lut3d *wlr_color_transform_lut3d_from_base(
|
||||
struct wlr_color_transform *tr);
|
||||
|
||||
/**
|
||||
* Gets a wlr_color_transform_lut3x1d from a generic wlr_color_transform.
|
||||
* Asserts that the base type is COLOR_TRANSFORM_LUT_3x1D
|
||||
*/
|
||||
struct wlr_color_transform_lut3x1d *wlr_color_transform_lut3x1d_from_base(
|
||||
struct wlr_color_transform *tr);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ static void color_transform_destroy(struct wlr_color_transform *tr) {
|
|||
wlr_color_transform_lut3d_from_base(tr);
|
||||
free(lut3d->lut_3d);
|
||||
break;
|
||||
case COLOR_TRANSFORM_LUT_3x1D:;
|
||||
struct wlr_color_transform_lut3x1d *lut3x1d =
|
||||
wlr_color_transform_lut3x1d_from_base(tr);
|
||||
free(lut3x1d->r);
|
||||
break;
|
||||
}
|
||||
wlr_addon_set_finish(&tr->addons);
|
||||
free(tr);
|
||||
|
|
@ -50,3 +55,10 @@ struct wlr_color_transform_lut3d *wlr_color_transform_lut3d_from_base(
|
|||
struct wlr_color_transform_lut3d *lut3d = wl_container_of(tr, lut3d, base);
|
||||
return lut3d;
|
||||
}
|
||||
|
||||
struct wlr_color_transform_lut3x1d *wlr_color_transform_lut3x1d_from_base(
|
||||
struct wlr_color_transform *tr) {
|
||||
assert(tr->type == COLOR_TRANSFORM_LUT_3x1D);
|
||||
struct wlr_color_transform_lut3x1d *lut = wl_container_of(tr, lut, base);
|
||||
return lut;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue