compositor: extract mode parsing from windowed output configuration
To make it reusable, extract parse_simple_mode() from wet_configure_windowed_output_from_config(). Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
parent
0706569ac9
commit
553387dd07
@ -1536,6 +1536,35 @@ allow_content_protection(struct weston_output *output,
|
|||||||
weston_output_allow_protection(output, allow_hdcp);
|
weston_output_allow_protection(output, allow_hdcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parse_simple_mode(struct weston_output *output,
|
||||||
|
struct weston_config_section *section, int *width,
|
||||||
|
int *height, struct wet_output_config *defaults,
|
||||||
|
struct wet_output_config *parsed_options)
|
||||||
|
{
|
||||||
|
*width = defaults->width;
|
||||||
|
*height = defaults->height;
|
||||||
|
|
||||||
|
if (section) {
|
||||||
|
char *mode;
|
||||||
|
|
||||||
|
weston_config_section_get_string(section, "mode", &mode, NULL);
|
||||||
|
if (!mode || sscanf(mode, "%dx%d", width, height) != 2) {
|
||||||
|
weston_log("Invalid mode for output %s. Using defaults.\n",
|
||||||
|
output->name);
|
||||||
|
*width = defaults->width;
|
||||||
|
*height = defaults->height;
|
||||||
|
}
|
||||||
|
free(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parsed_options->width)
|
||||||
|
*width = parsed_options->width;
|
||||||
|
|
||||||
|
if (parsed_options->height)
|
||||||
|
*height = parsed_options->height;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
wet_configure_windowed_output_from_config(struct weston_output *output,
|
wet_configure_windowed_output_from_config(struct weston_output *output,
|
||||||
struct wet_output_config *defaults)
|
struct wet_output_config *defaults)
|
||||||
@ -1547,8 +1576,8 @@ wet_configure_windowed_output_from_config(struct weston_output *output,
|
|||||||
struct weston_config_section *section = NULL;
|
struct weston_config_section *section = NULL;
|
||||||
struct wet_compositor *compositor = to_wet_compositor(output->compositor);
|
struct wet_compositor *compositor = to_wet_compositor(output->compositor);
|
||||||
struct wet_output_config *parsed_options = compositor->parsed_options;
|
struct wet_output_config *parsed_options = compositor->parsed_options;
|
||||||
int width = defaults->width;
|
int width;
|
||||||
int height = defaults->height;
|
int height;
|
||||||
|
|
||||||
assert(parsed_options);
|
assert(parsed_options);
|
||||||
|
|
||||||
@ -1559,28 +1588,11 @@ wet_configure_windowed_output_from_config(struct weston_output *output,
|
|||||||
|
|
||||||
section = weston_config_get_section(wc, "output", "name", output->name);
|
section = weston_config_get_section(wc, "output", "name", output->name);
|
||||||
|
|
||||||
if (section) {
|
parse_simple_mode(output, section, &width, &height, defaults,
|
||||||
char *mode;
|
parsed_options);
|
||||||
|
|
||||||
weston_config_section_get_string(section, "mode", &mode, NULL);
|
|
||||||
if (!mode || sscanf(mode, "%dx%d", &width,
|
|
||||||
&height) != 2) {
|
|
||||||
weston_log("Invalid mode for output %s. Using defaults.\n",
|
|
||||||
output->name);
|
|
||||||
width = defaults->width;
|
|
||||||
height = defaults->height;
|
|
||||||
}
|
|
||||||
free(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
allow_content_protection(output, section);
|
allow_content_protection(output, section);
|
||||||
|
|
||||||
if (parsed_options->width)
|
|
||||||
width = parsed_options->width;
|
|
||||||
|
|
||||||
if (parsed_options->height)
|
|
||||||
height = parsed_options->height;
|
|
||||||
|
|
||||||
wet_output_set_scale(output, section, defaults->scale, parsed_options->scale);
|
wet_output_set_scale(output, section, defaults->scale, parsed_options->scale);
|
||||||
if (wet_output_set_transform(output, section, defaults->transform,
|
if (wet_output_set_transform(output, section, defaults->transform,
|
||||||
parsed_options->transform) < 0) {
|
parsed_options->transform) < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user