gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. bac9040e6e72d43dee10


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. bac9040e6e72d43dee109b5340c5e00f4a47abae
Date: Thu, 25 Nov 2010 08:30:48 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  bac9040e6e72d43dee109b5340c5e00f4a47abae (commit)
       via  96e800706e4b9d1398c72610c1b6738fed2b0af0 (commit)
       via  ebd8a43b9a604860363c39b1f2bd9ae73e1d3ded (commit)
       via  82a05b4a55337833f0f182fb5b222ce06865b9af (commit)
       via  14811222467062aa6838262afbefbd126984320b (commit)
       via  298d031b0a3156127ddec68454c6f2d75b15f82d (commit)
       via  4cc24146c68c0614f522a7403cbcae6c93f977ab (commit)
       via  f66297f2aaafdc605fae5e399a045eec6b49cb86 (commit)
       via  9cb426c1b2e5786dce44eec7e34f5e47f0b14f4e (commit)
       via  92f238a21264ff2029e75120e1476585adfda2b5 (commit)
       via  09bbccfc586a227740f004665473523ca2e71f6c (commit)
      from  323c94c78e15453d7a8f8b127bd24c92111fe472 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=bac9040e6e72d43dee109b5340c5e00f4a47abae


commit bac9040e6e72d43dee109b5340c5e00f4a47abae
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Nov 25 09:16:22 2010 +0100

    Enable red5test and add sanity check.

diff --git a/testsuite/misc-ming.all/Makefile.am 
b/testsuite/misc-ming.all/Makefile.am
index 310219b..288be6d 100644
--- a/testsuite/misc-ming.all/Makefile.am
+++ b/testsuite/misc-ming.all/Makefile.am
@@ -1485,10 +1485,12 @@ remotingTestRunner: $(srcdir)/../generic-testrunner.sh 
remoting.swf
        chmod 755 $@
 
 red5test.swf: $(srcdir)/red5test.as Dejagnu.swf Makefile 
../actionscript.all/check.as ../actionscript.all/utils.as
-       $(MAKESWF) -n network -r12 -o $@ -v7 -DRED5_HOST='\"$(RED5_HOST)\"' 
-DUSE_DEJAGNU_MODULE -DOUTPUT_VERSION=7 Dejagnu.swf $(srcdir)/red5test.as 
$(srcdir)/../actionscript.all/dejagnu_so_fini.as
+       $(MAKESWF) -n network -r12 -o $@ -v7 -DRED5_HOST='\"$(RED5_HOST)\"' \
+               -DUSE_DEJAGNU_MODULE -DOUTPUT_VERSION=7 Dejagnu.swf 
$(srcdir)/red5test.as \
+               $(srcdir)/../actionscript.all/dejagnu_so_fini.as
 
 red5test-runner: $(srcdir)/../generic-testrunner.sh red5test.swf
-       sh $< $(top_builddir) red5test.swf > $@
+       sh $< -c "ENDOFTEST" $(top_builddir) red5test.swf > $@
        chmod 755 $@
 
 case6.swf: $(srcdir)/case6.as Makefile ../actionscript.all/check.as
@@ -1730,8 +1732,7 @@ if ENABLE_HTTP_TESTSUITE
 TEST_CASES += remotingTestRunner
 endif
 if ENABLE_RED5_TESTING
-# FIXME: this test needs more work before activation
-#TEST_CASES += red5test-runner
+TEST_CASES += red5test-runner
 endif
 endif
 
diff --git a/testsuite/misc-ming.all/red5test.as 
b/testsuite/misc-ming.all/red5test.as
index b4ac653..b87ccd0 100644
--- a/testsuite/misc-ming.all/red5test.as
+++ b/testsuite/misc-ming.all/red5test.as
@@ -26,7 +26,8 @@ stop();
 
 endOfTest = function()
 {
-    totals();
+    totals(29);
+    trace("ENDOFTEST");
     play();
 };
 

http://git.savannah.gnu.org/cgit//commit/?id=96e800706e4b9d1398c72610c1b6738fed2b0af0


commit 96e800706e4b9d1398c72610c1b6738fed2b0af0
Merge: ebd8a43 323c94c
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Nov 25 08:48:15 2010 +0100

    Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=ebd8a43b9a604860363c39b1f2bd9ae73e1d3ded


commit ebd8a43b9a604860363c39b1f2bd9ae73e1d3ded
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 24 17:42:03 2010 +0100

    Fix typos.

diff --git a/libcore/SWFMatrix.cpp b/libcore/SWFMatrix.cpp
index bef838c..5d8cf94 100644
--- a/libcore/SWFMatrix.cpp
+++ b/libcore/SWFMatrix.cpp
@@ -154,7 +154,7 @@ SWFMatrix::concatenate_translation(int xoffset, int yoffset)
 }
 
 // Concatenate scales to our SWFMatrix. When transforming points, these 
