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)
This commit is contained in:
parent
92b0cbd6da
commit
764168d62a
|
@ -148,6 +148,12 @@ void BKE_image_memorypack(struct Image *ima);
|
||||||
/* prints memory statistics for images */
|
/* prints memory statistics for images */
|
||||||
void BKE_image_print_memlist(void);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
/* quick lookup: supports 1 million frames, thousand passes */
|
/* quick lookup: supports 1 million frames, thousand passes */
|
||||||
#define IMA_MAKE_INDEX(frame, index) ((frame)<<10)+index
|
#define IMA_MAKE_INDEX(frame, index) ((frame)<<10)+index
|
||||||
#define IMA_INDEX_FRAME(index) (index>>10)
|
#define IMA_INDEX_FRAME(index) (index>>10)
|
||||||
|
#define IMA_INDEX_PASS(index) (index & ~1023)
|
||||||
|
|
||||||
/* ******** IMAGE PROCESSING ************* */
|
/* ******** 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 */
|
/* checks if image was already loaded, then returns same image */
|
||||||
/* otherwise creates new. */
|
/* otherwise creates new. */
|
||||||
/* does not load ibuf itself */
|
/* does not load ibuf itself */
|
||||||
|
|
|
@ -2487,6 +2487,12 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
|
||||||
/* ensure new user input gets handled ok */
|
/* ensure new user input gets handled ok */
|
||||||
node->need_exec= 0;
|
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) {
|
for(sock= node->outputs.first; sock; sock= sock->next) {
|
||||||
|
|
||||||
sock->new_sock->ns.data= sock->ns.data;
|
sock->new_sock->ns.data= sock->ns.data;
|
||||||
|
@ -2555,6 +2561,12 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
|
||||||
lnode->preview= NULL;
|
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) {
|
for(lsock= lnode->outputs.first; lsock; lsock= lsock->next) {
|
||||||
if(outsocket_exists(lnode->new_node, lsock->new_sock)) {
|
if(outsocket_exists(lnode->new_node, lsock->new_sock)) {
|
||||||
lsock->new_sock->ns.data= lsock->ns.data;
|
lsock->new_sock->ns.data= lsock->ns.data;
|
||||||
|
|
Loading…
Reference in New Issue