[Bf-blender-cvs] [cdfd3c1] asset-engine: Merge branch 'asset-experiments' into asset-engine

Bastien Montagne noreply at git.blender.org
Tue Mar 17 16:28:55 CET 2015


Commit: cdfd3c17f5d14936b6befd323589547c2b7aefa1
Author: Bastien Montagne
Date:   Tue Mar 17 16:27:39 2015 +0100
Branches: asset-engine
https://developer.blender.org/rBcdfd3c17f5d14936b6befd323589547c2b7aefa1

Merge branch 'asset-experiments' into asset-engine

Conflicts:
	source/blender/editors/space_file/filelist.c

===================================================================



===================================================================

diff --cc source/blender/blenkernel/BKE_asset.h
index c26797d,0000000..6036064
mode 100644,000000..100644
--- a/source/blender/blenkernel/BKE_asset.h
+++ b/source/blender/blenkernel/BKE_asset.h
@@@ -1,168 -1,0 +1,170 @@@
 +/*
 + * ***** BEGIN GPL LICENSE BLOCK *****
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * The Original Code is Copyright (C) 2015 Blender Foundation.
 + * All rights reserved.
 + *
 + * The Original Code is: all of this file.
 + *
 + * Contributor(s): none yet.
 + *
 + * ***** END GPL LICENSE BLOCK *****
 + */
 +
 +/** \file BKE_asset.h
 + *  \ingroup bke
 + */
 +
 +#ifndef __BKE_ASSET_H__
 +#define __BKE_ASSET_H__
 +
 +#ifdef __cplusplus
 +extern "C" {
 +#endif
 +
 +#include "DNA_space_types.h"
 +
 +struct AssetEngine;
 +struct AssetEngineType;
 +struct AssetUUIDList;
 +struct FileDirEntryArr;
 +struct FileDirEntry;
 +struct FileDirEntryVariant;
 +struct FileDirEntryRevision;
 +struct ExtensionRNA;
 +struct ID;
 +struct ListBase;
 +struct uiLayout;
 +
 +enum {
 +	AE_STATUS_VALID   = 1 << 0,
 +	AE_STATUS_RUNNING = 1 << 1,  /* Asset engine is performing some background tasks... */
 +};
 +
 +#define AE_FAKE_ENGINE_ID "none"
 +
 +extern ListBase asset_engines;
 +
 +/* AE instance/job is valid, is running, is idle, etc. */
 +typedef int (*ae_status)(struct AssetEngine *engine, const int job_id);
 +typedef float (*ae_progress)(struct AssetEngine *engine, const int job_id);
 +
 +/* To force end of given job (e.g. because it was cancelled by user...). */
 +typedef void (*ae_kill)(struct AssetEngine *engine, const int job_id);
 +
 +/* ***** All callbacks below shall be non-blocking (i.e. return immediately). ***** */
 +/* Those callbacks will be called from a 'fake-job' start *and* update functions (i.e. main thread, working one will
 + * just sleep).
 + * If given id is not null, engine should update from a running job if available, otherwise it should start a new one.
 + * It is the responsability of the engine to start/stop background processes to actually perform tasks as/if needed.
 + */
 +
 +/* Return (list) everything available at given root path. */
 +typedef int (*ae_list_dir)(struct AssetEngine *engine, const int job_id, struct FileDirEntryArr *entries_r);
 +/* Ensure given direntries are really available for append/link (some kind of 'anticipated loading'...). */
 +typedef int (*ae_ensure_entries)(struct AssetEngine *engine, const int job_id, struct AssetUUIDList *uuids);
 +
 +/* ***** All callbacks below are blocking. They shall be completed upon return. ***** */
 +
 +/* 'pre-loading' hook, called before opening/appending/linking given entries.
 + * Note first given uuid is the one of 'active' entry, and first entry in returned list will be considered as such too.
 + * E.g. allows the engine to ensure entries' paths are actually valid by downloading requested data, etc.
 + * If is_virtual is True, then there is no requirement that returned paths actually exist.
 + * Note that the generated list shall be simpler than the one generated by ae_list_dir, since only the path from
 + * active revision is used, no need to bother with variants, previews, etc.
 + * This allows to present 'fake' entries to user, and then import actual data.
 + */
 +typedef bool (*ae_load_pre)(struct AssetEngine *engine, struct AssetUUIDList *uuids,
 +                            struct FileDirEntryArr *entries_r);
 +
 +/* 'post-loading' hook, called after opening/appending/linking given entries.
 + * E.g. allows an advanced engine to make fancy scripted operations over loaded items. */
 +typedef bool (*ae_load_post)(struct AssetEngine *engine, struct ID *items, const int *num_items);
 +
 +typedef struct AssetEngineType {
 +	struct AssetEngineType *next, *prev;
 +
 +	/* type info */
 +	char idname[64]; /* best keep the same size as BKE_ST_MAXNAME */
 +	char name[64];
 +	int flag;
 +
 +	/* API */
 +	ae_status status;
 +	ae_progress progress;
 +
 +	ae_kill kill;
 +
 +	ae_list_dir list_dir;
 +	ae_ensure_entries ensure_entries;
 +
 +	ae_load_pre load_pre;
 +	ae_load_post load_post;
 +
 +	/* RNA integration */
 +	struct ExtensionRNA ext;
 +} AssetEngineType;
 +
 +typedef struct AssetEngine {
 +	AssetEngineType *type;
 +	void *py_instance;
 +
 +	int flag;
 +	int refcount;
 +
 +	struct ReportList *reports;
 +} AssetEngine;
 +
 +/* Engine Types */
 +void BKE_asset_engines_init(void);
 +void BKE_asset_engines_exit(void);
 +
 +AssetEngineType *BKE_asset_engines_find(const char *idname);
 +
 +/* Engine Instances */
 +AssetEngine *BKE_asset_engine_create(AssetEngineType *type);
 +AssetEngine *BKE_asset_engine_copy(AssetEngine *engine);
 +void BKE_asset_engine_free(AssetEngine *engine);
 +
 +void BKE_asset_engine_load_pre(AssetEngine *engine, struct FileDirEntryArr *r_entries);
 +
 +/* File listing utils... */
 +
 +typedef enum FileCheckType {
 +	CHECK_NONE  = 0,
 +	CHECK_DIRS  = 1 << 0,
 +	CHECK_FILES = 1 << 1,
 +	CHECK_ALL   = CHECK_DIRS | CHECK_FILES,
 +} FileCheckType;
 +
++void BKE_filedir_revision_free(struct FileDirEntryRevision *rev);
++
 +void BKE_filedir_variant_free(struct FileDirEntryVariant *var);
 +
 +void BKE_filedir_entry_free(struct FileDirEntry *entry);
 +void BKE_filedir_entry_clear(struct FileDirEntry *entry);
 +struct FileDirEntry *BKE_filedir_entry_copy(struct FileDirEntry *entry);
 +
 +void BKE_filedir_entryarr_clear(struct FileDirEntryArr *array);
 +
 +bool BKE_filedir_entry_is_selected(struct FileDirEntry *entry, FileCheckType check);
 +
 +#ifdef __cplusplus
 +}
 +#endif
 +
 +#endif /* __BKE_ASSET_H__ */
