aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Orzechowski <alex@ozal.ski>2023-05-10 16:02:07 -0400
committerAlexander Orzechowski <alex@ozal.ski>2023-05-11 03:51:01 -0400
commitb45396c790277f3527425bf60c9f27718edf25c8 (patch)
tree07eedbfbccd2469f2cf50b5476c47bc741e66dce
parente353c5c63175c6b3abcbf588aa29285d09817fa4 (diff)
wlr_drm_format: Introduce drm_format_finish
-rw-r--r--backend/drm/drm.c2
-rw-r--r--include/wlr/render/drm_format_set.h5
-rw-r--r--render/drm_format_set.c7
-rw-r--r--render/swapchain.c1
-rw-r--r--types/output/cursor.c1
-rw-r--r--types/output/output.c1
-rw-r--r--types/output/swapchain.c2
7 files changed, 19 insertions, 0 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 7b6b5451..0ac41afb 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -513,6 +513,7 @@ static bool drm_connector_state_update_primary_fb(struct wlr_drm_connector *conn
// TODO: fallback to modifier-less buffer allocation
bool ok = init_drm_surface(&plane->mgpu_surf, &drm->mgpu_renderer,
source_buf->width, source_buf->height, format);
+ wlr_drm_format_finish(format);
free(format);
if (!ok) {
return false;
@@ -953,6 +954,7 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
bool ok = init_drm_surface(&plane->mgpu_surf, &drm->mgpu_renderer,
buffer->width, buffer->height, format);
+ wlr_drm_format_finish(format);
free(format);
if (!ok) {
return false;
diff --git a/include/wlr/render/drm_format_set.h b/include/wlr/render/drm_format_set.h
index c8f3c309..90be4990 100644
--- a/include/wlr/render/drm_format_set.h
+++ b/include/wlr/render/drm_format_set.h
@@ -26,6 +26,11 @@ struct wlr_drm_format {
};
/**
+ * Free all resources allocated to this DRM format.
+ */
+void wlr_drm_format_finish(struct wlr_drm_format *format);
+
+/**
* A set of DRM formats and modifiers.
*
* This is used to describe the supported format + modifier combinations. For
diff --git a/render/drm_format_set.c b/render/drm_format_set.c
index 8f3aea99..280d6465 100644
--- a/render/drm_format_set.c
+++ b/render/drm_format_set.c
@@ -8,8 +8,13 @@
#include <wlr/util/log.h>
#include "render/drm_format_set.h"
+void wlr_drm_format_finish(struct wlr_drm_format *format) {
+ // For later
+}
+
void wlr_drm_format_set_finish(struct wlr_drm_format_set *set) {
for (size_t i = 0; i < set->len; ++i) {
+ wlr_drm_format_finish(set->formats[i]);
free(set->formats[i]);
}
free(set->formats);
@@ -60,6 +65,7 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format,
return false;
}
if (!wlr_drm_format_add(&fmt, modifier)) {
+ wlr_drm_format_finish(fmt);
return false;
}
@@ -196,6 +202,7 @@ struct wlr_drm_format *wlr_drm_format_intersect(
// If the intersection is empty, then the formats aren't compatible with
// each other.
if (format->len == 0) {
+ wlr_drm_format_set_finish(format);
free(format);
return NULL;
}
diff --git a/render/swapchain.c b/render/swapchain.c
index 5ccf812e..a15ac7f9 100644
--- a/render/swapchain.c
+++ b/render/swapchain.c
@@ -54,6 +54,7 @@ void wlr_swapchain_destroy(struct wlr_swapchain *swapchain) {
slot_reset(&swapchain->slots[i]);
}
wl_list_remove(&swapchain->allocator_destroy.link);
+ wlr_drm_format_finish(swapchain->format);
free(swapchain->format);
free(swapchain);
}
diff --git a/types/output/cursor.c b/types/output/cursor.c
index bea83f83..3e9eeed1 100644
--- a/types/output/cursor.c
+++ b/types/output/cursor.c
@@ -299,6 +299,7 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor)
wlr_swapchain_destroy(output->cursor_swapchain);
output->cursor_swapchain = wlr_swapchain_create(allocator,
width, height, format);
+ wlr_drm_format_finish(format);
free(format);
if (output->cursor_swapchain == NULL) {
wlr_log(WLR_ERROR, "Failed to create cursor swapchain");
diff --git a/types/output/output.c b/types/output/output.c
index f380f8a2..2a326a99 100644
--- a/types/output/output.c
+++ b/types/output/output.c
@@ -609,6 +609,7 @@ static bool output_basic_test(struct wlr_output *output,
return false;
}
+ wlr_drm_format_finish(format);
free(format);
}
diff --git a/types/output/swapchain.c b/types/output/swapchain.c
index 12018a3c..a284579e 100644
--- a/types/output/swapchain.c
+++ b/types/output/swapchain.c
@@ -32,6 +32,7 @@ static struct wlr_swapchain *create_swapchain(struct wlr_output *output,
if (!allow_modifiers && (format->len != 1 || format->modifiers[0] != DRM_FORMAT_MOD_LINEAR)) {
if (!wlr_drm_format_has(format, DRM_FORMAT_MOD_INVALID)) {
wlr_log(WLR_DEBUG, "Implicit modifiers not supported");
+ wlr_drm_format_finish(format);
free(format);
return NULL;
}
@@ -41,6 +42,7 @@ static struct wlr_swapchain *create_swapchain(struct wlr_output *output,
}
struct wlr_swapchain *swapchain = wlr_swapchain_create(allocator, width, height, format);
+ wlr_drm_format_finish(format);
free(format);
return swapchain;
}