Orange: made Image window react nicer to compositor output and own Curves;
authorTon Roosendaal <ton@blender.org>
Tue, 24 Jan 2006 10:35:43 +0000 (10:35 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 24 Jan 2006 10:35:43 +0000 (10:35 +0000)
- 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
source/blender/blenkernel/intern/colortools.c
source/blender/imbuf/IMB_imbuf.h
source/blender/src/drawimage.c

index dd739628fc5ec4b3b4b71c61024ad67744a5426e..a9d38162824d3035d42d4bbf0bf9f7b18d3048e1 100644 (file)
@@ -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
 
index 5b4c4ca107f7e8cc02cd4ee2d40af175fc16105c..f9854fae98c1f511c8e3ddf17930cec1729241cc 100644 (file)
@@ -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;
+}
+
index 623e9e901f95c81aaefa72a690701480494c32b1..ae7a7f527f1fa9f9f0d7e51e7aa84871950ffbd6 100644 (file)
@@ -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
 /**
index 9a002005e06c46f0c4ad8d54adb9fa8fc2c7fece..fa6a91b701d95c163cb5610b854835c75a318a16 100644 (file)
@@ -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