[Bf-blender-cvs] [4696bce] asset-engine: Merge branch 'asset-experiments' into asset-engine
Bastien Montagne
noreply at git.blender.org
Sat Apr 4 15:14:57 CEST 2015
Commit: 4696bce25735e9cfa1bd4112074dcc3d958bd479
Author: Bastien Montagne
Date: Sat Apr 4 13:15:17 2015 +0200
Branches: asset-engine
https://developer.blender.org/rB4696bce25735e9cfa1bd4112074dcc3d958bd479
Merge branch 'asset-experiments' into asset-engine
Conflicts:
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/filelist.h
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_asset.h
index 5714998,0000000..ea98001
mode 100644,000000..100644
--- a/source/blender/blenkernel/BKE_asset.h
+++ b/source/blender/blenkernel/BKE_asset.h
@@@ -1,186 -1,0 +1,184 @@@
+/*
+ * ***** 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 IDProperty;
+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.
+ */
+
+/* List everything available at given root path - only returns numbers of entries! */
+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. ***** */
+
+/* Perform sorting and/or filtering on engines' side.
+ * Note that engine is assumed to feature its own sorting/filtering settings!
+ * Number of available filtered entries is to be set in entries_r.
+ */
+typedef bool (*ae_sort_filter)(struct AssetEngine *engine, const bool sort, const bool filter, struct FileDirEntryArr *entries_r);
+
+/* Return specified block of entries in entries_r. */
+typedef bool (*ae_entries_block_get)(struct AssetEngine *engine, const int start_index, const int end_index,
+ struct FileDirEntryArr *entries_r);
+
+/* '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_sort_filter sort_filter;
+ ae_entries_block_get entries_block_get;
+ 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;
+
+ /* Custom sub-classes properties. */
+ IDProperty *properties;
+
+ 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 48d0a02,0000000..730ad47
mode 100644,000000..100644
--- a/source/blender/blenkernel/intern/asset.c
+++ b/source/blender/blenkernel/intern/asset.c
@@@ -1,343 -1,0 +1,330 @@@
+/*
+ * ***** 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_idprop.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).
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list