static struct shl_register text_reg = SHL_REGISTER_INIT(text_reg);
+static inline void kmscon_text_destroy(void *data)
+{
+ const struct kmscon_text_ops *ops = data;
+
+ kmscon_module_unref(ops->owner);
+}
+
/**
* kmscon_text_register:
* @ops: Text operations and name for new backend
log_debug("register text backend %s", ops->name);
- ret = shl_register_add(&text_reg, ops->name, (void*)ops);
+ ret = shl_register_add_cb(&text_reg, ops->name, (void*)ops,
+ kmscon_text_destroy);
if (ret) {
log_error("cannot register text backend %s: %d", ops->name,
ret);
return ret;
}
+ kmscon_module_ref(ops->owner);
return 0;
}
#include <errno.h>
#include <stdlib.h>
#include "font.h"
+#include "kmscon_module.h"
#include "tsm_screen.h"
#include "uterm.h"
struct kmscon_text_ops {
const char *name;
+ struct kmscon_module *owner;
int (*init) (struct kmscon_text *txt);
void (*destroy) (struct kmscon_text *txt);
int (*set) (struct kmscon_text *txt);
/* modularized backends */
+extern struct kmscon_text_ops kmscon_text_bblit_ops;
+extern struct kmscon_text_ops kmscon_text_bbulk_ops;
+extern struct kmscon_text_ops kmscon_text_gltex_ops;
+
#ifdef BUILD_ENABLE_RENDERER_BBLIT
int kmscon_text_bblit_load(void);
/*
* kmscon - Bit-Blitting Text Renderer Backend
*
- * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
+ * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
return ret;
}
-static const struct kmscon_text_ops kmscon_text_bblit_ops = {
+struct kmscon_text_ops kmscon_text_bblit_ops = {
.name = "bblit",
+ .owner = NULL,
.init = NULL,
.destroy = NULL,
.set = bblit_set,
/*
* kmscon - Bit-Blitting Bulk Text Renderer Backend
*
- * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
+ * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
txt->cols * txt->rows);
}
-static const struct kmscon_text_ops kmscon_text_bbulk_ops = {
+struct kmscon_text_ops kmscon_text_bbulk_ops = {
.name = "bbulk",
+ .owner = NULL,
.init = bbulk_init,
.destroy = bbulk_destroy,
.set = bbulk_set,
/*
* kmscon - OpenGL Textures Text Renderer Backend
*
- * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
+ * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
return 0;
}
-static const struct kmscon_text_ops kmscon_text_gltex_ops = {
+struct kmscon_text_ops kmscon_text_gltex_ops = {
.name = "gltex",
+ .owner = NULL,
.init = gltex_init,
.destroy = gltex_destroy,
.set = gltex_set,