diff --cc source/blender/blenkernel/intern/asset.c
index 458fa47,0000000..8321523
mode 100644,000000..100644
--- a/source/blender/blenkernel/intern/asset.c
+++ b/source/blender/blenkernel/intern/asset.c
@@@ -1,316 -1,0 +1,336 @@@
 +/*
 + * ***** BEGIN GPL LICENSE BLOCK *****
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * The Original Code is Copyright (C) 2015 Blender Foundation.
 + * All rights reserved.
 + *
 + * The Original Code is: all of this file.
 + *
 + * Contributor(s): none yet.
 + *
 + * ***** END GPL LICENSE BLOCK *****
 + */
 +
 +/** \file blender/blenkernel/intern/asset.c
 + *  \ingroup bke
 + */
 +
 +#include <stddef.h>
 +#include <stdlib.h>
 +#include <string.h>
 +
 +#include "MEM_guardedalloc.h"
 +
 +#include "RNA_access.h"
 +#include "RNA_types.h"
 +
 +#include "BLF_translation.h"
 +
 +#include "BLI_fileops_types.h"
 +#include "BLI_listbase.h"
 +#include "BLI_string.h"
 +#include "BLI_utildefines.h"
 +
 +#include "BKE_global.h"
 +#include "BKE_report.h"
 +#include "BKE_asset.h"
 +
 +#include "IMB_imbuf.h"
 +
 +#include "DNA_space_types.h"
 +
 +#ifdef WITH_PYTHON
 +#include "BPY_extern.h"
 +#endif
 +
 +/* Asset engine types (none intern!). */
 +
 +ListBase asset_engines = {NULL, NULL};
 +
 +void BKE_asset_engines_init(void)
 +{
 +	/* We just add a dummy engine, which 'is' our intern filelisting code from space_file! */
 +	AssetEngineType *aet = MEM_callocN(sizeof(*aet), __func__);
 +
 +	BLI_strncpy(aet->idname, AE_FAKE_ENGINE_ID, sizeof(aet->idname));
 +	BLI_strncpy(aet->name, "None", sizeof(aet->name));
 +
 +	BLI_addhead(&asset_engines, aet);
 +}
 +
 +void BKE_asset_engines_exit(void)
 +{
 +	AssetEngineType *type, *next;
 +
 +	for (type = asset_engines.first; type; type = next) {
 +		next = type->next;
 +
 +		BLI_remlink(&asset_engines, type);
 +
 +		if (type->ext.free) {
 +			type->ext.free(type->ext.data);
 +		}
 +
 +		MEM_freeN(type);
 +	}
 +}
 +
 +AssetEngineType *BKE_asset_engines_find(const char *idname)
 +{
 +	AssetEngineType *type;
 +
 +	type = BLI_findstring(&asset_engines, idname, offsetof(AssetEngineType, idname));
 +
 +	return type;
 +}
 +
 +/* Asset engine instances. */
 +
 +/* Create, Free */
 +
 +AssetEngine *BKE_asset_engine_create(AssetEngineType *type)
 +{
 +	AssetEngine *engine;
 +
 +	BLI_assert(type);
 +
 +	engine = MEM_callocN(sizeof(AssetEngine), __func__);
 +	engine->type = type;
 +	engine->refcount = 1;
 +
 +	return engine;
 +}
 +
 +/** Shalow copy only (i.e. memory is 100% shared, just increases refcount). */
 +AssetEngine *BKE_asset_engine_copy(AssetEngine *engine)
 +{
 +	engine->refcount++;
 +	return engine;
 +}
 +
 +void BKE_asset_engine_free(AssetEngine *engine)
 +{
 +	if (engine->refcount-- == 1) {
 +#ifdef WITH_PYTHON
 +		if (engine->py_instance) {
 +			BPY_DECREF_RNA_INVALIDATE(engine->py_instance);
 +		}
 +#endif
 +
 +		MEM_freeN(engine);
 +	}
 +}
 +
 +
 +/* API helpers. */
 +
 +void BKE_asset_engine_load_pre(AssetEngine *engine, FileDirEntryArr *r_entries)
 +{
 +	if (engine->type->load_pre) {
 +		AssetUUIDList *uuids = MEM_mallocN(sizeof(*uuids), __func__);
 +		FileDirEntry *en;
 +		const int nbr_entries = r_entries->nbr_entries;
 +		int i;
 +
 +		uuids->uuids = MEM_mallocN(sizeof(*uuids->uuids) * nbr_entries, __func__);
 +		uuids->nbr_uuids = nbr_entries;
 +
 +		for (i = 0, en = r_entries-

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list