mirror of
https://github.com/brl/mutter.git
synced 2024-11-27 02:20:43 -05:00
012b169a73
Most of the patches updated weren't failing but there were a number of hunk offsets when applying so it tidies that up. The change in mtx_transform.0.patch has been moved to clutter-actor.c.0.patch.
307 lines
9.0 KiB
Diff
307 lines
9.0 KiB
Diff
diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c
|
|
index 60ef0d3..dda0f6c 100644
|
|
--- a/clutter/clutter-alpha.c
|
|
+++ b/clutter/clutter-alpha.c
|
|
@@ -697,6 +697,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,
|
|
float angle,
|
|
@@ -716,7 +721,7 @@ sincx1024_func (ClutterAlpha *alpha,
|
|
|
|
x -= (512 * 512 / angle);
|
|
|
|
- sine = ((sinf (x * (G_PI/180.0)) + offset) / 2)
|
|
+ sine = ((cogl_angle_sin (x) + offset) / 2)
|
|
* CLUTTER_ALPHA_MAX_ALPHA;
|
|
|
|
sine = sine >> COGL_FIXED_Q;
|
|
@@ -724,11 +729,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,
|
|
@@ -747,7 +747,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));
|
|
|
|
@@ -806,9 +806,28 @@ 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);
|
|
+
|
|
+ /* shift from range [-1, 1] -> [0, 1] */
|
|
+ sine = (sine + 1.0) / 2.0;
|
|
+
|
|
+ CLUTTER_NOTE (ALPHA, "sine: %2f\n", sine);
|
|
+
|
|
+ return 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
|
|
@@ -842,18 +861,17 @@ clutter_sine_inc_func (ClutterAlpha *alpha,
|
|
ClutterTimeline * timeline;
|
|
gint frame;
|
|
gint n_frames;
|
|
- float 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 * (G_PI/180.0)) * 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);
|
|
}
|
|
|
|
/**
|
|
@@ -884,18 +902,17 @@ clutter_sine_dec_func (ClutterAlpha *alpha,
|
|
ClutterTimeline * timeline;
|
|
gint frame;
|
|
gint n_frames;
|
|
- float 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 * (G_PI/180.0)) * 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);
|
|
}
|
|
|
|
/**
|
|
@@ -926,18 +943,17 @@ clutter_sine_half_func (ClutterAlpha *alpha,
|
|
ClutterTimeline *timeline;
|
|
gint frame;
|
|
gint n_frames;
|
|
- float 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 * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA;
|
|
-
|
|
- return ((guint32) sine) >> COGL_FIXED_Q;
|
|
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
|
|
}
|
|
|
|
/**
|
|
@@ -962,19 +978,20 @@ clutter_sine_in_func (ClutterAlpha *alpha,
|
|
ClutterTimeline *timeline;
|
|
gint frame;
|
|
gint n_frames;
|
|
- float 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;
|
|
+ radians = ((float)frame / n_frames) * (G_PI / 2);
|
|
+ sine = sinf (radians - (G_PI / 2));
|
|
|
|
- sine = (sinf (x * (G_PI/180.0)) + 1) * CLUTTER_ALPHA_MAX_ALPHA;
|
|
+ /* shift from range [-1, 0] -> [0, 1] */
|
|
+ sine = sine + 1.0;
|
|
|
|
- return ((guint32) sine) >> COGL_FIXED_Q;
|
|
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
|
|
}
|
|
|
|
/**
|
|
@@ -998,18 +1015,17 @@ clutter_sine_out_func (ClutterAlpha *alpha,
|
|
ClutterTimeline *timeline;
|
|
gint frame;
|
|
gint n_frames;
|
|
- float 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 * (G_PI/180.0)) * 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);
|
|
}
|
|
|
|
/**
|
|
@@ -1034,18 +1050,20 @@ clutter_sine_in_out_func (ClutterAlpha *alpha,
|
|
ClutterTimeline *timeline;
|
|
gint frame;
|
|
gint n_frames;
|
|
- float 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));
|
|
|
|
- sine = (sinf (x * (G_PI/180.0)) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA;
|
|
+ /* shift from range [-1, 1] -> [0, 1] */
|
|
+ sine = (sine + 1.0) / 2.0;
|
|
|
|
- return ((guint32) sine) >> COGL_FIXED_Q;
|
|
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
|
|
}
|
|
|
|
/**
|
|
@@ -1113,30 +1131,23 @@ clutter_smoothstep_inc_func (ClutterAlpha *alpha,
|
|
ClutterTimeline *timeline;
|
|
gint frame;
|
|
gint n_frames;
|
|
- guint32 r;
|
|
- guint32 x;
|
|
+ float r;
|
|
+ float x;
|
|
|
|
/*
|
|
* The smoothstep function uses f(x) = -2x^3 + 3x^2 where x is from <0,1>,
|
|
- * and precission is critical -- we use 8.24 fixed format for this operation.
|
|
- * The earlier operations involve division, which we cannot do in 8.24 for
|
|
- * numbers in <0,1> we use ClutterFixed.
|
|
+ * and precission is critical.
|
|
*/
|
|
timeline = clutter_alpha_get_timeline (alpha);
|
|
frame = clutter_timeline_get_current_frame (timeline);
|
|
n_frames = clutter_timeline_get_n_frames (timeline);
|
|
|
|
- /*
|
|
- * Convert x to 8.24 for next step.
|
|
- */
|
|
- x = CLUTTER_FIXED_DIV (frame, n_frames) << 8;
|
|
+ x = (float)frame / n_frames;
|
|
|
|
/*
|
|
* f(x) = -2x^3 + 3x^2
|
|
- *
|
|
- * Convert result to ClutterFixed to avoid overflow in next step.
|
|
*/
|
|
- r = ((x >> 12) * (x >> 12) * 3 - (x >> 15) * (x >> 16) * (x >> 16)) >> 8;
|
|
+ r = -2 * x * x * x + 3 * x * x;
|
|
|
|
return (r * CLUTTER_ALPHA_MAX_ALPHA);
|
|
}
|
|
@@ -1204,9 +1215,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);
|
|
@@ -1214,7 +1225,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;
|
|
}
|
|
@@ -1255,9 +1266,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);
|
|
@@ -1265,7 +1276,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;
|
|
}
|