From 7d315d7bf9ab0376468929f0e41fbac98370e035 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 9 Mar 2021 17:23:55 +0100 Subject: sixel: implement P2=1 - transparent pixels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- terminal.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index 8be5dd74..0fcd97ea 100644 --- a/terminal.h +++ b/terminal.h @@ -112,6 +112,7 @@ struct sixel { int rows; int cols; struct coord pos; + bool opaque; }; struct grid { @@ -542,6 +543,8 @@ struct terminal { unsigned param; /* Currently collecting parameter, for RASTER, COLOR_SPEC and REPEAT */ unsigned param_idx; /* Parameters seen */ + bool transparent_bg; + /* Application configurable */ unsigned palette_size; /* Number of colors in palette */ unsigned max_width; /* Maximum image width, in pixels */ -- cgit v1.3