gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libbase/utility.h server/charac...


From: Zou Lunkai
Subject: [Gnash-commit] gnash ChangeLog libbase/utility.h server/charac...
Date: Mon, 16 Jun 2008 07:22:22 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Zou Lunkai <zoulunkai>  08/06/16 07:22:21

Modified files:
        .              : ChangeLog 
        libbase        : utility.h 
        server         : character.cpp matrix.h types.h 
        server/parser  : movie_def_impl.h 
        testsuite/server: MatrixTest.cpp 

Log message:
                * libbase/utility.h: implement a safer but slower 
PIXEL_TO_TWIPS().
                * server/types.h: move PIXEL_TO_TWIPS to utility.h
                * server/matrix.h: safe but slower version of FloatToFixed16() 
and DoubleToFixed16().
                * server/parser/movie_def_impl.h, character.cpp: head file and 
data types cleanups.
                * testsuite/server/MatrixTest.cpp: more telerrant about matrix 
test, from 10e-6 to 10-3,
                  enable the test file.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6935&r2=1.6936
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/utility.h?cvsroot=gnash&r1=1.60&r2=1.61
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.104&r2=1.105
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.h?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/server/types.h?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.82&r2=1.83
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/MatrixTest.cpp?cvsroot=gnash&r1=1.15&r2=1.16

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6935
retrieving revision 1.6936
diff -u -b -r1.6935 -r1.6936
--- ChangeLog   15 Jun 2008 15:00:16 -0000      1.6935
+++ ChangeLog   16 Jun 2008 07:22:19 -0000      1.6936
@@ -1,3 +1,12 @@
+2008-06-16 Zou Lunkai <address@hidden>
+
+       * libbase/utility.h: implement a safer but slower PIXEL_TO_TWIPS().
+       * server/types.h: move PIXEL_TO_TWIPS to utility.h
+       * server/matrix.h: safe but slower version of FloatToFixed16() and 
DoubleToFixed16().
+       * server/parser/movie_def_impl.h, character.cpp: head file and data 
types cleanups.
+       * testsuite/server/MatrixTest.cpp: more telerrant about matrix test, 
from 10e-6 to 10-3,
+         enable the test file.
+
 2008-06-15 Benjamin Wolsey <address@hidden>
 
        * server/vm/ASHandlers.cpp: drop unused env variable.

Index: libbase/utility.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/utility.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- libbase/utility.h   13 Jun 2008 09:13:05 -0000      1.60
+++ libbase/utility.h   16 Jun 2008 07:22:20 -0000      1.61
@@ -85,9 +85,14 @@
 
 
 #ifndef M_PI
-#define M_PI 3.141592654
+    #define M_PI 3.1415926536
 #endif // M_PI
 
+// Define this to enable fast float&double to uint32 conversion.
+// If the behaviour is undefined when overflow occurs with your 
+// compiler, disable this macro.
+#define TRUST_FLOAT_TO_UINT32_CONVERSION  1 
+
 // Commonly-used inlined mathematical functions are defined in
 // namespace gnash::utility so that it's clear where they
 // come from.
@@ -141,27 +146,39 @@
 
 } // end of namespace utility
 
-inline boost::int32_t Fixed16Mul(boost::int32_t a, boost::int32_t b)
+inline double TWIPS_TO_PIXELS(int i) 
 {
-    // truncate when overflow occurs.
-    return (boost::int32_t)((boost::int64_t)a * (boost::int64_t)b >> 16);
+    return i / 20.0; 
 }
 
-inline boost::int32_t FloatToFixed16(float a)
+// truncate when overflow occurs.
+inline int PIXELS_TO_TWIPS(double a) 
 {
+#ifdef TRUST_FLOAT_TO_UINT32_CONVERSION
     // truncate when overflow occurs.
-    return (boost::int32_t)(boost::uint32_t)(a * 65536.0f);
+    return (boost::int32_t)(boost::uint32_t)(a * 20); 
+#else
+    boost::int32_t  b;
+    if(a >= 0)
+    {
+       b = (boost::uint32_t)(std::fmod(a * 20.0, 4294967296.0));
+    }
+    else
+    {
+       b = -(boost::uint32_t)(std::fmod(-a * 20, 4294967296.0));
+    }
+    return b;
+#endif
 }
 
-inline boost::int32_t DoubleToFixed16(double a)
+inline boost::int32_t Fixed16Mul(boost::int32_t a, boost::int32_t b)
 {
     // truncate when overflow occurs.
-    return (boost::int32_t)(boost::uint32_t)(a * 65536.0);
+    return (boost::int32_t)((boost::int64_t)a * (boost::int64_t)b >> 16);
 }
 
 }
 
-
 /// \brief
 /// Return the smallest multiple of given base greater or equal
 /// given limit

Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -b -r1.104 -r1.105
--- server/character.cpp        13 Jun 2008 09:13:05 -0000      1.104
+++ server/character.cpp        16 Jun 2008 07:22:20 -0000      1.105
@@ -338,7 +338,7 @@
                }
 
                // input is in percent
-               float scale = static_cast<float>(scale_percent) / 100.f;
+               double scale = scale_percent / 100.0;
                ptr->set_y_scale(scale);
        }
        return rv;
