Revision: 37056
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37056
Author:   psy-fi
Date:     2011-05-31 19:32:48 +0000 (Tue, 31 May 2011)
Log Message:
-----------
aesthetic changes to fit submitted patch for review

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/blenlib/BLI_math_vector.h
    branches/soc-2011-onion/source/blender/blenlib/BLI_utildefines.h
    branches/soc-2011-onion/source/blender/blenlib/intern/math_vector_inline.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c
    branches/soc-2011-onion/source/blender/imbuf/intern/divers.c

Modified: branches/soc-2011-onion/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/BLI_math_vector.h    
2011-05-31 18:24:51 UTC (rev 37055)
+++ branches/soc-2011-onion/source/blender/blenlib/BLI_math_vector.h    
2011-05-31 19:32:48 UTC (rev 37056)
@@ -58,6 +58,8 @@
 
 /********************************* Arithmetic ********************************/
 
+MINLINE void add_v3_fl(float r[3], float f);
+MINLINE void add_v4_fl(float r[4], float f);
 MINLINE void add_v2_v2(float r[2], const float a[2]);
 MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2]);
 MINLINE void add_v3_v3(float r[3], const float a[3]);

Modified: branches/soc-2011-onion/source/blender/blenlib/BLI_utildefines.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/BLI_utildefines.h    
2011-05-31 18:24:51 UTC (rev 37055)
+++ branches/soc-2011-onion/source/blender/blenlib/BLI_utildefines.h    
2011-05-31 19:32:48 UTC (rev 37056)
@@ -103,6 +103,12 @@
 
 #define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : 
(char)((255.0f*(val))+0.5f))
 #define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: 
(unsigned short)(val*65535.0f + 0.5f))
+#define F3TOCHAR3(v2,v1) (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); 
(v1)[2]=FTOCHAR((v2[2]))
+#define F3TOCHAR4(v2,v1) (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); 
(v1)[2]=FTOCHAR((v2[2])); \
+                                               (v1)[3]=FTOCHAR((v2[3])); 
(v1)[3] = 255
+#define F4TOCHAR4(v2,v1) (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); 
(v1)[2]=FTOCHAR((v2[2])); \
+                                               (v1)[3]=FTOCHAR((v2[3])); 
(v1)[3]=FTOCHAR((v2[3]))
+ 
 
 #define VECCOPY(v1,v2)          {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= 
*(v2+2);}
 #define VECCOPY2D(v1,v2)          {*(v1)= *(v2); *(v1+1)= *(v2+1);}

Modified: 
branches/soc-2011-onion/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/math_vector_inline.c  
2011-05-31 18:24:51 UTC (rev 37055)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/math_vector_inline.c  
2011-05-31 19:32:48 UTC (rev 37056)
@@ -102,6 +102,21 @@
 
 /********************************* Arithmetic ********************************/
 
+MINLINE void add_v3_fl(float r[3], float f)
+{
+       r[0] += f;
+       r[1] += f;
+       r[2] += f;
+}
+
+MINLINE void add_v4_fl(float r[4], float f)
+{
+       r[0] += f;
+       r[1] += f;
+       r[2] += f;
+       r[3] += f;
+}
+
 MINLINE void add_v2_v2(float *r, const float *a)
 {
        r[0] += a[0];

Modified: 
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c   
2011-05-31 18:24:51 UTC (rev 37055)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c   
2011-05-31 19:32:48 UTC (rev 37056)
@@ -3698,9 +3698,9 @@
 static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, 
float *rgba, float alpha, float mask) {
        if (ps->is_texbrush) {
        /*rgba already holds a texture result here from higher level function*/
-               rgba[0] *= srgb_to_linearrgb(ps->brush->rgb[0]);
-               rgba[1] *= srgb_to_linearrgb(ps->brush->rgb[1]);
-               rgba[2] *= srgb_to_linearrgb(ps->brush->rgb[2]);
+               float rgba_br[3];
+               srgb_to_linearrgb_v3_v3(rgba_br, ps->brush->rgb);
+               mul_v3_v3(rgba, rgba_br);
        }
        else {
                VECCOPY(rgba, ps->brush->rgb);

Modified: branches/soc-2011-onion/source/blender/imbuf/intern/divers.c
===================================================================
--- branches/soc-2011-onion/source/blender/imbuf/intern/divers.c        
2011-05-31 18:24:51 UTC (rev 37055)
+++ branches/soc-2011-onion/source/blender/imbuf/intern/divers.c        
2011-05-31 19:32:48 UTC (rev 37056)
@@ -249,16 +249,9 @@
                                dstBytePxl = init_dstBytePxl + (ibuf->x*(y + j) 
+ x)*4;
                                srcFloatPxl = init_srcFloatPxl + (ibuf->x*(y + 
j) + x)*3;
                                for(i = 0;  i < w; i++, dstBytePxl+=4, 
srcFloatPxl+=3, bufferIndex += 4) {
-
-                                       bufferIndex[0]= 
linearrgb_to_srgb(srcFloatPxl[0]);
-                                       bufferIndex[1]= 
linearrgb_to_srgb(srcFloatPxl[1]);
-                                       bufferIndex[2]= 
linearrgb_to_srgb(srcFloatPxl[2]);
+                                       linearrgb_to_srgb_v3_v3(bufferIndex, 
srcFloatPxl);
+                                       F3TOCHAR4(bufferIndex, dstBytePxl);
                                        bufferIndex[3]= 1.0;
-
-                                       dstBytePxl[0] = FTOCHAR(bufferIndex[0]);
-                                       dstBytePxl[1] = FTOCHAR(bufferIndex[1]);
-                                       dstBytePxl[2] = FTOCHAR(bufferIndex[2]);
-                                       dstBytePxl[3] = 255;
                                }
                        }
                }
@@ -270,16 +263,10 @@
                                        srcFloatPxl = init_srcFloatPxl + 
(ibuf->x*(y + j) + x)*4;
                                        for(i = 0;  i < w; i++, dstBytePxl+=4, 
srcFloatPxl+=4, bufferIndex+=4) {
                                                const float d = 
(BLI_frand()-0.5f)*dither;
-
-                                               bufferIndex[0]= d + 
linearrgb_to_srgb(srcFloatPxl[0]);
-                                               bufferIndex[1]= d + 
linearrgb_to_srgb(srcFloatPxl[1]);
-                                               bufferIndex[2]= d + 
linearrgb_to_srgb(srcFloatPxl[2]);
-                                               bufferIndex[3]= d + 
srcFloatPxl[3];
-
-                                               dstBytePxl[0] = 
FTOCHAR(bufferIndex[0]);
-                                               dstBytePxl[1] = 
FTOCHAR(bufferIndex[1]);
-                                               dstBytePxl[2] = 
FTOCHAR(bufferIndex[2]);
-                                               dstBytePxl[3] = 
FTOCHAR(bufferIndex[3]);
+                                               
linearrgb_to_srgb_v3_v3(bufferIndex, srcFloatPxl);
+                                               bufferIndex[3] = srcFloatPxl[3];
+                                               add_v4_fl(bufferIndex, d);
+                                               F4TOCHAR4(bufferIndex, 
dstBytePxl);
                                        }
                                }
                        } else {
@@ -288,15 +275,9 @@
                                        dstBytePxl = init_dstBytePxl + 
(ibuf->x*(y + j) + x)*4;
                                        srcFloatPxl = init_srcFloatPxl + 
(ibuf->x*(y + j) + x)*4;
                                        for(i = 0;  i < w; i++, dstBytePxl+=4, 
srcFloatPxl+=4, bufferIndex+=4) {
-                                               bufferIndex[0]= 
linearrgb_to_srgb(srcFloatPxl[0]);
-                                               bufferIndex[1]= 
linearrgb_to_srgb(srcFloatPxl[1]);
-                                               bufferIndex[2]= 
linearrgb_to_srgb(srcFloatPxl[2]);
+                                               
linearrgb_to_srgb_v3_v3(bufferIndex, srcFloatPxl);
                                                bufferIndex[3]= srcFloatPxl[3];
-
-                                               dstBytePxl[0] = 
FTOCHAR(bufferIndex[0]);
-                                               dstBytePxl[1] = 
FTOCHAR(bufferIndex[1]);
-                                               dstBytePxl[2] = 
FTOCHAR(bufferIndex[2]);
-                                               dstBytePxl[3] = 
FTOCHAR(bufferIndex[3]);
+                                               F4TOCHAR4(bufferIndex, 
dstBytePxl);
                                        }
                                }
                        }
@@ -309,10 +290,8 @@
                                dstBytePxl = init_dstBytePxl + (ibuf->x*(y + j) 
+ x)*4;
                                srcFloatPxl = init_srcFloatPxl + (ibuf->x*(y + 
j) + x)*3;
                                for(i = 0;  i < w; i++, dstBytePxl+=4, 
srcFloatPxl+=3, bufferIndex+=4) {
-                                       dstBytePxl[0] = FTOCHAR(bufferIndex[0] 
= srcFloatPxl[0]);
-                                       dstBytePxl[1] = FTOCHAR(bufferIndex[1] 
= srcFloatPxl[1]);
-                                       dstBytePxl[2] = FTOCHAR(bufferIndex[2] 
= srcFloatPxl[2]);
-                                       dstBytePxl[3] = 255;
+                                       copy_v3_v3(bufferIndex, srcFloatPxl);
+                                       F3TOCHAR4(bufferIndex, dstBytePxl);
                                        bufferIndex[3] = 1.0;
                                }
                        }
@@ -325,16 +304,9 @@
                                        srcFloatPxl = init_srcFloatPxl + 
(ibuf->x*(y + j) + x)*4;
                                        for(i = 0;  i < w; i++, dstBytePxl+=4, 
srcFloatPxl+=4, bufferIndex+=4) {
                                                const float d = 
(BLI_frand()-0.5f)*dither;
-
-                                               bufferIndex[0]= d + 
srcFloatPxl[0];
-                                               bufferIndex[1]= d + 
srcFloatPxl[1];
-                                               bufferIndex[2]= d + 
srcFloatPxl[2];
-                                               bufferIndex[3]= d + 
srcFloatPxl[3];
-
-                                               dstBytePxl[0] = 
FTOCHAR(bufferIndex[0]);
-                                               dstBytePxl[1] = 
FTOCHAR(bufferIndex[1]);
-                                               dstBytePxl[2] = 
FTOCHAR(bufferIndex[2]);
-                                               dstBytePxl[3] = 
FTOCHAR(bufferIndex[3]);
+                                               copy_v4_v4(bufferIndex, 
srcFloatPxl);
+                                               add_v4_fl(bufferIndex,d);
+                                               F4TOCHAR4(bufferIndex, 
dstBytePxl);
                                        }
                                }
                        } else {
@@ -343,10 +315,8 @@
                                        dstBytePxl = init_dstBytePxl + 
(ibuf->x*(y + j) + x)*4;
                                        srcFloatPxl = init_srcFloatPxl + 
(ibuf->x*(y + j) + x)*4;
                                        for(i = 0;  i < w; i++, dstBytePxl+=4, 
srcFloatPxl+=4, bufferIndex+=4) {
-                                               dstBytePxl[0] = 
FTOCHAR(bufferIndex[0] = srcFloatPxl[0]);
-                                               dstBytePxl[1] = 
FTOCHAR(bufferIndex[1] = srcFloatPxl[1]);
-                                               dstBytePxl[2] = 
FTOCHAR(bufferIndex[2] = srcFloatPxl[2]);
-                                               dstBytePxl[3] = 
FTOCHAR(bufferIndex[3] = srcFloatPxl[3]);
+                                               copy_v4_v4(bufferIndex, 
srcFloatPxl);
+                                               F4TOCHAR4(bufferIndex, 
dstBytePxl);
                                        }
                                }
                        }
@@ -387,10 +357,7 @@
        else if (profile == IB_PROFILE_LINEAR_RGB) {
                if(channels == 3) {
                                for(i = 0;  i < w*h; i++, srcFloatPxl+=3, 
bufferIndex += 4) {
-
-                                       bufferIndex[0]= 
linearrgb_to_srgb(srcFloatPxl[0]);
-                                       bufferIndex[1]= 
linearrgb_to_srgb(srcFloatPxl[1]);
-                                       bufferIndex[2]= 
linearrgb_to_srgb(srcFloatPxl[2]);
+                                       
linearrgb_to_srgb_v3_v3(bufferIndex,srcFloatPxl);
                                        bufferIndex[3]= 1.0;
                                }
                        }
@@ -398,18 +365,14 @@
                        if (dither != 0.f) {
                                for(i = 0;  i < w*h; i++, srcFloatPxl+=4, 
bufferIndex+=4) {
                                        const float d = 
(BLI_frand()-0.5f)*dither;
-
-                                       bufferIndex[0]= d + 
linearrgb_to_srgb(srcFloatPxl[0]);
-                                       bufferIndex[1]= d + 
linearrgb_to_srgb(srcFloatPxl[1]);
-                                       bufferIndex[2]= d + 
linearrgb_to_srgb(srcFloatPxl[2]);
+                                       
linearrgb_to_srgb_v3_v3(bufferIndex,srcFloatPxl);
+                                       add_v3_fl(bufferIndex, d);
                                        bufferIndex[3]= d + srcFloatPxl[3];
                                }
 
                        } else {
                                for(i = 0;  i < w*h; i++, srcFloatPxl+=4, 
bufferIndex+=4) {
-                                       bufferIndex[0]= 
linearrgb_to_srgb(srcFloatPxl[0]);
-                                       bufferIndex[1]= 
linearrgb_to_srgb(srcFloatPxl[1]);
-                                       bufferIndex[2]= 
linearrgb_to_srgb(srcFloatPxl[2]);
+                                       
linearrgb_to_srgb_v3_v3(bufferIndex,srcFloatPxl);
                                        bufferIndex[3]= srcFloatPxl[3];
                                }
                        }
@@ -417,9 +380,7 @@
        }else if(ELEM(profile, IB_PROFILE_NONE, IB_PROFILE_SRGB)) {
                if(channels==3) {
                        for(i = 0;  i < w*h; i++, srcFloatPxl+=3, 
bufferIndex+=4) {
-                               bufferIndex[0] = srcFloatPxl[0];
-                               bufferIndex[1] = srcFloatPxl[1];
-                               bufferIndex[2] = srcFloatPxl[2];
+                               copy_v3_v3(bufferIndex, srcFloatPxl);
                                bufferIndex[3] = 1.0;
                        }
                }
@@ -427,18 +388,12 @@
                        if (dither != 0.f) {
                                for(i = 0;  i < w*h; i++, srcFloatPxl+=4, 
bufferIndex+=4) {
                                        const float d = 
(BLI_frand()-0.5f)*dither;
-
-                                       bufferIndex[0]= d + srcFloatPxl[0];
-                                       bufferIndex[1]= d + srcFloatPxl[1];
-                                       bufferIndex[2]= d + srcFloatPxl[2];
-                                       bufferIndex[3]= d + srcFloatPxl[3];
+                                       copy_v4_v4(bufferIndex, srcFloatPxl);
+                                       add_v4_fl(bufferIndex, d);
                                }
                        } else {
                                for(i = 0;  i < w*h; i++, srcFloatPxl+=4, 
bufferIndex+=4) {
-                                       bufferIndex[0] = srcFloatPxl[0];
-                                       bufferIndex[1] = srcFloatPxl[1];
-                                       bufferIndex[2] = srcFloatPxl[2];
-                                       bufferIndex[3] = srcFloatPxl[3];
+                                       copy_v4_v4(bufferIndex, srcFloatPxl);
                                }
                        }
                }

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to