From 3c1792bc86767c7cb4fcc59b065525e757c888a9 Mon Sep 17 00:00:00 2001 From: Tomas Frydrych Date: Mon, 11 Feb 2008 10:56:57 +0000 Subject: [PATCH] 2008-02-11 Tomas Frydrych * clutter/clutter-actor.c (clutter_actor_transform_stage_point): Moved part of the calculation to floating point to avoid overflow of ClutterFixed range for large actors (bug 613). --- ChangeLog | 10 ++++++++-- clutter/clutter-actor.c | 29 +++++++++++++++++++---------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05c18f8..3d3b70f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,14 @@ -2008-20-10 Matthew Allum +2008-02-11 Tomas Frydrych + + * clutter/clutter-actor.c (clutter_actor_transform_stage_point): + Moved part of the calculation to floating point to avoid overflow + of ClutterFixed range for large actors (bug 613). + +2008-02-10 Matthew Allum * clutter/osx/clutter-stage-osx.c Fix up a couple of typos breaking build. - + 2008-02-08 Emmanuele Bassi * clutter/clutter-actor.c: Add actor box diagram and notes. diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 626ebfd..9e15af0 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -4808,6 +4808,7 @@ clutter_actor_transform_stage_point (ClutterActor *self, #define FX2FP CLUTTER_FIXED_TO_DOUBLE #define FP2INT CLUTTER_FLOAT_TO_INT #define DET2X(a,b, c,d) (CFX_QMUL(a,d) - CFX_QMUL(b,c)) +#define DET2FP(a,b, c,d) (a*d - b*c) /* * First, find mapping from unit uv square to xy quadrilateral; this @@ -4831,15 +4832,23 @@ clutter_actor_transform_stage_point (ClutterActor *self, RQ[2][2] = CFX_ONE; } else - { /* projective transform */ - ClutterFixed dx1, dx2, dy1, dy2, del; + { /* + * projective transform + * + * Must do this in floating point, as the del value can overflow the + * range of ClutterFixed for large actors. + * + * TODO -- see if we could do this with sufficient precision in 26.8 + * fixed. + */ + double dx1, dx2, dy1, dy2, del; - dx1 = v[1].x - v[3].x; - dx2 = v[2].x - v[3].x; - dy1 = v[1].y - v[3].y; - dy2 = v[2].y - v[3].y; + dx1 = FX2FP (v[1].x - v[3].x); + dx2 = FX2FP (v[2].x - v[3].x); + dy1 = FX2FP (v[1].y - v[3].y); + dy2 = FX2FP (v[2].y - v[3].y); - del = DET2X (dx1,dx2, dy1,dy2); + del = DET2FP (dx1,dx2, dy1,dy2); if (!del) return FALSE; @@ -4848,9 +4857,9 @@ clutter_actor_transform_stage_point (ClutterActor *self, * The division here needs to be done in floating point for * precisions reasons. */ - RQ[0][2] = FP2FX (FX2FP (DET2X (px,dx2, py,dy2) / FX2FP (del))); - RQ[1][2] = FP2FX (FX2FP (DET2X (dx1,px, dy1,py) / FX2FP (del))); - RQ[1][2] = CFX_DIV (DET2X(dx1,px, dy1,py), del); + RQ[0][2] = FP2FX (DET2FP (FX2FP(px),dx2, FX2FP(py),dy2) / del); + RQ[1][2] = FP2FX (DET2FP (dx1,FX2FP(px), dy1,FX2FP(py)) / del); + RQ[1][2] = FP2FX (DET2FP(dx1,FX2FP(px), dy1,FX2FP(py))/del); RQ[2][2] = CFX_ONE; RQ[0][0] = v[1].x - v[0].x + CFX_QMUL (RQ[0][2], v[1].x); RQ[1][0] = v[2].x - v[0].x + CFX_QMUL (RQ[1][2], v[2].x); -- 2.7.4