diff options
author | Pekka Paalanen <pekka.paalanen@collabora.com> | 2023-09-20 17:20:48 +0300 |
---|---|---|
committer | Pekka Paalanen <pq@iki.fi> | 2024-05-06 10:39:42 +0000 |
commit | f408a245d0cc37d5e47365d86637579e81e0656a (patch) | |
tree | 108fe5e38218ef6db9db59eab8f1645c8c7fda68 | |
parent | 8556059785de127945b7902ace67a96f4dd808f9 (diff) |
frontend: drop compositor in wet_output_set_eotf_mode()
It would be painful to mock a struct wet_compositor in the tests, so
pass that one boolean as an explicit argument instead.
This makes it easier to extend the testing of the function.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
-rw-r--r-- | frontend/main.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/frontend/main.c b/frontend/main.c index 16a73a7f..268f2db1 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -1406,7 +1406,8 @@ wet_output_set_color_profile(struct weston_output *output, static int wet_output_set_eotf_mode(struct weston_output *output, - struct weston_config_section *section) + struct weston_config_section *section, + bool have_color_manager) { static const struct { const char *name; @@ -1417,13 +1418,10 @@ wet_output_set_eotf_mode(struct weston_output *output, { "st2084", WESTON_EOTF_MODE_ST2084 }, { "hlg", WESTON_EOTF_MODE_HLG }, }; - struct wet_compositor *compositor; enum weston_eotf_mode eotf_mode = WESTON_EOTF_MODE_SDR; char *str = NULL; unsigned i; - compositor = to_wet_compositor(output->compositor); - if (section) { weston_config_section_get_string(section, "eotf-mode", &str, NULL); @@ -1461,8 +1459,7 @@ wet_output_set_eotf_mode(struct weston_output *output, return -1; } - if (eotf_mode != WESTON_EOTF_MODE_SDR && - !compositor->use_color_manager) { + if (eotf_mode != WESTON_EOTF_MODE_SDR && !have_color_manager) { weston_log("Error: EOTF mode %s on output '%s' requires color-management=true in weston.ini\n", str, output->name); free(str); @@ -2214,7 +2211,7 @@ drm_backend_output_configure(struct weston_output *output, allow_content_protection(output, section); - if (wet_output_set_eotf_mode(output, section) < 0) + if (wet_output_set_eotf_mode(output, section, wet->use_color_manager) < 0) return -1; if (wet_output_set_color_characteristics(output, @@ -3123,11 +3120,12 @@ headless_backend_output_configure(struct weston_output *output) .scale = 1, .transform = WL_OUTPUT_TRANSFORM_NORMAL }; - struct weston_config *wc = wet_get_config(output->compositor); + struct wet_compositor *wet = to_wet_compositor(output->compositor); + struct weston_config *wc = wet->config; struct weston_config_section *section; section = weston_config_get_section(wc, "output", "name", output->name); - if (wet_output_set_eotf_mode(output, section) < 0) + if (wet_output_set_eotf_mode(output, section, wet->use_color_manager) < 0) return -1; if (wet_output_set_color_characteristics(output, wc, section) < 0) |