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.

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

References NR::identity(), SPCanvas::need_redraw, SPCanvas::need_update, SPCanvas::root, sp_canvas_item_invoke_update(), sp_canvas_paint_rect(), SPCanvas::tBottom, SPCanvas::tileH, SPCanvas::tiles, SPCanvas::tLeft, SPCanvas::tRight, SPCanvas::tTop, SPCanvas::x0, and SPCanvas::y0.

Referenced by do_update(), and objects_query_fillstroke().

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

    if (!canvas->need_redraw)
        return TRUE;

    GtkWidget const *widget = GTK_WIDGET(canvas);
    int const canvas_x1 = canvas->x0 + widget->allocation.width;
    int const canvas_y1 = canvas->y0 + widget->allocation.height;

    NRRectL topaint;
    topaint.x0 = topaint.y0 = topaint.x1 = topaint.y1 = 0;

    for (int j=canvas->tTop&(~3);j<canvas->tBottom;j+=4) {
        for (int i=canvas->tLeft&(~3);i<canvas->tRight;i+=4) {
            int  mode=0;
      
            int pl=i+1,pr=i,pt=j+4,pb=j;
            for (int l=MAX(j,canvas->tTop);l<MIN(j+4,canvas->tBottom);l++) {
                for (int k=MAX(i,canvas->tLeft);k<MIN(i+4,canvas->tRight);k++) {
                    if ( canvas->tiles[(k-canvas->tLeft)+(l-canvas->tTop)*canvas->tileH] ) {
                        mode|=1<<((k-i)+(l-j)*4);
                        if ( k < pl ) pl=k;
                        if ( k+1 > pr ) pr=k+1;
                        if ( l < pt ) pt=l;
                        if ( l+1 > pb ) pb=l+1;
                    }
                    canvas->tiles[(k-canvas->tLeft)+(l-canvas->tTop)*canvas->tileH]=0;
                }
            }
      
            if ( mode ) {
                NRRectL tile;
                tile.x0 = MAX (pl*32, canvas->x0);
                tile.y0 = MAX (pt*32, canvas->y0);
                tile.x1 = MIN (pr*32, canvas_x1);
                tile.y1 = MIN (pb*32, canvas_y1);
                if ((tile.x0 < tile.x1) && (tile.y0 < tile.y1)) {
                    nr_rect_l_union (&topaint, &topaint, &tile);
                }

            }
        }
    }

    canvas->need_redraw = FALSE;
    sp_canvas_paint_rect (canvas, topaint.x0, topaint.y0, topaint.x1, topaint.y1);

    return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index