* Factor code from renderers to main render.c functions.
This commit is contained in:
parent
99f3252c73
commit
711021abc7
5 changed files with 7 additions and 16 deletions
|
@ -43,10 +43,6 @@ int init_figlet(context_t *cx)
|
|||
if(open_font(cx))
|
||||
return -1;
|
||||
|
||||
cx->x = cx->y = 0;
|
||||
cx->w = cx->h = 0;
|
||||
cx->cv = cucul_create_canvas(1, 1);
|
||||
|
||||
cx->feed = feed_figlet;
|
||||
cx->flush = flush_figlet;
|
||||
cx->end = end_figlet;
|
||||
|
@ -125,7 +121,6 @@ static int flush_figlet(context_t *cx)
|
|||
static int end_figlet(context_t *cx)
|
||||
{
|
||||
cucul_free_canvas(cx->image);
|
||||
cucul_free_canvas(cx->cv);
|
||||
free(cx->lookup);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -41,10 +41,6 @@ int init_big(context_t *cx)
|
|||
cx->onechar = cucul_create_canvas(1, 1);
|
||||
cucul_set_color(cx->onechar, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK);
|
||||
|
||||
cx->x = cx->y = 0;
|
||||
cx->w = cx->h = 0;
|
||||
cx->cv = cucul_create_canvas(1, 1);
|
||||
|
||||
cx->feed = feed_big;
|
||||
cx->flush = flush_big;
|
||||
cx->end = end_big;
|
||||
|
@ -127,7 +123,6 @@ static int flush_big(context_t *cx)
|
|||
static int end_big(context_t *cx)
|
||||
{
|
||||
cucul_free_canvas(cx->onechar);
|
||||
cucul_free_canvas(cx->cv);
|
||||
free(cx->buf);
|
||||
cucul_free_font(cx->f);
|
||||
|
||||
|
|
|
@ -31,6 +31,11 @@
|
|||
|
||||
int render_init(context_t *cx)
|
||||
{
|
||||
cx->x = cx->y = 0;
|
||||
cx->w = cx->h = 0;
|
||||
cx->lines = 0;
|
||||
cx->cv = cucul_create_canvas(0, 0);
|
||||
|
||||
if(!strcasecmp(cx->font, "mono9"))
|
||||
return init_big(cx);
|
||||
|
||||
|
@ -114,6 +119,7 @@ int render_line(context_t *cx)
|
|||
int render_end(context_t *cx)
|
||||
{
|
||||
cx->end(cx);
|
||||
cucul_free_canvas(cx->cv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -34,9 +34,6 @@ int init_tiny(context_t *cx)
|
|||
{
|
||||
cx->ew = 16;
|
||||
cx->eh = 2;
|
||||
cx->x = cx->y = 0;
|
||||
cx->w = cx->h = 0;
|
||||
cx->cv = cucul_create_canvas(cx->ew, cx->eh);
|
||||
|
||||
cx->feed = feed_tiny;
|
||||
cx->flush = flush_tiny;
|
||||
|
@ -106,8 +103,6 @@ static int flush_tiny(context_t *cx)
|
|||
|
||||
static int end_tiny(context_t *cx)
|
||||
{
|
||||
cucul_free_canvas(cx->cv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ struct toilet_context
|
|||
|
||||
cucul_canvas_t *cv;
|
||||
cucul_canvas_t *torender;
|
||||
unsigned int w, h, ew, eh, x, y;
|
||||
unsigned int w, h, ew, eh, x, y, lines;
|
||||
|
||||
/* Render methods */
|
||||
int (*feed)(struct toilet_context *, uint32_t);
|
||||
|
|
Loading…
Reference in a new issue