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

Bastien Montagne noreply at git.blender.org
Thu Apr 2 17:35:01 CEST 2015


Commit: e70139964d65d5908f61ec7350c8370e42ba995a
Author: Bastien Montagne
Date:   Thu Apr 2 15:20:52 2015 +0200
Branches: asset-engine
https://developer.blender.org/rBe70139964d65d5908f61ec7350c8370e42ba995a

Merge branch 'asset-experiments' into asset-engine

Conflicts:
	source/blender/editors/space_file/filelist.c
	source/blender/editors/space_file/filelist.h
	source/blender/makesrna/intern/rna_internal.h

Notes:
* asset-experiments branch still needs some work (e.g. entires selection is to be reworked too),
  but was more than time to do a first merge...
* This is raw merge, code is hence broken and needs more fixes to take into account new changes!

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



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

diff --cc source/blender/editors/space_file/filelist.c
index bc1b996,1eea1c4..dc40989
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@@ -930,6 -967,215 +972,144 @@@ static void filelist_checkdir_main(stru
  	filelist_checkdir_lib(filelist, r_dir);
  }
  
 -static void filelist_entry_free(FileDirEntry *entry)
 -{
 -	if (entry->name) {
 -		MEM_freeN(entry->name);
 -	}
 -	if (entry->description) {
 -		MEM_freeN(entry->description);
 -	}
 -	if (entry->relpath) {
 -		MEM_freeN(entry->relpath);
 -	}
 -	if (entry->image) {
 -		IMB_freeImBuf(entry->image);
 -	}
 -	/* For now, consider FileDirEntryRevision::poin as not owned here, so no need to do anything about it */
 -
 -	if (!BLI_listbase_is_empty(&entry->variants)) {
 -		FileDirEntryVariant *var;
 -
 -		for (var = entry->variants.first; var; var = var->next) {
 -			if (var->name) {
 -				MEM_freeN(var->name);
 -			}
 -			if (var->description) {
 -				MEM_freeN(var->description);
 -			}
 -
 -			if (!BLI_listbase_is_empty(&var->revisions)) {
 -				FileDirEntryRevision *rev;
 -
 -				for (rev = var->revisions.first; rev; rev = rev->next) {
 -					if (rev->comment) {
 -						MEM_freeN(rev->comment);
 -					}
 -				}
 -
 -				BLI_freelistN(&var->revisions);
 -			}
 -		}
 -
 -		/* TODO: tags! */
 -
 -		BLI_freelistN(&entry->variants);
 -	}
 -	else if (entry->entry){
 -		MEM_freeN(entry->entry);
 -	}
 -}
 -
 -#if 0  /* UNUSED */
 -static void filelist_entry_clear(FileDirEntry *entry)
 -{
 -	filelist_entry_free(entry);
 -	memset(entry, 0, sizeof(*entry));
 -}
 -#endif
 -
 -static void filelist_direntryarr_free(FileDirEntryArr *array)
 -{
 -	FileDirEntry *entry;
 -
 -	for (entry = array->entries.first; entry; entry = entry->next) {
 -		filelist_entry_free(entry);
 -	}
 -	BLI_freelistN(&array->entries);
 -	array->nbr_entries = 0;
 -	array->nbr_entries_filtered = -1;
 -	array->entry_idx_start = -1;
 -	array->entry_idx_end = -1;
 -}
 -
