Orange: made Image window react nicer to compositor output and own Curves;

- Image curves are only applied now when curves panel is in use. Closing
  the panel will disable curves, reopen Panel enable curves.
  You can minimize the Curves panel to keep it active. That latter then
  works as visualization curves are being applied.

- Compositor output now also uses Image window curves, if active.
This commit is contained in:
Ton Roosendaal 2006-01-24 10:35:43 +00:00
parent 4db91f9784
commit a126178fd8
4 changed files with 62 additions and 1 deletions

@ -55,6 +55,6 @@ void curvemapping_evaluateRGBF(struct CurveMapping *cumap, float *vecout, con
void curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float *vecout, const float *vecin);
void curvemapping_do_image(struct CurveMapping *cumap, struct Image *ima);
void curvemapping_premultiply(struct CurveMapping *cumap, int restore);
int curvemapping_RGBA_does_something(struct CurveMapping *cumap);
#endif

@ -569,6 +569,8 @@ void curvemapping_do_image(CurveMapping *cumap, Image *ima)
return;
if(ima->ibuf->rect_float==NULL)
IMB_float_from_rect(ima->ibuf);
else if(ima->ibuf->rect==NULL)
imb_addrectImBuf(ima->ibuf);
curvemapping_premultiply(cumap, 0);
@ -588,3 +590,28 @@ void curvemapping_do_image(CurveMapping *cumap, Image *ima)
curvemapping_premultiply(cumap, 1);
}
int curvemapping_RGBA_does_something(CurveMapping *cumap)
{
int a;
if(cumap->black[0]!=0.0f) return 1;
if(cumap->black[1]!=0.0f) return 1;
if(cumap->black[2]!=0.0f) return 1;
if(cumap->white[0]!=1.0f) return 1;
if(cumap->white[1]!=1.0f) return 1;
if(cumap->white[2]!=1.0f) return 1;
for(a=0; a<CM_TOT; a++) {
if(cumap->cm[a].curve) {
if(cumap->cm[a].totpoint!=2) return 1;
if(cumap->cm[a].curve[0].x != 0.0f) return 1;
if(cumap->cm[a].curve[0].y != 0.0f) return 1;
if(cumap->cm[a].curve[1].x != 1.0f) return 1;
if(cumap->cm[a].curve[1].y != 1.0f) return 1;
}
}
return 0;
}

@ -478,6 +478,9 @@ void IMB_freezbuffloatImBuf(struct ImBuf * ibuf);
*/
void IMB_rectfill(struct ImBuf *drect, float col[4]);
/* exported for image tools in blender, to quickly allocate 32 bits rect */
short imb_addrectImBuf(struct ImBuf * ibuf);
void imb_freerectImBuf(struct ImBuf * ibuf);
#ifdef WITH_QUICKTIME
/**

@ -978,7 +978,22 @@ static void image_panel_curves(short cntrl) // IMAGE_HANDLER_PROPERTIES
}
}
/* are there curves? curves visible? and curves do something? */
static int image_curves_active(ScrArea *sa)
{
SpaceImage *sima= sa->spacedata.first;
if(sima->cumap) {
if(curvemapping_RGBA_does_something(sima->cumap)) {
short a;
for(a=0; a<SPACE_MAXHANDLER; a+=2) {
if(sima->blockhandler[a] == IMAGE_HANDLER_CURVES)
return 1;
}
}
}
return 0;
}
static void image_blockhandlers(ScrArea *sa)
{
@ -1268,6 +1283,8 @@ void drawimagespace(ScrArea *sa, void *spacedata)
MEM_freeN(rect);
}
else {
/* this part is generic image display */
if(sima->flag & SI_SHOW_ALPHA) {
if(ibuf->rect)
sima_draw_alpha_pixels(x1, y1, ibuf->x, ibuf->y, ibuf->rect);
@ -1283,6 +1300,20 @@ void drawimagespace(ScrArea *sa, void *spacedata)
sima_draw_alpha_backdrop(sima, x1, y1, (float)ibuf->x, (float)ibuf->y);
glEnable(GL_BLEND);
}
/* detect if we need to redo the curve map.
ibuf->rect is zero for compositor and render results after change
also: if no curves are active, we only keep the float rect
*/
if(ibuf->rect_float) {
if(image_curves_active(sa)) {
if(ibuf->rect==NULL)
curvemapping_do_image(G.sima->cumap, G.sima->image);
}
else if(ibuf->rect)
imb_freerectImBuf(ibuf);
}
if(ibuf->rect)
glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
else