text: use uterm_display directly
Instead of using the uterm-screen indirection, we now directly access uterm-display objects. We do not really intend to use virtual screens with kmscon so there is no need to make this more complex. I don't think consoles should every provide this feature. Instead, you should use real compositors for such tasks like Wayland+wlterm. kmscon, however, is rather an emergency tool or a safe backup than a fancy daily-use-console. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
2cac43f64e
commit
5f234e6592
@ -52,7 +52,6 @@
|
||||
struct screen {
|
||||
struct shl_dlist list;
|
||||
struct uterm_display *disp;
|
||||
struct uterm_screen *screen;
|
||||
struct kmscon_font *font;
|
||||
struct kmscon_font *bold_font;
|
||||
struct kmscon_text *txt;
|
||||
@ -84,7 +83,6 @@ struct kmscon_terminal {
|
||||
|
||||
static void redraw(struct kmscon_terminal *term)
|
||||
{
|
||||
struct uterm_screen *screen;
|
||||
struct shl_dlist *iter;
|
||||
struct screen *ent;
|
||||
|
||||
@ -93,14 +91,13 @@ static void redraw(struct kmscon_terminal *term)
|
||||
|
||||
shl_dlist_for_each(iter, &term->screens) {
|
||||
ent = shl_dlist_entry(iter, struct screen, list);
|
||||
screen = ent->screen;
|
||||
|
||||
tsm_screen_draw(term->console,
|
||||
kmscon_text_prepare_cb,
|
||||
kmscon_text_draw_cb,
|
||||
kmscon_text_render_cb,
|
||||
ent->txt);
|
||||
uterm_screen_swap(screen);
|
||||
kmscon_text_prepare_cb,
|
||||
kmscon_text_draw_cb,
|
||||
kmscon_text_render_cb,
|
||||
ent->txt);
|
||||
uterm_display_swap(ent->disp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,16 +212,10 @@ static int add_display(struct kmscon_terminal *term, struct uterm_display *disp)
|
||||
memset(scr, 0, sizeof(*scr));
|
||||
scr->disp = disp;
|
||||
|
||||
ret = uterm_screen_new_single(&scr->screen, disp);
|
||||
if (ret) {
|
||||
log_error("cannot create screen for display %p", scr->disp);
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
ret = kmscon_font_find(&scr->font, &attr, term->conf->font_engine);
|
||||
if (ret) {
|
||||
log_error("cannot create font");
|
||||
goto err_screen;
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
attr.bold = true;
|
||||
@ -235,7 +226,7 @@ static int add_display(struct kmscon_terminal *term, struct uterm_display *disp)
|
||||
kmscon_font_ref(scr->bold_font);
|
||||
}
|
||||
|
||||
ret = uterm_screen_use(scr->screen);
|
||||
ret = uterm_display_use(scr->disp);
|
||||
if (term->conf->render_engine)
|
||||
be = term->conf->render_engine;
|
||||
else if (!ret)
|
||||
@ -249,7 +240,7 @@ static int add_display(struct kmscon_terminal *term, struct uterm_display *disp)
|
||||
goto err_font;
|
||||
}
|
||||
|
||||
ret = kmscon_text_set(scr->txt, scr->font, scr->bold_font, scr->screen);
|
||||
ret = kmscon_text_set(scr->txt, scr->font, scr->bold_font, scr->disp);
|
||||
if (ret) {
|
||||
log_error("cannot set text-renderer parameters");
|
||||
goto err_text;
|
||||
@ -271,8 +262,6 @@ err_text:
|
||||
err_font:
|
||||
kmscon_font_unref(scr->bold_font);
|
||||
kmscon_font_unref(scr->font);
|
||||
err_screen:
|
||||
uterm_screen_unref(scr->screen);
|
||||
err_free:
|
||||
free(scr);
|
||||
return ret;
|
||||
@ -289,7 +278,6 @@ static void free_screen(struct kmscon_terminal *term, struct screen *scr,
|
||||
kmscon_text_unref(scr->txt);
|
||||
kmscon_font_unref(scr->bold_font);
|
||||
kmscon_font_unref(scr->font);
|
||||
uterm_screen_unref(scr->screen);
|
||||
uterm_display_unref(scr->disp);
|
||||
free(scr);
|
||||
|
||||
|
20
src/text.c
20
src/text.c
@ -296,7 +296,7 @@ void kmscon_text_unref(struct kmscon_text *text)
|
||||
* @txt: Valid text-renderer object
|
||||
* @font: font object
|
||||
* @bold_font: bold font object or NULL
|
||||
* @screen: screen object
|
||||
* @disp: display object
|
||||
*
|
||||
* This makes the text-renderer @txt use the font @font and screen @screen. You
|
||||
* can drop your reference to both after calling this.
|
||||
@ -313,11 +313,11 @@ void kmscon_text_unref(struct kmscon_text *text)
|
||||
int kmscon_text_set(struct kmscon_text *txt,
|
||||
struct kmscon_font *font,
|
||||
struct kmscon_font *bold_font,
|
||||
struct uterm_screen *screen)
|
||||
struct uterm_display *disp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!txt || !font || !screen)
|
||||
if (!txt || !font || !disp)
|
||||
return -EINVAL;
|
||||
|
||||
if (!bold_font)
|
||||
@ -327,21 +327,21 @@ int kmscon_text_set(struct kmscon_text *txt,
|
||||
|
||||
txt->font = font;
|
||||
txt->bold_font = bold_font;
|
||||
txt->screen = screen;
|
||||
txt->disp = disp;
|
||||
|
||||
if (txt->ops->set) {
|
||||
ret = txt->ops->set(txt);
|
||||
if (ret) {
|
||||
txt->font = NULL;
|
||||
txt->bold_font = NULL;
|
||||
txt->screen = NULL;
|
||||
txt->disp = NULL;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
kmscon_font_ref(txt->font);
|
||||
kmscon_font_ref(txt->bold_font);
|
||||
uterm_screen_ref(txt->screen);
|
||||
uterm_display_ref(txt->disp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -357,7 +357,7 @@ int kmscon_text_set(struct kmscon_text *txt,
|
||||
*/
|
||||
void kmscon_text_unset(struct kmscon_text *txt)
|
||||
{
|
||||
if (!txt || !txt->screen || !txt->font)
|
||||
if (!txt || !txt->disp || !txt->font)
|
||||
return;
|
||||
|
||||
if (txt->ops->unset)
|
||||
@ -365,10 +365,10 @@ void kmscon_text_unset(struct kmscon_text *txt)
|
||||
|
||||
kmscon_font_unref(txt->font);
|
||||
kmscon_font_unref(txt->bold_font);
|
||||
uterm_screen_unref(txt->screen);
|
||||
uterm_display_unref(txt->disp);
|
||||
txt->font = NULL;
|
||||
txt->bold_font = NULL;
|
||||
txt->screen = NULL;
|
||||
txt->disp = NULL;
|
||||
txt->cols = 0;
|
||||
txt->rows = 0;
|
||||
txt->rendering = false;
|
||||
@ -429,7 +429,7 @@ int kmscon_text_prepare(struct kmscon_text *txt)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!txt || !txt->font || !txt->screen)
|
||||
if (!txt || !txt->font || !txt->disp)
|
||||
return -EINVAL;
|
||||
|
||||
txt->rendering = true;
|
||||
|
@ -124,7 +124,7 @@ struct kmscon_text {
|
||||
|
||||
struct kmscon_font *font;
|
||||
struct kmscon_font *bold_font;
|
||||
struct uterm_screen *screen;
|
||||
struct uterm_display *disp;
|
||||
unsigned int cols;
|
||||
unsigned int rows;
|
||||
bool rendering;
|
||||
@ -155,7 +155,7 @@ void kmscon_text_unref(struct kmscon_text *txt);
|
||||
int kmscon_text_set(struct kmscon_text *txt,
|
||||
struct kmscon_font *font,
|
||||
struct kmscon_font *bold_font,
|
||||
struct uterm_screen *screen);
|
||||
struct uterm_display *disp);
|
||||
void kmscon_text_unset(struct kmscon_text *txt);
|
||||
unsigned int kmscon_text_get_cols(struct kmscon_text *txt);
|
||||
unsigned int kmscon_text_get_rows(struct kmscon_text *txt);
|
||||
|
@ -45,11 +45,15 @@
|
||||
static int bblit_set(struct kmscon_text *txt)
|
||||
{
|
||||
unsigned int sw, sh, fw, fh;
|
||||
struct uterm_mode *mode;
|
||||
|
||||
fw = txt->font->attr.width;
|
||||
fh = txt->font->attr.height;
|
||||
sw = uterm_screen_width(txt->screen);
|
||||
sh = uterm_screen_height(txt->screen);
|
||||
mode = uterm_display_get_current(txt->disp);
|
||||
if (!mode)
|
||||
return -EINVAL;
|
||||
sw = uterm_mode_get_width(mode);
|
||||
sh = uterm_mode_get_height(mode);
|
||||
|
||||
txt->cols = sw / fw;
|
||||
txt->rows = sh / fh;
|
||||
@ -85,17 +89,17 @@ static int bblit_draw(struct kmscon_text *txt,
|
||||
|
||||
/* draw glyph */
|
||||
if (attr->inverse) {
|
||||
ret = uterm_screen_blend(txt->screen, &glyph->buf,
|
||||
posx * txt->font->attr.width,
|
||||
posy * txt->font->attr.height,
|
||||
attr->br, attr->bg, attr->bb,
|
||||
attr->fr, attr->fg, attr->fb);
|
||||
ret = uterm_display_fake_blend(txt->disp, &glyph->buf,
|
||||
posx * txt->font->attr.width,
|
||||
posy * txt->font->attr.height,
|
||||
attr->br, attr->bg, attr->bb,
|
||||
attr->fr, attr->fg, attr->fb);
|
||||
} else {
|
||||
ret = uterm_screen_blend(txt->screen, &glyph->buf,
|
||||
posx * txt->font->attr.width,
|
||||
posy * txt->font->attr.height,
|
||||
attr->fr, attr->fg, attr->fb,
|
||||
attr->br, attr->bg, attr->bb);
|
||||
ret = uterm_display_fake_blend(txt->disp, &glyph->buf,
|
||||
posx * txt->font->attr.width,
|
||||
posy * txt->font->attr.height,
|
||||
attr->fr, attr->fg, attr->fb,
|
||||
attr->br, attr->bg, attr->bb);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -49,9 +49,6 @@ struct bbulk {
|
||||
#define FONT_WIDTH(txt) ((txt)->font->attr.width)
|
||||
#define FONT_HEIGHT(txt) ((txt)->font->attr.height)
|
||||
|
||||
#define SCREEN_WIDTH(txt) uterm_screen_width((txt)->screen)
|
||||
#define SCREEN_HEIGHT(txt) uterm_screen_height((txt)->screen)
|
||||
|
||||
static int bbulk_init(struct kmscon_text *txt)
|
||||
{
|
||||
struct bbulk *bb;
|
||||
@ -76,11 +73,15 @@ static int bbulk_set(struct kmscon_text *txt)
|
||||
struct bbulk *bb = txt->data;
|
||||
unsigned int sw, sh, i, j;
|
||||
struct uterm_video_blend_req *req;
|
||||
struct uterm_mode *mode;
|
||||
|
||||
memset(bb, 0, sizeof(*bb));
|
||||
|
||||
sw = SCREEN_WIDTH(txt);
|
||||
sh = SCREEN_HEIGHT(txt);
|
||||
mode = uterm_display_get_current(txt->disp);
|
||||
if (!mode)
|
||||
return -EINVAL;
|
||||
sw = uterm_mode_get_width(mode);
|
||||
sh = uterm_mode_get_height(mode);
|
||||
|
||||
txt->cols = sw / FONT_WIDTH(txt);
|
||||
txt->rows = sh / FONT_HEIGHT(txt);
|
||||
@ -162,8 +163,8 @@ static int bbulk_render(struct kmscon_text *txt)
|
||||
{
|
||||
struct bbulk *bb = txt->data;
|
||||
|
||||
return uterm_screen_blendv(txt->screen, bb->reqs,
|
||||
txt->cols * txt->rows);
|
||||
return uterm_display_fake_blendv(txt->disp, bb->reqs,
|
||||
txt->cols * txt->rows);
|
||||
}
|
||||
|
||||
static const struct kmscon_text_ops kmscon_text_bbulk_ops = {
|
||||
|
@ -101,14 +101,14 @@ struct gltex {
|
||||
GLuint uni_atlas;
|
||||
GLuint uni_advance_htex;
|
||||
GLuint uni_advance_vtex;
|
||||
|
||||
unsigned int sw;
|
||||
unsigned int sh;
|
||||
};
|
||||
|
||||
#define FONT_WIDTH(txt) ((txt)->font->attr.width)
|
||||
#define FONT_HEIGHT(txt) ((txt)->font->attr.height)
|
||||
|
||||
#define SCREEN_WIDTH(txt) uterm_screen_width((txt)->screen)
|
||||
#define SCREEN_HEIGHT(txt) uterm_screen_height((txt)->screen)
|
||||
|
||||
static int gltex_init(struct kmscon_text *txt)
|
||||
{
|
||||
struct gltex *gt;
|
||||
@ -144,9 +144,9 @@ static int gltex_set(struct kmscon_text *txt)
|
||||
int ret;
|
||||
static char *attr[] = { "position", "texture_position",
|
||||
"fgcolor", "bgcolor" };
|
||||
unsigned int sw, sh;
|
||||
GLint s;
|
||||
const char *ext;
|
||||
struct uterm_mode *mode;
|
||||
|
||||
memset(gt, 0, sizeof(*gt));
|
||||
shl_dlist_init(>->atlases);
|
||||
@ -163,9 +163,12 @@ static int gltex_set(struct kmscon_text *txt)
|
||||
if (ret)
|
||||
goto err_htable;
|
||||
|
||||
ret = uterm_screen_use(txt->screen);
|
||||
if (ret)
|
||||
ret = uterm_display_use(txt->disp);
|
||||
if (ret) {
|
||||
if (ret == -EOPNOTSUPP)
|
||||
log_error("display doesn't support hardware-acceleration");
|
||||
goto err_bold_htable;
|
||||
}
|
||||
|
||||
gl_clear_error();
|
||||
|
||||
@ -186,11 +189,12 @@ static int gltex_set(struct kmscon_text *txt)
|
||||
goto err_shader;
|
||||
}
|
||||
|
||||
sw = SCREEN_WIDTH(txt);
|
||||
sh = SCREEN_HEIGHT(txt);
|
||||
mode = uterm_display_get_current(txt->disp);
|
||||
gt->sw = uterm_mode_get_width(mode);
|
||||
gt->sh = uterm_mode_get_height(mode);
|
||||
|
||||
txt->cols = sw / FONT_WIDTH(txt);
|
||||
txt->rows = sh / FONT_HEIGHT(txt);
|
||||
txt->cols = gt->sw / FONT_WIDTH(txt);
|
||||
txt->rows = gt->sh / FONT_HEIGHT(txt);
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &s);
|
||||
if (s <= 0)
|
||||
@ -227,7 +231,7 @@ static void gltex_unset(struct kmscon_text *txt)
|
||||
struct atlas *atlas;
|
||||
bool gl = true;
|
||||
|
||||
ret = uterm_screen_use(txt->screen);
|
||||
ret = uterm_display_use(txt->disp);
|
||||
if (ret) {
|
||||
gl = false;
|
||||
log_warning("cannot activate OpenGL-CTX during destruction");
|
||||
@ -517,10 +521,9 @@ static int gltex_prepare(struct kmscon_text *txt)
|
||||
struct gltex *gt = txt->data;
|
||||
struct atlas *atlas;
|
||||
struct shl_dlist *iter;
|
||||
unsigned int sw, sh;
|
||||
int ret;
|
||||
|
||||
ret = uterm_screen_use(txt->screen);
|
||||
ret = uterm_display_use(txt->disp);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@ -530,11 +533,8 @@ static int gltex_prepare(struct kmscon_text *txt)
|
||||
atlas->cache_num = 0;
|
||||
}
|
||||
|
||||
sw = SCREEN_WIDTH(txt);
|
||||
sh = SCREEN_HEIGHT(txt);
|
||||
|
||||
gt->advance_x = 2.0 / sw * FONT_WIDTH(txt);
|
||||
gt->advance_y = 2.0 / sh * FONT_HEIGHT(txt);
|
||||
gt->advance_x = 2.0 / gt->sw * FONT_WIDTH(txt);
|
||||
gt->advance_y = 2.0 / gt->sh * FONT_HEIGHT(txt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -632,7 +632,7 @@ static int gltex_render(struct kmscon_text *txt)
|
||||
|
||||
gl_shader_use(gt->shader);
|
||||
|
||||
glViewport(0, 0, SCREEN_WIDTH(txt), SCREEN_HEIGHT(txt));
|
||||
glViewport(0, 0, gt->sw, gt->sh);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
gl_m4_identity(mat);
|
||||
|
Loading…
x
Reference in New Issue
Block a user