mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
wlr_drm_format: Change wlr_drm_format_create to init
This commit is contained in:
parent
e427e019c4
commit
099a147439
2 changed files with 6 additions and 12 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <wlr/render/drm_format_set.h>
|
#include <wlr/render/drm_format_set.h>
|
||||||
|
|
||||||
struct wlr_drm_format *wlr_drm_format_create(uint32_t format);
|
void wlr_drm_format_init(struct wlr_drm_format *fmt, uint32_t format);
|
||||||
bool wlr_drm_format_has(const struct wlr_drm_format *fmt, uint64_t modifier);
|
bool wlr_drm_format_has(const struct wlr_drm_format *fmt, uint64_t modifier);
|
||||||
bool wlr_drm_format_add(struct wlr_drm_format *fmt, uint64_t modifier);
|
bool wlr_drm_format_add(struct wlr_drm_format *fmt, uint64_t modifier);
|
||||||
struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format);
|
struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format);
|
||||||
|
|
|
@ -64,10 +64,12 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format,
|
||||||
return wlr_drm_format_add(*ptr, modifier);
|
return wlr_drm_format_add(*ptr, modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_drm_format *fmt = wlr_drm_format_create(format);
|
struct wlr_drm_format *fmt = calloc(1, sizeof(*fmt));
|
||||||
if (!fmt) {
|
if (!fmt) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_drm_format_init(fmt, format);
|
||||||
if (!wlr_drm_format_add(fmt, modifier)) {
|
if (!wlr_drm_format_add(fmt, modifier)) {
|
||||||
wlr_drm_format_finish(fmt);
|
wlr_drm_format_finish(fmt);
|
||||||
return false;
|
return false;
|
||||||
|
@ -92,17 +94,9 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_drm_format *wlr_drm_format_create(uint32_t format) {
|
void wlr_drm_format_init(struct wlr_drm_format *fmt, uint32_t format) {
|
||||||
size_t capacity = 4;
|
memset(fmt, 0, sizeof(*fmt));
|
||||||
struct wlr_drm_format *fmt = calloc(1, sizeof(*fmt));
|
|
||||||
if (!fmt) {
|
|
||||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
fmt->format = format;
|
fmt->format = format;
|
||||||
fmt->capacity = capacity;
|
|
||||||
fmt->modifiers = malloc(sizeof(*fmt->modifiers) * capacity);
|
|
||||||
return fmt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_drm_format_has(const struct wlr_drm_format *fmt, uint64_t modifier) {
|
bool wlr_drm_format_has(const struct wlr_drm_format *fmt, uint64_t modifier) {
|
||||||
|
|
Loading…
Reference in a new issue