Logo Search packages:      
Sourcecode: inkscape version File versions

static void sp_canvas_resize_tiles ( SPCanvas canvas,
int  nl,
int  nt,
int  nr,
int  nb 
) [static]

Helper that allocates a new tile array for the canvas, copying overlapping tiles from the old array

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

References SPCanvas::tBottom, SPCanvas::tileH, SPCanvas::tiles, SPCanvas::tileV, SPCanvas::tLeft, SPCanvas::tRight, and SPCanvas::tTop.

Referenced by sp_canvas_scroll_to(), and sp_canvas_size_allocate().

{
    if ( nl >= nr || nt >= nb ) {
        if ( canvas->tiles ) g_free(canvas->tiles);
        canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0;
        canvas->tileH=canvas->tileV=0;
        canvas->tiles=NULL;
        return;
    }
    int tl=sp_canvas_tile_floor(nl);
    int tt=sp_canvas_tile_floor(nt);
    int tr=sp_canvas_tile_ceil(nr);
    int tb=sp_canvas_tile_ceil(nb);

    int nh = tr-tl, nv = tb-tt;
    uint8_t* ntiles = (uint8_t*)g_malloc(nh*nv*sizeof(uint8_t));
    for (int i=tl; i<tr; i++) {
        for (int j=tt; j<tb; j++) {
            int ind = (i-tl) + (j-tt)*nh;
            if ( i >= canvas->tLeft && i < canvas->tRight && j >= canvas->tTop && j < canvas->tBottom ) {
                ntiles[ind]=canvas->tiles[(i-canvas->tLeft)+(j-canvas->tTop)*canvas->tileH]; // copy from the old tile
            } else {
                ntiles[ind]=0; // newly exposed areas get 0
            }
        }
    }
    if ( canvas->tiles ) g_free(canvas->tiles);
    canvas->tiles=ntiles;
    canvas->tLeft=tl;
    canvas->tTop=tt;
    canvas->tRight=tr;
    canvas->tBottom=tb;
    canvas->tileH=nh;
    canvas->tileV=nv;
}


Generated by  Doxygen 1.6.0   Back to index