text: add owner field to text-ops
When text-ops are registered via modules, we need an owner field so they're correctly tracked. Hence, add this field to all text-ops and correctly keep module references. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
074c06eafb
commit
0cecc8de1e
11
src/text.c
11
src/text.c
@ -45,6 +45,13 @@
|
||||
|
||||
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
|
||||
@ -68,13 +75,15 @@ int kmscon_text_register(const struct kmscon_text_ops *ops)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "font.h"
|
||||
#include "kmscon_module.h"
|
||||
#include "tsm_screen.h"
|
||||
#include "uterm.h"
|
||||
|
||||
@ -60,6 +61,7 @@ struct kmscon_text {
|
||||
|
||||
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);
|
||||
@ -108,6 +110,10 @@ int kmscon_text_render_cb(struct tsm_screen *con, void *data);
|
||||
|
||||
/* 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);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* 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
|
||||
@ -109,8 +109,9 @@ static int bblit_draw(struct kmscon_text *txt,
|
||||
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,
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* 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
|
||||
@ -173,8 +173,9 @@ static int bbulk_render(struct kmscon_text *txt)
|
||||
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,
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* 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
|
||||
@ -682,8 +682,9 @@ static int gltex_render(struct kmscon_text *txt)
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user