Ignore:
Timestamp:
Jul 26, 2009, 9:17:35 PM (10 years ago)
Author:
Sam Hocevar
Message:

Allow to temporarily disable dirty rectangle handling. This allows for huge
speedups when the calling application knows the dirty rectangle covered by
a complex operation.

File:
1 edited

Legend:

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

    r3580 r3583  
    3636
    3737static void merge_new_rect(caca_canvas_t *cv, int n);
     38
     39/** \brief Disable dirty rectangles.
     40 *
     41 *  Disable dirty rectangle handling for all \e libcaca graphic calls. This
     42 *  is handy when the calling application needs to do slow operations within
     43 *  a known area. Just call caca_add_dirty_rect() afterwards.
     44 *
     45 *  This function is recursive. Dirty rectangles are only reenabled when
     46 *  caca_enable_dirty_rect() is called as many times.
     47 *
     48 *  This function never fails.
     49 *
     50 *  \param cv A libcaca canvas.
     51 *  \return This function always returns 0.
     52 */
     53int caca_disable_dirty_rect(caca_canvas_t *cv)
     54{
     55    cv->dirty_disabled++;
     56
     57    return 0;
     58}
     59
     60/** \brief Enable dirty rectangles.
     61 *
     62 *  This function can only be called after caca_disable_dirty_rect() was
     63 *  called.
     64 *
     65 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     66 *  - \c EINVAL Dirty rectangles were not disabled.
     67 *
     68 *  \param cv A libcaca canvas.
     69 *  \return 0 in case of success, -1 if an error occurred.
     70 */
     71int caca_enable_dirty_rect(caca_canvas_t *cv)
     72{
     73    if(cv->dirty_disabled <= 0)
     74    {
     75        seterrno(EINVAL);
     76        return -1;
     77    }
     78
     79    cv->dirty_disabled--;
     80
     81    return 0;
     82}
    3883
    3984/** \brief Get the number of dirty rectangles in the canvas.
Note: See TracChangeset for help on using the changeset viewer.