Exemple #1
0
static void
nr_typeface_w32_finalize (NRObject *object)
{
    NRTypeFaceW32 *tfw32;

    tfw32 = (NRTypeFaceW32 *) object;

    nr_free (tfw32->otm);
    DeleteFont (tfw32->hfont);


    if (tfw32->slots) {
        unsigned int i;
        for (i = 0; i < tfw32->slots_length; i++) {
            if (tfw32->slots[i].outline.path > 0) {
				art_free (tfw32->slots[i].outline.path);
            }
        }
		nr_free (tfw32->slots);
    }
    if (tfw32->hgidx) nr_free (tfw32->hgidx);
    if (tfw32->vgidx) nr_free (tfw32->vgidx);

	((NRObjectClass *) (parent_class))->finalize (object);
}
Exemple #2
0
//buddy_alloc_pages_sub - the actual allocation implimentation, return a page whose size >=n,
//                      - the remaining free parts insert to other free list
static inline struct Page *buddy_alloc_pages_sub(uint32_t numa_id, size_t order)
{
	assert(order <= MAX_ORDER);
	size_t cur_order;
	for (cur_order = order; cur_order <= MAX_ORDER; cur_order++) {
		if (!list_empty(&free_list(numa_id, cur_order))) {
			list_entry_t *le = list_next(&free_list(numa_id, cur_order));
			struct Page *page = le2page(le, page_link);
			nr_free(numa_id, cur_order)--;
			list_del(le);
			size_t size = 1 << cur_order;
			while (cur_order > order) {
				cur_order--;
				size >>= 1;
				struct Page *buddy = page + size;
				buddy->property = cur_order;
				SetPageProperty(buddy);
				nr_free(numa_id, cur_order)++;
				list_add(&free_list(numa_id, cur_order),
					 &(buddy->page_link));
			}
			ClearPageProperty(page);
			return page;
		}
	}
Exemple #3
0
void
sp_sel_trans_shutdown (SPSelTrans *seltrans)
{
	gint i;

	for (i = 0; i < 8; i++) {
		if (seltrans->shandle[i]) {
			g_object_unref (G_OBJECT (seltrans->shandle[i]));
			seltrans->shandle[i] = NULL;
		}
		if (seltrans->rhandle[i]) {
			g_object_unref (G_OBJECT (seltrans->rhandle[i]));
			seltrans->rhandle[i] = NULL;
		}
	}
	if (seltrans->chandle) {
		g_object_unref (G_OBJECT (seltrans->chandle));
		seltrans->chandle = NULL;
	}

	if (seltrans->norm) {
		gtk_object_destroy (GTK_OBJECT (seltrans->norm));
		seltrans->norm = NULL;
	}
	if (seltrans->grip) {
		gtk_object_destroy (GTK_OBJECT (seltrans->grip));
		seltrans->grip = NULL;
	}
	if (seltrans->l1) {
		gtk_object_destroy (GTK_OBJECT (seltrans->l1));
		seltrans->l1 = NULL;
	}
	if (seltrans->l2) {
		gtk_object_destroy (GTK_OBJECT (seltrans->l2));
		seltrans->l2 = NULL;
	}
	if (seltrans->l3) {
		gtk_object_destroy (GTK_OBJECT (seltrans->l3));
		seltrans->l3 = NULL;
	}
	if (seltrans->l4) {
		gtk_object_destroy (GTK_OBJECT (seltrans->l4));
		seltrans->l4 = NULL;
	}

	if (seltrans->selection) {
		sp_signal_disconnect_by_data (seltrans->selection, seltrans);
	}

	nr_free (seltrans->spp);

	if (seltrans->items) {
		int i;
		for (i = 0; i < seltrans->nitems; i++) sp_object_unref (SP_OBJECT (seltrans->items[i]), NULL);
		nr_free (seltrans->items);
	}
	if (seltrans->transforms) nr_free (seltrans->transforms);
}
Exemple #4
0
static void
nr_typeface_w32_glyph_outline_unref (NRTypeFace *tf, unsigned int glyph, unsigned int metrics)
{
	NRTypeFaceW32 *tfw32;

	NRTypeFaceGlyphW32 *slot;



	tfw32 = (NRTypeFaceW32 *) tf;



	slot = nr_typeface_w32_ensure_slot (tfw32, glyph, metrics);



	if (slot && slot->olref > 0) {

		slot->olref -= 1;

		if (slot->olref < 1) {

			nr_free (slot->outline.path);

			slot->outline.path = NULL;

		}

	}

}
//buddy_init_memmap - build free_list for Page base follow  n continuous pages.
static void
buddy_init_memmap(struct Page *base, size_t n) {
    static int zone_num = 0;
    assert(n > 0 && zone_num < MAX_ZONE_NUM);
    struct Page *p = base;
    for (; p != base + n; p ++) {
        assert(PageReserved(p));
        p->flags = p->property = 0;
        p->zone_num = zone_num;
        set_page_ref(p, 0);
    }
    p = zones[zone_num ++].mem_base = base;
    size_t order = MAX_ORDER, order_size = (1 << order);
    while (n != 0) {
        while (n >= order_size) {
            p->property = order;
            SetPageProperty(p);
            list_add(&free_list(order), &(p->page_link));
            n -= order_size, p += order_size;
            nr_free(order) ++;
        }
        order --;
        order_size >>= 1;
    }
}
Exemple #6
0
//buddy_init_memmap - build free_list for Page base follow  n continuing pages.
static void buddy_init_memmap(struct numa_mem_zone *zone)
{
	static int zone_num = 0;
	size_t n = zone->n;
	assert(n > 0 && zone_num < MAX_NUMA_MEM_ZONES);
	zone_num ++;
	struct Page *base = zone->page;
	struct Page *p = base;
	for (; p != base + n; p++) {
		assert(PageReserved(p));
		p->flags = p->property = 0;
		p->zone_num = zone->id;
		set_page_ref(p, 0);
	}
	//p = zones[zone_num++].mem_base = base;
	p = base;
	size_t order = MAX_ORDER, order_size = (1 << order);
	uint32_t numa_id = zone->node->id;
	assert(numa_id < sysconf.lnuma_count);
	while (n != 0) {
		while (n >= order_size) {
			p->property = order;
			SetPageProperty(p);
			list_add(&free_list(numa_id, order), &(p->page_link));
			n -= order_size, p += order_size;
			nr_free(numa_id, order)++;
		}
		order--;
		order_size >>= 1;
	}
}
//buddy_init - init the free_list(0 ~ MAX_ORDER) & reset nr_free(0 ~ MAX_ORDER)
static void
buddy_init(void) {
    int i;
    for (i = 0; i <= MAX_ORDER; i ++) {
        list_init(&free_list(i));
        nr_free(i) = 0;
    }
}
Exemple #8
0
void
nr_vertex_free_one (NRVertex * v)
{
#ifndef NR_VERTEX_ALLOC
	v->next = ffvertex;
	ffvertex = v;
#else
	nr_free (v);
#endif
}
Exemple #9
0
//buddy_init - init the free_list(0 ~ MAX_ORDER) & reset nr_free(0 ~ MAX_ORDER)
static void buddy_init(void)
{
	int i, n;
	for (n = 0; n < MAX_NUMA_NODES; n++){
		for (i = 0; i <= MAX_ORDER; i++) {
			list_init(&free_list(n,i));
			nr_free(n,i) = 0;
		}
	}
}
Exemple #10
0
void
nr_vertex_free_list (NRVertex * v)
{
#ifndef NR_VERTEX_ALLOC
	NRVertex * l;
	for (l = v; l->next != NULL; l = l->next);
	l->next = ffvertex;
	ffvertex = v;
#else
	NRVertex *l, *n;
	l = v;
	while (l) {
		n = l->next;
		nr_free (l);
		l = n;
	}
#endif
}
Exemple #11
0
/**
 * Writes the given transform into the repr for the given item.
 */
static void
sp_path_write_transform (SPItem *item, SPRepr *repr, NRMatrixF *transform)
{
	SPPath *path;
	SPShape *shape;
	NRBPath dpath, spath;
	double ex;
	gchar *svgpath;
	SPStyle *style;

	path = (SPPath *) item;
	shape = (SPShape *) item;

	/* Calculate the DF */
	ex = NR_MATRIX_DF_EXPANSION (transform);

	/* Take the path for the shape, write it as an svgpath, and add it to the repr */
	spath.path = shape->curve->bpath;
	nr_path_duplicate_transform (&dpath, &spath, transform);
	svgpath = sp_svg_write_path (dpath.path);
	sp_repr_set_attr (repr, "d", svgpath);
	g_free (svgpath);
	nr_free (dpath.path);

	/* Wrte the style info into the repr */
	style = SP_OBJECT_STYLE (item);
	if (style->stroke.type != SP_PAINT_TYPE_NONE) {
		if (!NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON_D)) {
			gchar *str;
			/* Scale changed, so we have to adjust stroke width */
			style->stroke_width.computed *= ex;
			if (style->stroke_dash.n_dash != 0) {
				int i;
				for (i = 0; i < style->stroke_dash.n_dash; i++) style->stroke_dash.dash[i] *= ex;
				style->stroke_dash.offset *= ex;
			}
			str = sp_style_write_difference (style, SP_OBJECT_STYLE (SP_OBJECT_PARENT (item)));
			sp_repr_set_attr (repr, "style", str);
			g_free (str);
		}
	}
	sp_repr_set_attr (repr, "transform", NULL);
}
Exemple #12
0
static void
nr_typeface_gnome_finalize (NRObject *object)
{
    NRTypeFace *tf;
    NRTypeFaceGnome *tfg;

    tf = (NRTypeFace *) object;
    tfg = (NRTypeFaceGnome *) object;

    if (tfg->voutlines) {
        int i;
        for (i = 0; i < tf->nglyphs; i++) {
            if (tfg->voutlines[i].path) art_free (tfg->voutlines[i].path);
        }
        nr_free (tfg->voutlines);
    }

    gnome_font_face_unref (tfg->face);

    ((NRObjectClass *) (parent_class))->finalize (object);
}
Exemple #13
0
/* This takes area as blocks */
void
nr_uta_move_resize (NRUTA *uta, int x0, int y0, int x1, int y1)
{
	int x, y;
	NRULong *nutiles;
	nutiles = nr_new (NRULong, (y1 - y0) * (x1 - x0));
	for (y = y0; y < y1; y++) {
		for (x = x0; x < x1; x++) {
			if ((x >= uta->x0) && (y >= uta->y0) && (x < uta->x1) && (y < uta->y1)) {
				nutiles[(y - y0) * (x1 - x0) + (x - x0)] = uta->utiles[(y - uta->y0) * (uta->x1 - uta->x0) + (x - uta->x0)];
			} else {
				NR_UTILE_SET (nutiles + (y - y0) * (x1 - x0) + (x - x0), NR_UTILE_SIZE, NR_UTILE_SIZE, 0, 0);
			}
		}
	}
	nr_free (uta->utiles);
	uta->utiles = nutiles;
	uta->x0 = x0;
	uta->y0 = y0;
	uta->x1 = x1;
	uta->y1 = y1;
}
Exemple #14
0
void
nr_svp_free (NRSVP *svp)
{
	if (svp->points) nr_free (svp->points);
	free (svp);
}
Exemple #15
0
static void
nr_type_gnome_typefaces_destructor (NRNameList *list)
{
    nr_free (list->names);
}
Exemple #16
0
void
sp_sel_trans_ungrab (SPSelTrans * seltrans)
{
	SPItem * item;
	const GSList * l;
	gchar tstr[80];
	NRPointD p;
	unsigned int updh;

	g_return_if_fail (seltrans->grabbed);

	updh = TRUE;
	if (!seltrans->empty && seltrans->changed) {
		l = sp_selection_item_list (SP_DT_SELECTION (seltrans->desktop));

		tstr[79] = '\0';

		while (l != NULL) {
			item = SP_ITEM (l->data);
			/* fixme: We do not have to set it here (Lauris) */
			if (seltrans->show == SP_SELTRANS_SHOW_OUTLINE) {
				NRMatrixF i2d, i2dnew;
				sp_item_i2d_affine (item, &i2d);
				nr_matrix_multiply_ffd (&i2dnew, &i2d, &seltrans->current);
				sp_item_set_i2d_affine (item, &i2dnew);
			}
			if (seltrans->transform == SP_SELTRANS_TRANSFORM_OPTIMIZE) {
				sp_item_write_transform (item, SP_OBJECT_REPR (item), &item->transform);
				/* because item/repr affines may be out of sync, invoke reread */
				/* fixme: We should test equality to avoid unnecessary rereads */
				/* fixme: This probably is not needed (Lauris) */
				sp_object_read_attr (SP_OBJECT (item), "transform");
			} else {
				if (sp_svg_transform_write (tstr, 79, &item->transform)) {
					sp_repr_set_attr (SP_OBJECT (item)->repr, "transform", tstr);
				} else {
					sp_repr_set_attr (SP_OBJECT (item)->repr, "transform", NULL);
				}
			}
			l = l->next;
		}
		p = seltrans->center;
		seltrans->center.x = NR_MATRIX_DF_TRANSFORM_X (&seltrans->current, p.x, p.y);
		seltrans->center.y = NR_MATRIX_DF_TRANSFORM_Y (&seltrans->current, p.x, p.y);
		
		sp_document_done (SP_DT_DOCUMENT (seltrans->desktop));
		sp_selection_changed (SP_DT_SELECTION (seltrans->desktop));

		updh = FALSE;
	}

	if (seltrans->items) {
		int i;
		for (i = 0; i < seltrans->nitems; i++) sp_object_unref (SP_OBJECT (seltrans->items[i]), NULL);
		nr_free (seltrans->items);
		seltrans->items = NULL;
	}
	if (seltrans->transforms) {
		nr_free (seltrans->transforms);
		seltrans->transforms = NULL;
	}
	seltrans->nitems = 0;

	seltrans->grabbed = FALSE;
	seltrans->show_handles = TRUE;
	
	sp_canvas_item_hide (seltrans->norm);
	sp_canvas_item_hide (seltrans->grip);

        if (seltrans->show == SP_SELTRANS_SHOW_OUTLINE) {
		sp_canvas_item_hide (seltrans->l1);
		sp_canvas_item_hide (seltrans->l2);
		sp_canvas_item_hide (seltrans->l3);
		sp_canvas_item_hide (seltrans->l4);
	}

	sp_sel_trans_update_volatile_state (seltrans);
	if (updh) sp_sel_trans_update_handles (seltrans);
	if (seltrans->stamp_cache) {
		g_slist_free(seltrans->stamp_cache);
		seltrans->stamp_cache = NULL;
	}

}