Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-05-22 05:58:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-05-22 05:58:07 +0400
commit049b6cfa6ddcc44d8001804922f041367f3051c6 (patch)
treec57f4aec1f85b037009036c22109b2a3330acdb3 /source/blender/blenkernel
parent90db85a26301216d11c2adc956046b276ce8ef5f (diff)
Fix for image garbage collection failing to run for render-only views
Check for freeing old images was running per-object, move this to viewport drawing.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_image.h3
-rw-r--r--source/blender/blenkernel/intern/image.c64
2 files changed, 17 insertions, 50 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index db052f5d879..f02a5d09d2f 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -52,8 +52,9 @@ struct Main;
void BKE_images_init(void);
void BKE_images_exit(void);
+void BLI_image_free_buffers(struct Image *image);
/* call from library */
-void BKE_image_free(struct Image *me);
+void BKE_image_free(struct Image *image);
void BKE_imbuf_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf);
void BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 440320e98fe..2d5b6b0cdc4 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -256,7 +256,11 @@ static void image_free_cahced_frames(Image *image)
}
}
-static void image_free_buffers(Image *ima)
+/**
+ * Simply free the image data from memory,
+ * on display the image can load again (except for render buffers).
+ */
+void BLI_image_free_buffers(Image *ima)
{
image_free_cahced_frames(ima);
@@ -278,7 +282,7 @@ void BKE_image_free(Image *ima)
{
int a;
- image_free_buffers(ima);
+ BLI_image_free_buffers(ima);
if (ima->packedfile) {
freePackedFile(ima->packedfile);
ima->packedfile = NULL;
@@ -835,8 +839,7 @@ void BKE_image_memorypack(Image *ima)
void BKE_image_tag_time(Image *ima)
{
- if (ima)
- ima->lastused = (int)PIL_check_seconds_timer();
+ ima->lastused = (int)PIL_check_seconds_timer();
}
#if 0
@@ -854,43 +857,6 @@ static void tag_all_images_time()
}
#endif
-void free_old_images(void)
-{
- Image *ima;
- static int lasttime = 0;
- int ctime = (int)PIL_check_seconds_timer();
-
- /*
- * Run garbage collector once for every collecting period of time
- * if textimeout is 0, that's the option to NOT run the collector
- */
- if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime)
- return;
-
- /* of course not! */
- if (G.is_rendering)
- return;
-
- lasttime = ctime;
-
- ima = G.main->image.first;
- while (ima) {
- if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) {
- /* If it's in GL memory, deallocate and set time tag to current time
- * This gives textures a "second chance" to be used before dying. */
- if (ima->bindcode || ima->repbind) {
- GPU_free_image(ima);
- ima->lastused = ctime;
- }
- /* Otherwise, just kill the buffers */
- else {
- image_free_buffers(ima);
- }
- }
- ima = ima->id.next;
- }
-}
-
static uintptr_t image_mem_size(Image *image)
{
uintptr_t size = 0;
@@ -2251,7 +2217,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
switch (signal) {
case IMA_SIGNAL_FREE:
- image_free_buffers(ima);
+ BLI_image_free_buffers(ima);
if (iuser)
iuser->ok = 1;
break;
@@ -2283,7 +2249,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
#if 0
/* force reload on first use, but not for multilayer, that makes nodes and buttons in ui drawing fail */
if (ima->type != IMA_TYPE_MULTILAYER)
- image_free_buffers(ima);
+ BLI_image_free_buffers(ima);
#else
/* image buffers for non-sequence multilayer will share buffers with RenderResult,
* however sequence multilayer will own buffers. Such logic makes switching from
@@ -2292,7 +2258,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
* are nicely detecting anyway, but freeing buffers always here makes multilayer
* sequences behave stable
*/
- image_free_buffers(ima);
+ BLI_image_free_buffers(ima);
#endif
ima->ok = 1;
@@ -2311,14 +2277,14 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
if (pf) {
freePackedFile(ima->packedfile);
ima->packedfile = pf;
- image_free_buffers(ima);
+ BLI_image_free_buffers(ima);
}
else {
printf("ERROR: Image not available. Keeping packed image\n");
}
}
else
- image_free_buffers(ima);
+ BLI_image_free_buffers(ima);
if (iuser)
iuser->ok = 1;
@@ -2336,7 +2302,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
}
break;
case IMA_SIGNAL_COLORMANAGE:
- image_free_buffers(ima);
+ BLI_image_free_buffers(ima);
ima->ok = 1;
@@ -2474,7 +2440,7 @@ static void image_initialize_after_load(Image *ima, ImBuf *ibuf)
else de_interlace_ng(ibuf);
}
/* timer */
- ima->lastused = clock() / CLOCKS_PER_SEC;
+ BKE_image_tag_time(ima);
ima->ok = IMA_OK_LOADED;
@@ -2656,7 +2622,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
int assign = 0, flag;
/* always ensure clean ima */
- image_free_buffers(ima);
+ BLI_image_free_buffers(ima);
/* is there a PackedFile with this image ? */
if (ima->packedfile) {