Coding work while on the trip to london (based on Plumiferos wishlist);

- Icon previews for Images were created always for old files, which made
  browsing (menus) incredible slow. Added a minor change in the flow, so
  icons only get created when the user invokes loading images.
  Andrea; you might check this, probably not al cases are covered yet?

- Compositor: the 'File Output' node now has a min/max frame for which it
  writes files

- Compositor: fixed a very bad bug (even in 2.42a release) that made the
  depsgraph for nodes not work... while editing, only the nodes that change
  should be recalculated, but accidentally all of them were done each time.
This commit is contained in:
2006-10-26 10:13:16 +00:00
parent f0dcd2db75
commit 9f77785d7c
6 changed files with 58 additions and 36 deletions

View File

@@ -587,6 +587,10 @@ void load_image(Image * ima, int flags, char *relabase, int framenum)
if (ima->ibuf) {
detectBitmapFont(ima->ibuf);
/* preview is NULL when it has never been used as an icon before */
if(ima->preview==NULL)
BKE_icon_changed(BKE_icon_getid(&ima->id));
}
}
}

View File

@@ -804,6 +804,8 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup)
nif->imtype= G.scene->r.imtype;
nif->subimtype= G.scene->r.subimtype;
nif->quality= G.scene->r.quality;
nif->sfra= G.scene->r.sfra;
nif->efra= G.scene->r.efra;
}
}
@@ -1438,6 +1440,9 @@ void NodeTagChanged(bNodeTree *ntree, bNode *node)
void NodeTagIDChanged(bNodeTree *ntree, ID *id)
{
if(id==NULL)
return;
if(ntree->type==NTREE_COMPOSIT) {
bNode *node;
@@ -1874,7 +1879,7 @@ static void *exec_composite_node(void *node_v)
bNodeStack *nsin[MAX_SOCKET]; /* arbitrary... watch this */
bNodeStack *nsout[MAX_SOCKET]; /* arbitrary... watch this */
bNode *node= node_v;
ThreadData *thd= (ThreadData *)node->new_node;
ThreadData *thd= (ThreadData *)node->new_node; /* abuse */
node_get_stack(node, thd->stack, nsin, nsout);

View File

@@ -687,26 +687,31 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack *
if(in[0]->data) {
RenderData *rd= data;
NodeImageFile *nif= node->storage;
CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
ImBuf *ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0, 0);
char string[256];
ibuf->rect_float= cbuf->rect;
ibuf->dither= rd->dither_intensity;
BKE_makepicstring(string, nif->name, rd->cfra, nif->imtype);
if(0 == BKE_write_ibuf(ibuf, string, nif->imtype, nif->subimtype, nif->imtype==R_OPENEXR?nif->codec:nif->quality))
printf("Cannot save Node File Output to %s\n", string);
else
printf("Saved: %s\n", string);
IMB_freeImBuf(ibuf);
generate_preview(node, cbuf);
if(in[0]->data != cbuf)
free_compbuf(cbuf);
if(nif->sfra!=nif->efra && (rd->cfra<nif->sfra || rd->cfra>nif->efra)) {
return; /* BAIL OUT RETURN */
}
else {
CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
ImBuf *ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0, 0);
char string[256];
ibuf->rect_float= cbuf->rect;
ibuf->dither= rd->dither_intensity;
BKE_makepicstring(string, nif->name, rd->cfra, nif->imtype);
if(0 == BKE_write_ibuf(ibuf, string, nif->imtype, nif->subimtype, nif->imtype==R_OPENEXR?nif->codec:nif->quality))
printf("Cannot save Node File Output to %s\n", string);
else
printf("Saved: %s\n", string);
IMB_freeImBuf(ibuf);
generate_preview(node, cbuf);
if(in[0]->data != cbuf)
free_compbuf(cbuf);
}
}
}

View File

