[clutter] clutter-stage: Don't override the user's perspective matrix
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] clutter-stage: Don't override the user's perspective matrix
- Date: Thu, 16 Jun 2011 11:58:19 +0000 (UTC)
commit 2022e4c100d8d8e635ea38d990d6023f7306020f
Author: Neil Roberts <neil linux intel com>
Date: Mon Apr 4 18:42:52 2011 +0100
clutter-stage: Don't override the user's perspective matrix
Since eef9078f ClutterStage updates the aspect ratio of the
perspective matrix whenever the size of the stage changes. This meant
that if an application tries to set its own perspective matrix then
part of it would get overridden. It's not really clear what the
use-case of setting the perspective on the stage should be but it
seems like the safest bet is to always try to preserve the
application's request. The documentation for the function has been
tweaked to discourage its use.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2625
clutter/clutter-stage.c | 62 ++++++++++++++++++++++++++++++++--------------
1 files changed, 43 insertions(+), 19 deletions(-)
---
diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c
index 6373d8b..e231440 100644
--- a/clutter/clutter-stage.c
+++ b/clutter/clutter-stage.c
@@ -176,6 +176,7 @@ struct _ClutterStagePrivate
guint have_valid_pick_buffer : 1;
guint accept_focus : 1;
guint motion_events_enabled : 1;
+ guint has_custom_perspective : 1;
};
enum
@@ -2136,24 +2137,11 @@ clutter_stage_get_color (ClutterStage *stage,
*color = priv->color;
}
-/**
- * clutter_stage_set_perspective:
- * @stage: A #ClutterStage
- * @perspective: A #ClutterPerspective
- *
- * Sets the stage perspective.
- */
-void
-clutter_stage_set_perspective (ClutterStage *stage,
- ClutterPerspective *perspective)
+static void
+clutter_stage_set_perspective_internal (ClutterStage *stage,
+ ClutterPerspective *perspective)
{
- ClutterStagePrivate *priv;
-
- g_return_if_fail (CLUTTER_IS_STAGE (stage));
- g_return_if_fail (perspective != NULL);
- g_return_if_fail (perspective->z_far - perspective->z_near != 0);
-
- priv = stage->priv;
+ ClutterStagePrivate *priv = stage->priv;
if (priv->perspective.fovy == perspective->fovy &&
priv->perspective.aspect == perspective->aspect &&
@@ -2177,6 +2165,35 @@ clutter_stage_set_perspective (ClutterStage *stage,
}
/**
+ * clutter_stage_set_perspective:
+ * @stage: A #ClutterStage
+ * @perspective: A #ClutterPerspective
+ *
+ * Sets the stage perspective. Using this function is not recommended
+ * because it will disable Clutter's attempts to generate an
+ * appropriate perspective based on the size of the stage.
+ */
+void
+clutter_stage_set_perspective (ClutterStage *stage,
+ ClutterPerspective *perspective)
+{
+ ClutterStagePrivate *priv;
+
+ g_return_if_fail (CLUTTER_IS_STAGE (stage));
+ g_return_if_fail (perspective != NULL);
+ g_return_if_fail (perspective->z_far - perspective->z_near != 0);
+
+ priv = stage->priv;
+
+ /* If the application ever calls this function then we'll stop
+ automatically updating the perspective when the stage changes
+ size */
+ priv->has_custom_perspective = TRUE;
+
+ clutter_stage_set_perspective_internal (stage, perspective);
+}
+
+/**
* clutter_stage_get_perspective:
* @stage: A #ClutterStage
* @perspective: (out caller-allocates) (allow-none): return location for a
@@ -3134,8 +3151,15 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage)
priv->viewport[3]);
perspective = priv->perspective;
- perspective.aspect = priv->viewport[2] / priv->viewport[3];
- clutter_stage_set_perspective (stage, &perspective);
+
+ /* Ideally we want to regenerate the perspective matrix whenever
+ the size changes but if the user has provided a custom matrix
+ then we don't want to override it */
+ if (!priv->has_custom_perspective)
+ {
+ perspective.aspect = priv->viewport[2] / priv->viewport[3];
+ clutter_stage_set_perspective_internal (stage, &perspective);
+ }
cogl_matrix_init_identity (&priv->view);
cogl_matrix_view_2d_in_perspective (&priv->view,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]