Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-22 11:49:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-22 11:49:44 +0400
commit226c86ae58cdf292fd415db05c05fba46375738d (patch)
tree3f002f89da94cc0428529f469175c311d0341561 /source/blender
parentec3399efa6882ea5a8fe023092c0918ee7b135d9 (diff)
use an inline function for rgb -> bw conversion.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/tracking.c4
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c6
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp2
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp2
-rw-r--r--source/blender/editors/interface/interface_draw.c2
-rw-r--r--source/blender/nodes/composite/node_composite_util.c4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_levels.c11
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_valToRgb.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_valToRgb.c3
-rw-r--r--source/blender/render/intern/source/render_texture.c12
12 files changed, 26 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 3992f2be052..a5c04387b68 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -2396,7 +2396,7 @@ int BKE_tracking_context_step(MovieTrackingContext *context)
ImBuf *destination_ibuf;
int frame_delta = context->backwards ? -1 : 1;
int curfra = BKE_movieclip_remap_scene_to_clip_frame(context->clip, context->user.framenr);
- int nextfra;
+ /* int nextfra; */ /* UNUSED */
int a, ok = FALSE, map_size;
int frame_width, frame_height;
@@ -2414,7 +2414,7 @@ int BKE_tracking_context_step(MovieTrackingContext *context)
if (!destination_ibuf)
return FALSE;
- nextfra = curfra + frame_delta;
+ /* nextfra = curfra + frame_delta; */ /* UNUSED */
frame_width = destination_ibuf->x;
frame_height = destination_ibuf->y;
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 417c557af8a..f270a20003d 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -222,6 +222,12 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack)
r_col[2] = ((pack) >> 16) & 0xFF;
}
+/* XXX - investigate when/why rgb_to_bw & rgb_to_grayscale are different,
+ * and why we use both! whats the purpose of this? */
+MINLINE float rgb_to_bw(const float rgb[3])
+{
+ return 0.35f * rgb[0] + 0.45f * rgb[1] + 0.2f * rgb[2];
+}
MINLINE float rgb_to_grayscale(const float rgb[3])
{
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
index 8ef7605c21a..fe6be55e237 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
@@ -97,7 +97,7 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
{
case 1:
{
- sum += buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f;
+ sum += rgb_to_bw(&buffer[offset]);
break;
}
case 2:
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
index 75f4ac88d0a..811975c5e13 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
@@ -56,7 +56,7 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, Memory
{
case 1:
{
- float value = buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f;
+ float value = rgb_to_bw(&buffer[offset]);
sum += (value - mean) * (value - mean);
break;
}
diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp
index c66cb8df9be..0e2c1e29a1d 100644
--- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp
@@ -38,7 +38,7 @@ void ConvertColorToBWOperation::executePixel(float *outputValue, float x, float
{
float inputColor[4];
inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers);
- outputValue[0] = inputColor[0] * 0.35f + inputColor[1] * 0.45f + inputColor[2] * 0.2f;
+ outputValue[0] = rgb_to_bw(inputColor);
}
void ConvertColorToBWOperation::deinitExecution()
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index b14cbdaffc5..c14e27562b4 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1438,7 +1438,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
glEnd();
}
else if (cumap->cur == 3) {
- float lum = cumap->sample[0] * 0.35f + cumap->sample[1] * 0.45f + cumap->sample[2] * 0.2f;
+ float lum = rgb_to_bw(cumap->sample);
glColor3ub(240, 240, 240);
glBegin(GL_LINES);
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c
index 70788dfe0c8..f6011843b8a 100644
--- a/source/blender/nodes/composite/node_composite_util.c
+++ b/source/blender/nodes/composite/node_composite_util.c
@@ -207,7 +207,7 @@ void typecheck_compbuf_color(float *out, float *in, int outtype, int intype)
*out= 0.333333f*(in[0]+in[1]+in[2]);
}
else if (intype==CB_RGBA) {
- *out= in[0]*0.35f + in[1]*0.45f + in[2]*0.2f;
+ *out = rgb_to_bw(in);
}
}
else if (outtype==CB_VEC2) {
@@ -300,7 +300,7 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type)
}
else if (inbuf->type==CB_RGBA) {
for (; x>0; x--, outrf+= 1, inrf+= 4)
- *outrf= inrf[0]*0.35f + inrf[1]*0.45f + inrf[2]*0.2f;
+ *outrf = rgb_to_bw(inrf);
}
}
else if (type==CB_VEC2) {
diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c
index 5594c20a9df..0aeeb69210d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_levels.c
+++ b/source/blender/nodes/composite/nodes/node_composite_levels.c
@@ -45,11 +45,6 @@ static bNodeSocketTemplate cmp_node_view_levels_out[]={
{-1, 0, ""}
};
-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)
{
float value[4];
@@ -66,7 +61,7 @@ static void fill_bins(bNode* node, CompBuf* in, int* bins)
if (value[3] > 0.0f) { /* don't count transparent pixels */
switch (node->custom1) {
case 1: { /* all colors */
- rgb_tobw(value[0], value[1], value[2], &value[0]);
+ value[0] = rgb_to_bw(value);
value[0]=value[0]*255; /* scale to 0-255 range */
ivalue=(int)value[0];
break;
@@ -125,7 +120,7 @@ static float brightness_mean(bNode* node, CompBuf* in)
switch (node->custom1) {
case 1:
{
- rgb_tobw(value[0], value[1], value[2], &value[0]);
+ value[0] = rgb_to_bw(value);
sum+=value[0];
break;
}
@@ -176,7 +171,7 @@ static float brightness_standard_deviation(bNode* node, CompBuf* in, float mean)
switch (node->custom1) {
case 1:
{
- rgb_tobw(value[0], value[1], value[2], &value[0]);
+ value[0] = rgb_to_bw(value);
sum+=(value[0]-mean)*(value[0]-mean);
break;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c
index bdf6b4f1635..429ba262164 100644
--- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c
+++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c
@@ -111,7 +111,7 @@ static bNodeSocketTemplate cmp_node_rgbtobw_out[]= {
static void do_rgbtobw(bNode *UNUSED(node), float *out, float *in)
{
- out[0]= in[0]*0.35f + in[1]*0.45f + in[2]*0.2f;
+ out[0] = rgb_to_bw(in);
}
static void node_composit_exec_rgbtobw(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
index 1738606082f..fb3316c2036 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
@@ -104,7 +104,7 @@ static void node_shader_exec_rgbtobw(void *UNUSED(data), bNode *UNUSED(node), bN
/* stack order out: bw */
/* stack order in: col */
- out[0]->vec[0]= in[0]->vec[0]*0.35f + in[0]->vec[1]*0.45f + in[0]->vec[2]*0.2f;
+ out[0]->vec[0] = rgb_to_bw(in[0]->vec);
}
static int gpu_shader_rgbtobw(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out)
diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
index d1a02210038..10db0debd5b 100644
--- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
@@ -91,8 +91,7 @@ static void rgbtobw_valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNode
{
float cin[4];
tex_input_rgba(cin, in[0], p, thread);
-
- *out = cin[0] * 0.35f + cin[1] * 0.45f + cin[2] * 0.2f;
+ *out = rgb_to_bw(cin);
}
static void rgbtobw_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index f6fe8e8974d..e2a4ef1dca8 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -2852,7 +2852,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4])
/* texture output */
if (rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
+ texres.tin = rgb_to_bw(&texres.tr);
rgb= 0;
}
if (mtex->texflag & MTEX_NEGATIVE) {
@@ -2919,7 +2919,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4])
if (mtex->mapto & MAP_ALPHA) {
if (rgb) {
if (texres.talpha) texres.tin= texres.ta;
- else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
+ else texres.tin = rgb_to_bw(&texres.tr);
}
col_r[3]*= texres.tin;
@@ -3051,7 +3051,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h
/* texture output */
if (rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
+ texres.tin = rgb_to_bw(&texres.tr);
rgb= 0;
}
if (mtex->texflag & MTEX_NEGATIVE) {
@@ -3124,7 +3124,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h
}
}
if (mtex->mapto & WOMAP_BLEND) {
- if (rgb) texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
+ if (rgb) texres.tin = rgb_to_bw(&texres.tr);
*blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->blendfac, mtex->blendtype);
}
@@ -3264,7 +3264,7 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r
/* texture output */
if (rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb);
+ texres.tin = rgb_to_bw(&texres.tr);
rgb= 0;
}
if (mtex->texflag & MTEX_NEGATIVE) {
@@ -3358,7 +3358,7 @@ int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg,
rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output);
if (rgb) {
- texr.tin= (0.35f*texr.tr+0.45f*texr.tg+0.2f*texr.tb);
+ texr.tin = rgb_to_bw(&texr.tr);
}
else {
texr.tr= mtex->r;