converted more mixed tab/space indentations to tabs. only whitespace changes.
[blender.git] / source / blender / nodes / intern / CMP_nodes / CMP_levels.c
index f550bea..2c9f7d9 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** \file blender/nodes/intern/CMP_nodes/CMP_levels.c
+ *  \ingroup cmpnodes
+ */
+
+
 #include "../CMP_util.h"
 
 
@@ -47,7 +52,7 @@ static void rgb_tobw(float r, float g, float b, float* out)
        *out= r*0.35f + g*0.45f + b*0.2f;
 }
 
-static void fill_bins(bNode* node, CompBuf* in, int* bins)
+static void fill_bins(bNode* node, CompBuf* in, int* bins, int colorcor)
 {
        float value[4];
        int ivalue=0;
@@ -63,29 +68,39 @@ static void fill_bins(bNode* node, CompBuf* in, int* bins)
                        if(value[3] > 0.0) { /* don't count transparent pixels */
                                switch(node->custom1) {
                                        case 1: { /* all colors */
+                                               if(colorcor)
+                                                       linearrgb_to_srgb_v3_v3(&value[0],&value[0]);
                                                rgb_tobw(value[0],value[1],value[2], &value[0]);
                                                value[0]=value[0]*255; /* scale to 0-255 range */
                                                ivalue=(int)value[0];
                                                break;
                                        }
                                        case 2: { /* red channel */
+                                               if(colorcor)
+                                                       value[0]=linearrgb_to_srgb(value[0]);
                                                value[0]=value[0]*255; /* scale to 0-255 range */
                                                ivalue=(int)value[0];
                                                break;
                                        }
                                        case 3:  { /* green channel */
+                                               if(colorcor)
+                                                       value[1]=linearrgb_to_srgb(value[1]);
                                                value[1]=value[1]*255; /* scale to 0-255 range */
                                                ivalue=(int)value[1];
                                                break;
                                        }
                                        case 4: /*blue channel */
                                        {
+                                               if(colorcor)
+                                                       value[2]=linearrgb_to_srgb(value[2]);
                                                value[2]=value[2]*255; /* scale to 0-255 range */
                                                ivalue=(int)value[2];
                                                break;
                                        }
                                        case 5: /* luminence */
                                        {
+                                               if(colorcor)
+                                                       linearrgb_to_srgb_v3_v3(&value[0],&value[0]);
                                                rgb_to_yuv(value[0],value[1],value[2], &value[0], &value[1], &value[2]);
                                                value[0]=value[0]*255; /* scale to 0-255 range */
                                                ivalue=(int)value[0];
@@ -270,6 +285,7 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack *
 {
        CompBuf* cbuf;
        CompBuf* histogram;
+       RenderData *rd=data;
        float mean, std_dev;
        int bins[256];
        int x;
@@ -286,7 +302,7 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack *
        }
        
        /*fill bins */
-       fill_bins(node, in[0]->data, bins);
+       fill_bins(node, in[0]->data, bins, rd->color_mgt_flag & R_COLOR_MANAGEMENT);
 
        /* draw the histogram chart */
        draw_histogram(node, histogram, bins);
@@ -314,24 +330,21 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack *
 
 static void node_composit_init_view_levels(bNode* node)
 {
-   node->custom1=1; /*All channels*/
+       node->custom1=1; /*All channels*/
+}
+
+void register_node_type_cmp_view_levels(ListBase *lb)
+{
+       static bNodeType ntype;
+
+       node_type_base(&ntype, CMP_NODE_VIEW_LEVELS, "Levels", NODE_CLASS_OUTPUT, NODE_OPTIONS|NODE_PREVIEW,
+               cmp_node_view_levels_in, cmp_node_view_levels_out);
+       node_type_size(&ntype, 140, 100, 320);
+       node_type_init(&ntype, node_composit_init_view_levels);
+       node_type_storage(&ntype, "ImageUser", NULL, NULL);
+       node_type_exec(&ntype, node_composit_exec_view_levels);
+
+       nodeRegisterType(lb, &ntype);
 }
 
-bNodeType cmp_node_view_levels= {
-       /* *next,*prev */       NULL, NULL,
-       /* type code   */       CMP_NODE_VIEW_LEVELS,
-       /* name        */       "Levels",
-       /* widthrange */        140, 100, 320,
-       /* classopts  */        NODE_CLASS_OUTPUT, NODE_OPTIONS|NODE_PREVIEW,
-       /* input sock  */       cmp_node_view_levels_in,
-       /* output sock */       cmp_node_view_levels_out,
-       /* storage     */       "ImageUser",
-       /* execfunc    */       node_composit_exec_view_levels,
-       /* butfunc     */       NULL,
-       /* initfunc    */       node_composit_init_view_levels,
-       /* freestoragefunc    */        NULL,
-       /* copystoragefunc    */        NULL,
-       /* id          */       NULL
-       
-};