+ static void filelist_intern_free(FileListIntern *filelist_intern)
+ {
+ 	FileDirEntry *entry;
+ 
+ 	for (entry = filelist_intern->entries.first; entry; entry = entry->next) {
+ 		filelist_entry_free(entry);
+ 	}
+ 	BLI_freelistN(&filelist_intern->entries);
+ 
+ 	MEM_SAFE_FREE(filelist_intern->filtered);
+ }
+ 
+ static FileDirEntry *filelist_intern_create_entry(FileList *filelist, const int index)
+ {
+ 	/* Stupid code for now, later we will actually generate a new entry (from mempool)... */
+ 	return filelist->filelist_intern.filtered[index];
+ }
+ 
+ static void filelist_intern_release_entry(FileList *UNUSED(filelist), FileDirEntry *UNUSED(old))
+ {
+ 	/* We do nothing here actually, later we'll give back the mem to the mempool... */
+ }
+ 
+ static void filelist_cache_previewf(TaskPool *pool, void *taskdata, int threadid)
+ {
+ 	FileListEntryCache *cache = taskdata;
+ 	FileListEntryPreview *preview;
+ 
+ 	printf("%s: Start (%d)...\n", __func__, threadid);
+ 
+ 	/* Note we wait on queue here. */
+ 	while (!BLI_task_pool_canceled(pool) && (preview = BLI_thread_queue_pop(cache->previews_todo))) {
+ //		printf("%s: %d - %s - %p\n", __func__, preview->index, preview->path, preview->img);
+ 		if (preview->flags & FILE_TYPE_IMAGE) {
+ 			preview->img = IMB_thumb_manage(preview->path, THB_NORMAL, THB_SOURCE_IMAGE);
+ 		}
+ 		else if (preview->flags & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
+ 			preview->img = IMB_thumb_manage(preview->path, THB_NORMAL, THB_SOURCE_BLEND);
+ 		}
+ 		else if (preview->flags & FILE_TYPE_MOVIE) {
+ 			preview->img = IMB_thumb_manage(preview->path, THB_NORMAL, THB_SOURCE_MOVIE);
+ 			if (!preview->img) {
+ 				/* remember that file can't be loaded via IMB_open_anim */
+ 				preview->flags &= ~FILE_TYPE_MOVIE;
+ 				preview->flags |= FILE_TYPE_MOVIE_ICON;
+ 			}
+ 		}
+ 		BLI_thread_queue_push(cache->previews_done, preview);
+ 	}
+ 
+ 	printf("%s: End (%d)...\n", __func__, threadid);
+ }
+ 
+ static void filelist_cache_previews_clear(FileListEntryCache *cache)
+ {
+ 	FileListEntryPreview *preview;
+ 
+ 	if (cache->previews_pool) {
+ 		while ((preview = BLI_thread_queue_pop_timeout(cache->previews_todo, 0))) {
+ //			printf("%s: TODO %d - %s - %p\n", __func__, preview->index, preview->path, preview->img);
+ 			MEM_freeN(preview);
+ 		}
+ 		while ((preview = BLI_thread_queue_pop_timeout(cache->previews_done, 0))) {
+ //			printf("%s: DONE %d - %s - %p\n", __func__, preview->index, preview->path, preview->img);
+ 			if (preview->img) {
+ 				IMB_freeImBuf(preview->img);
+ 			}
+ 			MEM_freeN(preview);
+ 		}
+ 	}
+ }
+ 
+ static void filelist_cache_previews_free(FileListEntryCache *cache)
+ {
+ 	if (cache->previews_pool) {
+ 		BLI_thread_queue_nowait(cache->previews_todo);
+ 		BLI_thread_queue_nowait(cache->previews_done);
+ 		BLI_task_pool_cancel(cache->previews_pool);
+ 
+ 		filelist_cache_previews_clear(cache);
+ 
+ 		BLI_thread_queue_free(cache->previews_done);
+ 		BLI_thread_queue_free(cache->previews_todo);
+ 		BLI_task_pool_free(cache->previews_pool);
+ 		cache->previews_pool = NULL;
+ 		cache->previews_todo = NULL;
+ 		cache->previews_done = NULL;
+ 	}
+ }
+ 
+ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry, const int index)
+ {
+ 	FileListEntryCache *cache = &filelist->filelist_cache;
+ 
+ 	if (!entry->image &&
+ 		(entry->typeflag & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)))
+ 	{
+ 		FileListEntryPreview *preview = MEM_mallocN(sizeof(*preview), __func__);
+ 		BLI_join_dirfile(preview->path, sizeof(preview->path), filelist->filelist.root, entry->relpath);
+ 		preview->index = index;
+ 		preview->flags = entry->typeflag;
+ 		preview->img = NULL;
+ //		printf("%s: %d - %s - %p\n", __func__, preview->index, preview->path, preview->img);
+ 		BLI_thread_queue_push(cache->previews_todo, preview);
+ 	}
+ }
+ 
+ static void filelist_cache_init(FileListEntryCache *cache)
+ {
+ 	cache->block_cursor = cache->block_start_index = cache->block_end_index = 0;
+ 
+ 	cache->misc_entries = BLI_ghash_ptr_new_ex(__func__, FILELIST_ENTRYCACHESIZE);
+ 	cache->misc_cursor = 0;
+ }
+ 
+ static void filelist_cache_free(FileListEntryCache *cache)
+ {
+ 	filelist_cache_previews_free(cache);
+ 
+ 	/* Note we nearly have nothing to do here, entries are just 'borrowed', not owned by cache... */
+ 	if (cache->misc_entries) {
+ 		BLI_ghash_free(cache->misc_entries, NULL, NULL);
+ 		cache->misc_entries = NULL;
+ 	}
+ }
+ 
+ static void filelist_cache_clear(FileListEntryCache *cache)
+ {
+ 	filelist_cache_previews_free(cache);
+ 
+ 	/* Note we nearly have nothing to do here, entries are just 'borrowed', not owned by cache... */
+ 	cache->block_cursor = cache->block_start_index = cache->block_end_index = 0;
+ 
+ 	if (cache->misc_entries) {
+ 		BLI_ghash_clear_ex(cache->misc_entries, NULL, NULL, FILELIST_ENTRYCACHESIZE);
+ 	}
+ }
+ 
  FileList *filelist_new(short type)
  {
  	FileList *p = MEM_callocN(sizeof(*p), __func__);
@@@ -960,10 -1208,13 +1142,13 @@@ void filelist_clear(struct FileList *fi
  		return;
  	}
  
-     MEM_SAFE_FREE(filelist->filtered);
-     filelist->numfiltered = 0;
+ 	filelist_filter_clear(filelist);
  
 -	filelist_direntryarr_free(&filelist->filelist);
 +	BKE_filedir_entryarr_clear(&filelist->filelist);
+ 
+ 	filelist_cache_clear(&filelist->filelist_cache);
+ 
+ 	filelist_intern_free(&filelist->filelist_intern);
  }
  
  void filelist_free(struct FileList *filelist)
