[Bf-blender-cvs] [eeadd19] master: Cleanup: use define for playback frame limiter

Campbell Barton noreply at git.blender.org
Sat May 16 00:35:48 CEST 2015


Commit: eeadd19eb583bd2ddf6716472aafb8ee7fb49df2
Author: Campbell Barton
Date:   Sat May 16 08:34:36 2015 +1000
Branches: master
https://developer.blender.org/rBeeadd19eb583bd2ddf6716472aafb8ee7fb49df2

Cleanup: use define for playback frame limiter

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

M	source/blender/windowmanager/intern/wm_playanim.c

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

diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 66c502c..81e0b0e 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -71,6 +71,12 @@
 
 #include "WM_api.h"  /* only for WM_main_playanim */
 
+/* simple limiter to avoid flooding memory */
+#define USE_FRAME_CACHE_LIMIT
+#ifdef USE_FRAME_CACHE_LIMIT
+#  define PLAY_FRAME_CACHE_MAX 30
+#endif
+
 struct PlayState;
 static void playanim_window_zoom(struct PlayState *ps, const float zoom_offset);
 
@@ -223,11 +229,14 @@ typedef struct PlayAnimPict {
 
 static struct ListBase picsbase = {NULL, NULL};
 /* frames in memory - store them here to for easy deallocation later */
-static struct ListBase inmempicsbase = {NULL, NULL};
-static int added_images = 0;
 static bool fromdisk = false;
 static double ptottime = 0.0, swaptime = 0.04;
 
+#ifdef USE_FRAME_CACHE_LIMIT
+static struct ListBase inmempicsbase = {NULL, NULL};
+static int added_images = 0;
+#endif
+
 static PlayAnimPict *playanim_step(PlayAnimPict *playanim, int step)
 {
 	if (step > 0) {
@@ -1133,16 +1142,20 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
 			}
 
 			if (ibuf) {
+#ifdef USE_FRAME_CACHE_LIMIT
 				LinkData *node;
+#endif
 
 #ifdef USE_IMB_CACHE
 				ps.picture->ibuf = ibuf;
 #endif
+
+#ifdef USE_FRAME_CACHE_LIMIT
 				/* really basic memory conservation scheme. Keep frames in a fifo queue */
 				node = inmempicsbase.last;
 
-				while (added_images > 30) {
-					PlayAnimPict *pic = (PlayAnimPict *)node->data;
+				while (added_images > PLAY_FRAME_CACHE_MAX) {
+					PlayAnimPict *pic = node->data;
 
 					if (pic->ibuf != ibuf) {
 						LinkData *node_tmp;
@@ -1160,6 +1173,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
 
 				BLI_addhead(&inmempicsbase, BLI_genericNodeN(ps.picture));
 				added_images++;
+#endif  /* USE_FRAME_CACHE_LIMIT */
 
 				BLI_strncpy(ibuf->name, ps.picture->name, sizeof(ibuf->name));




More information about the Bf-blender-cvs mailing list