From fd511eb984a23b63b373e171666667c8213579c0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Oct 2009 22:05:30 +0000 Subject: Node Bugfixes: * Compo node backdrop works again. * Compo node previews and backdrop now get correct color management float to byte conversion. * Compo nodes got unecessarily recalculated while moving nodes. * Fix compo node viewer nodes not getting activated correctly. * Main compo node preview render computations are now outside of mutex lock, so better for multithreading. * Tex node outputs did not work in some files loaded from 2.4. * Change RNA updates to take into account groups that may be shared between multiple node trees. --- source/blender/nodes/intern/CMP_nodes/CMP_blur.c | 2 +- .../nodes/intern/CMP_nodes/CMP_channelMatte.c | 2 +- .../nodes/intern/CMP_nodes/CMP_chromaMatte.c | 2 +- .../nodes/intern/CMP_nodes/CMP_colorMatte.c | 2 +- .../blender/nodes/intern/CMP_nodes/CMP_composite.c | 4 +-- .../blender/nodes/intern/CMP_nodes/CMP_diffMatte.c | 2 +- .../nodes/intern/CMP_nodes/CMP_distanceMatte.c | 2 +- source/blender/nodes/intern/CMP_nodes/CMP_filter.c | 2 +- source/blender/nodes/intern/CMP_nodes/CMP_image.c | 4 +-- source/blender/nodes/intern/CMP_nodes/CMP_levels.c | 2 +- .../nodes/intern/CMP_nodes/CMP_lummaMatte.c | 2 +- source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c | 2 +- .../nodes/intern/CMP_nodes/CMP_outputFile.c | 2 +- .../nodes/intern/CMP_nodes/CMP_splitViewer.c | 2 +- .../blender/nodes/intern/CMP_nodes/CMP_texture.c | 2 +- source/blender/nodes/intern/CMP_nodes/CMP_viewer.c | 4 +-- source/blender/nodes/intern/CMP_util.c | 39 +++++++++++++++------- source/blender/nodes/intern/CMP_util.h | 2 +- source/blender/nodes/intern/TEX_nodes/TEX_output.c | 29 ++++++++-------- source/blender/nodes/intern/TEX_util.c | 4 --- 20 files changed, 63 insertions(+), 49 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_blur.c b/source/blender/nodes/intern/CMP_nodes/CMP_blur.c index a96f3489978..68ccb04581b 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_blur.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_blur.c @@ -671,7 +671,7 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN free_compbuf(img); } - generate_preview(node, out[0]->data); + generate_preview(data, node, out[0]->data); } static void node_composit_init_blur(bNode* node) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c index b0a2531ac1f..ac940d76ed6 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c @@ -166,7 +166,7 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack break; } - generate_preview(node, outbuf); + generate_preview(data, node, outbuf); out[0]->data=outbuf; if(out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c index 28b81fe9f47..c8cbe4538c5 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c @@ -154,7 +154,7 @@ static void node_composit_exec_chroma_matte(void *data, bNode *node, bNodeStack if(out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(chromabuf, CHAN_A); - generate_preview(node, chromabuf); + generate_preview(data, node, chromabuf); if(cbuf!=in[0]->data) free_compbuf(cbuf); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c index 470d04d9dcc..e1fa4d78b96 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c @@ -95,7 +95,7 @@ static void node_composit_exec_color_matte(void *data, bNode *node, bNodeStack * if(out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(colorbuf, CHAN_A); - generate_preview(node, colorbuf); + generate_preview(data, node, colorbuf); if(cbuf!=in[0]->data) free_compbuf(cbuf); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_composite.c b/source/blender/nodes/intern/CMP_nodes/CMP_composite.c index 800cccc2bfc..d117a3cb235 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_composite.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_composite.c @@ -73,7 +73,7 @@ static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **i zbuf->malloc= 0; free_compbuf(zbuf); } - generate_preview(node, outbuf); + generate_preview(data, node, outbuf); /* we give outbuf to rr... */ rr->rectf= outbuf->rect; @@ -91,7 +91,7 @@ static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **i } } if(in[0]->data) - generate_preview(node, in[0]->data); + generate_preview(data, node, in[0]->data); } bNodeType cmp_node_composite= { diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_diffMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_diffMatte.c index 68a1bcd5471..d36d586211b 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_diffMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_diffMatte.c @@ -108,7 +108,7 @@ static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack ** out[0]->data=outbuf; if(out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A); - generate_preview(node, outbuf); + generate_preview(data, node, outbuf); if(imbuf1!=in[0]->data) free_compbuf(imbuf1); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_distanceMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_distanceMatte.c index f24aedd6661..27b1ac1e181 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_distanceMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_distanceMatte.c @@ -111,7 +111,7 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac out[0]->data=workbuf; if(out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(workbuf, CHAN_A); - generate_preview(node, workbuf); + generate_preview(data, node, workbuf); if(inbuf!=in[0]->data) free_compbuf(inbuf); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_filter.c b/source/blender/nodes/intern/CMP_nodes/CMP_filter.c index 2c3b78e13a3..8300c791698 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_filter.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_filter.c @@ -212,7 +212,7 @@ static void node_composit_exec_filter(void *data, bNode *node, bNodeStack **in, out[0]->data= stackbuf; - generate_preview(node, out[0]->data); + generate_preview(data, node, out[0]->data); } } diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_image.c b/source/blender/nodes/intern/CMP_nodes/CMP_image.c index 00be52a81aa..5e22f5cf016 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_image.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_image.c @@ -254,7 +254,7 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **in, b if(out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(stackbuf, CHAN_A); - generate_preview(node, stackbuf); + generate_preview(data, node, stackbuf); } } }; @@ -386,7 +386,7 @@ static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **in, node_composit_rlayers_out(rd, rl, out, rr->rectx, rr->recty); - generate_preview(node, stackbuf); + generate_preview(data, node, stackbuf); } } } diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_levels.c b/source/blender/nodes/intern/CMP_nodes/CMP_levels.c index 6056e9a28f4..f0e314793ed 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_levels.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_levels.c @@ -305,7 +305,7 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * if(out[1]->hasoutput) out[1]->vec[0]= std_dev; - generate_preview(node, histogram); + generate_preview(data, node, histogram); if(cbuf!=in[0]->data) free_compbuf(cbuf); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c index 350def76736..3e284cd5ed1 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c @@ -87,7 +87,7 @@ static void node_composit_exec_luma_matte(void *data, bNode *node, bNodeStack ** composit1_pixel_processor(node, outbuf, outbuf, in[1]->vec, do_luma_matte, CB_RGBA); composit1_pixel_processor(node, outbuf, outbuf, in[1]->vec, do_yuva_to_rgba, CB_RGBA); - generate_preview(node, outbuf); + generate_preview(data, node, outbuf); out[0]->data=outbuf; if (out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c b/source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c index ca6de027b1d..25bb82b4a9f 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c @@ -74,7 +74,7 @@ static void node_composit_exec_mix_rgb(void *data, bNode *node, bNodeStack **in, out[0]->data= stackbuf; - generate_preview(node, out[0]->data); + generate_preview(data, node, out[0]->data); } } diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c index 8c63c348b57..e63e5802507 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c @@ -71,7 +71,7 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack * IMB_freeImBuf(ibuf); - generate_preview(node, cbuf); + generate_preview(data, node, cbuf); if(in[0]->data != cbuf) free_compbuf(cbuf); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_splitViewer.c b/source/blender/nodes/intern/CMP_nodes/CMP_splitViewer.c index 8ce5a7caa04..04383f478e9 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_splitViewer.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_splitViewer.c @@ -121,7 +121,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * composit3_pixel_processor(node, cbuf, buf1, in[0]->vec, buf2, in[1]->vec, mask, NULL, do_copy_split_rgba, CB_RGBA, CB_RGBA, CB_VAL); - generate_preview(node, cbuf); + generate_preview(data, node, cbuf); free_compbuf(cbuf); free_compbuf(mask); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_texture.c b/source/blender/nodes/intern/CMP_nodes/CMP_texture.c index b4d04076032..26e734579e3 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_texture.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_texture.c @@ -105,7 +105,7 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, VECCOPY(prevbuf->procedural_size, in[1]->vec); prevbuf->procedural_type= CB_RGBA; composit1_pixel_processor(node, prevbuf, prevbuf, out[0]->vec, do_copy_rgba, CB_RGBA); - generate_preview(node, prevbuf); + generate_preview(data, node, prevbuf); free_compbuf(prevbuf); if(out[0]->hasoutput) { diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_viewer.c b/source/blender/nodes/intern/CMP_nodes/CMP_viewer.c index c9e95e768c1..d0dcc5c6973 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_viewer.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_viewer.c @@ -106,12 +106,12 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, free_compbuf(zbuf); } - generate_preview(node, cbuf); + generate_preview(data, node, cbuf); free_compbuf(cbuf); } else if(in[0]->data) { - generate_preview(node, in[0]->data); + generate_preview(data, node, in[0]->data); } } diff --git a/source/blender/nodes/intern/CMP_util.c b/source/blender/nodes/intern/CMP_util.c index 075eefb4368..175a0a54371 100644 --- a/source/blender/nodes/intern/CMP_util.c +++ b/source/blender/nodes/intern/CMP_util.c @@ -604,9 +604,13 @@ static CompBuf *generate_procedural_preview(CompBuf *cbuf, int newx, int newy) return outbuf; } -void generate_preview(bNode *node, CompBuf *stackbuf) +void generate_preview(void *data, bNode *node, CompBuf *stackbuf) { + RenderData *rd= data; bNodePreview *preview= node->preview; + int xsize, ysize; + int color_manage= rd->color_mgt_flag & R_COLOR_MANAGEMENT; + unsigned char *rect; if(preview && stackbuf) { CompBuf *cbuf, *stackbuf_use; @@ -615,30 +619,41 @@ void generate_preview(bNode *node, CompBuf *stackbuf) stackbuf_use= typecheck_compbuf(stackbuf, CB_RGBA); - BLI_lock_thread(LOCK_PREVIEW); - if(stackbuf->x > stackbuf->y) { - preview->xsize= 140; - preview->ysize= (140*stackbuf->y)/stackbuf->x; + xsize= 140; + ysize= (140*stackbuf->y)/stackbuf->x; } else { - preview->ysize= 140; - preview->xsize= (140*stackbuf->x)/stackbuf->y; + ysize= 140; + xsize= (140*stackbuf->x)/stackbuf->y; } if(stackbuf_use->rect_procedural) - cbuf= generate_procedural_preview(stackbuf_use, preview->xsize, preview->ysize); + cbuf= generate_procedural_preview(stackbuf_use, xsize, ysize); else - cbuf= scalefast_compbuf(stackbuf_use, preview->xsize, preview->ysize); + cbuf= scalefast_compbuf(stackbuf_use, xsize, ysize); - /* this ensures free-compbuf does the right stuff */ - SWAP(float *, cbuf->rect, node->preview->rect); + /* convert to byte for preview */ + rect= MEM_callocN(sizeof(unsigned char)*4*xsize*ysize, "bNodePreview.rect"); - BLI_unlock_thread(LOCK_PREVIEW); + if(color_manage) + floatbuf_to_srgb_byte(cbuf->rect, rect, 0, xsize, 0, ysize, xsize); + else + floatbuf_to_byte(cbuf->rect, rect, 0, xsize, 0, ysize, xsize); free_compbuf(cbuf); if(stackbuf_use!=stackbuf) free_compbuf(stackbuf_use); + + BLI_lock_thread(LOCK_PREVIEW); + + if(preview->rect) + MEM_freeN(preview->rect); + preview->xsize= xsize; + preview->ysize= ysize; + preview->rect= rect; + + BLI_unlock_thread(LOCK_PREVIEW); } } diff --git a/source/blender/nodes/intern/CMP_util.h b/source/blender/nodes/intern/CMP_util.h index 2a2dc97ed73..bb08a448bf4 100644 --- a/source/blender/nodes/intern/CMP_util.h +++ b/source/blender/nodes/intern/CMP_util.h @@ -141,7 +141,7 @@ void composit4_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo int src1_type, int fac1_type, int src2_type, int fac2_type); CompBuf *valbuf_from_rgbabuf(CompBuf *cbuf, int channel); -void generate_preview(bNode *node, CompBuf *stackbuf); +void generate_preview(void *data, bNode *node, CompBuf *stackbuf); void do_copy_rgba(bNode *node, float *out, float *in); void do_copy_rgb(bNode *node, float *out, float *in); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c index 140c31a7986..580b4cde8bf 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c @@ -93,20 +93,23 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); tex_do_preview(node, params.coord, &target->tr); } - else if(cdata->which_output == node->custom1) { - TexParams params; - params_from_cdata(¶ms, cdata); + else { + /* 0 means don't care, so just use first */ + if(cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) { + TexParams params; + params_from_cdata(¶ms, cdata); + + osa(tex_input_rgba, &target->tr, in[0], ¶ms, cdata->thread); - osa(tex_input_rgba, &target->tr, in[0], ¶ms, cdata->thread); - - target->tin = (target->tr + target->tg + target->tb) / 3.0f; - target->talpha = 1.0f; - - if(target->nor) { - if(in[1]->hasinput) - osa(tex_input_vec, target->nor, in[1], ¶ms, cdata->thread); - else - target->nor = 0; + target->tin = (target->tr + target->tg + target->tb) / 3.0f; + target->talpha = 1.0f; + + if(target->nor) { + if(in[1]->hasinput) + osa(tex_input_vec, target->nor, in[1], ¶ms, cdata->thread); + else + target->nor = 0; + } } } } diff --git a/source/blender/nodes/intern/TEX_util.c b/source/blender/nodes/intern/TEX_util.c index 867bbd8c14e..8b247688e8c 100644 --- a/source/blender/nodes/intern/TEX_util.c +++ b/source/blender/nodes/intern/TEX_util.c @@ -176,10 +176,6 @@ void ntreeTexExecTree( TexResult dummy_texres; TexCallData data; - /* 0 means don't care, so just use first */ - if(which_output == 0) - which_output = 1; - if(!texres) texres = &dummy_texres; data.coord = coord; data.dxt = dxt; -- cgit v1.2.3