@@@ -974,12 -1225,8 +1159,13 @@@
  	}
  	
  	filelist_clear(filelist);
+ 	filelist_cache_free(&filelist->filelist_cache);  /* XXX TODO stupid! */
  
 +	if (filelist->ae) {
 +		BKE_asset_engine_free(filelist->ae);
 +		filelist->ae = NULL;
 +	}
 +
  	memset(&filelist->filter_data, 0, sizeof(filelist->filter_data));
  
  	filelist->need_sorting = false;
@@@ -1838,112 -2308,59 +2313,108 @@@ static void filelist_readjob_startjob(v
  {
  	FileListReadJob *flrj = flrjv;
  
 -	printf("START filelist reading (%d files, main thread: %d)\n",
 -	       flrj->filelist->filelist.nbr_entries, BLI_thread_is_main());
 +	if (flrj->filelist->ae) {
 +		flrj->progress = progress;
 +		flrj->stop = stop;
 +		/* When using AE engine, worker thread here is just sleeping! */
 +		while (flrj->filelist->filelist_pending && !*stop) {
 +			PIL_sleep_ms(10);
 +			*do_update = true;
 +		}
 +	}
 +	else {
- 		printf("START filelist reading (%d files, main thread: %d)\n",
- 			   flrj->filelist->filelist.nbr_entries, BLI_thread_is_main());
++	    printf("START filelist reading (%d files, main thread: %d)\n",
++	           flrj->filelist->filelist.nbr_entries, BLI_thread_is_main());
  
 -	BLI_mutex_lock(&flrj->lock);
 +		BLI_mutex_lock(&flrj->lock);
  
 -	BLI_assert((flrj->tmp_filelist == NULL) && flrj->filelist);
 +		BLI_assert((flrj->tmp_filelist == NULL) && flrj->filelist);
  
 -	flrj->tmp_filelist = MEM_dupallocN(flrj->filelist);
 +		flrj->tmp_filelist = MEM_dupallocN(flrj->filelist);
  
 -	BLI_mutex_unlock(&flrj->lock);
 +		BLI_mutex_unlock(&flrj->lock);
  
 -	BLI_listbase_clear(&flrj->tmp_filelist->filelist.entries);
 -	flrj->tmp_filelist->filelist.nbr_entries = 0;
 -	flrj->tmp_filelist->filelist_intern.filtered = NULL;
 -	BLI_listbase_clear(&flrj->tmp_filelist->filelist_intern.entries);
 -	flrj->tmp_filelist->libfiledata = NULL;
 -	memset(&flrj->tmp_filelist->filelist_cache, 0, sizeof(FileListEntryCache));
 +		BLI_listbase_clear(&flrj->tmp_filelist->filelist.entries);
 +		flrj->tmp_filelist->filelist.nbr_entries = 0;
- 		flrj->tmp_filelist->filtered = NULL;
- 		flrj->tmp_filelist->numfiltered = 0;
++		flrj->tmp_filelist->filelist_intern.filtered = NULL;
++		BLI_listbase_clear(&flrj->tmp_filelist->filelist_intern.entries);
 +		flrj->tmp_filelist->libfiledata = NULL;
++		memset(&flrj->tmp_filelist->filelist_cache, 0, sizeof(FileListEntryCache));
  
 -	flrj->tmp_filelist->read_jobf(flrj->tmp_filelist, flrj->main_name, stop, do_update, progress, &flrj->lock);
 +		flrj->tmp_filelist->read_jobf(flrj->tmp_filelist, flrj->main_name, stop, do_update, progress, &flrj->lock);
- 
- 		printf("END filelist reading (%d files, STOPPED: %d, DO_UPDATE: %d)\n",
- 			   flrj->filelist->filelist.nbr_entries, *stop, *do_update);
- 	}
  }
  
  static void filelist_readjob_update(void *flrjv)
  {
  	FileListReadJ

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list