From 3b3bf0160dad37001eb0614c6a92ce6f4b6df21a Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 14 May 2009 00:18:37 +0000 Subject: [PATCH] Fix a few dirty rectangle bugs found with the unit tests. Let that be a lesson to you: unit tests are good. --- caca/attr.c | 2 +- caca/canvas.c | 20 ++++++++++---------- caca/string.c | 5 ++++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/caca/attr.c b/caca/attr.c index be352ba..a544efa 100644 --- a/caca/attr.c +++ b/caca/attr.c @@ -156,7 +156,7 @@ int caca_put_attr(caca_canvas_t *cv, int x, int y, uint32_t attr) xmax++; } - caca_add_dirty_rectangle(cv, xmin, xmax, y, y); + caca_add_dirty_rectangle(cv, xmin, y, xmax, y); return 0; } diff --git a/caca/canvas.c b/caca/canvas.c index a0cd8ae..8d31660 100644 --- a/caca/canvas.c +++ b/caca/canvas.c @@ -321,16 +321,16 @@ uint8_t const * caca_get_canvas_attrs(caca_canvas_t const *cv) * \param cv A libcaca canvas. * \param xmin A pointer to an integer where the leftmost edge of the * dirty rectangle will be stored. - * \param xmax A pointer to an integer where the rightmost edge of the - * dirty rectangle will be stored. * \param ymin A pointer to an integer where the topmost edge of the * dirty rectangle will be stored. + * \param xmax A pointer to an integer where the rightmost edge of the + * dirty rectangle will be stored. * \param ymax A pointer to an integer where the bottommost edge of the * dirty rectangle will be stored. * \return This function always returns 0. */ -int caca_get_dirty_rectangle(caca_canvas_t *cv, int *xmin, int *xmax, - int *ymin, int *ymax) +int caca_get_dirty_rectangle(caca_canvas_t *cv, int *xmin, int *ymin, + int *xmax, int *ymax) { *xmin = cv->dirty_xmin; *xmax = cv->dirty_xmax; @@ -356,13 +356,13 @@ int caca_get_dirty_rectangle(caca_canvas_t *cv, int *xmin, int *xmax, * * \param cv A libcaca canvas. * \param xmin The leftmost edge of the additional dirty rectangle. - * \param xmax The rightmost edge of the additional dirty rectangle. * \param ymin The topmost edge of the additional dirty rectangle. + * \param xmax The rightmost edge of the additional dirty rectangle. * \param ymax The bottommost edge of the additional dirty rectangle. * \return This function always returns 0. */ -int caca_add_dirty_rectangle(caca_canvas_t *cv, int xmin, int xmax, - int ymin, int ymax) +int caca_add_dirty_rectangle(caca_canvas_t *cv, int xmin, int ymin, + int xmax, int ymax) { /* Ignore empty rectangles. */ if(xmin > xmax || ymin > ymax) @@ -399,13 +399,13 @@ int caca_add_dirty_rectangle(caca_canvas_t *cv, int xmin, int xmax, * * \param cv A libcaca canvas. * \param xmin The leftmost edge of the desired dirty rectangle. - * \param xmax The rightmost edge of the desired dirty rectangle. * \param ymin The topmost edge of the desired dirty rectangle. + * \param xmax The rightmost edge of the desired dirty rectangle. * \param ymax The bottommost edge of the desired dirty rectangle. * \return This function always returns 0. */ -int caca_set_dirty_rectangle(caca_canvas_t *cv, int xmin, int xmax, - int ymin, int ymax) +int caca_set_dirty_rectangle(caca_canvas_t *cv, int xmin, int ymin, + int xmax, int ymax) { /* Normalise values indicating an empty or out-of-bounds rectangle. */ if(xmin > xmax || ymin > ymax || diff --git a/caca/string.c b/caca/string.c index 4e70581..6a3ffcf 100644 --- a/caca/string.c +++ b/caca/string.c @@ -170,10 +170,13 @@ int caca_put_char(caca_canvas_t *cv, int x, int y, uint32_t ch) /* When overwriting the left part of a fullwidth character, * replace its right part with a space. */ if(x + 1 != (int)cv->width && curchar[1] == CACA_MAGIC_FULLWIDTH) + { curchar[1] = ' '; + xmax++; + } } - caca_add_dirty_rectangle(cv, xmin, xmax, y, y); + caca_add_dirty_rectangle(cv, xmin, y, xmax, y); curchar[0] = ch; curattr[0] = attr;