From a126178fd8eade4d7facdeb58bdd6592316e7f0a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 24 Jan 2006 10:35:43 +0000 Subject: [PATCH] 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. --- source/blender/blenkernel/BKE_colortools.h | 2 +- source/blender/blenkernel/intern/colortools.c | 27 ++++++++++++++++ source/blender/imbuf/IMB_imbuf.h | 3 ++ source/blender/src/drawimage.c | 31 +++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index dd739628fc5..a9d38162824 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -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 diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 5b4c4ca107f..f9854fae98c 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -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; acm[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; +} + diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 623e9e901f9..ae7a7f527f1 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -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 /** diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c index 9a002005e06..fa6a91b701d 100644 --- a/source/blender/src/drawimage.c +++ b/source/blender/src/drawimage.c @@ -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; ablockhandler[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