mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 16:40:41 -05:00
e8915fcb12
This commit doesn't actually include any direct changes to source; you have to run ./fixed-to-float.sh. Note: the script will make a number of commits itself to your git repository a various stages of the script. You will need to reset these if you want to re-run the script. * NB: Be carefull about how you reset your tree, if you are making changes to the script and patches, so you don't loose your changes * This aims to remove all use of fixed point within Clutter and Cogl. It aims to not break the Clutter API, including maintaining the CLUTTER_FIXED macros, (though they now handle floats not 16.16 fixed) It maintains cogl-fixed.[ch] as a utility API that can be used by applications (and potentially for focused internal optimisations), but all Cogl interfaces now accept floats in place of CoglFixed. Note: the choice to to use single precision floats, not doubles is very intentional. GPUs are basically all single precision; only this year have high end cards started adding double precision - aimed mostly at the GPGPU market. This means if you pass doubles into any GL[ES] driver, you can expect those numbers to be cast to a float. (Certainly this is true of Mesa wich casts most things to floats internally) It can be a noteable performance issue to cast from double->float frequently, and if we were to have an api defined in terms of doubles, that would imply a *lot* of unneeded casting. One of the noteable issues with fixed point was the amount of casting required, so I don't want to overshoot the mark and require just as much casting still. Double precision arithmatic is also slower, so it usually makes sense to minimize its use if the extra precision isn't needed. In the same way that the fast/low precision fixed API can be used sparingly for optimisations; if needs be in certain situations we can promote to doubles internally for higher precision. E.g. quoting Brian Paul (talking about performance optimisations for GL programmers): "Avoid double precision valued functions Mesa does all internal floating point computations in single precision floating point. API functions which take double precision floating point values must convert them to single precision. This can be expensive in the case of glVertex, glNormal, etc. "
86 lines
3.0 KiB
Diff
86 lines
3.0 KiB
Diff
diff --git a/clutter/clutter-units.h b/clutter/clutter-units.h
|
|
index 8337d19..2a8ef65 100644
|
|
--- a/clutter/clutter-units.h
|
|
+++ b/clutter/clutter-units.h
|
|
@@ -42,7 +42,7 @@ G_BEGIN_DECLS
|
|
*
|
|
* Since: 0.4
|
|
*/
|
|
-typedef gint32 ClutterUnit;
|
|
+typedef float ClutterUnit;
|
|
|
|
/*
|
|
* Currently CLUTTER_UNIT maps directly onto ClutterFixed. Nevertheless, the
|
|
@@ -50,11 +50,11 @@ typedef gint32 ClutterUnit;
|
|
* decide to change this relationship in the future.
|
|
*/
|
|
|
|
-#define CLUTTER_UNITS_FROM_INT(x) (COGL_FIXED_FROM_INT ((x)))
|
|
-#define CLUTTER_UNITS_TO_INT(x) (COGL_FIXED_TO_INT ((x)))
|
|
+#define CLUTTER_UNITS_FROM_INT(x) ((float)(x))
|
|
+#define CLUTTER_UNITS_TO_INT(x) ((int)(x))
|
|
|
|
-#define CLUTTER_UNITS_FROM_FLOAT(x) (COGL_FIXED_FROM_FLOAT ((x)))
|
|
-#define CLUTTER_UNITS_TO_FLOAT(x) (COGL_FIXED_TO_FLOAT ((x)))
|
|
+#define CLUTTER_UNITS_FROM_FLOAT(x) (x)
|
|
+#define CLUTTER_UNITS_TO_FLOAT(x) (x)
|
|
|
|
#define CLUTTER_UNITS_FROM_FIXED(x) (x)
|
|
#define CLUTTER_UNITS_TO_FIXED(x) (x)
|
|
@@ -90,7 +90,7 @@ typedef gint32 ClutterUnit;
|
|
*
|
|
* Since: 0.6
|
|
*/
|
|
-#define CLUTTER_UNITS_FROM_PANGO_UNIT(x) ((x) << 6)
|
|
+#define CLUTTER_UNITS_FROM_PANGO_UNIT(x) ((float)(x / 1024))
|
|
|
|
/**
|
|
* CLUTTER_UNITS_TO_PANGO_UNIT:
|
|
@@ -100,7 +100,7 @@ typedef gint32 ClutterUnit;
|
|
*
|
|
* Since: 0.6
|
|
*/
|
|
-#define CLUTTER_UNITS_TO_PANGO_UNIT(x) ((x) >> 6)
|
|
+#define CLUTTER_UNITS_TO_PANGO_UNIT(x) ((int)(x * 1024))
|
|
|
|
#define CLUTTER_UNITS_FROM_STAGE_WIDTH_PERCENTAGE(x) \
|
|
((clutter_actor_get_widthu (clutter_stage_get_default ()) * x) / 100)
|
|
@@ -125,8 +125,7 @@ typedef gint32 ClutterUnit;
|
|
#define CLUTTER_UNITS_FROM_MM(x) \
|
|
(CLUTTER_UNITS_FROM_FLOAT ((((x) * clutter_stage_get_resolution ((ClutterStage *) clutter_stage_get_default ())) / 25.4)))
|
|
|
|
-#define CLUTTER_UNITS_FROM_MMX(x) \
|
|
- (CFX_DIV (CFX_MUL ((x), clutter_stage_get_resolutionx ((ClutterStage *) clutter_stage_get_default ())), 0x196666))
|
|
+#define CLUTTER_UNITS_FROM_MMX(x) CLUTTER_UNITS_FROM_MM
|
|
|
|
/**
|
|
* CLUTTER_UNITS_FROM_POINTS:
|
|
@@ -139,9 +138,6 @@ typedef gint32 ClutterUnit;
|
|
#define CLUTTER_UNITS_FROM_POINTS(x) \
|
|
CLUTTER_UNITS_FROM_FLOAT ((((x) * clutter_stage_get_resolution ((ClutterStage *) clutter_stage_get_default ())) / 72.0))
|
|
|
|
-#define CLUTTER_UNITS_FROM_POINTSX(x) \
|
|
- (CFX_MUL ((x), clutter_stage_get_resolutionx ((ClutterStage *) clutter_stage_get_default ())) / 72)
|
|
-
|
|
#define CLUTTER_TYPE_UNIT (clutter_unit_get_type ())
|
|
#define CLUTTER_TYPE_PARAM_UNIT (clutter_param_unit_get_type ())
|
|
#define CLUTTER_PARAM_SPEC_UNIT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), CLUTTER_TYPE_PARAM_UNIT, ClutterParamSpecUnit))
|
|
@@ -154,7 +150,7 @@ typedef gint32 ClutterUnit;
|
|
*
|
|
* Since: 0.8
|
|
*/
|
|
-#define CLUTTER_MAXUNIT (0x7fffffff)
|
|
+#define CLUTTER_MAXUNIT (G_MAXFLOAT)
|
|
|
|
/**
|
|
* CLUTTER_MINUNIT:
|
|
@@ -163,7 +159,7 @@ typedef gint32 ClutterUnit;
|
|
*
|
|
* Since: 0.8
|
|
*/
|
|
-#define CLUTTER_MINUNIT (0x80000000)
|
|
+#define CLUTTER_MINUNIT (-G_MAXFLOAT)
|
|
|
|
/**
|
|
* CLUTTER_VALUE_HOLDS_UNIT:
|