backend-drm: Use renderer enum type for config selection

When we're selecting our renderer, use the enum rather than a boolean to
force Pixman on.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2022-12-29 18:14:52 +00:00 committed by Marius Vlad
parent e1da6c6615
commit c683ebdea3
3 changed files with 29 additions and 17 deletions

View File

@ -2892,34 +2892,31 @@ load_drm_backend(struct weston_compositor *c,
struct weston_config_section *section;
struct wet_compositor *wet = to_wet_compositor(c);
bool without_input = false;
bool use_pixman_default;
bool force_pixman = false;
int ret = 0;
wet->drm_use_current_mode = false;
section = weston_config_get_section(wc, "core", NULL, NULL);
/* Use the pixman renderer by default when GBM/EGL support is
* not enabled */
#if defined(BUILD_DRM_GBM)
use_pixman_default = false;
#else
use_pixman_default = true;
#endif
weston_config_section_get_bool(section, "use-pixman", &config.use_pixman,
use_pixman_default);
weston_config_section_get_bool(section, "use-pixman", &force_pixman,
false);
const struct weston_option options[] = {
{ WESTON_OPTION_STRING, "seat", 0, &config.seat_id },
{ WESTON_OPTION_STRING, "drm-device", 0, &config.specific_device },
{ WESTON_OPTION_BOOLEAN, "current-mode", 0, &wet->drm_use_current_mode },
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config.use_pixman },
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &force_pixman },
{ WESTON_OPTION_BOOLEAN, "continue-without-input", false, &without_input }
};
parse_options(options, ARRAY_LENGTH(options), argc, argv);
if (force_pixman)
config.renderer = WESTON_RENDERER_PIXMAN;
else
config.renderer = WESTON_RENDERER_AUTO;
section = weston_config_get_section(wc, "core", NULL, NULL);
weston_config_section_get_string(section,
"gbm-format", &config.gbm_format,

View File

@ -35,7 +35,7 @@
extern "C" {
#endif
#define WESTON_DRM_BACKEND_CONFIG_VERSION 5
#define WESTON_DRM_BACKEND_CONFIG_VERSION 6
struct libinput_device;
@ -201,8 +201,8 @@ weston_drm_virtual_output_get_api(struct weston_compositor *compositor)
struct weston_drm_backend_config {
struct weston_backend_config base;
/** Whether to use the pixman renderer instead of the OpenGL ES renderer. */
bool use_pixman;
/** Select the renderer type to use */
enum weston_renderer_type renderer;
/** The seat to be used for input and output.
*

View File

@ -3201,16 +3201,30 @@ drm_backend_create(struct weston_compositor *compositor,
goto err_udev_dev;
}
if (config->use_pixman) {
if (config->renderer == WESTON_RENDERER_AUTO) {
#ifdef BUILD_DRM_GBM
config->renderer = WESTON_RENDERER_GL;
#else
config->renderer = WESTON_RENDERER_PIXMAN;
#endif
}
switch (config->renderer) {
case WESTON_RENDERER_PIXMAN:
if (init_pixman(b) < 0) {
weston_log("failed to initialize pixman renderer\n");
goto err_udev_dev;
}
} else {
break;
case WESTON_RENDERER_GL:
if (init_egl(b) < 0) {
weston_log("failed to initialize egl\n");
goto err_udev_dev;
}
break;
default:
weston_log("unsupported renderer for DRM backend\n");
goto err_udev_dev;
}
b->base.destroy = drm_destroy;
@ -3376,6 +3390,7 @@ err_compositor:
static void
config_init_to_defaults(struct weston_drm_backend_config *config)
{
config->renderer = WESTON_RENDERER_AUTO;
config->use_pixman_shadow = true;
}