From 65e7bc636394f12e6f11cc6c5ba0c113c3a11bc1 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 7 Jan 2009 15:33:24 +0000 Subject: [PATCH] Replaces uses of CoglAngle with floats (Though the CoglAngle type remains) 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 | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/fixed-to-float.sh b/fixed-to-float.sh index 61088b23b..49cc14594 100755 --- a/fixed-to-float.sh +++ b/fixed-to-float.sh @@ -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:"