[Bf-blender-cvs] [f37adc43] asset-experiments: Merge branch 'master' into asset-experiments

Bastien Montagne noreply at git.blender.org
Thu Jul 16 19:45:36 CEST 2015


Commit: f37adc43124a5e7f31a4e3aaf0ca60343e83cc36
Author: Bastien Montagne
Date:   Thu Jul 16 19:45:22 2015 +0200
Branches: asset-experiments
https://developer.blender.org/rBf37adc43124a5e7f31a4e3aaf0ca60343e83cc36

Merge branch 'master' into asset-experiments

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



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

diff --cc source/blender/imbuf/intern/thumbs.c
index 8495844,09e7d04..1b14350
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@@ -626,79 -608,11 +630,85 @@@ ImBuf *IMB_thumb_manage(const char *org
  		}
  	}
  
+ 	/* Our imbuf **must** have a valid rect (i.e. 8-bits/channels) data, we rely on this in draw code.
+ 	 * However, in some cases we may end loading 16bits PNGs, which generated float buffers.
+ 	 * This should be taken care of in generation step, but add also a safeguard here! */
+ 	IMB_rect_from_float(img);
+ 	imb_freerectfloatImBuf(img);
+ 
  	return img;
  }
 +
 +/* ***** Threading ***** */
 +/* Thumbnail handling is not really threadsafe in itself.
 + * However, as long as we do not operate on the same file, we shall have no collision.
 + * So idea is to 'lock' a given source file path.
 + */
 +
 +static struct IMBThumbLocks {
 +	GSet *locked_paths;
 +	int lock_counter;
 +	ThreadCondition cond;
 +} thumb_locks = {0};
 +
 +void IMB_thumb_locks_acquire(void) {
 +	BLI_lock_thread(LOCK_IMAGE);
 +
 +	if (thumb_locks.lock_counter == 0) {
 +		BLI_assert(thumb_locks.locked_paths == NULL);
 +		thumb_locks.locked_paths = BLI_gset_str_new(__func__);
 +		BLI_condition_init(&thumb_locks.cond);
 +	}
 +	thumb_locks.lock_counter++;
 +
 +	BLI_assert(thumb_locks.locked_paths != NULL);
 +	BLI_assert(thumb_locks.lock_counter > 0);
 +	BLI_unlock_thread(LOCK_IMAGE);
 +}
 +
 +void IMB_thumb_locks_release(void) {
 +	BLI_lock_thread(LOCK_IMAGE);
 +	BLI_assert((thumb_locks.locked_paths != NULL) && (thumb_locks.lock_counter > 0));
 +
 +	thumb_locks.lock_counter--;
 +	if (thumb_locks.lock_counter == 0) {
 +		BLI_gset_free(thumb_locks.locked_paths, MEM_freeN);
 +		thumb_locks.locked_paths = NULL;
 +		BLI_condition_end(&thumb_locks.cond);
 +	}
 +
 +	BLI_unlock_thread(LOCK_IMAGE);
 +}
 +
 +void IMB_thumb_lock_path(const char *path) {
 +	void *key = BLI_strdup(path);
 +
 +	BLI_lock_thread(LOCK_IMAGE);
 +	BLI_assert((thumb_locks.locked_paths != NULL) && (thumb_locks.lock_counter > 0));
 +
 +	if (thumb_locks.locked_paths) {
 +		while (!BLI_gset_add(thumb_locks.locked_paths, key)) {
 +			BLI_condition_wait_global_mutex(&thumb_locks.cond, LOCK_IMAGE);
 +		}
 +//		printf("%s: locked %s\n", __func__, path);
 +	}
 +
 +	BLI_unlock_thread(LOCK_IMAGE);
 +}
 +
 +void IMB_thumb_unlock_path(const char *path) {
 +	const void *key = path;
 +
 +	BLI_lock_thread(LOCK_IMAGE);
 +	BLI_assert((thumb_locks.locked_paths != NULL) && (thumb_locks.lock_counter > 0));
 +
 +	if (thumb_locks.locked_paths) {
 +		if (!BLI_gset_remove(thumb_locks.locked_paths, key, MEM_freeN)) {
 +			BLI_assert(0);
 +		}
 +		BLI_condition_notify_all(&thumb_locks.cond);
 +//		printf("%s: UN-locked %s\n", __func__, path);
 +	}
 +
 +	BLI_unlock_thread(LOCK_IMAGE);
 +}




More information about the Bf-blender-cvs mailing list