@@ -199,6 +199,7 @@ typedef struct NodeHueSat {
typedef struct NodeImageFile {
char name[256];
short imtype, subimtype, quality, codec;
int sfra, efra;
} NodeImageFile;
#endif

View File

@@ -1047,6 +1047,9 @@ static int node_composit_buts_file_output(uiBlock *block, bNodeTree *ntree, bNod
{
if(block) {
NodeImageFile *nif= node->storage;
short x= (short)butr->xmin;
short y= (short)butr->ymin;
short w= (short)butr->xmax-butr->xmin;
char str[320];
node_imagetype_string(str);
@@ -1054,29 +1057,38 @@ static int node_composit_buts_file_output(uiBlock *block, bNodeTree *ntree, bNod
uiBlockBeginAlign(block);
uiDefBut(block, TEX, B_NOP, "",
butr->xmin, butr->ymin+40.0f, butr->xmax-butr->xmin, 20,
x, y+60, w, 20,
nif->name, 0.0f, 240.0f, 0, 0, "");
uiDefButS(block, MENU, B_NOP, str,
butr->xmin, butr->ymin+20.0f, butr->xmax-butr->xmin, 20,
x, y+40, w, 20,
&nif->imtype, 0.0f, 1.0f, 0, 0, "");
if(nif->imtype==R_OPENEXR) {
uiDefButBitS(block, TOG, R_OPENEXR_HALF, B_NOP, "Half",
butr->xmin, butr->ymin, (butr->xmax-butr->xmin)/2, 20,
x, y+20, w/2, 20,
&nif->subimtype, 0, 0, 0, 0, "");
uiDefButS(block, MENU,B_NOP, "Codec %t|None %x0|Pxr24 (lossy) %x1|ZIP (lossless) %x2|PIZ (lossless) %x3|RLE (lossless) %x4",
butr->xmin+(butr->xmax-butr->xmin)/2, butr->ymin, (butr->xmax-butr->xmin)/2, 20,
x+w/2, y+20, w/2, 20,
&nif->codec, 0, 0, 0, 0, "");
}
else {
uiDefButS(block, NUM, B_NOP, "Quality: ",
butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20,
x, y+20, w, 20,
&nif->quality, 10.0f, 100.0f, 10, 0, "");
}
/* start frame, end frame */
uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "SFra: ",
x, y, w/2, 20,
&nif->sfra, 1, MAXFRAMEF, 10, 0, "");
uiDefButI(block, NUM, B_NODE_EXEC+node->nr, "EFra: ",
x+w/2, y, w/2, 20,
&nif->efra, 1, MAXFRAMEF, 10, 0, "");
}
return 60;
return 80;
}
static void node_scale_cb(void *node_v, void *unused_v)

View File

@@ -671,7 +671,6 @@ static void icon_copy_rect(ImBuf *ibuf, RenderInfo *ri)
static void icon_from_image(Image *img, RenderInfo *ri)
{
unsigned int pr_size = ri->pr_rectx*ri->pr_recty*sizeof(unsigned int);
short image_loaded = 0;
/* img->ok is zero when Image cannot load */
if (img==NULL || img->ok==0)
@@ -684,27 +683,23 @@ static void icon_from_image(Image *img, RenderInfo *ri)
/* we only load image if there's no preview saved already ...
always loading and reducing images is too expensive */
/* new rule: never read images, so icons get created while user works,
not always on first use of a menu */
if(!img->preview) {
if(img->ibuf==NULL || img->ibuf->rect==NULL) {
load_image(img, IB_rect, G.sce, G.scene->r.cfra);
if(img->ok==0)
return;
image_loaded = 1;
return;
}
icon_copy_rect(img->ibuf, ri);
/* now copy the created preview to the DNA struct to be saved in file */
img->preview = MEM_callocN(sizeof(PreviewImage), "img_prv");
if (img->preview) {
printf("created image prv\n");
img->preview->w = ri->pr_rectx;
img->preview->h = ri->pr_recty;
img->preview->rect = MEM_callocN(pr_size, "prv_rect");
memcpy(img->preview->rect, ri->rect, pr_size);
}
/* if we only loaded image for preview, we don't want to keep it in memory -
important for huge image files */
if (image_loaded) free_image_buffers(img);
}
else {
unsigned int img_prv_size = img->preview->w*img->preview->h*sizeof(unsigned int);