@@ -543,7 +543,7 @@
        if ( fn.nargs == 0 ) // getter
        {
                // Verified against Macromedia player using 
samples/test_rotation.swf
-               float   angle = ptr->get_matrix().get_rotation();
+               double  angle = ptr->get_matrix().get_rotation();
 
                // Result is CLOCKWISE DEGREES, [-180,180]
                angle *= 180.0f / float(M_PI);
@@ -556,7 +556,7 @@
                matrix m = ptr->get_matrix();
 
                // input is in degrees
-               const float rotation = (float) fn.arg(0).to_number() * 
float(M_PI) / 180.f;
+               const double rotation = fn.arg(0).to_number() * float(M_PI) / 
180.f;
                m.set_rotation(rotation);
 
                ptr->set_matrix(m);

Index: server/matrix.h
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- server/matrix.h     13 Jun 2008 09:13:05 -0000      1.27
+++ server/matrix.h     16 Jun 2008 07:22:20 -0000      1.28
@@ -27,6 +27,7 @@
 #include "dsodefs.h" // for DSOEXPORT
 #include "Range2d.h" // for transforming Range2d<float>
 #include "Point2d.h" // for transforming Point2d<float> (typedefe'd to point)
+#include "utility.h" // for TRUST_FLOAT_TO_UINT32_CONVERSION
 
 #include <boost/cstdint.hpp>
 #include <iosfwd>
@@ -184,7 +185,46 @@
 private: 
     /// Return the determinant of this matrix in 32.32 fixed point format.
     boost::int64_t  determinant() const;
-};
+
+    inline boost::int32_t FloatToFixed16(float a)
+    {
+#ifdef TRUST_FLOAT_TO_UINT32_CONVERSION
+        // truncate when overflow occurs.
+        return (boost::int32_t)(boost::uint32_t)(a * 65536.0f);
+#else
+        boost::int32_t  b;
+        if(a >= 0)
+        {
+            b = (boost::uint32_t)(std::fmod(a*65536.0, 4294967296.0));
+        }
+        else
+        {
+            b = -(boost::uint32_t)(std::fmod(-a*65536.0, 4294967296.0));
+        }
+        return b;
+#endif
+    }
+
+    inline boost::int32_t DoubleToFixed16(double a)
+    {
+#ifdef TRUST_FLOAT_TO_UINT32_CONVERSION
+        // truncate when overflow occurs.
+        return (boost::int32_t)(boost::uint32_t)(a * 65536.0);
+#else
+        boost::int32_t  b;
+        if(a >= 0)
+        {
+            b = (boost::uint32_t)(std::fmod(a*65536.0, 4294967296.0));
+        }
+        else
+        {
+            b = -(boost::uint32_t)(std::fmod(-a*65536.0, 4294967296.0));
+        }
+        return b;
+#endif
+    }
+
+}; //end of matrix
 
 inline bool operator== (const matrix& a, const matrix& b)
 {

Index: server/types.h
===================================================================
RCS file: /sources/gnash/gnash/server/types.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/types.h      13 Jun 2008 09:13:05 -0000      1.26
+++ server/types.h      16 Jun 2008 07:22:20 -0000      1.27
@@ -11,10 +11,6 @@
 #include <string>
 #include <boost/cstdint.hpp> // for boost::?int??_t 
 
-inline double TWIPS_TO_PIXELS(int i) { return i / 20.0; }
-// truncate when overflow occurs.
-inline int PIXELS_TO_TWIPS(double d) { return (int)(unsigned int)(d * 20); }
-
 namespace gnash {
        class SWFStream;        // forward declaration
 

Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- server/parser/movie_def_impl.h      9 Jun 2008 14:31:55 -0000       1.82
+++ server/parser/movie_def_impl.h      16 Jun 2008 07:22:21 -0000      1.83
@@ -37,6 +37,7 @@
 #include "resource.h" // for boost::intrusive_ptr visibility of dtor
 #include "stream.h" // for get_bytes_loaded and visitbility of dtor 
(composition)
 #include "StringPredicates.h" // for case-insensitive string comparision 
(ExportMap)
+#include "utility.h" // for TWIPS_TO_PIXELS 
 
 #include <map> // for CharacterDictionary
 #include <set> // for _importSources

Index: testsuite/server/MatrixTest.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/server/MatrixTest.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- testsuite/server/MatrixTest.cpp     13 Jun 2008 09:17:29 -0000      1.15
+++ testsuite/server/MatrixTest.cpp     16 Jun 2008 07:22:21 -0000      1.16
@@ -34,7 +34,7 @@
        double _d;
        double _t; // tolerance
 
-       D(double d) : _d(d), _t(1e-6) {}
+       D(double d) : _d(d), _t(1e-3) {}
 
        // Set tolerance
        D(double d, double t) : _d(d), _t(t) {}
@@ -58,7 +58,6 @@
 int
 main(int /*argc*/, char** /*argv*/)
 {
-#if 0
     std::string label;
 
        // Check attributes of the identity
@@ -230,6 +229,5 @@
 
     check_equals(m1_inverse.get_x_translation(), 0);    
     check_equals(m1_inverse.get_y_translation(), 0);  
-#endif
 }
 




reply via email to

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