gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/array.cpp server/cxform....


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog server/array.cpp server/cxform....
Date: Sun, 18 May 2008 20:36:14 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/05/18 20:36:14

Modified files:
        .              : ChangeLog 
        server         : array.cpp cxform.cpp edit_text_character.cpp 
                         fill_style.cpp font.cpp matrix.cpp 
                         movie_root.cpp rect.cpp sprite_instance.cpp 
                         styles.cpp types.cpp 
        server/asobj   : string.cpp 
        server/parser  : morph2_character_def.cpp 
                         shape_character_def.cpp 
        server/swf     : SetBackgroundColorTag.h 
        libbase        : FLVParser.cpp noseek_fd_adapter.cpp tu_file.cpp 
                         utility.h zlib_adapter.cpp 
        libmedia       : AudioDecoderSimple.cpp 
        gui            : gnash.cpp 

Log message:
                * libbase/utility.h: move general mathematical functions under
                  gnash::utility namespace so that their origin is clearer in
                  the code.
                * server/sprite_instance.cpp: replace C99 round function with
                  std::floor(x + 0.5). This is different for negative 
half-values
                  but the testsuite passes and the original use of round doesn't
                  seem to have any particular reasoning. Comments explaining why
                  in case it causes problems.
                * server/parser/shape_character_def.cpp: ditto.
                * libbase/noseek_fd_adapter.cpp: fix some sizet_fmt warnings 
(there
                  are plenty more, but are ifdeffed out at the moment).
                * server/font.cpp: silence unused variable warning.
                * many files: add gnash::utility namespace for flerp, frnd etc.
        
        If the difference in round function causes errors not caught by the
        testsuite (though flash apparently rounds towards +Infinity in 
ActionScript),
        the most portable fix would be to add an inline 
utility::roundFunction() (or
        similar) that uses the C99 round where available and provides an
        implementation otherwise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6638&r2=1.6639
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.cpp?cvsroot=gnash&r1=1.106&r2=1.107
http://cvs.savannah.gnu.org/viewcvs/gnash/server/cxform.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.184&r2=1.185
http://cvs.savannah.gnu.org/viewcvs/gnash/server/fill_style.cpp?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/server/font.cpp?cvsroot=gnash&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.cpp?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.192&r2=1.193
http://cvs.savannah.gnu.org/viewcvs/gnash/server/rect.cpp?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.536&r2=1.537
http://cvs.savannah.gnu.org/viewcvs/gnash/server/styles.cpp?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/types.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/morph2_character_def.cpp?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/shape_character_def.cpp?cvsroot=gnash&r1=1.70&r2=1.71
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/SetBackgroundColorTag.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/FLVParser.cpp?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/noseek_fd_adapter.cpp?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/tu_file.cpp?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/utility.h?cvsroot=gnash&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/zlib_adapter.cpp?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/AudioDecoderSimple.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gnash.cpp?cvsroot=gnash&r1=1.119&r2=1.120

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6638
retrieving revision 1.6639
diff -u -b -r1.6638 -r1.6639
--- ChangeLog   18 May 2008 19:40:12 -0000      1.6638
+++ ChangeLog   18 May 2008 20:36:10 -0000      1.6639
@@ -1,3 +1,19 @@
+2008-05-18 Benjamin Wolsey <address@hidden>
+
+       * libbase/utility.h: move general mathematical functions under
+         gnash::utility namespace so that their origin is clearer in
+         the code.
+       * server/sprite_instance.cpp: replace C99 round function with
+         std::floor(x + 0.5). This is different for negative half-values
+         but the testsuite passes and the original use of round doesn't
+         seem to have any particular reasoning. Comments explaining why
+         in case it causes problems.
+       * server/parser/shape_character_def.cpp: ditto.
+       * libbase/noseek_fd_adapter.cpp: fix some sizet_fmt warnings (there
+         are plenty more, but are ifdeffed out at the moment).
+       * server/font.cpp: silence unused variable warning.
+       * many files: add gnash::utility namespace for flerp, frnd etc.
+
 2008-05-18 Sandro Santilli <address@hidden>
 
        * macros/kde.m4: add --with-kparts-install=user|system|prefix,

Index: server/array.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/array.cpp,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -b -r1.106 -r1.107
--- server/array.cpp    17 May 2008 10:47:07 -0000      1.106
+++ server/array.cpp    18 May 2008 20:36:11 -0000      1.107
@@ -924,7 +924,7 @@
        unsigned startoffset;
        int start = fn.arg(0).to_number<int>();
        if ( start < 0 ) start = array->size()+start; // start is negative, so 
+ means -abs()
-       startoffset = iclamp(start, 0, origlen);
+       startoffset = utility::iclamp(start, 0, origlen);
 #ifdef GNASH_DEBUG
        if ( startoffset != start )
                log_debug(_("Array.splice: start:%d became %u"), start, 
startoffset);
@@ -945,7 +945,7 @@
                        );
                        return as_value();
                }
