Ignore:
Timestamp:
May 21, 2009, 10:55:13 PM (12 years ago)
Author:
Sam Hocevar
Message:

Change the dirty rectangle API once again so that calling applications get
a more natural (x,y,w,h) 4-tuple to handle.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/dirty.c

    r3484 r3494  
    4242 *  \return The number of dirty rectangles in the given canvas.
    4343 */
    44 int caca_get_dirty_rectangle_count(caca_canvas_t *cv)
     44int caca_get_dirty_rect_count(caca_canvas_t *cv)
    4545{
    4646    return cv->ndirty;
     
    5050 *
    5151 *  Get the canvas's given dirty rectangle coordinates. The index must be
    52  *  within the dirty rectangle count. See caca_get_dirty_rectangle_count()
     52 *  within the dirty rectangle count. See caca_get_dirty_rect_count()
    5353 *  for how to compute this count.
    5454 *
     
    5959 *  \param cv A libcaca canvas.
    6060 *  \param r The requested rectangle index.
    61  *  \param xmin A pointer to an integer where the leftmost edge of the
    62  *              dirty rectangle will be stored.
    63  *  \param ymin A pointer to an integer where the topmost edge of the
    64  *              dirty rectangle will be stored.
    65  *  \param xmax A pointer to an integer where the rightmost edge of the
    66  *              dirty rectangle will be stored.
    67  *  \param ymax A pointer to an integer where the bottommost edge of the
    68  *              dirty rectangle will be stored.
     61 *  \param x A pointer to an integer where the leftmost edge of the
     62 *           dirty rectangle will be stored.
     63 *  \param y A pointer to an integer where the topmost edge of the
     64 *           dirty rectangle will be stored.
     65 *  \param width A pointer to an integer where the width of the
     66 *               dirty rectangle will be stored.
     67 *  \param height A pointer to an integer where the height of the
     68 *                dirty rectangle will be stored.
    6969 *  \return 0 in case of success, -1 if an error occurred.
    7070 */
    71 int caca_get_dirty_rectangle(caca_canvas_t *cv, int r,
    72                              int *xmin, int *ymin, int *xmax, int *ymax)
     71int caca_get_dirty_rect(caca_canvas_t *cv, int r,
     72                        int *x, int *y, int *width, int *height)
    7373{
    7474    if(r < 0 || r >= cv->ndirty)
     
    9191        cv->dirty_ymax = cv->height - 1;
    9292
    93     *xmin = cv->dirty_xmin;
    94     *xmax = cv->dirty_xmax;
    95     *ymin = cv->dirty_ymin;
    96     *ymax = cv->dirty_ymax;
     93    *x = cv->dirty_xmin;
     94    *y = cv->dirty_ymin;
     95    *width = cv->dirty_xmax - cv->dirty_xmin + 1;
     96    *height = cv->dirty_ymax - cv->dirty_ymin + 1;
    9797
    9898    return 0;
     
    102102 *
    103103 *  Add an invalidating zone to the canvas's dirty rectangle list. For more
    104  *  information about the dirty rectangles, see caca_get_dirty_rectangle().
     104 *  information about the dirty rectangles, see caca_get_dirty_rect().
    105105 *
    106106 *  This function may be useful to force refresh of a given zone of the
     
    113113 *
    114114 *  \param cv A libcaca canvas.
    115  *  \param xmin The leftmost edge of the additional dirty rectangle.
    116  *  \param ymin The topmost edge of the additional dirty rectangle.
    117  *  \param xmax The rightmost edge of the additional dirty rectangle.
    118  *  \param ymax The bottommost edge of the additional dirty rectangle.
     115 *  \param x The leftmost edge of the additional dirty rectangle.
     116 *  \param y The topmost edge of the additional dirty rectangle.
     117 *  \param width The width of the additional dirty rectangle.
     118 *  \param height The height of the additional dirty rectangle.
    119119 *  \return 0 in case of success, -1 if an error occurred.
    120120 */
    121 int caca_add_dirty_rectangle(caca_canvas_t *cv, int xmin, int ymin,
    122                              int xmax, int ymax)
     121int caca_add_dirty_rect(caca_canvas_t *cv, int x, int y,
     122                             int width, int height)
    123123{
    124124    /* Ignore empty and out-of-bounds rectangles */
    125     if(xmin > xmax || ymin > ymax
    126         || xmax < 0 || xmin >= cv->width || ymax < 0 || ymin >= cv->height)
     125    if(width <= 0 || height <= 0 || x + width <= 0 || x >= cv->width
     126        || y + height <= 0 || y >= cv->height)
    127127    {
    128128        seterrno(EINVAL);
     
    133133    {
    134134        cv->ndirty = 1;
    135         cv->dirty_xmin = xmin;
    136         cv->dirty_xmax = xmax;
    137         cv->dirty_ymin = ymin;
    138         cv->dirty_ymax = ymax;
     135        cv->dirty_xmin = x;
     136        cv->dirty_xmax = x + width - 1;
     137        cv->dirty_ymin = y;
     138        cv->dirty_ymax = y + height - 1;
    139139    }
    140140    else
    141141    {
    142         if(xmin < cv->dirty_xmin)
    143             cv->dirty_xmin = xmin;
    144         if(xmax > cv->dirty_xmax)
    145             cv->dirty_xmax = xmax;
    146         if(ymin < cv->dirty_ymin)
    147             cv->dirty_ymin = ymin;
    148         if(ymax > cv->dirty_ymax)
    149             cv->dirty_ymax = ymax;
     142        if(x < cv->dirty_xmin)
     143            cv->dirty_xmin = x;
     144        if(x + width - 1 > cv->dirty_xmax)
     145            cv->dirty_xmax = x + width - 1;
     146        if(y < cv->dirty_ymin)
     147            cv->dirty_ymin = y;
     148        if(y + height - 1 > cv->dirty_ymax)
     149            cv->dirty_ymax = y + height - 1;
    150150    }
    151151
     
    156156 *
    157157 *  Mark a cell area in the canvas as not dirty. For more information about
    158  *  the dirty rectangles, see caca_get_dirty_rectangle().
     158 *  the dirty rectangles, see caca_get_dirty_rect().
    159159 *
    160160 *  Values such that \b xmin > \b xmax or \b ymin > \b ymax indicate that
     
    165165 *
    166166 *  \param cv A libcaca canvas.
    167  *  \param xmin The leftmost edge of the clean rectangle.
    168  *  \param ymin The topmost edge of the clean rectangle.
    169  *  \param xmax The rightmost edge of the clean rectangle.
    170  *  \param ymax The bottommost edge of the clean rectangle.
     167 *  \param x The leftmost edge of the clean rectangle.
     168 *  \param y The topmost edge of the clean rectangle.
     169 *  \param width The width of the clean rectangle.
     170 *  \param height The height of the clean rectangle.
    171171 *  \return 0 in case of success, -1 if an error occurred.
    172172 */
    173 int caca_remove_dirty_rectangle(caca_canvas_t *cv, int xmin, int ymin,
    174                                 int xmax, int ymax)
     173int caca_remove_dirty_rect(caca_canvas_t *cv, int x, int y,
     174                           int width, int height)
    175175{
    176176    /* Ignore empty and out-of-bounds rectangles */
    177     if(xmin > xmax || ymin > ymax
    178         || xmax < 0 || xmin >= cv->width || ymax < 0 || ymin >= cv->height)
     177    if(width <= 0 || height <= 0 || x + width <= 0 || x >= cv->width
     178        || y + height <= 0 || y >= cv->height)
    179179    {
    180180        seterrno(EINVAL);
     
    198198 *  \return This function always returns 0.
    199199 */
    200 int caca_clear_dirty_rectangle_list(caca_canvas_t *cv)
     200int caca_clear_dirty_rect_list(caca_canvas_t *cv)
    201201{
    202202    cv->ndirty = 0;
Note: See TracChangeset for help on using the changeset viewer.