diff --git a/src/console.c b/src/console.c index 501b5e0..8bc5fb2 100644 --- a/src/console.c +++ b/src/console.c @@ -89,18 +89,10 @@ struct kmscon_buffer { struct line **mtop_buf; /* lines of the top margin */ unsigned int mbottom_y; /* number of rows in bottom margin */ struct line **mbottom_buf; /* lines of the bottom margin */ - - struct gl_m4_stack *stack; }; struct kmscon_console { size_t ref; - struct kmscon_font_factory *ff; - - /* font */ - unsigned int res_x; - unsigned int res_y; - struct kmscon_font *font; /* console cells */ struct kmscon_buffer *cells; @@ -656,20 +648,14 @@ static int kmscon_buffer_new(struct kmscon_buffer **out, unsigned int x, memset(buf, 0, sizeof(*buf)); - ret = gl_m4_stack_new(&buf->stack); - if (ret) - goto err_free; - ret = kmscon_buffer_resize(buf, x, y); if (ret) - goto err_stack; + goto err_free; log_debug("new buffer object"); *out = buf; return 0; -err_stack: - gl_m4_stack_free(buf->stack); err_free: free(buf); return ret; @@ -695,7 +681,6 @@ static void kmscon_buffer_free(struct kmscon_buffer *buf) free(buf->scroll_buf); free(buf->mtop_buf); free(buf->mbottom_buf); - gl_m4_stack_free(buf->stack); free(buf); } @@ -977,8 +962,7 @@ static inline unsigned int to_abs_y(struct kmscon_console *con, unsigned int y) return con->cells->mtop_y + y; } -int kmscon_console_new(struct kmscon_console **out, - struct kmscon_font_factory *ff) +int kmscon_console_new(struct kmscon_console **out) { struct kmscon_console *con; int ret; @@ -993,14 +977,12 @@ int kmscon_console_new(struct kmscon_console **out, memset(con, 0, sizeof(*con)); con->ref = 1; con->auto_wrap = true; - con->ff = ff; ret = kmscon_buffer_new(&con->cells, 0, 0); if (ret) goto err_free; log_debug("new console"); - kmscon_font_factory_ref(con->ff); *out = con; return 0; @@ -1031,9 +1013,7 @@ void kmscon_console_unref(struct kmscon_console *con) return; log_debug("destroying console"); - kmscon_font_unref(con->font); kmscon_buffer_free(con->cells); - kmscon_font_factory_unref(con->ff); free(con); } @@ -1053,69 +1033,6 @@ unsigned int kmscon_console_get_height(struct kmscon_console *con) return con->cells->size_y; } -/* - * Resize console to \x and \y. The \height argument is just a quality hint for - * internal rendering. It is supposed to be the maximal height in pixels of - * your output. The internal texture will have this height (the width is calced - * automatically from the font and height). You can still use *_map() to map - * this texture to arbitrary outputs but if you have huge resolutions, this - * would result in bad quality if you do not specify a proper height here. - * - * You need to have an active GL context when calling this. You must call this - * before calling *_draw(). Otherwise *_draw() will not work. - * Pass 0 for each parameter if you want to use the current value. Therefore: - * kmscon_console_resize(con, 0, 0, 0) has no effect as it doesn't change - * anything. - * If you called this once you must make sure that the GL context stays alive - * for as long as this console object does. Otherwise, on deinitialization we - * may call invalid OpenGL functions. - * TODO: Use proper dependencies here. Maybe pass in a kmscon_output or similar - * so we correctly activate GL contexts. - */ -int kmscon_console_resize(struct kmscon_console *con, unsigned int x, - unsigned int y, unsigned int height) -{ - int ret; - struct kmscon_font *font; - - if (!con) - return -EINVAL; - - if (!x) - x = con->cells->size_x; - if (!y) - y = con->cells->size_y; - if (!height) - height = con->res_y; - - if (x == con->cells->size_x && y == con->cells->size_y && - height == con->res_y) - return 0; - - log_debug("resizing to %ux%u:%u", x, y, height); - - ret = kmscon_buffer_resize(con->cells, x, y); - if (ret) - return ret; - - kmscon_console_move_to(con, con->cursor_x, con->cursor_y); - - ret = kmscon_font_factory_load(con->ff, &font, 0, - height / con->cells->size_y); - if (ret) { - log_err("cannot create new font: %d", ret); - return ret; - } - - kmscon_font_unref(con->font); - con->font = font; - con->res_x = con->cells->size_x * kmscon_font_get_width(con->font); - con->res_y = height; - log_debug("new resolution %ux%u", con->res_x, con->res_y); - - return 0; -} - void kmscon_console_draw(struct kmscon_console *con, struct font_screen *fscr) { if (!con) diff --git a/src/console.h b/src/console.h index 4c50d90..9ce8152 100644 --- a/src/console.h +++ b/src/console.h @@ -44,8 +44,7 @@ struct kmscon_console; /* console objects */ -int kmscon_console_new(struct kmscon_console **out, - struct kmscon_font_factory *ff); +int kmscon_console_new(struct kmscon_console **out); void kmscon_console_ref(struct kmscon_console *con); void kmscon_console_unref(struct kmscon_console *con); diff --git a/src/terminal.c b/src/terminal.c index ae83c31..e6fc2ff 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -256,14 +256,13 @@ static void input_event(struct kmscon_input *input, int kmscon_terminal_new(struct kmscon_terminal **out, struct ev_eloop *loop, - struct kmscon_font_factory *ff, struct uterm_video *video, struct kmscon_input *input) { struct kmscon_terminal *term; int ret; - if (!out || !loop || !ff || !video || !input) + if (!out || !loop || !video || !input) return -EINVAL; term = malloc(sizeof(*term)); @@ -280,7 +279,7 @@ int kmscon_terminal_new(struct kmscon_terminal **out, if (ret) goto err_free; - ret = kmscon_console_new(&term->console, ff); + ret = kmscon_console_new(&term->console); if (ret) goto err_idle; diff --git a/src/terminal.h b/src/terminal.h index 52f8813..cf906b9 100644 --- a/src/terminal.h +++ b/src/terminal.h @@ -36,7 +36,6 @@ #include #include "console.h" #include "eloop.h" -#include "font.h" #include "gl.h" #include "input.h" #include "uterm.h" @@ -55,7 +54,6 @@ typedef void (*kmscon_terminal_event_cb) int kmscon_terminal_new(struct kmscon_terminal **out, struct ev_eloop *loop, - struct kmscon_font_factory *ff, struct uterm_video *video, struct kmscon_input *input); void kmscon_terminal_ref(struct kmscon_terminal *term); diff --git a/src/ui.c b/src/ui.c index 62b2e82..9c8c637 100644 --- a/src/ui.c +++ b/src/ui.c @@ -33,7 +33,6 @@ #include #include "conf.h" #include "eloop.h" -#include "font.h" #include "input.h" #include "log.h" #include "terminal.h" @@ -46,7 +45,6 @@ struct kmscon_ui { struct ev_eloop *eloop; struct uterm_video *video; struct kmscon_input *input; - struct kmscon_font_factory *ff; struct kmscon_terminal *term; }; @@ -95,15 +93,10 @@ int kmscon_ui_new(struct kmscon_ui **out, ui->video = video; ui->input = input; - ret = kmscon_font_factory_new(&ui->ff); + ret = kmscon_terminal_new(&ui->term, eloop, ui->video, ui->input); if (ret) goto err_free; - ret = kmscon_terminal_new(&ui->term, eloop, ui->ff, ui->video, - ui->input); - if (ret) - goto err_ff; - ret = uterm_video_register_cb(ui->video, video_event, ui); if (ret) goto err_term; @@ -128,8 +121,6 @@ err_video: uterm_video_unregister_cb(ui->video, video_event, ui); err_term: kmscon_terminal_unref(ui->term); -err_ff: - kmscon_font_factory_unref(ui->ff); err_free: free(ui); return ret; @@ -143,7 +134,6 @@ void kmscon_ui_free(struct kmscon_ui *ui) kmscon_input_unregister_cb(ui->input, input_event, ui); uterm_video_unregister_cb(ui->video, video_event, ui); kmscon_terminal_unref(ui->term); - kmscon_font_factory_unref(ui->ff); kmscon_input_unref(ui->input); uterm_video_unref(ui->video); ev_eloop_unref(ui->eloop);