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-08-21 12:30:45 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-21 12:30:45 +0400
commit988df245519352ab80d8ad488660a0a2f7a963d3 (patch)
tree91f0e61c6543d0eda2af9794d5a7938b6e583072 /source/blender/blenkernel/intern/colortools.c
parent49d3766ceb17082fd64cdc0f01224237f1098564 (diff)
compositor color curve was MEM_dupallocN'ing the curve for every pixel calculation (when there were black or white inputs on the curve node).
avoid allocation by using local vars for black/white storage & curve calculation.
Diffstat (limited to 'source/blender/blenkernel/intern/colortools.c')
-rw-r--r--source/blender/blenkernel/intern/colortools.c55
1 files changed, 44 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 118169e8f7d..606fd83b1a5 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -145,21 +145,31 @@ CurveMapping *curvemapping_copy(CurveMapping *cumap)
return NULL;
}
-void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3])
+void curvemapping_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3])
{
int a;
-
- if (white)
+
+ for (a = 0; a < 3; a++) {
+ const float delta = white[a] - black[a];
+ if (delta != 0.0f) {
+ r_bwmul[a] = 1.0f / delta;
+ }
+ else {
+ r_bwmul[a] = 0.0f;
+ }
+ }
+}
+
+void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3])
+{
+ if (white) {
copy_v3_v3(cumap->white, white);
- if (black)
+ }
+ if (black) {
copy_v3_v3(cumap->black, black);
-
- for (a = 0; a < 3; a++) {
- if (cumap->white[a] == cumap->black[a])
- cumap->bwmul[a] = 0.0f;
- else
- cumap->bwmul[a] = 1.0f / (cumap->white[a] - cumap->black[a]);
- }
+ }
+
+ curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul);
}
/* ***************** operations on single curve ************* */
@@ -785,6 +795,29 @@ void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float
vecout[2] = curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2]));
}
+/** same as #curvemapping_evaluate_premulRGBF
+ * but black/bwmul are passed as args for the compositor
+ * where they can change per pixel.
+ *
+ * Use in conjunction with #curvemapping_set_black_white_ex
+ *
+ * \param black Use instead of cumap->black
+ * \param bwmul Use instead of cumap->bwmul
+ */
+void curvemapping_evaluate_premulRGBF_ex(CurveMapping *cumap, float vecout[3], const float vecin[3],
+ const float black[3], const float bwmul[3])
+{
+ float fac;
+
+ fac = (vecin[0] - black[0]) * bwmul[0];
+ vecout[0] = curvemap_evaluateF(cumap->cm, fac);
+
+ fac = (vecin[1] - black[1]) * bwmul[1];
+ vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac);
+
+ fac = (vecin[2] - black[2]) * bwmul[2];
+ vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac);
+}
/* RGB with black/white points and premult. tables are checked */
void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3])