diff options
author | Simon Ser <contact@emersion.fr> | 2021-03-31 16:50:17 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-10-01 09:21:50 -0600 |
commit | 833437d5921339f2862ccfb0493617630ea3937d (patch) | |
tree | 1e42c9eeb72a7e2af478c8db73824968b2b0c109 /render/drm_format_set.c | |
parent | 744a5c2fefc08980a3a4755ee8fc631a2f321736 (diff) |
render/drm_format_set: add wlr_drm_format_has
Diffstat (limited to 'render/drm_format_set.c')
-rw-r--r-- | render/drm_format_set.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/render/drm_format_set.c b/render/drm_format_set.c index bd8f0cb7..daded20b 100644 --- a/render/drm_format_set.c +++ b/render/drm_format_set.c @@ -48,13 +48,7 @@ bool wlr_drm_format_set_has(const struct wlr_drm_format_set *set, return true; } - for (size_t i = 0; i < fmt->len; ++i) { - if (fmt->modifiers[i] == modifier) { - return true; - } - } - - return false; + return wlr_drm_format_has(fmt, modifier); } bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format, @@ -106,6 +100,15 @@ struct wlr_drm_format *wlr_drm_format_create(uint32_t format) { return fmt; } +bool wlr_drm_format_has(const struct wlr_drm_format *fmt, uint64_t modifier) { + for (size_t i = 0; i < fmt->len; ++i) { + if (fmt->modifiers[i] == modifier) { + return true; + } + } + return false; +} + bool wlr_drm_format_add(struct wlr_drm_format **fmt_ptr, uint64_t modifier) { struct wlr_drm_format *fmt = *fmt_ptr; @@ -113,10 +116,8 @@ bool wlr_drm_format_add(struct wlr_drm_format **fmt_ptr, uint64_t modifier) { return true; } - for (size_t i = 0; i < fmt->len; ++i) { - if (fmt->modifiers[i] == modifier) { - return true; - } + if (wlr_drm_format_has(fmt, modifier)) { + return true; } if (fmt->len == fmt->cap) { |