mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 16:40:41 -05:00
264 lines
7.6 KiB
Diff
264 lines
7.6 KiB
Diff
|
diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c
|
||
|
index 3e4df4d..74a5c7a 100644
|
||
|
--- a/clutter/clutter-alpha.c
|
||
|
+++ b/clutter/clutter-alpha.c
|
||
|
@@ -694,6 +694,11 @@ clutter_ramp_func (ClutterAlpha *alpha,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
+#if 0
|
||
|
+/*
|
||
|
+ * The following three functions are left in place for reference
|
||
|
+ * purposes.
|
||
|
+ */
|
||
|
static guint32
|
||
|
sincx1024_func (ClutterAlpha *alpha,
|
||
|
ClutterAngle angle,
|
||
|
@@ -713,7 +718,7 @@ sincx1024_func (ClutterAlpha *alpha,
|
||
|
|
||
|
x -= (512 * 512 / angle);
|
||
|
|
||
|
- sine = ((sinf (x) + offset) / 2)
|
||
|
+ sine = ((cogl_angle_sin (x) + offset) / 2)
|
||
|
* CLUTTER_ALPHA_MAX_ALPHA;
|
||
|
|
||
|
sine = sine >> COGL_FIXED_Q;
|
||
|
@@ -721,11 +726,6 @@ sincx1024_func (ClutterAlpha *alpha,
|
||
|
return sine;
|
||
|
}
|
||
|
|
||
|
-#if 0
|
||
|
-/*
|
||
|
- * The following two functions are left in place for reference
|
||
|
- * purposes.
|
||
|
- */
|
||
|
static guint32
|
||
|
sincx_func (ClutterAlpha *alpha,
|
||
|
ClutterFixed angle,
|
||
|
@@ -744,7 +744,7 @@ sincx_func (ClutterAlpha *alpha,
|
||
|
x = CLUTTER_FIXED_MUL (x, CFX_PI)
|
||
|
- CLUTTER_FIXED_DIV (CFX_PI, angle);
|
||
|
|
||
|
- sine = (sinf (x) + offset) / 2;
|
||
|
+ sine = (cogl_angle_sin (x) + offset) / 2;
|
||
|
|
||
|
CLUTTER_NOTE (ALPHA, "sine: %2f\n", CLUTTER_FIXED_TO_DOUBLE (sine));
|
||
|
|
||
|
@@ -803,9 +803,25 @@ guint32
|
||
|
clutter_sine_func (ClutterAlpha *alpha,
|
||
|
gpointer dummy)
|
||
|
{
|
||
|
-#if 0
|
||
|
+#if 1
|
||
|
+ ClutterTimeline *timeline;
|
||
|
+ gint current_frame_num, n_frames;
|
||
|
+ float radians, sine;
|
||
|
+
|
||
|
+ timeline = clutter_alpha_get_timeline (alpha);
|
||
|
+
|
||
|
+ current_frame_num = clutter_timeline_get_current_frame (timeline);
|
||
|
+ n_frames = clutter_timeline_get_n_frames (timeline);
|
||
|
+
|
||
|
+ radians = ((float)current_frame_num / n_frames) * (2.0 * G_PI);
|
||
|
+ sine = sinf (radians);
|
||
|
+
|
||
|
+ CLUTTER_NOTE (ALPHA, "sine: %2f\n", sine);
|
||
|
+
|
||
|
+ return COGL_FLOAT_TO_INT ((sine * CLUTTER_ALPHA_MAX_ALPHA));
|
||
|
+#elif 0
|
||
|
return sinc_func (alpha, 2.0, 1.0);
|
||
|
-#else
|
||
|
+#elif 0
|
||
|
/* 2.0 above represents full circle */
|
||
|
return sincx1024_func (alpha, 1024, 1.0);
|
||
|
#endif
|
||
|
@@ -839,18 +855,17 @@ clutter_sine_inc_func (ClutterAlpha *alpha,
|
||
|
ClutterTimeline * timeline;
|
||
|
gint frame;
|
||
|
gint n_frames;
|
||
|
- ClutterAngle x;
|
||
|
- ClutterFixed sine;
|
||
|
+ float radians;
|
||
|
+ float sine;
|
||
|
|
||
|
timeline = clutter_alpha_get_timeline (alpha);
|
||
|
frame = clutter_timeline_get_current_frame (timeline);
|
||
|
n_frames = clutter_timeline_get_n_frames (timeline);
|
||
|
|
||
|
- x = 256 * frame / n_frames;
|
||
|
-
|
||
|
- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA;
|
||
|
+ radians = ((float)frame / n_frames) * (G_PI / 2);
|
||
|
+ sine = sinf (radians);
|
||
|
|
||
|
- return ((guint32) sine) >> COGL_FIXED_Q;
|
||
|
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
@@ -881,18 +896,17 @@ clutter_sine_dec_func (ClutterAlpha *alpha,
|
||
|
ClutterTimeline * timeline;
|
||
|
gint frame;
|
||
|
gint n_frames;
|
||
|
- ClutterAngle x;
|
||
|
- ClutterFixed sine;
|
||
|
+ float radians;
|
||
|
+ float sine;
|
||
|
|
||
|
timeline = clutter_alpha_get_timeline (alpha);
|
||
|
frame = clutter_timeline_get_current_frame (timeline);
|
||
|
n_frames = clutter_timeline_get_n_frames (timeline);
|
||
|
|
||
|
- x = 256 * frame / n_frames + 256;
|
||
|
-
|
||
|
- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA;
|
||
|
+ radians = ((float)frame / n_frames) * (G_PI / 2);
|
||
|
+ sine = sinf (radians + (G_PI / 2));
|
||
|
|
||
|
- return ((guint32) sine) >> COGL_FIXED_Q;
|
||
|
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
@@ -923,18 +937,17 @@ clutter_sine_half_func (ClutterAlpha *alpha,
|
||
|
ClutterTimeline *timeline;
|
||
|
gint frame;
|
||
|
gint n_frames;
|
||
|
- ClutterAngle x;
|
||
|
- ClutterFixed sine;
|
||
|
+ float radians;
|
||
|
+ float sine;
|
||
|
|
||
|
timeline = clutter_alpha_get_timeline (alpha);
|
||
|
frame = clutter_timeline_get_current_frame (timeline);
|
||
|
n_frames = clutter_timeline_get_n_frames (timeline);
|
||
|
|
||
|
- x = 512 * frame / n_frames;
|
||
|
+ radians = ((float)frame / n_frames) * G_PI;
|
||
|
+ sine = sinf (radians);
|
||
|
|
||
|
- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA;
|
||
|
-
|
||
|
- return ((guint32) sine) >> COGL_FIXED_Q;
|
||
|
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
@@ -959,19 +972,17 @@ clutter_sine_in_func (ClutterAlpha *alpha,
|
||
|
ClutterTimeline *timeline;
|
||
|
gint frame;
|
||
|
gint n_frames;
|
||
|
- ClutterAngle x;
|
||
|
- ClutterFixed sine;
|
||
|
+ float radians;
|
||
|
+ float sine;
|
||
|
|
||
|
timeline = clutter_alpha_get_timeline (alpha);
|
||
|
frame = clutter_timeline_get_current_frame (timeline);
|
||
|
n_frames = clutter_timeline_get_n_frames (timeline);
|
||
|
|
||
|
- /* XXX- if we use 768 we overflow */
|
||
|
- x = 256 * frame / n_frames + 767;
|
||
|
-
|
||
|
- sine = (sinf (x) + 1) * CLUTTER_ALPHA_MAX_ALPHA;
|
||
|
+ radians = ((float)frame / n_frames) * (G_PI / 2);
|
||
|
+ sine = sinf (radians - (G_PI / 2)) + 1.0;
|
||
|
|
||
|
- return ((guint32) sine) >> COGL_FIXED_Q;
|
||
|
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
@@ -995,18 +1006,17 @@ clutter_sine_out_func (ClutterAlpha *alpha,
|
||
|
ClutterTimeline *timeline;
|
||
|
gint frame;
|
||
|
gint n_frames;
|
||
|
- ClutterAngle x;
|
||
|
- ClutterFixed sine;
|
||
|
+ float radians;
|
||
|
+ float sine;
|
||
|
|
||
|
timeline = clutter_alpha_get_timeline (alpha);
|
||
|
frame = clutter_timeline_get_current_frame (timeline);
|
||
|
n_frames = clutter_timeline_get_n_frames (timeline);
|
||
|
|
||
|
- x = 256 * frame / n_frames;
|
||
|
-
|
||
|
- sine = sinf (x) * CLUTTER_ALPHA_MAX_ALPHA;
|
||
|
+ radians = ((float)frame / n_frames) * (G_PI / 2);
|
||
|
+ sine = sinf (radians);
|
||
|
|
||
|
- return ((guint32) sine) >> COGL_FIXED_Q;
|
||
|
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
@@ -1031,18 +1041,17 @@ clutter_sine_in_out_func (ClutterAlpha *alpha,
|
||
|
ClutterTimeline *timeline;
|
||
|
gint frame;
|
||
|
gint n_frames;
|
||
|
- ClutterAngle x;
|
||
|
- ClutterFixed sine;
|
||
|
+ float radians;
|
||
|
+ float sine;
|
||
|
|
||
|
timeline = clutter_alpha_get_timeline (alpha);
|
||
|
frame = clutter_timeline_get_current_frame (timeline);
|
||
|
n_frames = clutter_timeline_get_n_frames (timeline);
|
||
|
|
||
|
- x = -256 * frame / n_frames + 256;
|
||
|
+ radians = ((float)frame / n_frames) * G_PI;
|
||
|
+ sine = (sinf (radians - (G_PI / 2)) + 1.0) / 2.0;
|
||
|
|
||
|
- sine = (sinf (x) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA;
|
||
|
-
|
||
|
- return ((guint32) sine) >> COGL_FIXED_Q;
|
||
|
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
@@ -1201,9 +1210,9 @@ clutter_exp_inc_func (ClutterAlpha *alpha,
|
||
|
*
|
||
|
* (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA
|
||
|
*/
|
||
|
-#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff
|
||
|
-#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA
|
||
|
-#endif
|
||
|
+ /* XXX: If this fails:
|
||
|
+ * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */
|
||
|
+ g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0);
|
||
|
|
||
|
timeline = clutter_alpha_get_timeline (alpha);
|
||
|
frame = clutter_timeline_get_current_frame (timeline);
|
||
|
@@ -1211,7 +1220,7 @@ clutter_exp_inc_func (ClutterAlpha *alpha,
|
||
|
|
||
|
x = x_alpha_max * frame / n_frames;
|
||
|
|
||
|
- result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
+ result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
@@ -1252,9 +1261,9 @@ clutter_exp_dec_func (ClutterAlpha *alpha,
|
||
|
*
|
||
|
* (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA
|
||
|
*/
|
||
|
-#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff
|
||
|
-#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA
|
||
|
-#endif
|
||
|
+ /* XXX: If this fails:
|
||
|
+ * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */
|
||
|
+ g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0);
|
||
|
|
||
|
timeline = clutter_alpha_get_timeline (alpha);
|
||
|
frame = clutter_timeline_get_current_frame (timeline);
|
||
|
@@ -1262,7 +1271,7 @@ clutter_exp_dec_func (ClutterAlpha *alpha,
|
||
|
|
||
|
x = (x_alpha_max * (n_frames - frame)) / n_frames;
|
||
|
|
||
|
- result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
+ result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
|
||
|
|
||
|
return result;
|
||
|
}
|