summaryrefslogtreecommitdiff
path: root/render/fx_renderer/fx_effect_framebuffers.c
diff options
context:
space:
mode:
Diffstat (limited to 'render/fx_renderer/fx_effect_framebuffers.c')
-rw-r--r--render/fx_renderer/fx_effect_framebuffers.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/render/fx_renderer/fx_effect_framebuffers.c b/render/fx_renderer/fx_effect_framebuffers.c
new file mode 100644
index 0000000..4589b21
--- /dev/null
+++ b/render/fx_renderer/fx_effect_framebuffers.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <wlr/types/wlr_output.h>
+#include <wlr/util/addon.h>
+#include <wlr/util/log.h>
+
+#include "scenefx/render/fx_renderer/fx_effect_framebuffers.h"
+
+static void addon_handle_destroy(struct wlr_addon *addon) {
+ struct fx_effect_framebuffers *fbos = wl_container_of(addon, fbos, addon);
+ wlr_addon_finish(&fbos->addon);
+ free(fbos);
+}
+
+static const struct wlr_addon_interface fbos_addon_impl = {
+ .name = "fx_effect_framebuffers",
+ .destroy = addon_handle_destroy,
+};
+
+static bool fx_effect_framebuffers_assign(struct wlr_output *output,
+ struct fx_effect_framebuffers *fbos) {
+ wlr_addon_init(&fbos->addon, &output->addons, output, &fbos_addon_impl);
+ return true;
+}
+
+struct fx_effect_framebuffers *fx_effect_framebuffers_try_get(struct wlr_output *output) {
+ struct fx_effect_framebuffers *fbos = NULL;
+
+ struct wlr_addon *addon = wlr_addon_find(&output->addons, output,
+ &fbos_addon_impl);
+ if (!addon) {
+ goto create_new;
+ return NULL;
+ }
+
+ if (!(fbos = wl_container_of(addon, fbos, addon))) {
+ goto create_new;
+ }
+ return fbos;
+
+create_new:;
+ fbos = calloc(1, sizeof(*fbos));
+ if (!fbos) {
+ wlr_log(WLR_ERROR, "Could not allocate a fx_effect_framebuffers");
+ abort();
+ }
+ fbos->blur_buffer_dirty = false;
+
+ if (!fx_effect_framebuffers_assign(output, fbos)) {
+ wlr_log(WLR_ERROR, "Could not assign fx_effect_framebuffers to output: '%s'",
+ output->name);
+ abort();
+ }
+ return fbos;
+}