Replaces uses of CoglAngle with floats (Though the CoglAngle type remains)
authorRobert Bragg <robert@linux.intel.com>
Wed, 7 Jan 2009 15:33:24 +0000 (15:33 +0000)
committerRobert Bragg <robert@linux.intel.com>
Thu, 8 Jan 2009 11:47:27 +0000 (11:47 +0000)
The CoglAngle type can still be used for focused optimisations since the type
and macros remain. Uses of CoglAngle within Cogl have been replaced with floats;
COGL_ANGLE_FROM_DEG is no longer used anywhere and the replacements for
cogl_angle_cos -> cosf (same for sin) have been fixed to convert float values
in degrees to radians. This fixes the cogl-primitives API.

fixed-to-float.sh

index 61088b2..49cc145 100755 (executable)
@@ -51,9 +51,11 @@ find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_1/1.0/g' {} \;
 find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_0_5/0.5/g' {} \;
 find ./clutter -iname '*.[ch]' -exec sed -i 's/COGL_FIXED_PI/G_PI/g' {} \;
 
-find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_angle_cos/cosf/g' {} \;
-find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_angle_sin/sinf/g' {} \;
-find ./clutter -iname '*.[ch]' -exec sed -i 's/cogl_angle_tan/tanf/g' {} \;
+find ./clutter -iname '*.[ch]' -exec sed -i -r 's/COGL_ANGLE_FROM_DEG \((.*)\),/\1,/g' {} \;
+
+find ./clutter -iname '*.[ch]' -exec perl -p -i -e "s|cogl_angle_cos \((.*?)\)|cosf (\1 * (G_PI/180.0))|;" {} \;
+find ./clutter -iname '*.[ch]' -exec perl -p -i -e "s|cogl_angle_sin \((.*?)\)|sinf (\1 * (G_PI/180.0))|;" {} \;
+find ./clutter -iname '*.[ch]' -exec perl -p -i -e "s|cogl_angle_tan \((.*?)\)|tanf (\1 * (G_PI/180.0))|;" {} \;
 
 #XXX: NB: cogl_fixed_div must be done before mul since there is a case were they
 #are nested which would otherwise break the assumption used here that the last
@@ -104,6 +106,15 @@ sed -i 's/float:/CoglFixed:/g' clutter/cogl/cogl-types.h
 sed -i 's/gint32 float/gint32 CoglFixed/g' clutter/cogl/cogl-types.h
 git-checkout clutter/cogl/cogl-fixed.h clutter/cogl/common/cogl-fixed.c
 
+find ./clutter -iname '*.[ch]' -exec sed -i 's/CoglAngle/float/g' {} \;
+
+# maintain the existing CoglAngle code as utility code for applications:
+sed -i 's/float:/CoglAngle:/g' clutter/cogl/cogl-types.h
+sed -i 's/gint32 float/gint32 CoglAngle/g' clutter/cogl/cogl-types.h
+git-checkout clutter/cogl/cogl-fixed.h clutter/cogl/common/cogl-fixed.c
+
+find ./clutter -iname '*.[ch]' ! -iname 'clutter-fixed.h' -exec sed -i 's/ClutterAngle/float/g' {} \;
+
 echo "Cogl API to remove/replace with float versions:"
 find ./clutter/ -iname '*.c' -exec grep '^cogl_[a-zA-Z_]*x ' {} \; | cut -d' ' -f1|grep -v 'box$'|grep -v 'matrix$'
 echo "Clutter API to remove/replace with float versions:"