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>2018-05-07 18:31:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-07 18:51:40 +0300
commitf74d85ffc8232a859b1419f5dc25b244ae04375f (patch)
treef74928d7681488c044ea65249eaaa5b6900d246b /source/blender/blenlib/intern/math_base_inline.c
parent905eeb0bc7f46efb95cb5450cc6c2ec27f02730c (diff)
Cleanup: rename char/float conversion functions
- FTOCHAR -> unit_float_to_uchar_clamp - F3TOCHAR3 -> unit_float_to_uchar_clamp_v3 (swap args) - F4TOCHAR4 -> unit_float_to_uchar_clamp_v4 (swap args) - FTOUSHORT -> unit_float_to_ushort_clamp - USHORTTOUCHAR -> unit_ushort_to_uchar
Diffstat (limited to 'source/blender/blenlib/intern/math_base_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 82ed6cd1cd1..268279f98b1 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -514,35 +514,34 @@ MALWAYS_INLINE __m128 _bli_math_blend_sse(const __m128 mask,
}
/* Low level conversion functions */
-/* TODO: name sensibly. */
-MINLINE unsigned char FTOCHAR(float val)
+MINLINE unsigned char unit_float_to_uchar_clamp(float val)
{
return (unsigned char)(((val <= 0.0f) ? 0 : ((val > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * val) + 0.5f))));
}
-#define FTOCHAR(val) ((CHECK_TYPE_INLINE(val, float)), FTOCHAR(val))
+#define unit_float_to_uchar_clamp(val) ((CHECK_TYPE_INLINE(val, float)), unit_float_to_uchar_clamp(val))
-MINLINE unsigned short FTOUSHORT(float val)
+MINLINE unsigned short unit_float_to_ushort_clamp(float val)
{
return (unsigned short)((val >= 1.0f - 0.5f / 65535) ? 65535 : (val <= 0.0f) ? 0 : (val * 65535.0f + 0.5f));
}
-#define FTOUSHORT(val) ((CHECK_TYPE_INLINE(val, float)), FTOUSHORT(val))
+#define unit_float_to_ushort_clamp(val) ((CHECK_TYPE_INLINE(val, float)), unit_float_to_ushort_clamp(val))
-MINLINE unsigned char USHORTTOUCHAR(unsigned short val)
+MINLINE unsigned char unit_ushort_to_uchar(unsigned short val)
{
return (unsigned char)(((val) >= 65535 - 128) ? 255 : ((val) + 128) >> 8);
}
-#define USHORTTOUCHAR(val) ((CHECK_TYPE_INLINE(val, unsigned short)), USHORTTOUCHAR(val))
+#define unit_ushort_to_uchar(val) ((CHECK_TYPE_INLINE(val, unsigned short)), unit_ushort_to_uchar(val))
-#define F3TOCHAR3(v2, v1) { \
- (v1)[0] = FTOCHAR((v2[0])); \
- (v1)[1] = FTOCHAR((v2[1])); \
- (v1)[2] = FTOCHAR((v2[2])); \
+#define unit_float_to_uchar_clamp_v3(v1, v2) { \
+ (v1)[0] = unit_float_to_uchar_clamp((v2[0])); \
+ (v1)[1] = unit_float_to_uchar_clamp((v2[1])); \
+ (v1)[2] = unit_float_to_uchar_clamp((v2[2])); \
} ((void)0)
-#define F4TOCHAR4(v2, v1) { \
- (v1)[0] = FTOCHAR((v2[0])); \
- (v1)[1] = FTOCHAR((v2[1])); \
- (v1)[2] = FTOCHAR((v2[2])); \
- (v1)[3] = FTOCHAR((v2[3])); \
+#define unit_float_to_uchar_clamp_v4(v1, v2) { \
+ (v1)[0] = unit_float_to_uchar_clamp((v2[0])); \
+ (v1)[1] = unit_float_to_uchar_clamp((v2[1])); \
+ (v1)[2] = unit_float_to_uchar_clamp((v2[2])); \
+ (v1)[3] = unit_float_to_uchar_clamp((v2[3])); \
} ((void)0)
#endif /* __SSE2__ */