···
440
-
/* Unscaled code path if font_scale_{x,y} == 1 */
441
-
static void plot_char_unscaled(struct flanterm_fb_context *ctx, struct flanterm_fb_char *c, size_t x, size_t y) {
442
-
uint32_t default_bg = ctx->default_bg;
440
+
static void plot_char_scaled_canvas(struct flanterm_context *_ctx, struct flanterm_fb_char *c, size_t x, size_t y) {
441
+
struct flanterm_fb_context *ctx = (void *)_ctx;
443
+
if (x >= _ctx->cols || y >= _ctx->rows) {
x = ctx->offset_x + x * ctx->glyph_width;
y = ctx->offset_y + y * ctx->glyph_height;
···
bool *glyph = &ctx->font_bool[c->c * ctx->font_height * ctx->font_width];
// naming: fx,fy for font coordinates, gx,gy for glyph coordinates
for (size_t gy = 0; gy < ctx->glyph_height; gy++) {
453
+
uint8_t fy = gy / ctx->font_scale_y;
volatile uint32_t *fb_line = ctx->framebuffer + x + (y + gy) * (ctx->pitch / 4);
uint32_t *canvas_line = ctx->canvas + x + (y + gy) * ctx->width;
452
-
bool *glyph_pointer = glyph + (gy * ctx->font_width);
456
+
bool *glyph_pointer = glyph + (fy * ctx->font_width);
for (size_t fx = 0; fx < ctx->font_width; fx++) {
455
-
if (ctx->canvas != NULL) {
456
-
bg = c->bg == 0xffffffff ? canvas_line[fx] : c->bg;
457
-
fg = c->fg == 0xffffffff ? canvas_line[fx] : c->fg;
459
-
bg = c->bg == 0xffffffff ? default_bg : c->bg;
460
-
fg = c->fg == 0xffffffff ? default_bg : c->fg;
458
+
for (size_t i = 0; i < ctx->font_scale_x; i++) {
459
+
size_t gx = ctx->font_scale_x * fx + i;
460
+
uint32_t bg = c->bg == 0xffffffff ? canvas_line[gx] : c->bg;
461
+
uint32_t fg = c->fg == 0xffffffff ? canvas_line[gx] : c->fg;
462
+
fb_line[gx] = *glyph_pointer ? fg : bg;
462
-
fb_line[fx] = *(glyph_pointer++) ? fg : bg;
467
-
static void plot_char(struct flanterm_context *_ctx, struct flanterm_fb_char *c, size_t x, size_t y) {
469
+
static void plot_char_scaled_uncanvas(struct flanterm_context *_ctx, struct flanterm_fb_char *c, size_t x, size_t y) {
struct flanterm_fb_context *ctx = (void *)_ctx;
if (x >= _ctx->cols || y >= _ctx->rows) {
474
-
if(ctx->font_scale_x == 1 && ctx->font_scale_y == 1) {
475
-
plot_char_unscaled(ctx, c, x, y);
uint32_t default_bg = ctx->default_bg;
478
+
uint32_t bg = c->bg == 0xffffffff ? default_bg : c->bg;
479
+
uint32_t fg = c->fg == 0xffffffff ? default_bg : c->fg;
x = ctx->offset_x + x * ctx->glyph_width;
y = ctx->offset_y + y * ctx->glyph_height;
···
for (size_t gy = 0; gy < ctx->glyph_height; gy++) {
uint8_t fy = gy / ctx->font_scale_y;
volatile uint32_t *fb_line = ctx->framebuffer + x + (y + gy) * (ctx->pitch / 4);
489
-
uint32_t *canvas_line = ctx->canvas + x + (y + gy) * ctx->width;
bool *glyph_pointer = glyph + (fy * ctx->font_width);
for (size_t fx = 0; fx < ctx->font_width; fx++) {
for (size_t i = 0; i < ctx->font_scale_x; i++) {
size_t gx = ctx->font_scale_x * fx + i;
495
-
if (ctx->canvas != NULL) {
496
-
bg = c->bg == 0xffffffff ? canvas_line[gx] : c->bg;
497
-
fg = c->fg == 0xffffffff ? canvas_line[gx] : c->fg;
499
-
bg = c->bg == 0xffffffff ? default_bg : c->bg;
500
-
fg = c->fg == 0xffffffff ? default_bg : c->fg;
fb_line[gx] = *glyph_pointer ? fg : bg;
···
509
-
#ifdef FLANTERM_FB_ENABLE_MASKING
510
-
static void plot_char_masked(struct flanterm_context *_ctx, struct flanterm_fb_char *old, struct flanterm_fb_char *c, size_t x, size_t y) {
500
+
static void plot_char_unscaled_canvas(struct flanterm_context *_ctx, struct flanterm_fb_char *c, size_t x, size_t y) {
struct flanterm_fb_context *ctx = (void *)_ctx;
if (x >= _ctx->cols || y >= _ctx->rows) {
···
x = ctx->offset_x + x * ctx->glyph_width;
y = ctx->offset_y + y * ctx->glyph_height;
510
+
bool *glyph = &ctx->font_bool[c->c * ctx->font_height * ctx->font_width];
511
+
// naming: fx,fy for font coordinates, gx,gy for glyph coordinates
512
+
for (size_t gy = 0; gy < ctx->glyph_height; gy++) {
513
+
volatile uint32_t *fb_line = ctx->framebuffer + x + (y + gy) * (ctx->pitch / 4);
514
+
uint32_t *canvas_line = ctx->canvas + x + (y + gy) * ctx->width;
515
+
bool *glyph_pointer = glyph + (gy * ctx->font_width);
516
+
for (size_t fx = 0; fx < ctx->font_width; fx++) {
517
+
uint32_t bg = c->bg == 0xffffffff ? canvas_line[fx] : c->bg;
518
+
uint32_t fg = c->fg == 0xffffffff ? canvas_line[fx] : c->fg;
519
+
fb_line[fx] = *(glyph_pointer++) ? fg : bg;
524
+
static void plot_char_unscaled_uncanvas(struct flanterm_context *_ctx, struct flanterm_fb_char *c, size_t x, size_t y) {
525
+
struct flanterm_fb_context *ctx = (void *)_ctx;
527
+
if (x >= _ctx->cols || y >= _ctx->rows) {
uint32_t default_bg = ctx->default_bg;
522
-
bool *new_glyph = &ctx->font_bool[c->c * ctx->font_height * ctx->font_width];
523
-
bool *old_glyph = &ctx->font_bool[old->c * ctx->font_height * ctx->font_width];
533
+
uint32_t bg = c->bg == 0xffffffff ? default_bg : c->bg;
534
+
uint32_t fg = c->fg == 0xffffffff ? default_bg : c->fg;
536
+
x = ctx->offset_x + x * ctx->glyph_width;
537
+
y = ctx->offset_y + y * ctx->glyph_height;
539
+
bool *glyph = &ctx->font_bool[c->c * ctx->font_height * ctx->font_width];
540
+
// naming: fx,fy for font coordinates, gx,gy for glyph coordinates
for (size_t gy = 0; gy < ctx->glyph_height; gy++) {
525
-
uint8_t fy = gy / ctx->font_scale_y;
volatile uint32_t *fb_line = ctx->framebuffer + x + (y + gy) * (ctx->pitch / 4);
527
-
uint32_t *canvas_line = ctx->canvas + x + (y + gy) * ctx->width;
543
+
bool *glyph_pointer = glyph + (gy * ctx->font_width);
for (size_t fx = 0; fx < ctx->font_width; fx++) {
529
-
bool old_draw = old_glyph[fy * ctx->font_width + fx];
530
-
bool new_draw = new_glyph[fy * ctx->font_width + fx];
531
-
if (old_draw == new_draw)
533
-
for (size_t i = 0; i < ctx->font_scale_x; i++) {
534
-
size_t gx = ctx->font_scale_x * fx + i;
536
-
if (ctx->canvas != NULL) {
537
-
bg = c->bg == 0xffffffff ? canvas_line[gx] : c->bg;
538
-
fg = c->fg == 0xffffffff ? canvas_line[gx] : c->fg;
540
-
bg = c->bg == 0xffffffff ? default_bg : c->bg;
541
-
fg = c->fg == 0xffffffff ? default_bg : c->fg;
543
-
fb_line[gx] = new_draw ? fg : bg;
545
+
fb_line[fx] = *(glyph_pointer++) ? fg : bg;
static inline bool compare_char(struct flanterm_fb_char *a, struct flanterm_fb_char *b) {
return !(a->c != b->c || a->bg != b->bg || a->fg != b->fg);
···
776
-
plot_char(_ctx, &c, ctx->cursor_x, ctx->cursor_y);
776
+
ctx->plot_char(_ctx, &c, ctx->cursor_x, ctx->cursor_y);
···
if (ctx->map[offset] == NULL) {
796
-
#ifdef FLANTERM_FB_ENABLE_MASKING
797
-
struct flanterm_fb_char *old = &ctx->grid[offset];
798
-
if (q->c.bg == old->bg && q->c.fg == old->fg) {
799
-
plot_char_masked(_ctx, old, &q->c, q->x, q->y);
801
-
plot_char(_ctx, &q->c, q->x, q->y);
804
-
plot_char(_ctx, &q->c, q->x, q->y);
796
+
ctx->plot_char(_ctx, &q->c, q->x, q->y);
ctx->grid[offset] = q->c;
if ((ctx->old_cursor_x != ctx->cursor_x || ctx->old_cursor_y != ctx->cursor_y) || _ctx->cursor_enabled == false) {
if (ctx->old_cursor_x < _ctx->cols && ctx->old_cursor_y < _ctx->rows) {
812
-
plot_char(_ctx, &ctx->grid[ctx->old_cursor_x + ctx->old_cursor_y * _ctx->cols], ctx->old_cursor_x, ctx->old_cursor_y);
803
+
ctx->plot_char(_ctx, &ctx->grid[ctx->old_cursor_x + ctx->old_cursor_y * _ctx->cols], ctx->old_cursor_x, ctx->old_cursor_y);
···
size_t x = i % _ctx->cols;
size_t y = i / _ctx->cols;
863
-
plot_char(_ctx, &ctx->grid[i], x, y);
854
+
ctx->plot_char(_ctx, &ctx->grid[i], x, y);
if (_ctx->cursor_enabled) {
···
for (size_t i = 0; i < ctx->width * ctx->height; i++) {
ctx->canvas[i] = convert_colour(_ctx, canvas[i]);
1133
+
if (font_scale_x == 1 && font_scale_y == 1) {
1134
+
if (canvas == NULL) {
1135
+
ctx->plot_char = plot_char_unscaled_uncanvas;
1137
+
ctx->plot_char = plot_char_unscaled_canvas;
1140
+
if (canvas == NULL) {
1141
+
ctx->plot_char = plot_char_scaled_uncanvas;
1143
+
ctx->plot_char = plot_char_scaled_canvas;