aboutsummaryrefslogtreecommitdiff
path: root/render/drm_format_set.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-12-02 14:32:50 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-12-02 14:27:07 +0000
commitc9b378d21a06fd690223a95fe437054dff0228cd (patch)
treecdcc6610740e8b935366768d1c5817d6c5e9c233 /render/drm_format_set.c
parent21c45168383d1e6dc408d3492d9dae80f52cf2dd (diff)
render/drm-format-set: add wlr_drm_format_set_copy()
Diffstat (limited to 'render/drm_format_set.c')
-rw-r--r--render/drm_format_set.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/render/drm_format_set.c b/render/drm_format_set.c
index 13471746..3adef0b2 100644
--- a/render/drm_format_set.c
+++ b/render/drm_format_set.c
@@ -140,6 +140,31 @@ struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format) {
return duped_format;
}
+bool wlr_drm_format_set_copy(struct wlr_drm_format_set *dst, const struct wlr_drm_format_set *src) {
+ struct wlr_drm_format **formats = malloc(src->len * sizeof(formats[0]));
+ if (formats == NULL) {
+ return false;
+ }
+
+ struct wlr_drm_format_set out = {
+ .len = 0,
+ .capacity = src->len,
+ .formats = formats,
+ };
+
+ size_t i;
+ for (i = 0; i < src->len; i++) {
+ out.formats[out.len] = wlr_drm_format_dup(src->formats[i]);
+ if (out.formats[out.len] == NULL) {
+ wlr_drm_format_set_finish(&out);
+ return false;
+ }
+ out.len++;
+ }
+
+ return true;
+}
+
struct wlr_drm_format *wlr_drm_format_intersect(
const struct wlr_drm_format *a, const struct wlr_drm_format *b) {
assert(a->format == b->format);