aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-08-07 19:02:49 +0200
committerSimon Ser <contact@emersion.fr>2020-11-15 22:48:42 +0100
commit7c6212a0f71eeab23a4ff4241cb266ec219fad2d (patch)
treeb03d28bc5d4597fec82d323a72c830f3fd3024df
parent5913040110bde856fa6dc98d3b844cf7f25f5674 (diff)
render/drm_format_set: introduce wlr_drm_format_dup
-rw-r--r--include/render/drm_format_set.h8
-rw-r--r--render/drm_format_set.c12
2 files changed, 20 insertions, 0 deletions
diff --git a/include/render/drm_format_set.h b/include/render/drm_format_set.h
new file mode 100644
index 00000000..ae1fcc47
--- /dev/null
+++ b/include/render/drm_format_set.h
@@ -0,0 +1,8 @@
+#ifndef RENDER_DRM_FORMAT_SET_H
+#define RENDER_DRM_FORMAT_SET_H
+
+#include <wlr/render/drm_format_set.h>
+
+struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format);
+
+#endif
diff --git a/render/drm_format_set.c b/render/drm_format_set.c
index cbcc0875..54fc8ae1 100644
--- a/render/drm_format_set.c
+++ b/render/drm_format_set.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <wlr/render/drm_format_set.h>
#include <wlr/util/log.h>
+#include "render/drm_format_set.h"
void wlr_drm_format_set_finish(struct wlr_drm_format_set *set) {
for (size_t i = 0; i < set->len; ++i) {
@@ -125,3 +126,14 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format,
set->formats[set->len++] = fmt;
return true;
}
+
+struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format) {
+ size_t format_size = sizeof(struct wlr_drm_format) +
+ format->len * sizeof(format->modifiers[0]);
+ struct wlr_drm_format *duped_format = malloc(format_size);
+ if (duped_format == NULL) {
+ return NULL;
+ }
+ memcpy(duped_format, format, format_size);
+ return duped_format;
+}