mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-01 07:16:18 -04:00
render/color: Invert ownership model of color_transform types.
Color transform can have multiple types and these different types want to store different metadata. We previously stored this metadata directly on wlr_color_transform even for transforms that don't use it. Instead, let's take the prior art from wlr_scene where each scene node is built on a base node. Notice how wlr_color_transform_lut3d now has a `struct wlr_color_transform base`. This is advantageous in multiple ways: 1. We don't allocate memory for metadata that will never be used. 2. This is more type safe: Compositors can pass around a struct wlr_color_transform_lut3d if they know they only want to use a 3d_lut. 3. This is more scalable. As we add more transform types, we don't have to keep growing a monolithic struct.
This commit is contained in:
parent
fa2abbeefb
commit
3187479c07
4 changed files with 54 additions and 23 deletions
|
|
@ -116,7 +116,14 @@ static bool render_pass_submit(struct wlr_render_pass *wlr_pass) {
|
|||
.uv_off = { 0, 0 },
|
||||
.uv_size = { 1, 1 },
|
||||
};
|
||||
size_t dim = pass->color_transform ? pass->color_transform->lut3d.dim_len : 1;
|
||||
|
||||
size_t dim = 1;
|
||||
if (pass->color_transform && pass->color_transform->type == COLOR_TRANSFORM_LUT_3D) {
|
||||
struct wlr_color_transform_lut3d *lut3d =
|
||||
wlr_color_transform_lut3d_from_base(pass->color_transform);
|
||||
dim = lut3d->dim_len;
|
||||
}
|
||||
|
||||
struct wlr_vk_frag_output_pcr_data frag_pcr_data = {
|
||||
.lut_3d_offset = 0.5f / dim,
|
||||
.lut_3d_scale = (float)(dim - 1) / dim,
|
||||
|
|
@ -894,7 +901,8 @@ static struct wlr_vk_color_transform *vk_color_transform_create(
|
|||
}
|
||||
|
||||
if (transform->type == COLOR_TRANSFORM_LUT_3D) {
|
||||
if (!create_3d_lut_image(renderer, &transform->lut3d,
|
||||
if (!create_3d_lut_image(renderer,
|
||||
wlr_color_transform_lut3d_from_base(transform),
|
||||
&vk_transform->lut_3d.image,
|
||||
&vk_transform->lut_3d.image_view,
|
||||
&vk_transform->lut_3d.memory,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue