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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-08-11 00:17:11 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-08-11 00:17:11 +0400
commit0b2324f679c84a96f6a076da7f9822ef82774e10 (patch)
tree5afaeea63447df1943544953182862b3a5b2c463 /source/blender/blenkernel/intern/colortools.c
parent690e117ed3dbee183cd0632ee899c3022a806854 (diff)
2.5: Small optimization in color management code to avoid doing
computation with doubles instead of floats, about 2x faster.
Diffstat (limited to 'source/blender/blenkernel/intern/colortools.c')
-rw-r--r--source/blender/blenkernel/intern/colortools.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 2280ec71f7a..26f9245abc7 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -68,33 +68,33 @@
void gamma_correct_rec709(float *c, float gamma)
{
/* Rec. 709 gamma correction. */
- float cc = 0.018f;
+ const float cc = 0.018f;
if (*c < cc)
- *c *= ((1.099f * (float)pow(cc, gamma)) - 0.099f) / cc;
+ *c *= ((1.099f * (float)powf(cc, gamma)) - 0.099f) * (1.0f/cc);
else
- *c = (1.099f * (float)pow(*c, gamma)) - 0.099f;
+ *c = (1.099f * (float)powf(*c, gamma)) - 0.099f;
}
void gamma_correct(float *c, float gamma)
{
- *c = pow((*c), gamma);
+ *c = powf((*c), gamma);
}
float srgb_to_linearrgb(float c)
{
if (c < 0.04045f)
- return (c < 0.f)?0.f:c / 12.92;
+ return (c < 0.0f)? 0.0f: c*(1.0f/12.92f);
else
- return pow((c + 0.055)/1.055, 2.4);
+ return powf((c + 0.055f)*(1.0f/1.055f), 2.4f);
}
float linearrgb_to_srgb(float c)
{
- if (c < 0.0031308)
- return (c < 0.f)?0.f:c * 12.92;
+ if (c < 0.0031308f)
+ return (c < 0.0f)? 0.0f: c * 12.92f;
else
- return 1.055 * pow(c, 1.0/2.4) - 0.055;
+ return 1.055f * powf(c, 1.0f/2.4f) - 0.055f;
}
/* utility function convert an RGB triplet from sRGB to linear RGB color space */