-               len = iclamp(lenval, 0, origlen-startoffset);
+               len = utility::iclamp(lenval, 0, origlen-startoffset);
        }
 
        //----------------

Index: server/cxform.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/cxform.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/cxform.cpp   16 May 2008 07:15:41 -0000      1.12
+++ server/cxform.cpp   18 May 2008 20:36:11 -0000      1.13
@@ -28,8 +28,6 @@
 #include "log.h"
 #include "utility.h" // for fclamp
 
-using namespace std;
-
 namespace gnash {
 
 cxform cxform::identity;
@@ -77,10 +75,10 @@
 void   cxform::transform(boost::uint8_t& r, boost::uint8_t& g, boost::uint8_t& 
b, boost::uint8_t& a) const
 // Faster transform() method for loops (avoids creation of rgba object)
 {
-       r = (boost::uint8_t) fclamp(r * m_[0][0] + m_[0][1], 0, 255);
-       g = (boost::uint8_t) fclamp(g * m_[1][0] + m_[1][1], 0, 255);
-       b = (boost::uint8_t) fclamp(b * m_[2][0] + m_[2][1], 0, 255);
-       a = (boost::uint8_t) fclamp(a * m_[3][0] + m_[3][1], 0, 255);
+       r = (boost::uint8_t) utility::fclamp(r * m_[0][0] + m_[0][1], 0, 255);
+       g = (boost::uint8_t) utility::fclamp(g * m_[1][0] + m_[1][1], 0, 255);
+       b = (boost::uint8_t) utility::fclamp(b * m_[2][0] + m_[2][1], 0, 255);
+       a = (boost::uint8_t) utility::fclamp(a * m_[3][0] + m_[3][1], 0, 255);
 }
 
 void   cxform::read_rgb(stream& in)
@@ -156,15 +154,15 @@
 /// Force component values to be in legal range.
 void cxform::clamp()
 {
-       m_[0][0] = fclamp(m_[0][0], 0, 1);
-       m_[1][0] = fclamp(m_[1][0], 0, 1);
-       m_[2][0] = fclamp(m_[2][0], 0, 1);
-       m_[3][0] = fclamp(m_[3][0], 0, 1);
-       
-       m_[0][1] = fclamp(m_[0][1], -255.0f, 255.0f);
-       m_[1][1] = fclamp(m_[1][1], -255.0f, 255.0f);
-       m_[2][1] = fclamp(m_[2][1], -255.0f, 255.0f);
-       m_[3][1] = fclamp(m_[3][1], -255.0f, 255.0f);
+       m_[0][0] = utility::fclamp(m_[0][0], 0, 1);
+       m_[1][0] = utility::fclamp(m_[1][0], 0, 1);
+       m_[2][0] = utility::fclamp(m_[2][0], 0, 1);
+       m_[3][0] = utility::fclamp(m_[3][0], 0, 1);
+       
+       m_[0][1] = utility::fclamp(m_[0][1], -255.0f, 255.0f);
+       m_[1][1] = utility::fclamp(m_[1][1], -255.0f, 255.0f);
+       m_[2][1] = utility::fclamp(m_[2][1], -255.0f, 255.0f);
+       m_[3][1] = utility::fclamp(m_[3][1], -255.0f, 255.0f);
 }
 
 void   cxform::print() const

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -b -r1.184 -r1.185
--- server/edit_text_character.cpp      17 May 2008 15:48:10 -0000      1.184
+++ server/edit_text_character.cpp      18 May 2008 20:36:11 -0000      1.185
@@ -718,7 +718,7 @@
                        gnash::key::code c = id.keyCode;
 
                        // maybe _text is changed in ActionScript
-                       m_cursor = imin(m_cursor, _text.size());
+                       m_cursor = utility::imin(m_cursor, _text.size());
 
                        switch (c)
                        {
@@ -1075,7 +1075,7 @@
                // @@ TODO this should be generic to class character!
                // Arg is in percent.
                cxform  cx = get_cxform();
-               cx.m_[3][0] = 
fclamp(utility::infinite_to_fzero(val.to_number()) / 100.f, 0, 1);
+               cx.m_[3][0] = 
utility::fclamp(utility::infinite_to_fzero(val.to_number()) / 100.f, 0, 1);
                set_cxform(cx);
                return true;
        }

Index: server/fill_style.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/fill_style.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- server/fill_style.cpp       21 Apr 2008 11:27:43 -0000      1.27
+++ server/fill_style.cpp       18 May 2008 20:36:12 -0000      1.28
@@ -499,8 +499,8 @@
     for (size_t j=0, nj=m_gradients.size(); j<nj; ++j)
     {
         m_gradients[j].m_ratio =
-            (boost::uint8_t) frnd(
-                flerp(a.m_gradients[j].m_ratio, b.m_gradients[j].m_ratio, t)
+            (boost::uint8_t) utility::frnd(
+                utility::flerp(a.m_gradients[j].m_ratio, 
b.m_gradients[j].m_ratio, t)
                 );
         m_gradients[j].m_color.set_lerp(a.m_gradients[j].m_color, 
b.m_gradients[j].m_color, t);
     }

Index: server/font.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/font.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- server/font.cpp     16 May 2008 07:18:47 -0000      1.65
+++ server/font.cpp     18 May 2008 20:36:12 -0000      1.66
@@ -234,6 +234,7 @@
                m_is_bold          = flags & (1 << 0);
         // don't know the usage, so we discard it.
                int     discarded = in->read_u8();
+               UNUSED(discarded);
 
                IF_VERBOSE_PARSE (
             log_parse(" has_layout = %d", has_layout);

Index: server/matrix.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/matrix.cpp   17 May 2008 10:47:11 -0000      1.28
+++ server/matrix.cpp   18 May 2008 20:36:12 -0000      1.29
@@ -140,6 +140,7 @@
 matrix::set_lerp(const matrix& m1, const matrix& m2, float t)
 // Set this matrix to a blend of m1 and m2, parameterized by t.
 {
+    using utility::flerp;
        m_[0][0] = flerp(m1.m_[0][0], m2.m_[0][0], t);
        m_[1][0] = flerp(m1.m_[1][0], m2.m_[1][0], t);
        m_[0][1] = flerp(m1.m_[0][1], m2.m_[0][1], t);

Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -b -r1.192 -r1.193
--- server/movie_root.cpp       2 May 2008 20:01:36 -0000       1.192
+++ server/movie_root.cpp       18 May 2008 20:36:12 -0000      1.193
@@ -1979,7 +1979,7 @@
 {
        //GNASH_REPORT_FUNCTION;
 
-       boost::uint8_t newAlpha = iclamp(frnd(alpha * 255.0f), 0, 255);
+       boost::uint8_t newAlpha = utility::iclamp(utility::frnd(alpha * 
255.0f), 0, 255);
 
         if ( m_background_color.m_a != newAlpha )
        {

Index: server/rect.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/rect.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/rect.cpp     28 Jan 2008 15:16:51 -0000      1.17
+++ server/rect.cpp     18 May 2008 20:36:12 -0000      1.18
@@ -144,6 +144,7 @@
        
        // TODO: remove double calls to get_{x,y}_{min,max}
        //       to remove double equivalent assertions
+       using utility::flerp;
        float xmin = flerp(a.get_x_min(), b.get_x_min(), t);
        float ymin = flerp(a.get_y_min(), b.get_y_min(), t);
        float xmax = flerp(a.get_x_max(), b.get_x_max(), t);
@@ -163,8 +164,8 @@
        // nothing to do, point is surely inside
        if ( _range.isWorld() ) return;
 
-       p.x = fclamp(p.x, _range.getMinX(), _range.getMaxX());
-       p.y = fclamp(p.y, _range.getMinY(), _range.getMaxY());
+       p.x = utility::fclamp(p.x, _range.getMinX(), _range.getMaxX());
+       p.y = utility::fclamp(p.y, _range.getMinY(), _range.getMaxY());
 }
 
 std::string

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.536
retrieving revision 1.537
diff -u -b -r1.536 -r1.537
--- server/sprite_instance.cpp  17 May 2008 10:47:12 -0000      1.536
+++ server/sprite_instance.cpp  18 May 2008 20:36:12 -0000      1.537
@@ -65,16 +65,14 @@
 #include <string>
 #include <cmath>
 
-#ifdef __sgi
-extern double round(double);
-#pragma optional round
-#endif
-
 #include <functional> // for mem_fun, bind1st
 #include <algorithm> // for for_each
 #include <boost/algorithm/string/case_conv.hpp>
 
-using namespace std;
+//#ifdef __sgi
+//extern double round(double);
+//#pragma optional round
+//#endif
 
 namespace gnash {
 
@@ -371,7 +369,7 @@
   if ( this_depth < character::staticDepthOffset )
   {
     IF_VERBOSE_ASCODING_ERRORS(
-    stringstream ss; fn.dump_args(ss);
+    std::stringstream ss; fn.dump_args(ss);
     log_aserror(_("%s.swapDepths(%s): won't swap a clip below depth %d (%d)"),
       sprite->getTarget(), ss.str(), character::staticDepthOffset, this_depth);
     );
@@ -415,7 +413,7 @@
     if ( sprite->get_depth() == target_depth )
     {
       IF_VERBOSE_ASCODING_ERRORS(
-      stringstream ss; fn.dump_args(ss);
+      std::stringstream ss; fn.dump_args(ss);
       log_aserror(_("%s.swapDepths(%s): ignored, source and target characters 
have the same depth %d"),
         sprite->getTarget(), ss.str(), target_depth);
       );
@@ -432,7 +430,7 @@
     if ( isnan(td) )
     {
       IF_VERBOSE_ASCODING_ERRORS(
-      stringstream ss; fn.dump_args(ss);
+      std::stringstream ss; fn.dump_args(ss);
       log_aserror(_("%s.swapDepths(%s): first argument invalid "
         "(neither a sprite nor a number)"),
         sprite->getTarget(), ss.str());
@@ -449,7 +447,7 @@
     if ( sprite->get_depth() == target_depth )
     {
       IF_VERBOSE_ASCODING_ERRORS(
-      stringstream ss; fn.dump_args(ss);
+      std::stringstream ss; fn.dump_args(ss);
       log_aserror(_("%s.swapDepths(%s): ignored, character already at depth 
%d"),
         sprite->getTarget(), ss.str(), target_depth);
       );
@@ -1092,8 +1090,13 @@
   matrix world_mat = sprite->get_world_matrix();
   world_mat.transform_by_inverse(pt);
 
-  obj->set_member(NSV::PROP_X, TWIPS_TO_PIXELS(round(pt.x)));
-  obj->set_member(NSV::PROP_Y, TWIPS_TO_PIXELS(round(pt.y)));
+  // These used to be: round(pt.x), which would round negative
+  // half-values away from zero (-0.5 - > -1), whereas
+  // std::floor(x + 0.5) always rounds towards +Infinity (-0.5 -> 0).
+  // All other cases should be the same. The testsuite doesn't
+  // notice the difference.
+  obj->set_member(NSV::PROP_X, TWIPS_TO_PIXELS(std::floor(pt.x + 0.5)));
+  obj->set_member(NSV::PROP_Y, TWIPS_TO_PIXELS(std::floor(pt.y + 0.5)));
 
   return ret;
 }
@@ -1154,8 +1157,13 @@
   matrix world_mat = sprite->get_world_matrix();
   world_mat.transform(pt);
 
-  obj->set_member(NSV::PROP_X, TWIPS_TO_PIXELS(round(pt.x)));
-  obj->set_member(NSV::PROP_Y, TWIPS_TO_PIXELS(round(pt.y)));
+  // These used to be: round(pt.x), which would round negative
+  // half-values away from zero (-0.5 - > -1), whereas
+  // std::floor(x + 0.5) always rounds towards +Infinity (-0.5 -> 0).
+  // All other cases should be the same. The testsuite doesn't
+  // notice the difference.
+  obj->set_member(NSV::PROP_X, TWIPS_TO_PIXELS(std::floor(pt.x + 0.5)));
+  obj->set_member(NSV::PROP_Y, TWIPS_TO_PIXELS(std::floor(pt.y + 0.5)));
 
   return ret;
 
@@ -1356,7 +1364,7 @@
     return as_value();
   }
 
-  thickness = 
boost::uint16_t(PIXELS_TO_TWIPS(boost::uint16_t(fclamp(fn.arg(0).to_number(), 
0, 255))));
+  thickness = 
boost::uint16_t(PIXELS_TO_TWIPS(boost::uint16_t(utility::fclamp(fn.arg(0).to_number(),
 0, 255))));
   bool scaleThicknessVertically = true;
   bool scaleThicknessHorizontally = true;
   bool pixelHinting = false;
@@ -1368,14 +1376,14 @@
   if ( fn.nargs > 1 )
   {
     // 2^24 is the max here
-    boost::uint32_t rgbval = boost::uint32_t(fclamp(fn.arg(1).to_number(), 0, 
16777216));
+    boost::uint32_t rgbval = 
boost::uint32_t(utility::fclamp(fn.arg(1).to_number(), 0, 16777216));
     r = boost::uint8_t( (rgbval&0xFF0000) >> 16);
     g = boost::uint8_t( (rgbval&0x00FF00) >> 8);
     b = boost::uint8_t( (rgbval&0x0000FF) );
 
     if ( fn.nargs > 2 )
     {
-      float alphaval = fclamp(fn.arg(2).to_number(), 0, 100);
+      float alphaval = utility::fclamp(fn.arg(2).to_number(), 0, 100);
       a = boost::uint8_t( 255 * (alphaval/100) );
 
       if ( fn.nargs > 3 )
@@ -1472,7 +1480,7 @@
           }
           if ( fn.nargs > 7 )
           {
-            miterLimitFactor = iclamp(fn.arg(7).to_int(), 1, 255);
+            miterLimitFactor = utility::iclamp(fn.arg(7).to_int(), 1, 255);
           }
 
           IF_VERBOSE_ASCODING_ERRORS(
@@ -1614,14 +1622,14 @@
   if ( fn.nargs > 0 )
   {
     // 2^24 is the max here
-    boost::uint32_t rgbval = boost::uint32_t(fclamp(fn.arg(0).to_number(), 0, 
16777216));
+    boost::uint32_t rgbval = 
boost::uint32_t(utility::fclamp(fn.arg(0).to_number(), 0, 16777216));
     r = boost::uint8_t( (rgbval&0xFF0000) >> 16);
     g = boost::uint8_t( (rgbval&0x00FF00) >> 8);
     b = boost::uint8_t( (rgbval&0x0000FF) );
 
     if ( fn.nargs > 1 )
     {
-      a = 255 * iclamp(fn.arg(1).to_int(), 0, 100) / 100;
+      a = 255 * utility::iclamp(fn.arg(1).to_int(), 0, 100) / 100;
       IF_VERBOSE_ASCODING_ERRORS(
       if ( fn.nargs > 2 )
       {
@@ -1667,7 +1675,7 @@
   );
 
   bool radial = false;
-  string typeStr = fn.arg(0).to_string();
+  std::string typeStr = fn.arg(0).to_string();
   // Case-sensitive comparison needed for this ...
   if ( typeStr == "radial" ) radial = true;
   else if ( typeStr == "linear" ) radial = false;
@@ -1881,10 +1889,10 @@
     boost::uint32_t col = colVal.is_number() ? colVal.to_int() : 0;
 
     as_value alpVal = alphas->getMember(key);
-    boost::uint8_t alp = alpVal.is_number() ? iclamp(alpVal.to_int(), 0, 255) 
: 0;
+    boost::uint8_t alp = alpVal.is_number() ? utility::iclamp(alpVal.to_int(), 
0, 255) : 0;
 
     as_value ratVal = ratios->getMember(key);
-    boost::uint8_t rat = ratVal.is_number() ? iclamp(ratVal.to_int(), 0, 255) 
: 0;
+    boost::uint8_t rat = ratVal.is_number() ? utility::iclamp(ratVal.to_int(), 
0, 255) : 0;
 
     rgba color;
     color.parseRGB(col);
@@ -1941,13 +1949,13 @@
             bool swapped = false;
             if ( y1 < y0 )
             {
-                swap(y1, y0);
+                std::swap(y1, y0);
                 swapped = true;
             }
 
             if ( x1 < x0 )
             {
-                swap(x1, x0);
+                std::swap(x1, x0);
                 swapped = true;
             }
 
@@ -2878,7 +2886,7 @@
     return obj;
   }
 
-  string name = _vm.getStringTable().value(key);
+  std::string name = _vm.getStringTable().value(key);
 
   // See if we have a match on the display list.
   character* ch;
@@ -4556,7 +4564,7 @@
         if ( sendVarsMethod == 1 )
        {
                // Append variables
-               string qs = url.querystring();
+               std::string qs = url.querystring();
                if ( qs.empty() ) url.set_querystring(postdata);
                else url.set_querystring(qs + std::string("&") + postdata);
        }
@@ -4588,8 +4596,8 @@
       itEnd=vals.end();
     it != itEnd; ++it)
   {
-    const string name = PROPNAME(it->first);
-    const string& val = it->second;
+    const std::string name = PROPNAME(it->first);
+    const std::string& val = it->second;
 #ifdef DEBUG_LOAD_VARIABLES
     log_debug(_("Setting variable '%s' to value '%s'"), name, val);
 #endif
@@ -4630,8 +4638,8 @@
   for (VariableMap::const_iterator it=vars.begin(), itEnd=vars.end();
     it != itEnd; ++it)
   {
-    const string& name = it->first;
-    const string& val = it->second;
+    const std::string& name = it->first;
+    const std::string& val = it->second;
     set_member(st.find(PROPNAME(name)), val);
   }
 }

Index: server/styles.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/styles.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/styles.cpp   5 May 2008 11:44:33 -0000       1.43
+++ server/styles.cpp   18 May 2008 20:36:12 -0000      1.44
@@ -146,7 +146,8 @@
 void
 line_style::set_lerp(const line_style& ls1, const line_style& ls2, float ratio)
 {
-       m_width = (boost::uint16_t)frnd(flerp(ls1.getThickness(), 
ls2.getThickness(), ratio));
+       m_width = static_cast<boost::uint16_t>(
+           utility::frnd(utility::flerp(ls1.getThickness(), 
ls2.getThickness(), ratio)));
        m_color.set_lerp(ls1.get_color(), ls2.get_color(), ratio);
        if ( ls1._scaleVertically != ls2._scaleVertically )
        {

Index: server/types.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/types.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/types.cpp    17 May 2008 10:47:13 -0000      1.29
+++ server/types.cpp    18 May 2008 20:36:12 -0000      1.30
@@ -82,10 +82,12 @@
        
        void    rgba::set_lerp(const rgba& a, const rgba& b, float f)
        {
-               m_r = (boost::uint8_t) frnd(flerp(a.m_r, b.m_r, f));
-               m_g = (boost::uint8_t) frnd(flerp(a.m_g, b.m_g, f));
-               m_b = (boost::uint8_t) frnd(flerp(a.m_b, b.m_b, f));
-               m_a = (boost::uint8_t) frnd(flerp(a.m_a, b.m_a, f));
+           using utility::frnd;
+           using utility::flerp;
+               m_r = static_cast<boost::uint8_t>(frnd(flerp(a.m_r, b.m_r, f)));
+               m_g = static_cast<boost::uint8_t>(frnd(flerp(a.m_g, b.m_g, f)));
+               m_b = static_cast<boost::uint8_t>(frnd(flerp(a.m_b, b.m_b, f)));
+               m_a = static_cast<boost::uint8_t>(frnd(flerp(a.m_a, b.m_a, f)));
        }
 
 std::ostream&

Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- server/asobj/string.cpp     21 Apr 2008 11:27:44 -0000      1.67
+++ server/asobj/string.cpp     18 May 2008 20:36:13 -0000      1.68
@@ -210,7 +210,7 @@
         index = subject.size() + index;
     }
 
-    index = iclamp(index, 0, subject.size());
+    index = utility::iclamp(index, 0, subject.size());
 
     return index;
 }
@@ -295,7 +295,7 @@
        {
                return as_value(array.get());
        }
-        max = iclamp((size_t)max_in, 0, wstr.size());
+        max = utility::iclamp((size_t)max_in, 0, wstr.size());
     }
 
     if ( wstr.empty() )

Index: server/parser/morph2_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/morph2_character_def.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/parser/morph2_character_def.cpp      28 Apr 2008 13:23:27 -0000      
1.25
+++ server/parser/morph2_character_def.cpp      18 May 2008 20:36:13 -0000      
1.26
@@ -158,8 +158,8 @@
                        const path& p1 = i < paths1.size() ? paths1[i] : 
empty_path;
                        const path& p2 = n < paths2.size() ? paths2[n] : 
empty_path;
 
-                       float new_ax = flerp(p1.ap.x, p2.ap.x, ratio);
-                       float new_ay = flerp(p1.ap.y, p2.ap.y, ratio);
+                       float new_ax = utility::flerp(p1.ap.x, p2.ap.x, ratio);
+                       float new_ay = utility::flerp(p1.ap.y, p2.ap.y, ratio);
 
                        p.reset ( new_ax, new_ay, p1.getLeftFill(), 
p2.getRightFill(), p1.getLineStyle() );
 
@@ -173,10 +173,10 @@
                                const edge& e1 = j < p1.size() ? p1[j] : 
empty_edge;
                                const edge& e2 = k < p2.size() ? p2[k] : 
empty_edge;
 
-                               e.cp.x = static_cast<int>(flerp(e1.cp.x, 
e2.cp.x, ratio));
-                               e.cp.y = static_cast<int>(flerp(e1.cp.y, 
e2.cp.y, ratio));
-                               e.ap.x = static_cast<int>(flerp(e1.ap.x, 
e2.ap.x, ratio));
-                               e.ap.y = static_cast<int>(flerp(e1.ap.y, 
e2.ap.y, ratio));
+                               e.cp.x = 
static_cast<int>(utility::flerp(e1.cp.x, e2.cp.x, ratio));
+                               e.cp.y = 
static_cast<int>(utility::flerp(e1.cp.y, e2.cp.y, ratio));
+                               e.ap.x = 
static_cast<int>(utility::flerp(e1.ap.x, e2.ap.x, ratio));
+                               e.ap.y = 
static_cast<int>(utility::flerp(e1.ap.y, e2.ap.y, ratio));
                                k++;
                                if (p2.size() <= k)
                                {

Index: server/parser/shape_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/shape_character_def.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- server/parser/shape_character_def.cpp       29 Apr 2008 11:29:04 -0000      
1.70
+++ server/parser/shape_character_def.cpp       18 May 2008 20:36:13 -0000      
1.71
@@ -36,10 +36,10 @@
 #include <cfloat>
 #include <algorithm>
 
-#ifdef __sgi
-extern double round(double);
-#pragma optional round
-#endif
+//#ifdef __sgi
+//extern double round(double);
+//#pragma optional round
+//#endif
 
 // Define the macro below to always compute bounds for shape characters
 // and compare them with the bounds encoded in the SWF
@@ -62,7 +62,7 @@
 
     void  set_curve_max_pixel_error(float pixel_error)
     {
-        s_curve_max_pixel_error = fclamp(pixel_error, 1e-6f, 1e6f);
+        s_curve_max_pixel_error = utility::fclamp(pixel_error, 1e-6f, 1e6f);
     }
 
     float get_curve_max_pixel_error()
@@ -902,8 +902,12 @@
         // any visible inaccuracy before the shape is scaled more an 2000x). 
The
         // resulting coordinate is *very* close to the original one and still 
in the
         // same coordinate system.
-        x = (round(x * 2000.0f) + 0.5f) / 2000.0f;
-        y = (round(y * 2000.0f) + 0.5f) / 2000.0f;
+        
+        // These used to use round(x), now use std::floor(x + 0.5f), which
+        // means that negative half-values are rounded in a different
+        // direction. The testsuite notices no differences.
+        x = (std::floor(x * 2000.0f + 0.5f) + 0.5f) / 2000.0f;
+        y = (std::floor(y * 2000.0f + 0.5f) + 0.5f) / 2000.0f;
 
         point pt(x, y);
 

Index: server/swf/SetBackgroundColorTag.h
===================================================================
RCS file: /sources/gnash/gnash/server/swf/SetBackgroundColorTag.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/swf/SetBackgroundColorTag.h  30 Apr 2008 13:34:29 -0000      1.3
+++ server/swf/SetBackgroundColorTag.h  18 May 2008 20:36:13 -0000      1.4
@@ -86,7 +86,7 @@
        {
                float   current_alpha = m->get_background_alpha();
                rgba newcolor = m_color; // to avoid making m_color mutable
-               newcolor.m_a = frnd(current_alpha * 255.0f);
+               newcolor.m_a = utility::frnd(current_alpha * 255.0f);
                m->set_background_color(newcolor);
        }
 

Index: libbase/FLVParser.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/FLVParser.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- libbase/FLVParser.cpp       12 May 2008 08:33:15 -0000      1.35
+++ libbase/FLVParser.cpp       18 May 2008 20:36:13 -0000      1.36
@@ -349,7 +349,7 @@
        size_t guess = size_t(time / tpf);
 
        // Here we test if the guess was ok, and adjust if needed.
-       size_t bestFrame = iclamp(guess, 0, _audioFrames.size()-1);
+       size_t bestFrame = utility::iclamp(guess, 0, _audioFrames.size()-1);
 
        // Here we test if the guess was ok, and adjust if needed.
        long diff = _audioFrames[bestFrame]->timestamp - time;
@@ -410,7 +410,7 @@
        double tpf = lastFrame->timestamp / numFrames; // time per frame
        size_t guess = size_t(time / tpf);
 
-       size_t bestFrame = iclamp(guess, 0, _videoFrames.size()-1);
+       size_t bestFrame = utility::iclamp(guess, 0, _videoFrames.size()-1);
 
        // Here we test if the guess was ok, and adjust if needed.
        long diff = _videoFrames[bestFrame]->timestamp - time;

Index: libbase/noseek_fd_adapter.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/noseek_fd_adapter.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- libbase/noseek_fd_adapter.cpp       21 Jan 2008 20:55:45 -0000      1.25
+++ libbase/noseek_fd_adapter.cpp       18 May 2008 20:36:13 -0000      1.26
@@ -47,6 +47,7 @@
 #endif
 
 #include <string>
+#include <boost/format.hpp>
 
 namespace noseek_fd_adapter
 {
@@ -223,9 +224,7 @@
                ssize_t bytesRead = read(_fd, (void*)_buf, bytesNeeded);
                if ( bytesRead < 0 )
                {
-                       fprintf(stderr,
-                               "Error reading " SIZET_FMT " bytes from input 
stream",
-                               bytesNeeded);
+                       std::cerr << boost::format(_("Error reading %d bytes 
from input stream")) % bytesNeeded;
                        _running = false;
                        // this looks like a CRITICAL error (since we don't 
handle it..)
                        throw gnash::GnashException("Error reading from input 
stream");

Index: libbase/tu_file.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/tu_file.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- libbase/tu_file.cpp 28 Mar 2008 10:10:33 -0000      1.26
+++ libbase/tu_file.cpp 18 May 2008 20:36:13 -0000      1.27
@@ -263,7 +263,7 @@
     
     int        bytes_left = byte_count;
     while (bytes_left) {
-       int     to_copy = imin(bytes_left, BUFSIZE);
+       int     to_copy = utility::imin(bytes_left, BUFSIZE);
        
        int     read_count = src->read_bytes(buffer, to_copy);
        int     write_count = write_bytes(buffer, read_count);

Index: libbase/utility.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/utility.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- libbase/utility.h   17 May 2008 10:47:15 -0000      1.52
+++ libbase/utility.h   18 May 2008 20:36:13 -0000      1.53
@@ -86,6 +86,10 @@
 #define M_PI 3.141592654
 #endif // M_PI
 
+// Commonly-used inlined mathematical functions are defined in
+// namespace gnash::utility so that it's clear where they
+// come from.
+
 namespace gnash {
 namespace utility {
 
@@ -105,33 +109,62 @@
     return utility::isFinite(x) ? x : 0.0f;
 }
 
+inline int iabs(int i)
+{
+    if (i < 0) return -i;
+    else return i;
 }
+
+/* fmax()/fmin() is C99 */
+inline float fmax(float a, float b)
+{
+    if (a < b) return b;
+    else return a;
 }
-//
-// some misc handy math functions
-//
-namespace std {
+
+inline float fmin(float a, float b)
+{
+    if (a < b) return a;
+    else return b;
 }
-inline int     iabs(int i) { if (i < 0) return -i; else return i; }
-/* fmax()/fmin() is C99 */
-inline float   fmax(float a, float b) { if (a < b) return b; else return a; }
-inline float   fmin(float a, float b) { if (a < b) return a; else return b; }
-inline int     imax(int a, int b) { if (a < b) return b; else return a; }
-inline int     imin(int a, int b) { if (a < b) return a; else return b; }
 
-inline int     iclamp(int i, int min, int max) {
+inline int imax(int a, int b)
+{
+    if (a < b) return b;
+    else return a;
+}
+
+inline int imin(int a, int b)
+{
+    if (a < b) return a;
+    else return b;
+}
+
+inline int iclamp(int i, int min, int max)
+{
        assert( min <= max );
        return imax(min, imin(i, max));
 }
 
-inline float   fclamp(float f, float xmin, float xmax) {
+inline float fclamp(float f, float xmin, float xmax)
+{
        assert( xmin <= xmax );
        return fmax(xmin, fmin(f, xmax));
 }
 
-inline float flerp(float a, float b, float f) { return (b - a) * f + a; }
+inline float flerp(float a, float b, float f)
+{
+    return (b - a) * f + a;
+}
+
+inline int frnd(float f) 
+{
+    return static_cast<int>(f + 0.5f);
+}
+
+}
+}
 
-inline int     frnd(float f) { return (int)(f + 0.5f); }       // replace with 
inline asm if desired
 
 /// \brief
 /// Return the smallest multiple of given base greater or equal
@@ -147,7 +180,6 @@
 // Handy macro to quiet compiler warnings about unused parameters/variables.
 #define UNUSED(x) (x) = (x)
 
-
 // Compile-time constant size of array.
 #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
 

Index: libbase/zlib_adapter.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/zlib_adapter.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- libbase/zlib_adapter.cpp    12 Dec 2007 14:59:50 -0000      1.21
+++ libbase/zlib_adapter.cpp    18 May 2008 20:36:13 -0000      1.22
@@ -280,7 +280,7 @@
                {
                        int     to_read = pos - inf->m_logical_stream_pos;
                        assert(to_read > 0);
-                       int     to_read_this_time = imin(to_read, ZBUF_SIZE);
+                       int     to_read_this_time = utility::imin(to_read, 
ZBUF_SIZE);
                        assert(to_read_this_time > 0);
 
                        int     bytes_read = inf->inflate_from_stream(temp, 
to_read_this_time);

Index: libmedia/AudioDecoderSimple.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/AudioDecoderSimple.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- libmedia/AudioDecoderSimple.cpp     6 Mar 2008 05:22:51 -0000       1.15
+++ libmedia/AudioDecoderSimple.cpp     18 May 2008 20:36:14 -0000      1.16
@@ -82,11 +82,11 @@
                if (code_sign_bit) delta = -delta;
 
                sample += delta;
-               sample = iclamp(sample, -32768, 32767);
+               sample = utility::iclamp(sample, -32768, 32767);
 
                /* Update our stepsize index.  Use a lookup table. */
                stepsize_index += index_update_table[code_mag];
-               stepsize_index = iclamp(stepsize_index, 0, STEPSIZE_CT - 1);
+               stepsize_index = utility::iclamp(stepsize_index, 0, STEPSIZE_CT 
- 1);
        }
 
        /* Uncompress 4096 mono samples of ADPCM. */

Index: gui/gnash.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gnash.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -b -r1.119 -r1.120
--- gui/gnash.cpp       9 May 2008 19:34:11 -0000       1.119
+++ gui/gnash.cpp       18 May 2008 20:36:14 -0000      1.120
@@ -272,7 +272,7 @@
                     player.setStartFullscreen(true);
                     break;                    
                 case 's':
-                    player.setScale( fclamp(
+                    player.setScale( utility::fclamp(
                                     parser.argument<float>(i),
                                     0.01f, 100.f) );
                     break;




reply via email to

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