コード例 #1
0
ファイル: icons.c プロジェクト: BHCLL/blendocv
int BKE_icon_getid(struct ID* id)
{
	Icon* new_icon = NULL;

	if (!id || G.background)
		return 0;

	if (id->icon_id)
		return id->icon_id;

	id->icon_id = get_next_free_id();

	if (!id->icon_id){
		printf("BKE_icon_getid: Internal error - not enough IDs\n");
		return 0;
	}

	new_icon = MEM_callocN(sizeof(Icon), "texicon");

	new_icon->obj = id;
	new_icon->type = GS(id->name);
	
	/* next two lines make sure image gets created */
	new_icon->drawinfo = NULL;
	new_icon->drawinfo_free = NULL;

	BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(id->icon_id), new_icon);
	
	return id->icon_id;
}
コード例 #2
0
ファイル: icons.c プロジェクト: DrangPo/blender
/**
 * Return icon id of given preview, or create new icon if not found.
 */
int BKE_icon_preview_ensure(PreviewImage *preview)
{
	Icon *new_icon = NULL;

	if (!preview || G.background)
		return 0;

	if (preview->icon_id)
		return preview->icon_id;

	preview->icon_id = get_next_free_id();

	if (!preview->icon_id) {
		printf("%s: Internal error - not enough IDs\n", __func__);
		return 0;
	}

	new_icon = MEM_mallocN(sizeof(Icon), __func__);

	new_icon->obj = preview;
	new_icon->type = 0;  /* Special, tags as non-ID icon/preview. */

	/* next two lines make sure image gets created */
	new_icon->drawinfo = NULL;
	new_icon->drawinfo_free = NULL;

	BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(preview->icon_id), new_icon);

	return preview->icon_id;
}
コード例 #3
0
ファイル: icons.c プロジェクト: khanhha/blender
/**
 * Return icon id of given preview, or create new icon if not found.
 */
int BKE_icon_preview_ensure(ID *id, PreviewImage *preview)
{
	Icon *new_icon = NULL;

	if (!preview || G.background)
		return 0;

	if (id) {
		BLI_assert(BKE_previewimg_id_ensure(id) == preview);
	}

	if (preview->icon_id) {
		BLI_assert(!id || !id->icon_id || id->icon_id == preview->icon_id);
		return preview->icon_id;
	}

	if (id && id->icon_id) {
		preview->icon_id = id->icon_id;
		return preview->icon_id;
	}

	preview->icon_id = get_next_free_id();

	if (!preview->icon_id) {
		printf("%s: Internal error - not enough IDs\n", __func__);
		return 0;
	}

	/* Ensure we synchronize ID icon_id with its previewimage if available, and generate suitable 'ID' icon. */
	if (id) {
		id->icon_id = preview->icon_id;
		return icon_id_ensure_create_icon(id);
	}

	new_icon = MEM_mallocN(sizeof(Icon), __func__);

	new_icon->obj = preview;
	new_icon->type = 0;  /* Special, tags as non-ID icon/preview. */

	/* next two lines make sure image gets created */
	new_icon->drawinfo = NULL;
	new_icon->drawinfo_free = NULL;

	BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(preview->icon_id), new_icon);

	return preview->icon_id;
}
コード例 #4
0
ファイル: icons.c プロジェクト: khanhha/blender
int BKE_icon_id_ensure(struct ID *id)
{
	if (!id || G.background)
		return 0;

	if (id->icon_id)
		return id->icon_id;

	id->icon_id = get_next_free_id();

	if (!id->icon_id) {
		printf("%s: Internal error - not enough IDs\n", __func__);
		return 0;
	}

	/* Ensure we synchronize ID icon_id with its previewimage if it has one. */
	PreviewImage **p_prv = BKE_previewimg_id_get_p(id);
	if (p_prv && *p_prv) {
		BLI_assert(ELEM((*p_prv)->icon_id, 0, id->icon_id));
		(*p_prv)->icon_id = id->icon_id;
	}

	return icon_id_ensure_create_icon(id);
}