From 162613b630e4a7a2eca6ac292c409ba4902c46bc Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 22 May 2009 10:18:44 +0000 Subject: [PATCH] caca_put_char(): only add a dirty rectangle if the paster character is different from what was already there. --- caca/string.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/caca/string.c b/caca/string.c index b6eb194..3f3fa0d 100644 --- a/caca/string.c +++ b/caca/string.c @@ -176,7 +176,12 @@ int caca_put_char(caca_canvas_t *cv, int x, int y, uint32_t ch) } } - caca_add_dirty_rect(cv, xmin, y, xmax - xmin + 1, 1); + /* Only add a dirty rectangle if we are pasting a different character + * or attribute at that place. This does not account for inconsistencies + * in the canvas, ie. if CACA_MAGIC_FULLWIDTH lies at illegal places, + * but it's the caller's responsibility not to corrupt the contents. */ + if(curchar[0] != ch || curattr[0] != attr) + caca_add_dirty_rect(cv, xmin, y, xmax - xmin + 1, 1); curchar[0] = ch; curattr[0] = attr;