[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47838] trunk/blender/source/blender/ blenlib: move one line color conversion functions to be inline.

Campbell Barton ideasman42 at gmail.com
Wed Jun 13 17:13:20 CEST 2012


Revision: 47838
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47838
Author:   campbellbarton
Date:     2012-06-13 15:13:19 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
move one line color conversion functions to be inline.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_color.h
    trunk/blender/source/blender/blenlib/intern/math_color.c
    trunk/blender/source/blender/blenlib/intern/math_color_inline.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_color.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_color.h	2012-06-13 15:05:42 UTC (rev 47837)
+++ trunk/blender/source/blender/blenlib/BLI_math_color.h	2012-06-13 15:13:19 UTC (rev 47838)
@@ -74,12 +74,7 @@
 unsigned int rgb_to_cpack(float r, float g, float b);
 unsigned int hsv_to_cpack(float h, float s, float v);
 
-float rgb_to_grayscale(const float rgb[3]);
-unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]);
-float rgb_to_luma(const float rgb[3]);
-unsigned char rgb_to_luma_byte(const unsigned char rgb[3]);
-float rgb_to_luma_y(const float rgb[3]);
-float rgb_to_luma_rec709_byte(const unsigned char rgb[3]);
+/* rgb_to_grayscale & rgb_to_luma functions moved to math_color_inline.c */
 
 /**************** Profile Transformations *****************/
 

Modified: trunk/blender/source/blender/blenlib/intern/math_color.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_color.c	2012-06-13 15:05:42 UTC (rev 47837)
+++ trunk/blender/source/blender/blenlib/intern/math_color.c	2012-06-13 15:13:19 UTC (rev 47838)
@@ -496,37 +496,6 @@
 	return 0; /* Color within RGB gamut */
 }
 
-float rgb_to_grayscale(const float rgb[3])
-{
-	return 0.3f * rgb[0] + 0.58f * rgb[1] + 0.12f * rgb[2];
-}
-
-unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
-{
-	return (76 * (unsigned short) rgb[0] + 148 * (unsigned short) rgb[1] + 31 * (unsigned short) rgb[2]) / 255;
-}
-
-float rgb_to_luma(const float rgb[3])
-{
-	return 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2];
-}
-
-unsigned char rgb_to_luma_byte(const unsigned char rgb[3])
-{
-	return (76 * (unsigned short) rgb[0] + 150 * (unsigned short) rgb[1] + 29 * (unsigned short) rgb[2]) / 255;
-}
-
-/* gamma-corrected RGB --> CIE XYZ
- * for this function we only get the Y component
- * see: http://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch6/ch6_color_models.html
- *
- * also known as:
- * luminance rec. 709 */
-float rgb_to_luma_y(const float rgb[3])
-{
-	return 0.212671f * rgb[0] + 0.71516f * rgb[1] + 0.072169f * rgb[2];
-}
-
 /* ********************************* lift/gamma/gain / ASC-CDL conversion ********************************* */
 
 void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power)

Modified: trunk/blender/source/blender/blenlib/intern/math_color_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_color_inline.c	2012-06-13 15:05:42 UTC (rev 47837)
+++ trunk/blender/source/blender/blenlib/intern/math_color_inline.c	2012-06-13 15:13:19 UTC (rev 47838)
@@ -222,4 +222,37 @@
 	r_col[2] = ((pack) >> 16) & 0xFF;
 }
 
+
+MINLINE float rgb_to_grayscale(const float rgb[3])
+{
+	return 0.3f * rgb[0] + 0.58f * rgb[1] + 0.12f * rgb[2];
+}
+
+MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
+{
+	return (76 * (unsigned short) rgb[0] + 148 * (unsigned short) rgb[1] + 31 * (unsigned short) rgb[2]) / 255;
+}
+
+MINLINE float rgb_to_luma(const float rgb[3])
+{
+	return 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2];
+}
+
+MINLINE unsigned char rgb_to_luma_byte(const unsigned char rgb[3])
+{
+	return (76 * (unsigned short) rgb[0] + 150 * (unsigned short) rgb[1] + 29 * (unsigned short) rgb[2]) / 255;
+}
+
+/* gamma-corrected RGB --> CIE XYZ
+ * for this function we only get the Y component
+ * see: http://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch6/ch6_color_models.html
+ *
+ * also known as:
+ * luminance rec. 709 */
+MINLINE float rgb_to_luma_y(const float rgb[3])
+{
+	return 0.212671f * rgb[0] + 0.71516f * rgb[1] + 0.072169f * rgb[2];
+}
+
+
 #endif /* __MATH_COLOR_INLINE_C__ */




More information about the Bf-blender-cvs mailing list