-// scales happen first, then our matirx.
+// scales happen first, then our matrix.
 void
 SWFMatrix::concatenate_scale(double xscale, double yscale)
 {
diff --git a/testsuite/libcore.all/MatrixTest.cpp 
b/testsuite/libcore.all/MatrixTest.cpp
index 02b51cf..b96e9a7 100644
--- a/testsuite/libcore.all/MatrixTest.cpp
+++ b/testsuite/libcore.all/MatrixTest.cpp
@@ -259,7 +259,7 @@ main(int /*argc*/, char** /*argv*/)
     
     SWFMatrix m1_inverse = m1;
     m1_inverse.invert();
-    // concatenate the inverse SWFMatrix and orignial SWFMatrix.
+    // concatenate the inverse SWFMatrix and original SWFMatrix.
     m1_inverse.concatenate(m1); 
     // the result is expected to be an identity SWFMatrix. 
     check_equals(m1_inverse, identity);
@@ -276,7 +276,7 @@ main(int /*argc*/, char** /*argv*/)
     check_equals(m1_inverse.d(), 16384 * 65536);
     check_equals(m1_inverse.ty(), -16384 * 20);
     
-    // concatenate the inverse SWFMatrix and orignial SWFMatrix.
+    // concatenate the inverse SWFMatrix and original SWFMatrix.
     m1_inverse.concatenate(m1);
     // the result is expected to be an identity SWFMatrix. 
     check_equals(m1_inverse, identity);

http://git.savannah.gnu.org/cgit//commit/?id=82a05b4a55337833f0f182fb5b222ce06865b9af


commit 82a05b4a55337833f0f182fb5b222ce06865b9af
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 24 17:40:47 2010 +0100

    Fix testsuite.

diff --git a/testsuite/libcore.all/MatrixTest.cpp 
b/testsuite/libcore.all/MatrixTest.cpp
index 9d7132a..02b51cf 100644
--- a/testsuite/libcore.all/MatrixTest.cpp
+++ b/testsuite/libcore.all/MatrixTest.cpp
@@ -264,22 +264,17 @@ main(int /*argc*/, char** /*argv*/)
     // the result is expected to be an identity SWFMatrix. 
     check_equals(m1_inverse, identity);
 
-    m1.sx  = 4;   // 1/16384
-    m1.shy = 0;
-    m1.tx  = 20;
-    m1.shx = 0;
-    m1.sy  = 4;   // 1/16384
-    m1.ty  = 20;
+    m1 = SWFMatrix(4, 0, 0, 4, 20, 20);
     
     m1_inverse = m1;
     m1_inverse.invert();
     
-    check_equals(m1_inverse.sx, 16384 * 65536);
-    check_equals(m1_inverse.shy, 0);
-    check_equals(m1_inverse.tx, -16384 * 20);
-    check_equals(m1_inverse.shx, 0);
-    check_equals(m1_inverse.sy, 16384 * 65536);
-    check_equals(m1_inverse.ty, -16384 * 20);
+    check_equals(m1_inverse.a(), 16384 * 65536);
+    check_equals(m1_inverse.b(), 0);
+    check_equals(m1_inverse.tx(), -16384 * 20);
+    check_equals(m1_inverse.c(), 0);
+    check_equals(m1_inverse.d(), 16384 * 65536);
+    check_equals(m1_inverse.ty(), -16384 * 20);
     
     // concatenate the inverse SWFMatrix and orignial SWFMatrix.
     m1_inverse.concatenate(m1);

http://git.savannah.gnu.org/cgit//commit/?id=14811222467062aa6838262afbefbd126984320b


commit 14811222467062aa6838262afbefbd126984320b
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 24 13:27:14 2010 +0100

    More rationalizing.

diff --git a/libcore/SWFMatrix.cpp b/libcore/SWFMatrix.cpp
index b710454..bef838c 100644
--- a/libcore/SWFMatrix.cpp
+++ b/libcore/SWFMatrix.cpp
@@ -269,17 +269,18 @@ SWFMatrix&
 SWFMatrix::invert()
 {
     const boost::int64_t det = determinant();
+
     if (det == 0) {
         set_identity();
         return *this;
     }
 
-    const double d = 65536.0 * 65536.0 / det;
+    const double dn = 65536.0 * 65536.0 / det;
     
-    const boost::int32_t t0 = (boost::int32_t)(_d * d);
-    _d  = (boost::int32_t)(_a * d);
-    _c = (boost::int32_t)(-_c * d);
-    _b = (boost::int32_t)(-_b * d);
+    const boost::int32_t t0 = (boost::int32_t)(d() * dn);
+    _d  = (boost::int32_t)(a() * dn);
+    _c = (boost::int32_t)(-c() * dn);
+    _b = (boost::int32_t)(-b() * dn);
 
     const boost::int32_t t4 = - (multiplyFixed16(_tx, t0) + 
multiplyFixed16(_ty, _c));
     _ty = - (multiplyFixed16(_tx, _b) + multiplyFixed16(_ty, _d));
@@ -293,15 +294,17 @@ SWFMatrix::invert()
 double
 SWFMatrix::get_x_scale() const
 {
-    return std::sqrt((static_cast<double>(a()) * a() +
-                static_cast<double>(b()) * b())) / 65536.0;
+    const double a2 = static_cast<double>(a()) * a();
+    const double b2 = static_cast<double>(b()) * b();
+    return std::sqrt(a2 + b2) / 65536.0;
 }
 
 double
 SWFMatrix::get_y_scale() const
 {
-    return std::sqrt((static_cast<double>(d()) * d() +
-                static_cast<double>(c()) * c())) / 65536.0;
+    const double d2 = static_cast<double>(d()) * d();
+    const double c2 = static_cast<double>(c()) * c();
+    return std::sqrt(d2 + c2) / 65536.0;
 }
 
 double
@@ -321,8 +324,7 @@ SWFMatrix::determinant() const
     // Det(T) = ( (_a * _d * 1 ) + (_c * _ty * 0) + (_tx * _b *  0) ) -
     //          ( (0  * _d * _tx) + (0  * _ty * _a) + (1 * _c * _b) )
     //        = _a * _d - _b * _c
-
-    return (boost::int64_t)_a * _d - (boost::int64_t)_b * _c;
+    return (boost::int64_t)a() * d() - (boost::int64_t)b() * c();
 }
 
 std::ostream&

http://git.savannah.gnu.org/cgit//commit/?id=298d031b0a3156127ddec68454c6f2d75b15f82d


commit 298d031b0a3156127ddec68454c6f2d75b15f82d
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 24 13:15:41 2010 +0100

    Reduce duplication and make the code safer.

diff --git a/libcore/SWFMatrix.cpp b/libcore/SWFMatrix.cpp
index 82f5c70..b710454 100644
--- a/libcore/SWFMatrix.cpp
+++ b/libcore/SWFMatrix.cpp
@@ -44,6 +44,22 @@ namespace gnash {
 
 namespace {
 
+inline double
+rotationX(const SWFMatrix& m)
+{
+    const double b = m.b();
+    const double a = m.a();
+    return std::atan2(b, a);
+};
+
+inline double
+rotationY(const SWFMatrix& m)
+{
+    const double c = m.c();
+    const double d = m.d();
+    return std::atan2(-c, d);
+};
+
 inline boost::int32_t
 toFixed16(double a)
 {
@@ -176,8 +192,7 @@ SWFMatrix::set_scale_rotation(double x_scale, double 
y_scale, double angle)
 void
 SWFMatrix::set_x_scale(double xscale)
 {
-    const double rot_x =
-        std::atan2(static_cast<double>(_b), static_cast<double>(_a));
+    const double rot_x = rotationX(*this);
     _a = toFixed16(xscale * std::cos(rot_x));
     _b = toFixed16(xscale * std::sin(rot_x)); 
 }
@@ -185,8 +200,7 @@ SWFMatrix::set_x_scale(double xscale)
 void
 SWFMatrix::set_y_scale(double yscale)
 {
-    const double rot_y =
-        std::atan2(static_cast<double>(-_c), static_cast<double>(_d));
+    const double rot_y = rotationY(*this);
 
     _c = -toFixed16(yscale * std::sin(rot_y));
     _d = toFixed16(yscale * std::cos(rot_y));
@@ -202,10 +216,9 @@ SWFMatrix::set_scale(double xscale, double yscale)
 void
 SWFMatrix::set_rotation(double rotation)
 {   
-    const double rot_x =
-        std::atan2(static_cast<double>(_b), static_cast<double>(_a));
-    const double rot_y =
-        std::atan2(static_cast<double>(-_c), static_cast<double>(_d));
+    const double rot_x = rotationX(*this);
+    const double rot_y = rotationY(*this);
+
     const double scale_x = get_x_scale();
     const double scale_y = get_y_scale();
  
@@ -280,22 +293,21 @@ SWFMatrix::invert()
 double
 SWFMatrix::get_x_scale() const
 {
-    return std::sqrt((static_cast<double>(_a) * _a +
-                static_cast<double>(_b) * _b)) / 65536.0;
+    return std::sqrt((static_cast<double>(a()) * a() +
+                static_cast<double>(b()) * b())) / 65536.0;
 }
 
 double
 SWFMatrix::get_y_scale() const
 {
-    return std::sqrt((static_cast<double>(_d) * _d +
-                static_cast<double>(_c) * _c)) / 65536.0;
+    return std::sqrt((static_cast<double>(d()) * d() +
+                static_cast<double>(c()) * c())) / 65536.0;
 }
 
 double
 SWFMatrix::get_rotation() const
 {
-    // more successes in misc-ming.all/SWFMatrix_test.c
-    return std::atan2(static_cast<double>(_b), _a); 
+    return rotationX(*this);
 }
 
 // private

http://git.savannah.gnu.org/cgit//commit/?id=4cc24146c68c0614f522a7403cbcae6c93f977ab


commit 4cc24146c68c0614f522a7403cbcae6c93f977ab
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 24 13:07:49 2010 +0100

    Provide accessors to SWFMatrix and hide data.

diff --git a/libcore/SWFMatrix.cpp b/libcore/SWFMatrix.cpp
index 65bb31e..82f5c70 100644
--- a/libcore/SWFMatrix.cpp
+++ b/libcore/SWFMatrix.cpp
@@ -67,8 +67,8 @@ multiplyFixed16(boost::int32_t a, boost::int32_t b)
 void
 SWFMatrix::transform(geometry::Point2d& p) const
 {
-    boost::int32_t t0 = multiplyFixed16(sx, p.x) + multiplyFixed16(shy, p.y) + 
tx;
-    boost::int32_t t1 = multiplyFixed16(shx,p.x) + multiplyFixed16(sy,  p.y) + 
ty;
+    boost::int32_t t0 = multiplyFixed16(_a, p.x) + multiplyFixed16(_c, p.y) + 
_tx;
+    boost::int32_t t1 = multiplyFixed16(_b,p.x) + multiplyFixed16(_d,  p.y) + 
_ty;
     p.x = t0;
     p.y = t1;
 }
@@ -76,8 +76,8 @@ SWFMatrix::transform(geometry::Point2d& p) const
 void
 SWFMatrix::transform(boost::int32_t& x, boost::int32_t& y) const
 {
-    const boost::int32_t t0 = multiplyFixed16(sx, x) + multiplyFixed16(shy, y) 
+ tx;
-    const boost::int32_t t1 = multiplyFixed16(shx,x) + multiplyFixed16(sy,  y) 
+ ty;
+    const boost::int32_t t0 = multiplyFixed16(_a, x) + multiplyFixed16(_c, y) 
+ _tx;
+    const boost::int32_t t1 = multiplyFixed16(_b,x) + multiplyFixed16(_d,  y) 
+ _ty;
     x = t0;
     y = t1;
 }
@@ -109,20 +109,20 @@ SWFMatrix::transform(geometry::Range2d<boost::int32_t>& 
r) const
 void
 SWFMatrix::set_identity()
 {
-    sx = sy = 65536;
-    shx = shy = tx = ty = 0;
+    _a = _d = 65536;
+    _b = _c = _tx = _ty = 0;
 }
 
 void
 SWFMatrix::concatenate(const SWFMatrix& m)
 {
     SWFMatrix t;
-    t.sx =  multiplyFixed16(sx, m.sx)  + multiplyFixed16(shy, m.shx);
-    t.shx = multiplyFixed16(shx, m.sx) + multiplyFixed16(sy, m.shx);
-    t.shy = multiplyFixed16(sx, m.shy) + multiplyFixed16(shy, m.sy);
-    t.sy =  multiplyFixed16(shx, m.shy)+ multiplyFixed16(sy, m.sy);
-    t.tx =  multiplyFixed16(sx, m.tx)  + multiplyFixed16(shy, m.ty) + tx;
-    t.ty =  multiplyFixed16(shx, m.tx) + multiplyFixed16(sy, m.ty)  + ty;
+    t._a =  multiplyFixed16(_a, m._a)  + multiplyFixed16(_c, m._b);
+    t._b = multiplyFixed16(_b, m._a) + multiplyFixed16(_d, m._b);
+    t._c = multiplyFixed16(_a, m._c) + multiplyFixed16(_c, m._d);
+    t._d =  multiplyFixed16(_b, m._c)+ multiplyFixed16(_d, m._d);
+    t._tx =  multiplyFixed16(_a, m._tx)  + multiplyFixed16(_c, m._ty) + _tx;
+    t._ty =  multiplyFixed16(_b, m._tx) + multiplyFixed16(_d, m._ty)  + _ty;
 
     *this = t;
 }
@@ -133,8 +133,8 @@ SWFMatrix::concatenate(const SWFMatrix& m)
 void
 SWFMatrix::concatenate_translation(int xoffset, int yoffset)
 {
-    tx += multiplyFixed16(sx,  xoffset) + multiplyFixed16(shy, yoffset);
-    ty += multiplyFixed16(shx, xoffset) + multiplyFixed16(sy, yoffset);
+    _tx += multiplyFixed16(_a,  xoffset) + multiplyFixed16(_c, yoffset);
+    _ty += multiplyFixed16(_b, xoffset) + multiplyFixed16(_d, yoffset);
 }
 
 // Concatenate scales to our SWFMatrix. When transforming points, these 
@@ -142,22 +142,22 @@ SWFMatrix::concatenate_translation(int xoffset, int 
yoffset)
 void
 SWFMatrix::concatenate_scale(double xscale, double yscale)
 {
-    sx  = multiplyFixed16(sx, toFixed16(xscale));
-    shy = multiplyFixed16(shy,toFixed16(yscale));
-    shx = multiplyFixed16(shx,toFixed16(xscale));
-    sy  = multiplyFixed16(sy, toFixed16(yscale)); 
+    _a  = multiplyFixed16(_a, toFixed16(xscale));
+    _c = multiplyFixed16(_c,toFixed16(yscale));
+    _b = multiplyFixed16(_b,toFixed16(xscale));
+    _d  = multiplyFixed16(_d, toFixed16(yscale)); 
 }
 
 // Set this SWFMatrix to a blend of m1 and m2, parameterized by t.
 void
 SWFMatrix::set_lerp(const SWFMatrix& m1, const SWFMatrix& m2, float t)
 {
-    sx = lerp<float>(m1.sx, m2.sx, t);
-    shx = lerp<float>(m1.shx, m2.shx, t);
-    shy = lerp<float>(m1.shy, m2.shy, t);
-    sy = lerp<float>(m1.sy, m2.sy, t);
-    tx = lerp<float>(m1.tx, m2.tx, t);
-    ty = lerp<float>(m1.ty, m2.ty, t);
+    _a = lerp<float>(m1._a, m2._a, t);
+    _b = lerp<float>(m1._b, m2._b, t);
+    _c = lerp<float>(m1._c, m2._c, t);
+    _d = lerp<float>(m1._d, m2._d, t);
+    _tx = lerp<float>(m1._tx, m2._tx, t);
+    _ty = lerp<float>(m1._ty, m2._ty, t);
 }
 
 // Set the scale & rotation part of the SWFMatrix.
@@ -167,29 +167,29 @@ SWFMatrix::set_scale_rotation(double x_scale, double 
y_scale, double angle)
 {
     const double cos_angle = std::cos(angle);
     const double sin_angle = std::sin(angle);
-    sx  = toFixed16(x_scale * cos_angle);
-    shy = toFixed16(y_scale * -sin_angle);
-    shx = toFixed16(x_scale * sin_angle);
-    sy  = toFixed16(y_scale * cos_angle); 
+    _a  = toFixed16(x_scale * cos_angle);
+    _c = toFixed16(y_scale * -sin_angle);
+    _b = toFixed16(x_scale * sin_angle);
+    _d  = toFixed16(y_scale * cos_angle); 
 }
 
 void
 SWFMatrix::set_x_scale(double xscale)
 {
     const double rot_x =
-        std::atan2(static_cast<double>(shx), static_cast<double>(sx));
-    sx = toFixed16(xscale * std::cos(rot_x));
-    shx = toFixed16(xscale * std::sin(rot_x)); 
+        std::atan2(static_cast<double>(_b), static_cast<double>(_a));
+    _a = toFixed16(xscale * std::cos(rot_x));
+    _b = toFixed16(xscale * std::sin(rot_x)); 
 }
 
 void
 SWFMatrix::set_y_scale(double yscale)
 {
     const double rot_y =
-        std::atan2(static_cast<double>(-shy), static_cast<double>(sy));
+        std::atan2(static_cast<double>(-_c), static_cast<double>(_d));
 
-    shy = -toFixed16(yscale * std::sin(rot_y));
-    sy = toFixed16(yscale * std::cos(rot_y));
+    _c = -toFixed16(yscale * std::sin(rot_y));
+    _d = toFixed16(yscale * std::cos(rot_y));
 }
 
 void
@@ -203,16 +203,16 @@ void
 SWFMatrix::set_rotation(double rotation)
 {   
     const double rot_x =
-        std::atan2(static_cast<double>(shx), static_cast<double>(sx));
+        std::atan2(static_cast<double>(_b), static_cast<double>(_a));
     const double rot_y =
-        std::atan2(static_cast<double>(-shy), static_cast<double>(sy));
+        std::atan2(static_cast<double>(-_c), static_cast<double>(_d));
     const double scale_x = get_x_scale();
     const double scale_y = get_y_scale();
  
-    sx = toFixed16(scale_x * std::cos(rotation));
-    shx = toFixed16(scale_x * std::sin(rotation)); 
-    shy = -toFixed16(scale_y * std::sin(rot_y - rot_x + rotation));
-    sy = toFixed16(scale_y * std::cos(rot_y - rot_x + rotation));
+    _a = toFixed16(scale_x * std::cos(rotation));
+    _b = toFixed16(scale_x * std::sin(rotation)); 
+    _c = -toFixed16(scale_y * std::sin(rot_y - rot_x + rotation));
+    _d = toFixed16(scale_y * std::cos(rot_y - rot_x + rotation));
 }
 
 // Transform point 'p' by our SWFMatrix.  Put the result in *result.
@@ -221,8 +221,8 @@ SWFMatrix::transform(point* result, const point& p) const
 {
     assert(result);
 
-    result->x = multiplyFixed16(sx,  p.x) + multiplyFixed16(shy, p.y) + tx;
-    result->y = multiplyFixed16(shx, p.x) + multiplyFixed16(sy,  p.y) + ty;
+    result->x = multiplyFixed16(_a,  p.x) + multiplyFixed16(_c, p.y) + _tx;
+    result->y = multiplyFixed16(_b, p.x) + multiplyFixed16(_d,  p.y) + _ty;
 }
 
 void 
@@ -263,16 +263,16 @@ SWFMatrix::invert()
 
     const double d = 65536.0 * 65536.0 / det;
     
-    const boost::int32_t t0 = (boost::int32_t)(sy * d);
-    sy  = (boost::int32_t)(sx * d);
-    shy = (boost::int32_t)(-shy * d);
-    shx = (boost::int32_t)(-shx * d);
+    const boost::int32_t t0 = (boost::int32_t)(_d * d);
+    _d  = (boost::int32_t)(_a * d);
+    _c = (boost::int32_t)(-_c * d);
+    _b = (boost::int32_t)(-_b * d);
 
-    const boost::int32_t t4 = - (multiplyFixed16(tx, t0) + multiplyFixed16(ty, 
shy));
-    ty = - (multiplyFixed16(tx, shx) + multiplyFixed16(ty, sy));
+    const boost::int32_t t4 = - (multiplyFixed16(_tx, t0) + 
multiplyFixed16(_ty, _c));
+    _ty = - (multiplyFixed16(_tx, _b) + multiplyFixed16(_ty, _d));
 
-    sx = t0;
-    tx = t4;
+    _a = t0;
+    _tx = t4;
 
     return *this;
 }
@@ -280,37 +280,37 @@ SWFMatrix::invert()
 double
 SWFMatrix::get_x_scale() const
 {
-    return std::sqrt((static_cast<double>(sx) * sx +
-                static_cast<double>(shx) * shx)) / 65536.0;
+    return std::sqrt((static_cast<double>(_a) * _a +
+                static_cast<double>(_b) * _b)) / 65536.0;
 }
 
 double
 SWFMatrix::get_y_scale() const
 {
-    return std::sqrt((static_cast<double>(sy) * sy +
-                static_cast<double>(shy) * shy)) / 65536.0;
+    return std::sqrt((static_cast<double>(_d) * _d +
+                static_cast<double>(_c) * _c)) / 65536.0;
 }
 
 double
 SWFMatrix::get_rotation() const
 {
     // more successes in misc-ming.all/SWFMatrix_test.c
-    return std::atan2(static_cast<double>(shx), sx); 
+    return std::atan2(static_cast<double>(_b), _a); 
 }
 
 // private
 boost::int64_t
 SWFMatrix::determinant() const
 {
-    // | sx    shy     tx |
-    // | shx   sy      ty |   = T. Using the Leibniz formula:
+    // | _a    _c      _tx |
+    // | _b    _d      _ty |   = T. Using the Leibniz formula:
     // | 0     0       1  |
     //
-    // Det(T) = ( (sx * sy * 1 ) + (shy * ty * 0) + (tx * shx *  0) ) -
-    //          ( (0  * sy * tx) + (0  * ty * sx) + (1 * shy * shx) )
-    //        = sx * sy - shx * shy
+    // Det(T) = ( (_a * _d * 1 ) + (_c * _ty * 0) + (_tx * _b *  0) ) -
+    //          ( (0  * _d * _tx) + (0  * _ty * _a) + (1 * _c * _b) )
+    //        = _a * _d - _b * _c
 
-    return (boost::int64_t)sx * sy - (boost::int64_t)shx * shy;
+    return (boost::int64_t)_a * _d - (boost::int64_t)_b * _c;
 }
 
 std::ostream&
@@ -321,18 +321,18 @@ operator<<(std::ostream& o, const SWFMatrix& m)
 
     o << std::endl << "|"
       << std::setw(fieldWidth) << std::fixed << std::setprecision(4) 
-      << m.sx / 65536.0 << " "
+      << m.a() / 65536.0 << " "
       << std::setw(fieldWidth) << std::fixed << std::setprecision(4) 
-      << m.shy/ 65536.0 << " "
+      << m.c()/ 65536.0 << " "
       << std::setw(fieldWidth) << std::fixed << std::setprecision(4) 
-      << twipsToPixels(m.tx) << " |" 
+      << twipsToPixels(m.tx()) << " |" 
       << std::endl << "|"
       << std::setw(fieldWidth) << std::fixed << std::setprecision(4) 
-      << m.shx/ 65536.0 << " "
+      << m.b()/ 65536.0 << " "
       << std::setw(fieldWidth) << std::fixed << std::setprecision(4) 
-      << m.sy / 65536.0 << " "
+      << m.d() / 65536.0 << " "
       << std::setw(fieldWidth) << std::fixed << std::setprecision(4) 
-      << twipsToPixels(m.ty) << " |";
+      << twipsToPixels(m.ty()) << " |";
       
       return o;
 }
diff --git a/libcore/SWFMatrix.h b/libcore/SWFMatrix.h
index fd55e5c..c3ba1de 100644
--- a/libcore/SWFMatrix.h
+++ b/libcore/SWFMatrix.h
@@ -54,46 +54,52 @@ class DSOEXPORT SWFMatrix
 {
 public:
 
-    /// Xscale, 16.16 fixed point. xx in swfdec. 'a' in AS Matrix.
-    boost::int32_t sx; 
-
-    /// Xshear, 16.16 fixed point. yx in swfdec. 'b' in AS Matrix.
-    boost::int32_t shx;
-
-    /// Yshear, 16.16 fixed point. xy in swfdec. 'c' in AS Matrix.
-    boost::int32_t shy;
-
-    /// Yscale, 16.16 fixed point. yy in swfdec. 'd' in AS Matrix.
-    boost::int32_t sy; 
-
-    /// Xtranslation, TWIPS. x0 in swfdec. 'tx' in AS Matrix.
-    boost::int32_t tx; 
-
-    /// Ytranslation, TWIPS. y0 in swfdec. 'ty' in AS Matrix.
-    boost::int32_t ty; 
-             
     /// Construct an identity SWFMatrix
     SWFMatrix()
         :
-        sx(65536),
-        shx(0),
-        shy(0),
-        sy(65536),
-        tx(0),
-        ty(0)
+        _a(65536),
+        _b(0),
+        _c(0),
+        _d(65536),
+        _tx(0),
+        _ty(0)
     {}
 
     /// Construct a SWFMatrix with all values.
     SWFMatrix(int a, int b, int c, int d, int x, int y)
         :
-        sx(a),
-        shx(b),
-        shy(c),
-        sy(d),
-        tx(x),
-        ty(y)
+        _a(a),
+        _b(b),
+        _c(c),
+        _d(d),
+        _tx(x),
+        _ty(y)
     {}
 
+    boost::int32_t a() const {
+        return _a;
+    }
+
+    boost::int32_t b() const {
+        return _b;
+    }
+
+    boost::int32_t c() const {
+        return _c;
+    }
+
+    boost::int32_t d() const {
+        return _d;
+    }
+
+    boost::int32_t tx() const {
+        return _tx;
+    }
+
+    boost::int32_t ty() const {
+        return _ty;
+    }
+
     /// Set the SWFMatrix to identity.
     void set_identity();
 
@@ -107,7 +113,7 @@ public:
     //
     /// When transforming points, the translation
     /// happens first, then our original xform.
-    void concatenate_translation(int tx, int ty);
+    void concatenate_translation(int _tx, int _ty);
 
     /// Concatenate scale x and y to the front of our SWFMatrix 
     //
@@ -135,18 +141,18 @@ public:
 
     /// Set x translation in TWIPS
     void set_x_translation(int x) {
-        tx = x;
+        _tx = x;
     }
 
     /// Set y translation in TWIPS.
     void set_y_translation(int y) {
-        ty = y;
+        _ty = y;
     }
 
     /// Set x and y translation in TWIPS.
     void set_translation(int x, int y) {
-        tx = x;
-        ty = y;
+        _tx = x;
+        _ty = y;
     }
 
     /// Transform a given point by our SWFMatrix
@@ -183,31 +189,53 @@ public:
 
     /// return x translation n TWIPS unit.
     int get_x_translation() const {
-        return tx;
+        return _tx;
     }
 
     /// return y translation in TWIPS unit.
     int get_y_translation() const {
-        return ty;
+        return _ty;
     }
 
+    /// Allow direct access to values for equality
+    friend bool operator==(const SWFMatrix& a, const SWFMatrix& b);
+
 private: 
 
     /// Return the determinant of this SWFMatrix in 32.32 fixed point format.
     boost::int64_t  determinant() const;
 
+    /// Xscale, 16.16 fixed point. xx in swfdec. 'a' in AS Matrix.
+    boost::int32_t _a; 
+
+    /// Xshear, 16.16 fixed point. yx in swfdec. 'b' in AS Matrix.
+    boost::int32_t _b;
+
+    /// Yshear, 16.16 fixed point. xy in swfdec. 'c' in AS Matrix.
+    boost::int32_t _c;
+
+    /// Yscale, 16.16 fixed point. yy in swfdec. 'd' in AS Matrix.
+    boost::int32_t _d; 
+
+    /// Xtranslation, TWIPS. x0 in swfdec. '_tx' in AS Matrix.
+    boost::int32_t _tx; 
+
+    /// Ytranslation, TWIPS. y0 in swfdec. '_ty' in AS Matrix.
+    boost::int32_t _ty; 
+             
+
 }; //end of SWFMatrix
 
 inline bool
 operator==(const SWFMatrix& a, const SWFMatrix& b)
 {
     return  
-        a.sx  == b.sx  &&
-        a.shx == b.shx &&
-        a.tx  == b.tx  &&
-        a.sy  == b.sy  &&
-        a.shy == b.shy &&
-        a.ty  == b.ty;
+        a.a()  == b._a  &&
+        a._b == b._b &&
+        a._tx  == b._tx  &&
+        a._d  == b._d  &&
+        a._c == b._c &&
+        a._ty  == b._ty;
 }
 
 std::ostream& operator<<(std::ostream& o, const SWFMatrix& m);
diff --git a/libcore/TextField.cpp b/libcore/TextField.cpp
index 80e1703..d413f22 100644
--- a/libcore/TextField.cpp
+++ b/libcore/TextField.cpp
@@ -1202,14 +1202,14 @@ TextField::format_text()
             /// Autosize right expands from the previous right margin.
             SWFMatrix m;
 
-            m.tx = oldBounds.get_x_max() - _bounds.width();
+            m.set_x_translation(oldBounds.get_x_max() - _bounds.width());
             m.transform(_bounds);
         }
         else if (_autoSize == AUTOSIZE_CENTER) {
             // Autosize center expands from the previous center.
             SWFMatrix m;
-            m.tx = oldBounds.get_x_min() + oldBounds.width() / 2.0 - 
-                _bounds.width() / 2.0;
+            m.set_x_translation(oldBounds.get_x_min() + oldBounds.width() / 
2.0 - 
+                    _bounds.width() / 2.0);
             m.transform(_bounds);
         }
     }
@@ -1219,7 +1219,6 @@ TextField::format_text()
        
     // align the last (or single) line
     align_line(getTextAlignment(), last_line_start_record, x);
-       
 
     scrollLines();
        
diff --git a/libcore/asobj/MovieClip_as.cpp b/libcore/asobj/MovieClip_as.cpp
index 55e5c61..c16ff9f 100644
--- a/libcore/asobj/MovieClip_as.cpp
+++ b/libcore/asobj/MovieClip_as.cpp
@@ -2010,8 +2010,8 @@ movieclip_beginBitmapFill(const fn_call& fn)
     // not exactly intuitive.
     mat.invert();
     mat.concatenate_scale(1 / 20., 1 / 20.);
-    mat.tx /= 20;
-    mat.ty /= 20;
+    mat.set_x_translation(mat.tx() / 20);
+    mat.set_y_translation(mat.ty() / 20);
 
     ptr->graphics().beginFill(BitmapFill(t, bd->bitmapInfo(), mat, p));
     bd->attach(ptr);
diff --git a/libcore/asobj/TextSnapshot_as.cpp 
b/libcore/asobj/TextSnapshot_as.cpp
index 58d4237..866bdac 100644
--- a/libcore/asobj/TextSnapshot_as.cpp
+++ b/libcore/asobj/TextSnapshot_as.cpp
@@ -19,7 +19,10 @@
 
 
 #include "TextSnapshot_as.h"
-#include "GnashException.h" // for ActionException
+
+#include <boost/algorithm/string/compare.hpp>
+#include <boost/dynamic_bitset.hpp>
+#include <algorithm>
 
 #include "as_object.h" // for inheritance
 #include "log.h"
@@ -35,11 +38,7 @@
 #include "swf/TextRecord.h"
 #include "RGBA.h"
 #include "GnashNumeric.h"
-
 #include "namedStrings.h"
-#include <boost/algorithm/string/compare.hpp>
-#include <boost/dynamic_bitset.hpp>
-#include <algorithm>
 
 namespace gnash {
 
@@ -282,13 +281,13 @@ TextSnapshot_as::getTextRunInfo(size_t start, size_t end, 
as_object& ri) const
                 el->init_member("height", twipsToPixels(tr->textHeight()));
 
                 const double factor = 65536.0;
-                el->init_member("matrix_a", mat.sx / factor);
-                el->init_member("matrix_b", mat.shx / factor);
-                el->init_member("matrix_c", mat.shy / factor);
-                el->init_member("matrix_d", mat.sy / factor);
+                el->init_member("matrix_a", mat.a() / factor);
+                el->init_member("matrix_b", mat.b() / factor);
+                el->init_member("matrix_c", mat.c() / factor);
+                el->init_member("matrix_d", mat.d() / factor);
 
-                const double xpos = twipsToPixels(mat.tx + x);
-                const double ypos = twipsToPixels(mat.ty + tr->yOffset());
+                const double xpos = twipsToPixels(mat.tx() + x);
+                const double ypos = twipsToPixels(mat.ty() + tr->yOffset());
                 el->init_member("matrix_tx", xpos);
                 el->init_member("matrix_ty", ypos);
 
diff --git a/libcore/asobj/flash/geom/Transform_as.cpp 
b/libcore/asobj/flash/geom/Transform_as.cpp
index 92acea9..d140f78 100644
--- a/libcore/asobj/flash/geom/Transform_as.cpp
+++ b/libcore/asobj/flash/geom/Transform_as.cpp
@@ -242,12 +242,12 @@ transform_concatenatedMatrix(const fn_call& fn)
         const SWFMatrix& m = relay->worldMatrix();
 
         fn_call::Args args;
-        args += m.sx / factor,
-                m.shx / factor,
-                m.shy / factor,
-                m.sy / factor,
-                twipsToPixels(m.tx),
-                twipsToPixels(m.ty);
+        args += m.a() / factor,
+                m.b() / factor,
+                m.c() / factor,
+                m.d() / factor,
+                twipsToPixels(m.tx()),
+                twipsToPixels(m.ty());
 
         as_object* matrixObj = constructInstance(*matrixCtor, fn.env(), args);
 
@@ -286,12 +286,12 @@ transform_matrix(const fn_call& fn)
         const SWFMatrix& m = relay->matrix();
 
         fn_call::Args args;
-        args += m.sx / factor,
-                m.shx / factor,
-                m.shy / factor,
-                m.sy / factor,
-                twipsToPixels(m.tx),
-                twipsToPixels(m.ty);
+        args += m.a() / factor,
+                m.b() / factor,
+                m.c() / factor,
+                m.d() / factor,
+                twipsToPixels(m.tx()),
+                twipsToPixels(m.ty());
 
         as_object* matrixObj = constructInstance(*matrixCtor, fn.env(), args);
 
diff --git a/libcore/swf/TextRecord.cpp b/libcore/swf/TextRecord.cpp
index 419cec4..d4cdd18 100644
--- a/libcore/swf/TextRecord.cpp
+++ b/libcore/swf/TextRecord.cpp
@@ -227,7 +227,7 @@ TextRecord::displayRecords(Renderer& renderer, const 
Transform& xform,
             if (embedded) m = mat;
             else {
                 // Device fonts adopt the concatenated translation.
-                m.concatenate_translation(mat.tx, mat.ty);
+                m.concatenate_translation(mat.tx(), mat.ty());
                 // Device fonts have each glyph scaled in both dimensions
                 // by the matrix's y scale.
                 const double textScale = mat.get_y_scale();
diff --git a/librender/agg/Renderer_agg.cpp b/librender/agg/Renderer_agg.cpp
index 211899f..fe22b39 100644
--- a/librender/agg/Renderer_agg.cpp
+++ b/librender/agg/Renderer_agg.cpp
@@ -745,8 +745,8 @@ public:
         
         // convert Gnash SWFMatrix to AGG SWFMatrix and scale down to
         // pixel coordinates while we're at it
-        agg::trans_affine mtx(mat.sx / 65536.0, mat.shx / 65536.0, 
-            mat.shy / 65536.0, mat.sy / 65536.0, mat.tx, mat.ty);        
+        agg::trans_affine mtx(mat.a() / 65536.0, mat.b() / 65536.0, 
+            mat.c() / 65536.0, mat.d() / 65536.0, mat.tx(), mat.ty());        
         
         // invert SWFMatrix since this is used for the image source
         mtx.invert();
diff --git a/librender/agg/Renderer_agg_style.h 
b/librender/agg/Renderer_agg_style.h
index 0f7f471..4392852 100644
--- a/librender/agg/Renderer_agg_style.h
+++ b/librender/agg/Renderer_agg_style.h
@@ -232,8 +232,8 @@ public:
         :
         AggStyle(false),
         m_cx(cx),
-        m_tr(mat.sx / 65536.0, mat.shx/65536.0, mat.shy / 65536.0,
-              mat.sy / 65536.0, mat.tx, mat.ty),
+        m_tr(mat.a() / 65536.0, mat.b() / 65536.0, mat.c() / 65536.0,
+              mat.d() / 65536.0, mat.tx(), mat.ty()),
         m_span_interpolator(m_tr),
         m_gradient_adaptor(gr),
         m_sg(m_span_interpolator, m_gradient_adaptor, m_gradient_lut, 0,
@@ -358,8 +358,8 @@ public:
     m_rbuf(data, width, height, rowlen),  
     m_pixf(m_rbuf),
     m_img_src(m_pixf),
-    m_tr(mat.sx / 65535.0, mat.shx / 65535.0, mat.shy / 65535.0,
-            mat.sy / 65535.0, mat.tx, mat.ty),
+    m_tr(mat.a() / 65535.0, mat.b() / 65535.0, mat.c() / 65535.0,
+            mat.d() / 65535.0, mat.tx(), mat.ty()),
     m_interpolator(m_tr),
     m_sg(m_img_src, m_interpolator)
   {
diff --git a/librender/cairo/Renderer_cairo.cpp 
b/librender/cairo/Renderer_cairo.cpp
index f2c407e..7bf4d31 100644
--- a/librender/cairo/Renderer_cairo.cpp
+++ b/librender/cairo/Renderer_cairo.cpp
@@ -1153,9 +1153,9 @@ void
 init_cairo_matrix(cairo_matrix_t* cairo_matrix, const SWFMatrix& gnash_matrix)
 {
     cairo_matrix_init(cairo_matrix,
-                      gnash_matrix.sx/65536.0, gnash_matrix.shx/65536.0,
-                      gnash_matrix.shy/65536.0, gnash_matrix.sy/65536.0,
-                      gnash_matrix.tx, gnash_matrix.ty);
+              gnash_matrix.a()/65536.0, gnash_matrix.b()/65536.0,
+              gnash_matrix.c()/65536.0, gnash_matrix.d()/65536.0,
+              gnash_matrix.tx(), gnash_matrix.ty());
 }
 
 
diff --git a/librender/opengl/Renderer_ogl.cpp 
b/librender/opengl/Renderer_ogl.cpp
index c8a5c57..fcbdb5b 100644
--- a/librender/opengl/Renderer_ogl.cpp
+++ b/librender/opengl/Renderer_ogl.cpp
@@ -317,13 +317,13 @@ public:
     // Multiply (AKA "append") the new SWFMatrix with the current OpenGL one.
     float mat[16];
     memset(&mat[0], 0, sizeof(mat));
-    mat[0] = m.sx / 65536.0f;
-    mat[1] = m.shx / 65536.0f;
-    mat[4] = m.shy / 65536.0f;
-    mat[5] = m.sy / 65536.0f;
+    mat[0] = m.a() / 65536.0f;
+    mat[1] = m.b() / 65536.0f;
+    mat[4] = m.c() / 65536.0f;
+    mat[5] = m.d() / 65536.0f;
     mat[10] = 1;
-    mat[12] = m.tx;
-    mat[13] = m.ty;
+    mat[12] = m.tx();
+    mat[13] = m.ty();
     mat[15] = 1;
     glMultMatrixf(mat);
   }
@@ -683,15 +683,15 @@ bitmap_info_ogl::apply(const gnash::SWFMatrix& 
bitmap_matrix,
   const gnash::SWFMatrix& m = bitmap_matrix;
   glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
   float p[4] = { 0, 0, 0, 0 };
-  p[0] = m.sx / 65536.0f * inv_width;
-  p[1] = m.shy / 65536.0f * inv_width;
-  p[3] = m.tx * inv_width;
+  p[0] = m.a() / 65536.0f * inv_width;
+  p[1] = m.c() / 65536.0f * inv_width;
+  p[3] = m.tx() * inv_width;
   glTexGenfv(GL_S, GL_OBJECT_PLANE, p);
 
   glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-  p[0] = m.shx / 65536.0f * inv_height;
-  p[1] = m.shy / 65536.0f * inv_height;
-  p[3] = m.ty * inv_height;
+  p[0] = m.b() / 65536.0f * inv_height;
+  p[1] = m.c() / 65536.0f * inv_height;
+  p[3] = m.ty() * inv_height;
   glTexGenfv(GL_T, GL_OBJECT_PLANE, p);
   
 }

http://git.savannah.gnu.org/cgit//commit/?id=f66297f2aaafdc605fae5e399a045eec6b49cb86


commit f66297f2aaafdc605fae5e399a045eec6b49cb86
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 24 12:39:12 2010 +0100

    Include required header.

diff --git a/libcore/vm/ASHandlers.h b/libcore/vm/ASHandlers.h
index c69f986..f44b997 100644
--- a/libcore/vm/ASHandlers.h
+++ b/libcore/vm/ASHandlers.h
@@ -21,6 +21,7 @@
 #include <string>
 #include <vector>
 
+#include "SWF.h"
 
 // Forward declarations
 namespace gnash {

http://git.savannah.gnu.org/cgit//commit/?id=9cb426c1b2e5786dce44eec7e34f5e47f0b14f4e


commit 9cb426c1b2e5786dce44eec7e34f5e47f0b14f4e
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 24 11:52:44 2010 +0100

    Handle overflows without UB.

diff --git a/libbase/GnashNumeric.h b/libbase/GnashNumeric.h
index fb4f029..62a4434 100644
--- a/libbase/GnashNumeric.h
+++ b/libbase/GnashNumeric.h
@@ -34,6 +34,9 @@
 #include <algorithm>
 #include <boost/cstdint.hpp>
 #include <limits>
+#include <boost/type_traits/make_signed.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
+#include <boost/utility/enable_if.hpp>
 
 namespace gnash {
 
@@ -55,6 +58,66 @@ isFinite(double d)
 #endif
 }
 
+/// Convert an unsigned type to a signed type of the same width.
+//
+/// This mimics the conversion from a two's complement signed type
+/// to a corresponding unsigned type. This is the de facto default
+/// conversion on most i686 machines, but the behaviour is undefined
+/// *in all cases* in C++, and produces incorrect results on
+/// some platforms.
+//
+/// @tparam unsigned_type   The type to convert from
+/// @param t                The value to convert
+/// @return                 An unsigned type of the same width
+template<typename unsigned_type>
+typename boost::make_signed<unsigned_type>::type
+to_signed(unsigned_type t,
+    typename boost::enable_if<
+        typename boost::is_unsigned<unsigned_type> >::type* dummy = 0)
+{
+    (void)dummy;
+    typedef typename boost::make_signed<unsigned_type>::type signed_type;
+
+    // The max of the corresponding signed type can be represented in the
+    // unsigned type.
+    const unsigned_type max = std::numeric_limits<signed_type>::max();
+
+    if (t <= max) return t;
+
+    const signed_type x = t & max;
+
+    const signed_type min = std::numeric_limits<signed_type>::min();
+
+    return min + x;
+};
+
+/// Convert a signed type to an unsigned type of the same width.
+//
+/// This mimics the conversion from an unsigned type to a two's
+/// complement signed type. This is the de facto default
+/// conversion on most i686 machines, but the behaviour is undefined
+/// *in all cases* in C++, and produces incorrect results on
+/// some platforms.
+//
+/// @tparam signed_type     The type to convert from
+/// @param t                The value to convert
+/// @return                 A signed type of the same width
+template<typename signed_type>
+typename boost::make_unsigned<signed_type>::type
+to_unsigned(signed_type t,
+    typename boost::enable_if<
+        typename boost::is_signed<signed_type> >::type* dummy = 0)
+{
+    (void)dummy;
+
+    typedef typename boost::make_unsigned<signed_type>::type unsigned_type;
+
+    // Anything positive can be represented.
+    if (t >= 0) return t;
+
+    return std::numeric_limits<unsigned_type>::max() + t + 1;
+};
+
 inline double
 infinite_to_zero(double x)
 {
@@ -110,7 +173,7 @@ truncateWithFactor(double a)
                 std::numeric_limits<boost::int32_t>::min() / factor;
 
     if (a >= lowerSignedLimit && a <= upperSignedLimit) {
-        return static_cast<boost::int32_t>(a * factor);
+        return to_signed<boost::uint32_t>(a * factor);
     }
 
     // This slow truncation happens only in very unlikely cases.
diff --git a/libcore/SWFMatrix.cpp b/libcore/SWFMatrix.cpp
index a95195a..65bb31e 100644
--- a/libcore/SWFMatrix.cpp
+++ b/libcore/SWFMatrix.cpp
@@ -21,31 +21,45 @@
 //
 
 #include "SWFMatrix.h"
+
+#include <cmath>
+#include <iomanip>
+
 #include "log.h"
 #include "GnashNumeric.h"
 #include "SWFRect.h"
 #include "Point2d.h"
 
-#include <cmath>
-#include <iomanip>
 
+// This class intentionally uses overflows, which are not allowed in
+// signed types; apart from being UB always, in practice it produces
+// different results on different platforms.
+//
+// To avoid this, all calculations where an overflow could occur
+// should use only unsigned types, but assign to the signed SWFMatrix
+// members using only signed types. This would be much easier
+// if the matrix values were also unsigned but were converted to
+// signed for external users.
 namespace gnash {
 
 namespace {
 
 inline boost::int32_t
-DoubleToFixed16(double a)
+toFixed16(double a)
 {
     return truncateWithFactor<65536>(a);
 }
 
 inline boost::int32_t
-Fixed16Mul(boost::int32_t a, boost::int32_t b)
+multiplyFixed16(boost::int32_t a, boost::int32_t b)
 {
-    // truncate when overflow occurs.
-    return static_cast<boost::int32_t>(
-            (static_cast<boost::int64_t>(a) *
-             static_cast<boost::int64_t>(b) + 0x8000) >> 16);
+    // Overflows are permitted only in unsigned types, so
+    // convert using two's complement first.
+    const boost::uint32_t mult = 
+        (to_unsigned<boost::int64_t>(a) * to_unsigned<boost::int64_t>(b) + 
0x8000) >> 16;
+
+    // Convert back.
+    return to_signed<boost::uint32_t>(mult);
 }
 
 } // anonymous namepace
@@ -53,8 +67,8 @@ Fixed16Mul(boost::int32_t a, boost::int32_t b)
 void
 SWFMatrix::transform(geometry::Point2d& p) const
 {
-    boost::int32_t t0 = Fixed16Mul(sx, p.x) + Fixed16Mul(shy, p.y) + tx;
-    boost::int32_t t1 = Fixed16Mul(shx,p.x) + Fixed16Mul(sy,  p.y) + ty;
+    boost::int32_t t0 = multiplyFixed16(sx, p.x) + multiplyFixed16(shy, p.y) + 
tx;
+    boost::int32_t t1 = multiplyFixed16(shx,p.x) + multiplyFixed16(sy,  p.y) + 
ty;
     p.x = t0;
     p.y = t1;
 }
@@ -62,8 +76,8 @@ SWFMatrix::transform(geometry::Point2d& p) const
 void
 SWFMatrix::transform(boost::int32_t& x, boost::int32_t& y) const
 {
-    const boost::int32_t t0 = Fixed16Mul(sx, x) + Fixed16Mul(shy, y) + tx;
-    const boost::int32_t t1 = Fixed16Mul(shx,x) + Fixed16Mul(sy,  y) + ty;
+    const boost::int32_t t0 = multiplyFixed16(sx, x) + multiplyFixed16(shy, y) 
+ tx;
+    const boost::int32_t t1 = multiplyFixed16(shx,x) + multiplyFixed16(sy,  y) 
+ ty;
     x = t0;
     y = t1;
 }
@@ -103,12 +117,12 @@ void
 SWFMatrix::concatenate(const SWFMatrix& m)
 {
     SWFMatrix t;
-    t.sx =  Fixed16Mul(sx, m.sx)  + Fixed16Mul(shy, m.shx);
-    t.shx = Fixed16Mul(shx, m.sx) + Fixed16Mul(sy, m.shx);
-    t.shy = Fixed16Mul(sx, m.shy) + Fixed16Mul(shy, m.sy);
-    t.sy =  Fixed16Mul(shx, m.shy)+ Fixed16Mul(sy, m.sy);
-    t.tx =  Fixed16Mul(sx, m.tx)  + Fixed16Mul(shy, m.ty) + tx;
-    t.ty =  Fixed16Mul(shx, m.tx) + Fixed16Mul(sy, m.ty)  + ty;
+    t.sx =  multiplyFixed16(sx, m.sx)  + multiplyFixed16(shy, m.shx);
+    t.shx = multiplyFixed16(shx, m.sx) + multiplyFixed16(sy, m.shx);
+    t.shy = multiplyFixed16(sx, m.shy) + multiplyFixed16(shy, m.sy);
+    t.sy =  multiplyFixed16(shx, m.shy)+ multiplyFixed16(sy, m.sy);
+    t.tx =  multiplyFixed16(sx, m.tx)  + multiplyFixed16(shy, m.ty) + tx;
+    t.ty =  multiplyFixed16(shx, m.tx) + multiplyFixed16(sy, m.ty)  + ty;
 
     *this = t;
 }
@@ -119,8 +133,8 @@ SWFMatrix::concatenate(const SWFMatrix& m)
 void
 SWFMatrix::concatenate_translation(int xoffset, int yoffset)
 {
-    tx += Fixed16Mul(sx,  xoffset) + Fixed16Mul(shy, yoffset);
-    ty += Fixed16Mul(shx, xoffset) + Fixed16Mul(sy, yoffset);
+    tx += multiplyFixed16(sx,  xoffset) + multiplyFixed16(shy, yoffset);
+    ty += multiplyFixed16(shx, xoffset) + multiplyFixed16(sy, yoffset);
 }
 
 // Concatenate scales to our SWFMatrix. When transforming points, these 
@@ -128,10 +142,10 @@ SWFMatrix::concatenate_translation(int xoffset, int 
yoffset)
 void
 SWFMatrix::concatenate_scale(double xscale, double yscale)
 {
-    sx  = Fixed16Mul(sx, DoubleToFixed16(xscale));
-    shy = Fixed16Mul(shy,DoubleToFixed16(yscale));
-    shx = Fixed16Mul(shx,DoubleToFixed16(xscale));
-    sy  = Fixed16Mul(sy, DoubleToFixed16(yscale)); 
+    sx  = multiplyFixed16(sx, toFixed16(xscale));
+    shy = multiplyFixed16(shy,toFixed16(yscale));
+    shx = multiplyFixed16(shx,toFixed16(xscale));
+    sy  = multiplyFixed16(sy, toFixed16(yscale)); 
 }
 
 // Set this SWFMatrix to a blend of m1 and m2, parameterized by t.
@@ -153,10 +167,10 @@ SWFMatrix::set_scale_rotation(double x_scale, double 
y_scale, double angle)
 {
     const double cos_angle = std::cos(angle);
     const double sin_angle = std::sin(angle);
-    sx  = DoubleToFixed16(x_scale * cos_angle);
-    shy = DoubleToFixed16(y_scale * -sin_angle);
-    shx = DoubleToFixed16(x_scale * sin_angle);
-    sy  = DoubleToFixed16(y_scale * cos_angle); 
+    sx  = toFixed16(x_scale * cos_angle);
+    shy = toFixed16(y_scale * -sin_angle);
+    shx = toFixed16(x_scale * sin_angle);
+    sy  = toFixed16(y_scale * cos_angle); 
 }
 
 void
@@ -164,8 +178,8 @@ SWFMatrix::set_x_scale(double xscale)
 {
     const double rot_x =
         std::atan2(static_cast<double>(shx), static_cast<double>(sx));
-    sx = DoubleToFixed16(xscale * std::cos(rot_x));
-    shx = DoubleToFixed16(xscale * std::sin(rot_x)); 
+    sx = toFixed16(xscale * std::cos(rot_x));
+    shx = toFixed16(xscale * std::sin(rot_x)); 
 }
 
 void
@@ -174,8 +188,8 @@ SWFMatrix::set_y_scale(double yscale)
     const double rot_y =
         std::atan2(static_cast<double>(-shy), static_cast<double>(sy));
 
-    shy = -DoubleToFixed16(yscale * std::sin(rot_y));
-    sy = DoubleToFixed16(yscale * std::cos(rot_y));
+    shy = -toFixed16(yscale * std::sin(rot_y));
+    sy = toFixed16(yscale * std::cos(rot_y));
 }
 
 void
@@ -195,10 +209,10 @@ SWFMatrix::set_rotation(double rotation)
     const double scale_x = get_x_scale();
     const double scale_y = get_y_scale();
  
-    sx = DoubleToFixed16(scale_x * std::cos(rotation));
-    shx = DoubleToFixed16(scale_x * std::sin(rotation)); 
-    shy = -DoubleToFixed16(scale_y * std::sin(rot_y - rot_x + rotation));
-    sy = DoubleToFixed16(scale_y * std::cos(rot_y - rot_x + rotation));
+    sx = toFixed16(scale_x * std::cos(rotation));
+    shx = toFixed16(scale_x * std::sin(rotation)); 
+    shy = -toFixed16(scale_y * std::sin(rot_y - rot_x + rotation));
+    sy = toFixed16(scale_y * std::cos(rot_y - rot_x + rotation));
 }
 
 // Transform point 'p' by our SWFMatrix.  Put the result in *result.
@@ -207,8 +221,8 @@ SWFMatrix::transform(point* result, const point& p) const
 {
     assert(result);
 
-    result->x = Fixed16Mul(sx,  p.x) + Fixed16Mul(shy, p.y) + tx;
-    result->y = Fixed16Mul(shx, p.x) + Fixed16Mul(sy,  p.y) + ty;
+    result->x = multiplyFixed16(sx,  p.x) + multiplyFixed16(shy, p.y) + tx;
+    result->y = multiplyFixed16(shx, p.x) + multiplyFixed16(sy,  p.y) + ty;
 }
 
 void 
@@ -254,8 +268,8 @@ SWFMatrix::invert()
     shy = (boost::int32_t)(-shy * d);
     shx = (boost::int32_t)(-shx * d);
 
-    const boost::int32_t t4 = - (Fixed16Mul(tx, t0) + Fixed16Mul(ty, shy));
-    ty = - (Fixed16Mul(tx, shx) + Fixed16Mul(ty, sy));
+    const boost::int32_t t4 = - (multiplyFixed16(tx, t0) + multiplyFixed16(ty, 
shy));
+    ty = - (multiplyFixed16(tx, shx) + multiplyFixed16(ty, sy));
 
     sx = t0;
     tx = t4;
diff --git a/libcore/vm/ASHandlers.cpp b/libcore/vm/ASHandlers.cpp
index 5d2696f..a683b64 100644
--- a/libcore/vm/ASHandlers.cpp
+++ b/libcore/vm/ASHandlers.cpp
@@ -18,17 +18,24 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-
 #ifdef HAVE_CONFIG_H
 #include "gnashconfig.h"
 #endif
 
+#include "ASHandlers.h"
+
+#include <string>
+#include <vector>
+#include <cstdlib> // std::mbstowcs
+#include <boost/scoped_array.hpp>
+#include <boost/random.hpp>
+#include <boost/lexical_cast.hpp>
+#include <algorithm> 
+
 #include "smart_ptr.h"
 #include "log.h"
 #include "SWF.h"
 #include "rc.h"
-#include "ASHandlers.h"
-
 #include "NativeFunction.h"
 #include "Function.h"
 #include "as_function.h"
@@ -55,14 +62,6 @@
 #include "RunResources.h"
 #include "ObjectURI.h"
 
-#include <string>
-#include <vector>
-#include <cstdlib> // std::mbstowcs
-#include <boost/scoped_array.hpp>
-#include <boost/random.hpp>
-#include <boost/lexical_cast.hpp>
-#include <algorithm> // std::swap
-
 // GNASH_PARANOIA_LEVEL:
 // 0 : no assertions
 // 1 : quick assertions
@@ -1518,9 +1517,10 @@ ActionChr(ActionExec& thread)
 {
     as_environment& env = thread.env;
     
-    // Only handles values up to 65535
-    const boost::uint16_t c =
-        static_cast<boost::uint16_t>(toInt(env.top(0), getVM(env)));
+    // The conversion to unsigned happens before truncation;
+    // this is important.
+    const boost::uint16_t c = to_unsigned<boost::int32_t>(
+        toInt(env.top(0), getVM(env)));
 
     // If the argument to chr() is '0', we return
     // nothing, not NULL
@@ -1541,14 +1541,11 @@ ActionChr(ActionExec& thread)
     // Values above 256 evaluate to value % 256, 
     // through the cast, which is expected behaviour.
     const unsigned char uc = static_cast<unsigned char>(c);
-    if (uc == 0)
-    {
+    if (uc == 0) {
         env.top(0).set_string("");
         return;
     }
-    std::string s;
-    s.push_back(uc);
-    env.top(0).set_string(s);
+    env.top(0).set_string(std::string(1, uc));
 }
 
 void
@@ -1668,9 +1665,10 @@ ActionMbChr(ActionExec& thread)
         // No need to return.
     }
 
-    // Cut to uint16, as characters above 65535 'wrap around'
-    const boost::uint16_t i = 
-        static_cast<boost::uint16_t>(toInt(env.top(0), getVM(env)));
+    // The conversion to unsigned happens before truncation;
+    // this is important.
+    const boost::uint16_t i = to_unsigned<boost::int32_t>(
+        toInt(env.top(0), getVM(env)));
     
     std::string out = utf8::encodeUnicodeCharacter(i);
     
@@ -1695,8 +1693,6 @@ ActionStrictMode(ActionExec& thread)
     );
 }
 
-
-
 // also known as WaitForFrame2
 void
 ActionWaitForFrameExpression(ActionExec& thread)
@@ -3035,7 +3031,7 @@ ActionShiftRight(ActionExec& thread)
 {
     as_environment& env = thread.env;
 
-    boost::uint32_t amount = toInt(env.top(0), getVM(env));
+    boost::uint32_t amount = to_unsigned(toInt(env.top(0), getVM(env)));
     boost::int32_t value = toInt(env.top(1), getVM(env));
 
     value = value >> amount;
@@ -3049,7 +3045,7 @@ ActionShiftRight2(ActionExec& thread)
 {
     as_environment& env = thread.env;
 
-    boost::uint32_t amount = toInt(env.top(0), getVM(env)); 
+    boost::uint32_t amount = to_unsigned(toInt(env.top(0), getVM(env))); 
     boost::int32_t value = toInt(env.top(1), getVM(env));
 
     value = boost::uint32_t(value) >> amount;

http://git.savannah.gnu.org/cgit//commit/?id=92f238a21264ff2029e75120e1476585adfda2b5


commit 92f238a21264ff2029e75120e1476585adfda2b5
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 24 09:56:23 2010 +0100

    Don't enforce a specific locale, as Gnash should pass tests under all 
locales.

diff --git a/testsuite/simple.exp b/testsuite/simple.exp
index 5172c22..8960782 100644
--- a/testsuite/simple.exp
+++ b/testsuite/simple.exp
@@ -20,9 +20,6 @@ set file all
 set params ""
 
 global env
-set env(LANG) en_US.UTF-8
-set env(LANGUAGE) en_US.UTF-8
-set env(LC_ALL) en_US.UTF-8
 
 # testcases is set by the Makefile in the site.exp data file.
 foreach file $testcases {
@@ -127,8 +124,6 @@ foreach file $testcases {
                fail "${file} exited with non-zero code ([lindex $retcode 3])"
        }
 
-
-
     # force a close of the executable to be safe.
     catch close
 }

http://git.savannah.gnu.org/cgit//commit/?id=09bbccfc586a227740f004665473523ca2e71f6c


commit 09bbccfc586a227740f004665473523ca2e71f6c
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Nov 24 09:55:48 2010 +0100

    Make some errors into aserrors.

diff --git a/libcore/asobj/flash/geom/Transform_as.cpp 
b/libcore/asobj/flash/geom/Transform_as.cpp
index f3422f9..92acea9 100644
--- a/libcore/asobj/flash/geom/Transform_as.cpp
+++ b/libcore/asobj/flash/geom/Transform_as.cpp
@@ -38,7 +38,6 @@
 namespace gnash {
 
 namespace {
-
     as_value transform_colorTransform(const fn_call& fn);
     as_value transform_concatenatedColorTransform(const fn_call& fn);
     as_value transform_concatenatedMatrix(const fn_call& fn);
@@ -47,14 +46,12 @@ namespace {
     as_value transform_ctor(const fn_call& fn);
     void attachTransformInterface(as_object& o);
     as_value get_flash_geom_transform_constructor(const fn_call& fn);
-    
 }
 
 
 
 class Transform_as : public Relay
 {
-
 public:
 
     Transform_as(MovieClip& movieClip)
@@ -83,8 +80,7 @@ public:
 
 protected:
 
-    virtual void markReachableResources() const
-    {
+    virtual void markReachableResources() const {
         _movieClip.setReachable();
     }
 
@@ -111,7 +107,6 @@ namespace {
 as_value
 transform_colorTransform(const fn_call& fn)
 {
-
     const double factor = 256.0;
 
     Transform_as* relay = ensure<ThisIsNative<Transform_as> >(fn);
@@ -124,7 +119,9 @@ transform_colorTransform(const fn_call& fn)
         as_function* colorTransformCtor = colorTrans.to_function();
 
         if (!colorTransformCtor) {
-            log_error("Failed to construct flash.geom.ColorTransform!");
+            IF_VERBOSE_ASCODING_ERRORS(
+                log_aserror("Failed to construct flash.geom.ColorTransform!");
+            );
             return as_value();
         }
 
@@ -142,9 +139,7 @@ transform_colorTransform(const fn_call& fn)
     }
 
     // Setter
-
-    if (fn.nargs > 1)
-    {
+    if (fn.nargs > 1) {
         IF_VERBOSE_ASCODING_ERRORS(
             std::ostringstream ss;
             fn.dump_args(ss);
@@ -200,7 +195,9 @@ transform_concatenatedColorTransform(const fn_call& fn)
         as_function* colorTransformCtor = colorTrans.to_function();
 
         if (!colorTransformCtor) {
-            log_error("Failed to construct flash.geom.ColorTransform!");
+            IF_VERBOSE_ASCODING_ERRORS(
+                log_aserror("Failed to construct flash.geom.ColorTransform!");
+            );
             return as_value();
         }
 
@@ -228,8 +225,7 @@ transform_concatenatedMatrix(const fn_call& fn)
 
     Transform_as* relay = ensure<ThisIsNative<Transform_as> >(fn);
 
-    if (!fn.nargs)
-    {
+    if (!fn.nargs) {
 
         // If it's not found, construction will fail.
         as_value matrix(findObject(fn.env(), "flash.geom.Matrix"));
@@ -237,7 +233,9 @@ transform_concatenatedMatrix(const fn_call& fn)
         as_function* matrixCtor = matrix.to_function();
 
         if (!matrixCtor) {
-            log_error("Failed to construct flash.geom.Matrix!");
+            IF_VERBOSE_ASCODING_ERRORS(
+                log_aserror("Failed to construct flash.geom.Matrix!");
+            );
             return as_value();
         }
 
@@ -262,7 +260,6 @@ transform_concatenatedMatrix(const fn_call& fn)
 as_value
 transform_matrix(const fn_call& fn)
 {
-
     const double factor = 65536.0;
 
     // TODO: What happens if you do: "mat = mc.transform.matrix; mat.a = 6;"
@@ -272,8 +269,7 @@ transform_matrix(const fn_call& fn)
     // set our _movieClip's matrix from the AS matrix.
     Transform_as* relay = ensure<ThisIsNative<Transform_as> >(fn);
 
-    if (!fn.nargs)
-    {
+    if (!fn.nargs) {
 
         // If it's not found, construction will fail.
         as_value matrix(findObject(fn.env(), "flash.geom.Matrix"));
@@ -281,7 +277,9 @@ transform_matrix(const fn_call& fn)
         as_function* matrixCtor = matrix.to_function();
 
         if (!matrixCtor) {
-            log_error("Failed to construct flash.geom.Matrix!");
+            IF_VERBOSE_ASCODING_ERRORS(
+                log_aserror("Failed to construct flash.geom.Matrix!");
+            );
             return as_value();
         }
 
@@ -301,9 +299,7 @@ transform_matrix(const fn_call& fn)
     }
 
     // Setter
-
-    if (fn.nargs > 1)
-    {
+    if (fn.nargs > 1) {
         IF_VERBOSE_ASCODING_ERRORS(
             std::ostringstream ss;
             fn.dump_args(ss);
@@ -312,10 +308,8 @@ transform_matrix(const fn_call& fn)
         );
     }
 
-
     as_object* obj = toObject(fn.arg(0), getVM(fn));
-    if (!obj)
-    {
+    if (!obj) {
         IF_VERBOSE_ASCODING_ERRORS(
             std::ostringstream ss;
             fn.dump_args(ss);
@@ -324,13 +318,11 @@ transform_matrix(const fn_call& fn)
         );
         return as_value();
     }
-    
 
     const SWFMatrix m = toSWFMatrix(*obj);
     relay->setMatrix(m);
 
     return as_value();
-
 }
 
 as_value
@@ -342,8 +334,6 @@ transform_pixelBounds(const fn_call& fn)
     return as_value();
 }
 
-
-
 as_value
 transform_ctor(const fn_call& fn)
 {
@@ -407,5 +397,4 @@ attachTransformInterface(as_object& o)
 }
 
 } // anonymous namespace
-
 } // end of gnash namespace

-----------------------------------------------------------------------

Summary of changes:
 libbase/GnashNumeric.h                    |   65 ++++++++++-
 libcore/SWFMatrix.cpp                     |  194 ++++++++++++++++------------
 libcore/SWFMatrix.h                       |  114 +++++++++++-------
 libcore/TextField.cpp                     |    7 +-
 libcore/asobj/MovieClip_as.cpp            |    4 +-
 libcore/asobj/TextSnapshot_as.cpp         |   21 ++--
 libcore/asobj/flash/geom/Transform_as.cpp |   71 +++++------
 libcore/swf/TextRecord.cpp                |    2 +-
 libcore/vm/ASHandlers.cpp                 |   48 ++++----
 libcore/vm/ASHandlers.h                   |    1 +
 librender/agg/Renderer_agg.cpp            |    4 +-
 librender/agg/Renderer_agg_style.h        |    8 +-
 librender/cairo/Renderer_cairo.cpp        |    6 +-
 librender/opengl/Renderer_ogl.cpp         |   24 ++--
 testsuite/libcore.all/MatrixTest.cpp      |   23 ++--
 testsuite/misc-ming.all/Makefile.am       |    9 +-
 testsuite/misc-ming.all/red5test.as       |    3 +-
 testsuite/simple.exp                      |    5 -
 18 files changed, 352 insertions(+), 257 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]