mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 19:12:04 +00:00
more fixed point work
This commit is contained in:
parent
b8b0d01c91
commit
685c583d51
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
2007-01-23 Tomas Frydrych <tf@openedhand.com>
|
||||
|
||||
* clutter/clutter-fixed.c:
|
||||
(_clutter_double_to_fixed):
|
||||
(_clutter_double_to_int):
|
||||
Fixed to avoid problems with punned pointers and gcc
|
||||
optimatisation.
|
||||
|
||||
* clutter/pango/pangoclutter-private.h:
|
||||
Simplified PANGO_PIXELS_26_6 macro.
|
||||
|
||||
* clutter/pango/pangoclutter-font.c:
|
||||
(_pango_clutter_font_new):
|
||||
Replace floating with fixed point math.
|
||||
|
||||
2007-01-19 Tomas Frydrych <tf@openedhand.com>
|
||||
|
||||
* clutter/clutter-fixed.c: (clutter_sqrti):
|
||||
|
@ -538,8 +538,15 @@ const double _magic = 68719476736.0*1.5;
|
||||
ClutterFixed
|
||||
_clutter_double_to_fixed (double val)
|
||||
{
|
||||
val = val + _magic;
|
||||
return ((gint32*)&val)[_CFX_MAN];
|
||||
union
|
||||
{
|
||||
double d;
|
||||
unsigned int i[2];
|
||||
} dbl;
|
||||
|
||||
dbl.d = val;
|
||||
dbl.d = dbl.d + _magic;
|
||||
return dbl.i[0];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -556,8 +563,15 @@ _clutter_double_to_fixed (double val)
|
||||
ClutterFixed
|
||||
_clutter_double_to_int (double val)
|
||||
{
|
||||
val = val + _magic;
|
||||
return ((gint32*)&val)[_CFX_MAN] >> 16;
|
||||
union
|
||||
{
|
||||
double d;
|
||||
unsigned int i[2];
|
||||
} dbl;
|
||||
|
||||
dbl.d = val;
|
||||
dbl.d = dbl.d + _magic;
|
||||
return dbl.i[0] >> 16;
|
||||
}
|
||||
|
||||
#undef _CFX_MAN
|
||||
|
@ -79,7 +79,14 @@ _pango_clutter_font_new (PangoClutterFontMap *fontmap_, FcPattern *pattern)
|
||||
NULL);
|
||||
|
||||
if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &d) == FcResultMatch)
|
||||
font->size = d * PANGO_SCALE;
|
||||
{
|
||||
/* Cannot use 16.16 fixed here, because multiplying by PANGO_SCALE
|
||||
* could easily take us out of range, but we do not need the 16 bit
|
||||
* precission for the fraction, so we use 20.12 fixed point here
|
||||
*/
|
||||
int f = CLUTTER_FLOAT_TO_FIXED (d) >> 4;
|
||||
font->size = (f * PANGO_SCALE) >> 12;
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
@ -29,10 +29,23 @@
|
||||
/* Defines duped */
|
||||
|
||||
#define PANGO_SCALE_26_6 (PANGO_SCALE / (1<<6))
|
||||
|
||||
/* We only use the PANGO_SCALE_26_6 macro for scaling font size.
|
||||
* Font sizes are normally given in points with at most one single
|
||||
* decimal place fraction. If we do not do the rounding here, we will
|
||||
* be suffering from an error < 0.016pt, which is entirely negligeable
|
||||
* as far as font sizes are concerned.
|
||||
*/
|
||||
#if 0
|
||||
#define PANGO_PIXELS_26_6(d) \
|
||||
(((d) >= 0) ? \
|
||||
((d) + PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6 : \
|
||||
((d) - PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6)
|
||||
#else
|
||||
#define PANGO_PIXELS_26_6(d) \
|
||||
(d / PANGO_SCALE_26_6)
|
||||
#endif
|
||||
|
||||
#define PANGO_UNITS_26_6(d) (PANGO_SCALE_26_6 * (d))
|
||||
|
||||
#define PANGO_TYPE_CLUTTER_FONT (pango_clutter_font_get_type ())
|
||||
|
Loading…
Reference in New Issue
Block a user