foot/sixel.h
Daniel Eklöf 7d315d7bf9
sixel: implement P2=1 - transparent pixels
When P2=1, empty pixels are transparent.

This patch also changes the behavior of P2=0|2, from setting empty
pixels to the default background color, to instead use the *current*
background color.

To implement this, a couple of changes are needed:

* Sixel pixels always use alpha=1.0, except for *empty* cells when
  P2=1 (i.e. transparent pixels).
* The renderer draws sixels with the OVER operator, instead of the SRC
  operator.
* The renderer *must* now render the cells beneath the sixel. As an
  optimization, this is only done for sixels where P2=1. I.e. for
  fully opaque sixels, there’s no need to render the cells beneath.

The sixel renderer isn’t yet hooked into the multi-threaded
renderer. This means *rows* (not just the cells) beneath
maybe-transparent sixels are rendered single-threaded.

Closes #391.
2021-03-11 17:34:19 +01:00

44 lines
1.6 KiB
C

#pragma once
#include "terminal.h"
#define SIXEL_MAX_COLORS 1024u
#define SIXEL_MAX_WIDTH 10000u
#define SIXEL_MAX_HEIGHT 10000u
void sixel_fini(struct terminal *term);
void sixel_init(struct terminal *term, int p1, int p2, int p3);
void sixel_put(struct terminal *term, uint8_t c);
void sixel_unhook(struct terminal *term);
void sixel_destroy(struct sixel *sixel);
void sixel_destroy_all(struct terminal *term);
void sixel_scroll_up(struct terminal *term, int rows);
void sixel_scroll_down(struct terminal *term, int rows);
void sixel_cell_size_changed(struct terminal *term);
void sixel_reflow(struct terminal *term);
/*
* Remove sixel data from the specified location. Used when printing
* or erasing characters, and when emitting new sixel images, to
* remove sixel data that would otherwise be rendered on-top.
*
* Row numbers are relative to the current grid offset
*/
void sixel_overwrite_by_rectangle(
struct terminal *term, int row, int col, int height, int width);
void sixel_overwrite_by_row(struct terminal *term, int row, int col, int width);
void sixel_overwrite_at_cursor(struct terminal *term, int width);
void sixel_colors_report_current(struct terminal *term);
void sixel_colors_reset(struct terminal *term);
void sixel_colors_set(struct terminal *term, unsigned count);
void sixel_colors_report_max(struct terminal *term);
void sixel_geometry_report_current(struct terminal *term);
void sixel_geometry_reset(struct terminal *term);
void sixel_geometry_set(struct terminal *term, unsigned width, unsigned height);
void sixel_geometry_report_max(struct terminal *term);