Ignore:
Timestamp:
May 14, 2009, 2:18:23 AM (11 years ago)
Author:
Sam Hocevar
Message:

Finish the dirty rectangle architecture. They are now reliable in the sense
that anything outside the dirty rectangle is guaranteed to be unchanged, but
we currently mark far too many cells as dirty. This must be optimised.

File:
1 edited

Legend:

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

    r3443 r3448  
    9090    cv->frames[0].curattr = 0;
    9191    cv->frames[0].name = strdup("frame#00000000");
    92     cv->frames[0].dirty_xmin = 0;
    93     cv->frames[0].dirty_xmax = -1;
    94     cv->frames[0].dirty_ymin = 0;
    95     cv->frames[0].dirty_ymax = -1;
    9692
    9793    _caca_load_frame_info(cv);
    9894    caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT);
     95
     96    cv->dirty_xmin = 0;
     97    cv->dirty_xmax = -1;
     98    cv->dirty_ymin = 0;
     99    cv->dirty_ymax = -1;
    99100
    100101    cv->ff = NULL;
     
    332333                             int *ymin, int *ymax)
    333334{
    334     *xmin = cv->frames[cv->frame].dirty_xmin;
    335     *xmax = cv->frames[cv->frame].dirty_xmax;
    336     *ymin = cv->frames[cv->frame].dirty_ymin;
    337     *ymax = cv->frames[cv->frame].dirty_ymax;
     335    *xmin = cv->dirty_xmin;
     336    *xmax = cv->dirty_xmax;
     337    *ymin = cv->dirty_ymin;
     338    *ymax = cv->dirty_ymax;
    338339
    339340    return 0;
     
    372373        return 0;
    373374
    374     if(xmin < cv->frames[cv->frame].dirty_xmin)
    375         cv->frames[cv->frame].dirty_xmin = xmin;
    376 
    377     if(xmax > cv->frames[cv->frame].dirty_xmax)
    378         cv->frames[cv->frame].dirty_xmax = xmax;
    379 
    380     if(ymin < cv->frames[cv->frame].dirty_ymin)
    381         cv->frames[cv->frame].dirty_ymin = ymin;
    382 
    383     if(ymax > cv->frames[cv->frame].dirty_ymax)
    384         cv->frames[cv->frame].dirty_ymax = ymax;
     375    if(xmin < cv->dirty_xmin)
     376        cv->dirty_xmin = xmin;
     377
     378    if(xmax > cv->dirty_xmax)
     379        cv->dirty_xmax = xmax;
     380
     381    if(ymin < cv->dirty_ymin)
     382        cv->dirty_ymin = ymin;
     383
     384    if(ymax > cv->dirty_ymax)
     385        cv->dirty_ymax = ymax;
    385386
    386387    return 0;
     
    417418    }
    418419
    419     cv->frames[cv->frame].dirty_xmin = xmin;
    420     cv->frames[cv->frame].dirty_xmax = xmax;
    421     cv->frames[cv->frame].dirty_ymin = ymin;
    422     cv->frames[cv->frame].dirty_ymax = ymax;
     420    cv->dirty_xmin = xmin;
     421    cv->dirty_xmax = xmax;
     422    cv->dirty_ymin = ymin;
     423    cv->dirty_ymax = ymax;
    423424
    424425    return 0;
     
    556557            }
    557558        }
     559
     560        caca_add_dirty_rectangle(cv, old_width, 0, width - 1, old_height - 1);
    558561    }
    559562    else
     
    595598            }
    596599        }
    597     }
     600
     601        caca_add_dirty_rectangle(cv, 0, old_height, old_width - 1, height - 1);
     602    }
     603
     604    /* XXX: technically we should not worry about the dirty rectangle in
     605     * the bottom-right corner, because we only handle one dirty rectangle,
     606     * but in case the API changes later, we make sure this is handled. */
     607    if(width > old_width && height > old_height)
     608        caca_add_dirty_rectangle(cv, old_width, old_height,
     609                                 width - 1, height - 1);
    598610
    599611    /* Step 4: if new area is smaller, resize memory area now. */
Note: See TracChangeset for help on using the changeset viewer.