diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-27 22:32:44 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-27 22:32:44 +0300 |
commit | 764168d62a22659ac9947835a3308f7bc66fc1d5 (patch) | |
tree | 4a65fa9c4a2070d95092acc73658a4e131d7549c | |
parent | 92b0cbd6da1809efaaa28fe9e7271464631e8275 (diff) |
2.5
Added support in threaded compositor to copy the viewer
image safely away, prevents crashing especially for
people using blender -E or redrawing viewer while it
composites.
(Note; reloading images in nodes, render result, and
probably other cases have to be checked still)
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 28 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 12 |
3 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index d1bcd63c936..816baa20467 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -148,6 +148,12 @@ void BKE_image_memorypack(struct Image *ima); /* prints memory statistics for images */ void BKE_image_print_memlist(void); +/* empty image block, of similar type and filename */ +struct Image *BKE_image_copy(struct Image *ima); + +/* merge source into dest, and free source */ +void BKE_image_merge(struct Image *dest, struct Image *source); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 1b851444e04..ee631a89083 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -91,6 +91,7 @@ /* quick lookup: supports 1 million frames, thousand passes */ #define IMA_MAKE_INDEX(frame, index) ((frame)<<10)+index #define IMA_INDEX_FRAME(index) (index>>10) +#define IMA_INDEX_PASS(index) (index & ~1023) /* ******** IMAGE PROCESSING ************* */ @@ -332,6 +333,33 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) } } +/* empty image block, of similar type and filename */ +Image *BKE_image_copy(Image *ima) +{ + Image *new= image_alloc(ima->id.name+2, ima->source, ima->type); + + BLI_strncpy(new->name, ima->name, sizeof(ima->name)); + + new->gen_x= ima->gen_x; + new->gen_y= ima->gen_y; + new->gen_type= ima->gen_type; + + return new; +} + +void BKE_image_merge(Image *dest, Image *source) +{ + ImBuf *ibuf; + + while((ibuf= source->ibufs.first)) { + BLI_remlink(&source->ibufs, ibuf); + image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index)); + } + + free_libblock(&G.main->image, source); +} + + /* checks if image was already loaded, then returns same image */ /* otherwise creates new. */ /* does not load ibuf itself */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index f6407e9416c..d41dda4c81e 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2487,6 +2487,12 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) /* ensure new user input gets handled ok */ node->need_exec= 0; + if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if(node->id && (node->flag & NODE_DO_OUTPUT)) { + node->new_node->id= (ID *)BKE_image_copy((Image *)node->id); + } + } + for(sock= node->outputs.first; sock; sock= sock->next) { sock->new_sock->ns.data= sock->ns.data; @@ -2555,6 +2561,12 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree) lnode->preview= NULL; } + if(ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if(lnode->id && (lnode->flag & NODE_DO_OUTPUT)) { + BKE_image_merge((Image *)lnode->new_node->id, (Image *)lnode->id); + } + } + for(lsock= lnode->outputs.first; lsock; lsock= lsock->next) { if(outsocket_exists(lnode->new_node, lsock->new_sock)) { lsock->new_sock->ns.data= lsock->ns.data; |