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 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:
|
* kmscon_text_register:
|
||||||
* @ops: Text operations and name for new backend
|
* @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);
|
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) {
|
if (ret) {
|
||||||
log_error("cannot register text backend %s: %d", ops->name,
|
log_error("cannot register text backend %s: %d", ops->name,
|
||||||
ret);
|
ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kmscon_module_ref(ops->owner);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
#include "kmscon_module.h"
|
||||||
#include "tsm_screen.h"
|
#include "tsm_screen.h"
|
||||||
#include "uterm.h"
|
#include "uterm.h"
|
||||||
|
|
||||||
@ -60,6 +61,7 @@ struct kmscon_text {
|
|||||||
|
|
||||||
struct kmscon_text_ops {
|
struct kmscon_text_ops {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
struct kmscon_module *owner;
|
||||||
int (*init) (struct kmscon_text *txt);
|
int (*init) (struct kmscon_text *txt);
|
||||||
void (*destroy) (struct kmscon_text *txt);
|
void (*destroy) (struct kmscon_text *txt);
|
||||||
int (*set) (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 */
|
/* 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
|
#ifdef BUILD_ENABLE_RENDERER_BBLIT
|
||||||
|
|
||||||
int kmscon_text_bblit_load(void);
|
int kmscon_text_bblit_load(void);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* kmscon - Bit-Blitting Text Renderer Backend
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files
|
* a copy of this software and associated documentation files
|
||||||
@ -109,8 +109,9 @@ static int bblit_draw(struct kmscon_text *txt,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct kmscon_text_ops kmscon_text_bblit_ops = {
|
struct kmscon_text_ops kmscon_text_bblit_ops = {
|
||||||
.name = "bblit",
|
.name = "bblit",
|
||||||
|
.owner = NULL,
|
||||||
.init = NULL,
|
.init = NULL,
|
||||||
.destroy = NULL,
|
.destroy = NULL,
|
||||||
.set = bblit_set,
|
.set = bblit_set,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* kmscon - Bit-Blitting Bulk Text Renderer Backend
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files
|
* 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);
|
txt->cols * txt->rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct kmscon_text_ops kmscon_text_bbulk_ops = {
|
struct kmscon_text_ops kmscon_text_bbulk_ops = {
|
||||||
.name = "bbulk",
|
.name = "bbulk",
|
||||||
|
.owner = NULL,
|
||||||
.init = bbulk_init,
|
.init = bbulk_init,
|
||||||
.destroy = bbulk_destroy,
|
.destroy = bbulk_destroy,
|
||||||
.set = bbulk_set,
|
.set = bbulk_set,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* kmscon - OpenGL Textures Text Renderer Backend
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files
|
* a copy of this software and associated documentation files
|
||||||
@ -682,8 +682,9 @@ static int gltex_render(struct kmscon_text *txt)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct kmscon_text_ops kmscon_text_gltex_ops = {
|
struct kmscon_text_ops kmscon_text_gltex_ops = {
|
||||||
.name = "gltex",
|
.name = "gltex",
|
||||||
|
.owner = NULL,
|
||||||
.init = gltex_init,
|
.init = gltex_init,
|
||||||
.destroy = gltex_destroy,
|
.destroy = gltex_destroy,
|
||||||
.set = gltex_set,
|
.set = gltex_set,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user