···
-
/* Unscaled code path if font_scale_{x,y} == 1 */
-
static void plot_char_unscaled(struct flanterm_fb_context *ctx, struct flanterm_fb_char *c, size_t x, size_t y) {
-
uint32_t default_bg = ctx->default_bg;
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++) {
volatile uint32_t *fb_line = ctx->framebuffer + x + (y + gy) * (ctx->pitch / 4);
uint32_t *canvas_line = ctx->canvas + x + (y + gy) * ctx->width;
-
bool *glyph_pointer = glyph + (gy * ctx->font_width);
for (size_t fx = 0; fx < ctx->font_width; fx++) {
-
if (ctx->canvas != NULL) {
-
bg = c->bg == 0xffffffff ? canvas_line[fx] : c->bg;
-
fg = c->fg == 0xffffffff ? canvas_line[fx] : c->fg;
-
bg = c->bg == 0xffffffff ? default_bg : c->bg;
-
fg = c->fg == 0xffffffff ? default_bg : c->fg;
-
fb_line[fx] = *(glyph_pointer++) ? fg : bg;
-
static void plot_char(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) {
-
if(ctx->font_scale_x == 1 && ctx->font_scale_y == 1) {
-
plot_char_unscaled(ctx, c, x, y);
uint32_t default_bg = ctx->default_bg;
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);
-
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;
-
if (ctx->canvas != NULL) {
-
bg = c->bg == 0xffffffff ? canvas_line[gx] : c->bg;
-
fg = c->fg == 0xffffffff ? canvas_line[gx] : c->fg;
-
bg = c->bg == 0xffffffff ? default_bg : c->bg;
-
fg = c->fg == 0xffffffff ? default_bg : c->fg;
fb_line[gx] = *glyph_pointer ? fg : bg;
···
-
#ifdef FLANTERM_FB_ENABLE_MASKING
-
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) {
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;
uint32_t default_bg = ctx->default_bg;
-
bool *new_glyph = &ctx->font_bool[c->c * ctx->font_height * ctx->font_width];
-
bool *old_glyph = &ctx->font_bool[old->c * ctx->font_height * ctx->font_width];
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);
-
uint32_t *canvas_line = ctx->canvas + x + (y + gy) * ctx->width;
for (size_t fx = 0; fx < ctx->font_width; fx++) {
-
bool old_draw = old_glyph[fy * ctx->font_width + fx];
-
bool new_draw = new_glyph[fy * ctx->font_width + fx];
-
if (old_draw == new_draw)
-
for (size_t i = 0; i < ctx->font_scale_x; i++) {
-
size_t gx = ctx->font_scale_x * fx + i;
-
if (ctx->canvas != NULL) {
-
bg = c->bg == 0xffffffff ? canvas_line[gx] : c->bg;
-
fg = c->fg == 0xffffffff ? canvas_line[gx] : c->fg;
-
bg = c->bg == 0xffffffff ? default_bg : c->bg;
-
fg = c->fg == 0xffffffff ? default_bg : c->fg;
-
fb_line[gx] = new_draw ? 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);
···
-
plot_char(_ctx, &c, ctx->cursor_x, ctx->cursor_y);
···
if (ctx->map[offset] == NULL) {
-
#ifdef FLANTERM_FB_ENABLE_MASKING
-
struct flanterm_fb_char *old = &ctx->grid[offset];
-
if (q->c.bg == old->bg && q->c.fg == old->fg) {
-
plot_char_masked(_ctx, old, &q->c, q->x, q->y);
-
plot_char(_ctx, &q->c, q->x, q->y);
-
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) {
-
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;
-
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]);