mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-26 14:40:12 +01:00
frontend: use weston_enum_map for renderers
Entrench the use of weston_enum_map more, even though in this case it doesn't buy much. Make the array 'static const' which it should have been already. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
0787422248
commit
8694665f4f
1 changed files with 7 additions and 10 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
#include <libweston/config-parser.h>
|
#include <libweston/config-parser.h>
|
||||||
|
|
||||||
#include "shared/helpers.h"
|
#include "shared/helpers.h"
|
||||||
|
#include "shared/string-helpers.h"
|
||||||
#include "weston-private.h"
|
#include "weston-private.h"
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -64,10 +65,7 @@ get_backend_from_string(const char *name,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct {
|
static const struct weston_enum_map renderer_name_map[] = {
|
||||||
char *name;
|
|
||||||
enum weston_renderer_type renderer;
|
|
||||||
} renderer_name_map[] = {
|
|
||||||
{ "auto", WESTON_RENDERER_AUTO },
|
{ "auto", WESTON_RENDERER_AUTO },
|
||||||
{ "gl", WESTON_RENDERER_GL },
|
{ "gl", WESTON_RENDERER_GL },
|
||||||
{ "vulkan", WESTON_RENDERER_VULKAN },
|
{ "vulkan", WESTON_RENDERER_VULKAN },
|
||||||
|
|
@ -79,16 +77,15 @@ bool
|
||||||
get_renderer_from_string(const char *name,
|
get_renderer_from_string(const char *name,
|
||||||
enum weston_renderer_type *renderer)
|
enum weston_renderer_type *renderer)
|
||||||
{
|
{
|
||||||
size_t i;
|
const struct weston_enum_map *entry;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
name = "auto";
|
name = "auto";
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(renderer_name_map); i++) {
|
entry = weston_enum_map_find_name(renderer_name_map, name);
|
||||||
if (strcmp(name, renderer_name_map[i].name) == 0) {
|
if (entry) {
|
||||||
*renderer = renderer_name_map[i].renderer;
|
*renderer = entry->value;
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue