Logo Search packages:      
Sourcecode: inkscape version File versions

static int paint ( SPCanvas canvas  )  [static]

Helper that repaints the areas in the canvas that need it.

Returns:
true if all the dirty parts have been redrawn

Definition at line 2031 of file sp-canvas.cpp.

References SPCanvas::forced_redraw_count, SPCanvas::forced_redraw_limit, Geom::identity(), SPCanvas::need_redraw, SPCanvas::need_update, SPCanvas::root, sp_canvas_item_invoke_update(), sp_canvas_paint_rect(), SPCanvas::tileH, SPCanvas::tiles, SPCanvas::tLeft, and SPCanvas::tTop.

Referenced by do_update(), find_references(), and objects_query_fillstroke().

{
    if (canvas->need_update) {
        sp_canvas_item_invoke_update (canvas->root, Geom::identity(), 0);
        canvas->need_update = FALSE;
    }

    if (!canvas->need_redraw)
        return TRUE;

    Gdk::Region to_paint;

    for (int j=canvas->tTop; j<canvas->tBottom; j++) {
        for (int i=canvas->tLeft; i<canvas->tRight; i++) {
            int tile_index = (i - canvas->tLeft) + (j - canvas->tTop)*canvas->tileH;

            if ( canvas->tiles[tile_index] ) { // if this tile is dirtied (nonzero)
                to_paint.union_with_rect(Gdk::Rectangle(i*TILE_SIZE, j*TILE_SIZE,
                                   TILE_SIZE, TILE_SIZE));
            }

        }
    }

    if (!to_paint.empty()) {
        Glib::ArrayHandle<Gdk::Rectangle> rect = to_paint.get_rectangles();
        typedef Glib::ArrayHandle<Gdk::Rectangle>::const_iterator Iter;
        for (Iter i=rect.begin(); i != rect.end(); ++i) {
            int x0 = (*i).get_x();
            int y0 = (*i).get_y();
            int x1 = x0 + (*i).get_width();
            int y1 = y0 + (*i).get_height();
            if (!sp_canvas_paint_rect(canvas, x0, y0, x1, y1)) {
                // Aborted
                return FALSE;
            };
        }
    }

    canvas->need_redraw = FALSE;

    // we've had a full unaborted redraw, reset the full redraw counter
    if (canvas->forced_redraw_limit != -1) {
        canvas->forced_redraw_count = 0;
    }

    return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index