diff options
-rw-r--r-- | src/font.h | 3 | ||||
-rw-r--r-- | src/font_freetype.c | 11 | ||||
-rw-r--r-- | src/font_pango.c | 11 | ||||
-rw-r--r-- | tests/test_console.c | 6 | ||||
-rw-r--r-- | tests/test_terminal.c | 6 |
5 files changed, 26 insertions, 11 deletions
@@ -35,13 +35,14 @@ #define KMSCON_FONT_H #include <stdlib.h> +#include "output.h" #include "unicode.h" struct kmscon_font_factory; struct kmscon_font; int kmscon_font_factory_new(struct kmscon_font_factory **out, - struct kmscon_symbol_table *st); + struct kmscon_symbol_table *st, struct kmscon_compositor *comp); void kmscon_font_factory_ref(struct kmscon_font_factory *ff); void kmscon_font_factory_unref(struct kmscon_font_factory *ff); diff --git a/src/font_freetype.c b/src/font_freetype.c index f619872..ccb59e5 100644 --- a/src/font_freetype.c +++ b/src/font_freetype.c @@ -37,6 +37,7 @@ #include "font.h" #include "log.h" +#include "output.h" #include "unicode.h" #include <ft2build.h> @@ -46,6 +47,8 @@ struct kmscon_font_factory { unsigned long ref; struct kmscon_symbol_table *st; FT_Library lib; + struct kmscon_compositor *comp; + struct kmscon_context *ctx; }; struct kmscon_font { @@ -62,13 +65,13 @@ struct kmscon_glyph { }; int kmscon_font_factory_new(struct kmscon_font_factory **out, - struct kmscon_symbol_table *st) + struct kmscon_symbol_table *st, struct kmscon_compositor *comp) { struct kmscon_font_factory *ff; FT_Error err; int ret; - if (!out) + if (!out || !st || !comp) return -EINVAL; ff = malloc(sizeof(*ff)); @@ -78,6 +81,8 @@ int kmscon_font_factory_new(struct kmscon_font_factory **out, memset(ff, 0, sizeof(*ff)); ff->ref = 1; ff->st = st; + ff->comp = comp; + ff->ctx = kmscon_compositor_get_context(comp); err = FT_Init_FreeType(&ff->lib); if (err) { @@ -86,6 +91,7 @@ int kmscon_font_factory_new(struct kmscon_font_factory **out, goto err_free; } + kmscon_compositor_ref(ff->comp); kmscon_symbol_table_ref(ff->st); *out = ff; @@ -118,6 +124,7 @@ void kmscon_font_factory_unref(struct kmscon_font_factory *ff) if (err) log_warning("font: cannot deinitialize FreeType library\n"); + kmscon_compositor_unref(ff->comp); kmscon_symbol_table_unref(ff->st); free(ff); } diff --git a/src/font_pango.c b/src/font_pango.c index 8fd12fe..22c58ee 100644 --- a/src/font_pango.c +++ b/src/font_pango.c @@ -41,6 +41,7 @@ #include <pango/pangocairo.h> #include "font.h" #include "log.h" +#include "output.h" #include "unicode.h" enum glyph_type { @@ -71,6 +72,8 @@ struct kmscon_glyph { struct kmscon_font_factory { unsigned long ref; struct kmscon_symbol_table *st; + struct kmscon_compositor *comp; + struct kmscon_context *ctx; }; struct kmscon_font { @@ -228,11 +231,11 @@ static int kmscon_glyph_set(struct kmscon_glyph *glyph, } int kmscon_font_factory_new(struct kmscon_font_factory **out, - struct kmscon_symbol_table *st) + struct kmscon_symbol_table *st, struct kmscon_compositor *comp) { struct kmscon_font_factory *ff; - if (!out) + if (!out || !st || !comp) return -EINVAL; ff = malloc(sizeof(*ff)); @@ -242,7 +245,10 @@ int kmscon_font_factory_new(struct kmscon_font_factory **out, memset(ff, 0, sizeof(*ff)); ff->ref = 1; ff->st = st; + ff->comp = comp; + ff->ctx = kmscon_compositor_get_context(comp); + kmscon_compositor_ref(ff->comp); kmscon_symbol_table_ref(ff->st); *out = ff; @@ -265,6 +271,7 @@ void kmscon_font_factory_unref(struct kmscon_font_factory *ff) if (--ff->ref) return; + kmscon_compositor_unref(ff->comp); kmscon_symbol_table_unref(ff->st); free(ff); } diff --git a/tests/test_console.c b/tests/test_console.c index d243644..536a50b 100644 --- a/tests/test_console.c +++ b/tests/test_console.c @@ -274,15 +274,15 @@ static int setup_eloop(struct console *con) if (ret) goto err_loop; - ret = kmscon_font_factory_new(&con->ff, con->st); + ret = kmscon_compositor_new(&con->comp); if (ret) goto err_loop; - ret = kmscon_compositor_new(&con->comp); + ret = kmscon_compositor_use(con->comp); if (ret) goto err_loop; - ret = kmscon_compositor_use(con->comp); + ret = kmscon_font_factory_new(&con->ff, con->st, con->comp); if (ret) goto err_loop; diff --git a/tests/test_terminal.c b/tests/test_terminal.c index 969f1ec..ae4cc39 100644 --- a/tests/test_terminal.c +++ b/tests/test_terminal.c @@ -158,15 +158,15 @@ static int setup_app(struct app *app) if (ret) goto err_loop; - ret = kmscon_font_factory_new(&app->ff, app->st); + ret = kmscon_compositor_new(&app->comp); if (ret) goto err_loop; - ret = kmscon_compositor_new(&app->comp); + ret = kmscon_compositor_use(app->comp); if (ret) goto err_loop; - ret = kmscon_compositor_use(app->comp); + ret = kmscon_font_factory_new(&app->ff, app->st, app->comp); if (ret) goto err_loop; |