mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
render/drm_format_set: introduce wlr_drm_format_dup
This commit is contained in:
parent
5913040110
commit
7c6212a0f7
2 changed files with 20 additions and 0 deletions
8
include/render/drm_format_set.h
Normal file
8
include/render/drm_format_set.h
Normal file
|
@ -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
|
|
@ -6,6 +6,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wlr/render/drm_format_set.h>
|
#include <wlr/render/drm_format_set.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
#include "render/drm_format_set.h"
|
||||||
|
|
||||||
void wlr_drm_format_set_finish(struct wlr_drm_format_set *set) {
|
void wlr_drm_format_set_finish(struct wlr_drm_format_set *set) {
|
||||||
for (size_t i = 0; i < set->len; ++i) {
|
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;
|
set->formats[set->len++] = fmt;
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue