[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47918] trunk/blender/source/blender: code cleanup: replace most fRGB functions with inline vector functions
Campbell Barton
ideasman42 at gmail.com
Thu Jun 14 21:22:59 CEST 2012
Revision: 47918
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47918
Author: campbellbarton
Date: 2012-06-14 19:22:55 +0000 (Thu, 14 Jun 2012)
Log Message:
-----------
code cleanup: replace most fRGB functions with inline vector functions
Modified Paths:
--------------
trunk/blender/source/blender/compositor/operations/COM_GlareBaseOperation.h
trunk/blender/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
trunk/blender/source/blender/nodes/composite/node_composite_util.c
trunk/blender/source/blender/nodes/composite/node_composite_util.h
trunk/blender/source/blender/nodes/composite/nodes/node_composite_glare.c
trunk/blender/source/blender/nodes/composite/nodes/node_composite_tonemap.c
Modified: trunk/blender/source/blender/compositor/operations/COM_GlareBaseOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_GlareBaseOperation.h 2012-06-14 19:19:11 UTC (rev 47917)
+++ trunk/blender/source/blender/compositor/operations/COM_GlareBaseOperation.h 2012-06-14 19:22:55 UTC (rev 47918)
@@ -32,16 +32,6 @@
typedef float fRGB[4];
/* TODO - replace with BLI_math_vector */
-/* copy c2 to c1 */
-#define fRGB_copy(c1, c2) { c1[0] = c2[0]; c1[1] = c2[1]; c1[2] = c2[2]; c1[3] = c2[3]; } (void)0
-/* add c2 to c1 */
-#define fRGB_add(c1, c2) { c1[0] += c2[0]; c1[1] += c2[1]; c1[2] += c2[2]; } (void)0
-/* multiply c by float value s */
-#define fRGB_mult(c, s) { c[0] *= s; c[1] *= s; c[2] *= s; } (void)0
-/* multiply c2 by s and add to c1 */
-#define fRGB_madd(c1, c2, s) { c1[0] += c2[0] * s; c1[1] += c2[1] * s; c1[2] += c2[2] * s; } (void)0
-/* multiply c2 by color c1 */
-#define fRGB_colormult(c, cs) { c[0] *= cs[0]; c[1] *= cs[1]; c[2] *= cs[2]; } (void)0
/* multiply c2 by color rgb, rgb as separate arguments */
#define fRGB_rgbmult(c, r, g, b) { c[0] *= (r); c[1] *= (g); c[2] *= (b); } (void)0
Modified: trunk/blender/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp 2012-06-14 19:19:11 UTC (rev 47917)
+++ trunk/blender/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp 2012-06-14 19:22:55 UTC (rev 47918)
@@ -277,7 +277,7 @@
for (y = 0; y < kernelHeight; y++) {
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUMBER_OF_CHANNELS];
for (x = 0; x < kernelWidth; x++)
- fRGB_add(wt, colp[x]);
+ add_v3_v3(wt, colp[x]);
}
if (wt[0] != 0.f) wt[0] = 1.f / wt[0];
if (wt[1] != 0.f) wt[1] = 1.f / wt[1];
@@ -285,7 +285,7 @@
for (y = 0; y < kernelHeight; y++) {
colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUMBER_OF_CHANNELS];
for (x = 0; x < kernelWidth; x++)
- fRGB_colormult(colp[x], wt);
+ mul_v3_v3(colp[x], wt);
}
// copy image data, unpacking interleaved RGBA into separate channels
@@ -395,7 +395,7 @@
//w = (1.f-fabs(u))*(1.f-fabs(v));
// actually, Hanning window is ok, cos^2 for some reason is slower
w = (0.5f + 0.5f * cos((double)u * M_PI)) * (0.5f + 0.5f * cos((double)v * M_PI));
- fRGB_mult(fcol, w);
+ mul_v3_fl(fcol, w);
ckrn->writePixel(x, y, fcol);
}
}
Modified: trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp 2012-06-14 19:19:11 UTC (rev 47917)
+++ trunk/blender/source/blender/compositor/operations/COM_GlareGhostOperation.cpp 2012-06-14 19:22:55 UTC (rev 47918)
@@ -85,11 +85,11 @@
s = (u - 0.5f) * sc + 0.5f, t = (v - 0.5f) * sc + 0.5f;
tbuf1->read(c, s * gbuf->getWidth(), t * gbuf->getHeight());
sm = smoothMask(s, t);
- fRGB_mult(c, sm);
+ mul_v3_fl(c, sm);
s = (u - 0.5f) * isc + 0.5f, t = (v - 0.5f) * isc + 0.5f;
tbuf2->read(tc, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
sm = smoothMask(s, t);
- fRGB_madd(c, tc, sm);
+ madd_v3_v3fl(c, tc, sm);
gbuf->writePixel(x, y, c);
}
@@ -109,9 +109,9 @@
s = (u - 0.5f) * scalef[np] + 0.5f;
t = (v - 0.5f) * scalef[np] + 0.5f;
gbuf->read(c, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
- fRGB_colormult(c, cm[np]);
+ mul_v3_v3(c, cm[np]);
sm = smoothMask(s, t) * 0.25f;
- fRGB_madd(tc, c, sm);
+ madd_v3_v3fl(tc, c, sm);
}
tbuf1->addPixel(x, y, tc);
}
Modified: trunk/blender/source/blender/nodes/composite/node_composite_util.c
===================================================================
--- trunk/blender/source/blender/nodes/composite/node_composite_util.c 2012-06-14 19:19:11 UTC (rev 47917)
+++ trunk/blender/source/blender/nodes/composite/node_composite_util.c 2012-06-14 19:22:55 UTC (rev 47918)
@@ -1022,7 +1022,7 @@
for (y=0; y<in2->y; y++) {
colp = (fRGB*)&in2->rect[y*in2->x*in2->type];
for (x=0; x<in2->x; x++)
- fRGB_add(wt, colp[x]);
+ add_v3_v3(wt, colp[x]);
}
if (wt[0] != 0.f) wt[0] = 1.f/wt[0];
if (wt[1] != 0.f) wt[1] = 1.f/wt[1];
@@ -1030,7 +1030,7 @@
for (y=0; y<in2->y; y++) {
colp = (fRGB*)&in2->rect[y*in2->x*in2->type];
for (x=0; x<in2->x; x++)
- fRGB_colormult(colp[x], wt);
+ mul_v3_v3(colp[x], wt);
}
// copy image data, unpacking interleaved RGBA into separate channels
@@ -1279,14 +1279,14 @@
xx = x*scale;
mx = xx + scale;
if (mx > src->x) mx = src->x;
- colsum[0] = colsum[1] = colsum[2] = 0.f;
+ zero_v3(colsum);
for (sy=yy; sy<my; sy++) {
fRGB* scolp = (fRGB*)&src->rect[sy*src->x*src->type];
for (sx=xx; sx<mx; sx++)
- fRGB_add(colsum, scolp[sx]);
+ add_v3_v3(colsum, scolp[sx]);
}
- fRGB_mult(colsum, fscale);
- fRGB_copy(fcolp[x], colsum);
+ mul_v3_fl(colsum, fscale);
+ copy_v3_v3(fcolp[x], colsum);
}
}
}
Modified: trunk/blender/source/blender/nodes/composite/node_composite_util.h
===================================================================
--- trunk/blender/source/blender/nodes/composite/node_composite_util.h 2012-06-14 19:19:11 UTC (rev 47917)
+++ trunk/blender/source/blender/nodes/composite/node_composite_util.h 2012-06-14 19:22:55 UTC (rev 47918)
@@ -182,16 +182,6 @@
/* utility functions used by glare, tonemap and lens distortion */
/* soms macros for color handling */
typedef float fRGB[4];
-/* copy c2 to c1 */
-#define fRGB_copy(c1, c2) { c1[0]=c2[0]; c1[1]=c2[1]; c1[2]=c2[2]; c1[3]=c2[3]; } (void)0
-/* add c2 to c1 */
-#define fRGB_add(c1, c2) { c1[0]+=c2[0]; c1[1]+=c2[1]; c1[2]+=c2[2]; } (void)0
-/* multiply c by float value s */
-#define fRGB_mult(c, s) { c[0]*=s; c[1]*=s; c[2]*=s; } (void)0
-/* multiply c2 by s and add to c1 */
-#define fRGB_madd(c1, c2, s) { c1[0]+=c2[0]*s; c1[1]+=c2[1]*s; c1[2]+=c2[2]*s; } (void)0
-/* multiply c2 by color c1 */
-#define fRGB_colormult(c, cs) { c[0]*=cs[0]; c[1]*=cs[1]; c[2]*=cs[2]; } (void)0
/* multiply c2 by color rgb, rgb as separate arguments */
#define fRGB_rgbmult(c, r, g, b) { c[0]*=(r); c[1]*=(g); c[2]*=(b); } (void)0
Modified: trunk/blender/source/blender/nodes/composite/nodes/node_composite_glare.c
===================================================================
--- trunk/blender/source/blender/nodes/composite/nodes/node_composite_glare.c 2012-06-14 19:19:11 UTC (rev 47917)
+++ trunk/blender/source/blender/nodes/composite/nodes/node_composite_glare.c 2012-06-14 19:22:55 UTC (rev 47918)
@@ -53,16 +53,16 @@
dcolp = (fRGB*)&dst->rect[y*dst->x*dst->type];
scolp = (fRGB*)&src->rect[y*dst->x*dst->type];
for (x=0; x<dst->x; x++) {
- fRGB_copy(c1, dcolp[x]);
- fRGB_copy(c2, scolp[x]);
+ copy_v3_v3(c1, dcolp[x]);
+ copy_v3_v3(c2, scolp[x]);
c1[0] += mix*(c2[0] - c1[0]);
c1[1] += mix*(c2[1] - c1[1]);
c1[2] += mix*(c2[2] - c1[2]);
if (c1[0] < 0.f) c1[0] = 0.f;
if (c1[1] < 0.f) c1[1] = 0.f;
if (c1[2] < 0.f) c1[2] = 0.f;
- fRGB_mult(c1, mf);
- fRGB_copy(dcolp[x], c1);
+ mul_v3_fl(c1, mf);
+ copy_v3_v3(dcolp[x], c1);
}
}
}
@@ -72,7 +72,7 @@
for (y=0; y<dst->y; y++) {
dcolp = (fRGB*)&dst->rect[y*dst->x*dst->type];
for (x=0; x<dst->x; x++) {
- fRGB_copy(c1, dcolp[x]);
+ copy_v3_v3(c1, dcolp[x]);
qd_getPixelLerp(src, (x + 0.5f)*xr - 0.5f, (y + 0.5f)*yr - 0.5f, c2);
c1[0] += mix*(c2[0] - c1[0]);
c1[1] += mix*(c2[1] - c1[1]);
@@ -80,8 +80,8 @@
if (c1[0] < 0.f) c1[0] = 0.f;
if (c1[1] < 0.f) c1[1] = 0.f;
if (c1[2] < 0.f) c1[2] = 0.f;
- fRGB_mult(c1, mf);
- fRGB_copy(dcolp[x], c1);
+ mul_v3_fl(c1, mf);
+ copy_v3_v3(dcolp[x], c1);
}
}
}
@@ -146,11 +146,11 @@
xm = x - i;
xp = x + i;
qd_getPixel(tbuf1, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf1, (ndg->angle ? xm : x), ym, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf1, (ndg->angle ? xp : x), yp, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf1, x, y, c);
}
}
@@ -162,11 +162,11 @@
xm = x - i;
xp = x + i;
qd_getPixel(tbuf1, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf1, (ndg->angle ? xm : x), ym, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf1, (ndg->angle ? xp : x), yp, tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf1, x, y, c);
}
}
@@ -179,11 +179,11 @@
xm = x - i;
xp = x + i;
qd_getPixel(tbuf2, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf2, xm, (ndg->angle ? yp : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf2, xp, (ndg->angle ? ym : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf2, x, y, c);
}
}
@@ -195,11 +195,11 @@
xm = x - i;
xp = x + i;
qd_getPixel(tbuf2, x, y, c);
- fRGB_mult(c, f1);
+ mul_v3_fl(c, f1);
qd_getPixel(tbuf2, xm, (ndg->angle ? yp : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_getPixel(tbuf2, xp, (ndg->angle ? ym : y), tc);
- fRGB_madd(c, tc, f2);
+ madd_v3_v3fl(c, tc, f2);
qd_setPixel(tbuf2, x, y, c);
}
}
@@ -342,11 +342,11 @@
s = (u-0.5f)*sc + 0.5f, t = (v-0.5f)*sc + 0.5f;
qd_getPixelLerp(tbuf1, s*gbuf->x, t*gbuf->y, c);
sm = smoothMask(s, t);
- fRGB_mult(c, sm);
+ mul_v3_fl(c, sm);
s = (u-0.5f)*isc + 0.5f, t = (v-0.5f)*isc + 0.5f;
qd_getPixelLerp(tbuf2, s*gbuf->x - 0.5f, t*gbuf->y - 0.5f, tc);
sm = smoothMask(s, t);
- fRGB_madd(c, tc, sm);
+ madd_v3_v3fl(c, tc, sm);
qd_setPixel(gbuf, x, y, c);
}
}
@@ -363,9 +363,9 @@
s = (u-0.5f)*scalef[np] + 0.5f;
t = (v-0.5f)*scalef[np] + 0.5f;
qd_getPixelLerp(gbuf, s*gbuf->x - 0.5f, t*gbuf->y - 0.5f, c);
- fRGB_colormult(c, cm[np]);
+ mul_v3_v3(c, cm[np]);
sm = smoothMask(s, t)*0.25f;
- fRGB_madd(tc, c, sm);
+ madd_v3_v3fl(tc, c, sm);
}
p = (x + y*tbuf1->x)*tbuf1->type;
tbuf1->rect[p] += tc[0];
@@ -413,7 +413,7 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list