gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10691: Drop unused functions, clea


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10691: Drop unused functions, clean up and some minor renaming.
Date: Thu, 12 Mar 2009 14:49:07 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10691
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2009-03-12 14:49:07 +0100
message:
  Drop unused functions, clean up and some minor renaming.
modified:
  backend/render_handler_agg.cpp
  backend/render_handler_cairo.cpp
  backend/render_handler_ogl.cpp
  libcore/DynamicShape.cpp
  libcore/parser/BitmapMovieDefinition.h
  libcore/parser/SWFMovieDefinition.h
  libcore/parser/morph2_character_def.cpp
  libcore/parser/morph2_character_def.h
  libcore/parser/shape_character_def.cpp
  libcore/parser/shape_character_def.h
    ------------------------------------------------------------
    revno: 10689.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-03-12 08:09:47 +0100
    message:
      Formatting and code cleanup in morph2_character_def.
    modified:
      libcore/parser/morph2_character_def.cpp
    ------------------------------------------------------------
    revno: 10689.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-03-12 08:53:23 +0100
    message:
      Fix unused variable warning.
    modified:
      libcore/parser/BitmapMovieDefinition.h
      libcore/parser/SWFMovieDefinition.h
    ------------------------------------------------------------
    revno: 10689.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-03-12 08:54:13 +0100
    message:
      Renaming and refactoring.
    modified:
      libcore/DynamicShape.cpp
      libcore/parser/morph2_character_def.cpp
      libcore/parser/shape_character_def.cpp
      libcore/parser/shape_character_def.h
    ------------------------------------------------------------
    revno: 10689.1.4
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-03-12 09:30:45 +0100
    message:
      Algorithmize code for efficiency and ease of reading.
      
      Rename functions for clarity and to make them more likely to fit on
      one line.
    modified:
      backend/render_handler_agg.cpp
      backend/render_handler_cairo.cpp
      backend/render_handler_ogl.cpp
      libcore/parser/morph2_character_def.cpp
      libcore/parser/shape_character_def.h
    ------------------------------------------------------------
    revno: 10689.1.5
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-03-12 09:54:27 +0100
    message:
      Remove unnecessary variables from the class definition. Drop declarations 
of
      non-existent functions.
    modified:
      libcore/parser/morph2_character_def.cpp
      libcore/parser/morph2_character_def.h
    ------------------------------------------------------------
    revno: 10689.1.6
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-03-12 10:23:59 +0100
    message:
      More function name shortening.
    modified:
      backend/render_handler_agg.cpp
      backend/render_handler_cairo.cpp
      backend/render_handler_ogl.cpp
      libcore/parser/morph2_character_def.cpp
      libcore/parser/shape_character_def.h
=== modified file 'backend/render_handler_agg.cpp'
--- a/backend/render_handler_agg.cpp    2009-03-10 20:43:50 +0000
+++ b/backend/render_handler_agg.cpp    2009-03-12 09:23:59 +0000
@@ -882,7 +882,7 @@
     if (_clipbounds_selected.empty()) return; 
       
     GnashPaths paths;
-    apply_matrix_to_path(def->get_paths(), paths, mat);
+    apply_matrix_to_path(def->paths(), paths, mat);
 
     // If it's a mask, we don't need the rest.
     if (m_drawing_mask) {
@@ -975,11 +975,11 @@
     const SWFMatrix& mat, const cxform& cx)
     {
     
-        const std::vector<fill_style>& fill_styles = def->get_fill_styles();
-        const std::vector<line_style>& line_styles = def->get_line_styles();
+        const std::vector<fill_style>& fill_styles = def->fillStyles();
+        const std::vector<line_style>& line_styles = def->lineStyles();
         bool have_shape, have_outline;
 
-        analyzePaths(def->get_paths(), have_shape, have_outline);
+        analyzePaths(def->paths(), have_shape, have_outline);
 
         if (!have_shape && !have_outline) {
             // Early return for invisible character.
@@ -987,7 +987,7 @@
         }    
 
         GnashPaths paths;
-        apply_matrix_to_path(def->get_paths(), paths, mat);
+        apply_matrix_to_path(def->paths(), paths, mat);
 
         // Masks apparently do not use agg_paths, so return
         // early

=== modified file 'backend/render_handler_cairo.cpp'
--- a/backend/render_handler_cairo.cpp  2009-01-22 20:10:39 +0000
+++ b/backend/render_handler_cairo.cpp  2009-03-12 09:23:59 +0000
@@ -937,7 +937,7 @@
     const cxform& cx)
   {
         
-    const PathVec& path_vec = def->get_paths();
+    const PathVec& path_vec = def->paths();
     
     if (!path_vec.size()) {
       return;    
@@ -957,8 +957,8 @@
 
     std::vector<PathVec::const_iterator> subshapes = find_subshapes(path_vec);
     
-    const std::vector<fill_style>& fill_styles = def->get_fill_styles();
-    const std::vector<line_style>& line_styles = def->get_line_styles();
+    const std::vector<fill_style>& fill_styles = def->fillStyles();
+    const std::vector<line_style>& line_styles = def->lineStyles();
 
     for (size_t i = 0; i < subshapes.size()-1; ++i) {
       PathVec subshape_paths;
@@ -987,7 +987,7 @@
     
     glyph_fs.push_back(coloring);
     
-    const PathVec& path_vec = def->get_paths();
+    const PathVec& path_vec = def->paths();
     
     std::vector<line_style> dummy_ls;
     

=== modified file 'backend/render_handler_ogl.cpp'
--- a/backend/render_handler_ogl.cpp    2009-01-22 20:10:39 +0000
+++ b/backend/render_handler_ogl.cpp    2009-03-12 09:23:59 +0000
@@ -1476,7 +1476,7 @@
   }
   
   PathPtrVec
-  get_paths_by_style(const PathVec& path_vec, unsigned int style)
+  paths_by_style(const PathVec& path_vec, unsigned int style)
   {
     PathPtrVec paths;
     for (PathVec::const_iterator it = path_vec.begin(), end = path_vec.end();
@@ -1543,7 +1543,7 @@
     PathPointMap pathpoints = getPathPoints(normalized);
     
     for (size_t i = 0; i < fill_styles.size(); ++i) {
-      PathPtrVec paths = get_paths_by_style(normalized, i+1);
+      PathPtrVec paths = paths_by_style(normalized, i+1);
       
       if (!paths.size()) {
         continue;
@@ -1612,7 +1612,7 @@
     const cxform& cx)
   {
   
-    const PathVec& path_vec = def->get_paths();
+    const PathVec& path_vec = def->paths();
 
     if (!path_vec.size()) {
       // No paths. Nothing to draw...
@@ -1639,8 +1639,8 @@
 
     std::vector<PathVec::const_iterator> subshapes = find_subshapes(path_vec);
     
-    const std::vector<fill_style>& fill_styles = def->get_fill_styles();
-    const std::vector<line_style>& line_styles = def->get_line_styles();
+    const std::vector<fill_style>& fill_styles = def->fillStyles();
+    const std::vector<line_style>& line_styles = def->lineStyles();
     
     for (size_t i = 0; i < subshapes.size()-1; ++i) {
       PathVec subshape_paths;
@@ -1672,7 +1672,7 @@
     
     oglScopeMatrix scope_mat(mat);
     
-    draw_subshape(def->get_paths(), mat, dummy_cx, glyph_fs, dummy_ls);
+    draw_subshape(def->paths(), mat, dummy_cx, glyph_fs, dummy_ls);
   }
 
   virtual void set_scale(float xscale, float yscale) {

=== modified file 'libcore/DynamicShape.cpp'
--- a/libcore/DynamicShape.cpp  2009-02-25 22:33:03 +0000
+++ b/libcore/DynamicShape.cpp  2009-03-12 07:54:13 +0000
@@ -40,10 +40,10 @@
 DynamicShape::clear()
 {
        //clear_meshes();
-       m_paths.clear();
-       m_fill_styles.clear();
-       m_line_styles.clear();
-       m_bound.set_null();
+       _paths.clear();
+       _fill_styles.clear();
+       _line_styles.clear();
+       _bound.set_null();
        _currpath=0; // or would point to invalid memory
        _currfill = _currline = 0; // or would point to cleared m_fill_style 
and m_line_styles respectively
 
@@ -53,8 +53,8 @@
 void
 DynamicShape::add_path(const path& pth)
 {
-       m_paths.push_back(pth);
-       _currpath = &(m_paths.back());
+       _paths.push_back(pth);
+       _currpath = &(_paths.back());
        //compute_bound(&m_bound);
 }
 
@@ -147,8 +147,8 @@
        // Close any pending filled path (_currpath should be last path)
        if ( _currpath && _currfill)
        {
-               assert( ! m_paths.empty() );
-               assert( _currpath == &(m_paths.back()) );
+               assert(!_paths.empty());
+               assert(_currpath == &(_paths.back()));
                _currpath->close();
        }
 
@@ -200,11 +200,11 @@
        _currpath->drawLineTo(x, y);
 
        // Update bounds 
-       unsigned thickness = _currline ? 
m_line_styles[_currline-1].getThickness() : 0;
+       unsigned thickness = _currline ? 
_line_styles[_currline-1].getThickness() : 0;
        if ( _currpath->size() == 1 ) {
-               _currpath->expandBounds(m_bound, thickness, swfVersion);
+               _currpath->expandBounds(_bound, thickness, swfVersion);
        } else {
-               m_bound.expand_to_circle(x, y, swfVersion < 8 ? thickness : 
thickness/2.0);
+               _bound.expand_to_circle(x, y, swfVersion < 8 ? thickness : 
thickness/2.0);
        }
     
        // Update current pen position
@@ -225,13 +225,16 @@
        _currpath->drawCurveTo(cx, cy, ax, ay);
 
        // Update bounds 
-       unsigned thickness = _currline ? 
m_line_styles[_currline-1].getThickness() : 0;
+       unsigned thickness = _currline ? 
_line_styles[_currline-1].getThickness() : 0;
        if ( _currpath->size() == 1 ) {
-               _currpath->expandBounds(m_bound, thickness, swfVersion);
-       } else {
-               m_bound.expand_to_circle(ax, ay, swfVersion < 8 ? thickness : 
thickness/2.0);
-               m_bound.expand_to_circle(cx, cy, swfVersion < 8 ? thickness : 
thickness/2.0);
+               _currpath->expandBounds(_bound, thickness, swfVersion);
        }
+    else {
+               _bound.expand_to_circle(ax, ay, 
+                swfVersion < 8 ? thickness : thickness/2.0);
+               _bound.expand_to_circle(cx, cy,
+                swfVersion < 8 ? thickness : thickness/2.0);
+    }
 
        // Update current pen position
        _x = ax;
@@ -244,8 +247,7 @@
 size_t
 DynamicShape::add_fill_style(const fill_style& stl)
 {
-       typedef FillStyleVect V;
-       V& v=m_fill_styles;
+       FillStyles& v = _fill_styles;
 
        // TODO: check if the style is already in our list
        //       (needs operator== defined for fill_style)
@@ -256,8 +258,7 @@
 size_t
 DynamicShape::add_line_style(const line_style& stl)
 {
-       typedef LineStyleVect V;
-       V& v=m_line_styles;
+       LineStyles& v = _line_styles;
 
        // TODO: check if the style is already in our list
        //       (needs operator== defined for line_style)

=== modified file 'libcore/parser/BitmapMovieDefinition.h'
--- a/libcore/parser/BitmapMovieDefinition.h    2009-03-10 20:43:50 +0000
+++ b/libcore/parser/BitmapMovieDefinition.h    2009-03-12 07:53:23 +0000
@@ -57,7 +57,7 @@
        BitmapMovieDefinition(std::auto_ptr<GnashImage> image,
             const std::string& url);
 
-    virtual character* createDisplayObject(character* parent, int id) {
+    virtual character* createDisplayObject(character*, int) {
         return 0;
     }
 

=== modified file 'libcore/parser/SWFMovieDefinition.h'
--- a/libcore/parser/SWFMovieDefinition.h       2009-03-10 20:43:50 +0000
+++ b/libcore/parser/SWFMovieDefinition.h       2009-03-12 07:53:23 +0000
@@ -385,7 +385,7 @@
        ///
        movie_instance* create_movie_instance(character* parent=0);
 
-    virtual character* createDisplayObject(character* parent, int id) {
+    virtual character* createDisplayObject(character*, int) {
         return 0;
     }
 

=== modified file 'libcore/parser/morph2_character_def.cpp'
--- a/libcore/parser/morph2_character_def.cpp   2009-01-22 20:10:39 +0000
+++ b/libcore/parser/morph2_character_def.cpp   2009-03-12 09:23:59 +0000
@@ -31,12 +31,40 @@
 
 namespace gnash {
 
+/// Functors for path and style manipulation.
+namespace {
+
+template<typename T>
+class Lerp
+{
+public:
+    Lerp(typename T::const_iterator style1, typename T::const_iterator style2,
+            const double ratio)
+        :
+        _style1(style1),
+        _style2(style2),
+        _ratio(ratio)
+    {}
+
+    void operator()(typename T::value_type& st)
+    {
+        st.set_lerp(*_style1, *_style2, _ratio);
+        ++_style1, ++_style2;
+    }
+
+private:
+    typename T::const_iterator _style1;
+    typename T::const_iterator _style2;
+    const double _ratio;
+};
+
 // Facilities for working with list of paths.
-class PathList {
-
+class PathList
+{
+    typedef shape_character_def::Paths Paths;
 public:
 
-       PathList(const std::vector<path>& paths)
+       PathList(const Paths& paths)
                :
                _paths(paths),
                _currpath(0),
@@ -59,11 +87,11 @@
        const edge& getNextEdge()
        {
                const edge& ret = _paths[_currpath][_curredge];
-               if ( ++_curredge >= _paths[_currpath].size() )
+        if ( ++_curredge >= _paths[_currpath].size() )
                {
                        if ( ++_currpath >= _paths.size() )
                        {
-                               // this is not really needed,
+                // this is not really needed,
                                // but it's simpler to do so that
                                // to make next call fail or abort..
                                _currpath = 0;
@@ -74,19 +102,20 @@
        }
 
        /// Compute total number of edges
-       static size_t computeNumberOfEdges(const std::vector<path>& paths)
+       static size_t computeNumberOfEdges(const Paths& paths)
        {
                size_t count=0;
-               for (size_t i = 0, e=paths.size(); i<e; ++i)
-               {
-                       count += paths[i].size();
+               for (Paths::const_iterator i = paths.begin(), e = paths.end();
+                i != e; ++i) {
+
+                       count += i->size();
                }
                return count;
        }
 
 private:
 
-       const std::vector<path>& _paths;
+       const Paths& _paths;
 
        size_t _currpath;
 
@@ -96,11 +125,13 @@
 
 };
 
-morph2_character_def::morph2_character_def():
-    m_last_ratio(-1.0f)
-{   /* Markus: No delete??? */
-    m_shape1 = new shape_character_def();
-    m_shape2 = new shape_character_def();
+} // anonymous namespace
+
+morph2_character_def::morph2_character_def()
+    :
+    m_shape1(new shape_character_def),
+    m_shape2(new shape_character_def)
+{
 }
 
 
@@ -108,38 +139,30 @@
 {
 }
 
-void   morph2_character_def::display(character* inst)
+void
+morph2_character_def::display(character* inst)
 {
-//             GNASH_REPORT_FUNCTION;
-
-    unsigned int i = 0;
-    float ratio = inst->get_ratio() / 65535.0;
+
+    const double ratio = inst->get_ratio() / 65535.0;
+
     // bounds
-    rect       new_bound;
+    rect new_bound;
     new_bound.set_lerp(m_shape1->get_bound(), m_shape2->get_bound(), ratio);
     set_bound(new_bound);
 
     // fill styles
-    for (; i < m_fill_styles.size(); i++)
-    {
-        fill_style& fs = m_fill_styles[i];
-
-        const fill_style& fs1 = m_shape1->get_fill_styles()[i];
-        const fill_style& fs2 = m_shape2->get_fill_styles()[i];
-
-        fs.set_lerp(fs1, fs2, ratio);
-    }
+    const FillStyles::const_iterator fs1 = m_shape1->fillStyles().begin();
+    const FillStyles::const_iterator fs2 = m_shape2->fillStyles().begin();
+
+    std::for_each(_fill_styles.begin(), _fill_styles.end(),
+            Lerp<FillStyles>(fs1, fs2, ratio));
 
     // line styles
-    for (i=0; i < m_line_styles.size(); i++)
-    {
-        line_style& ls = m_line_styles[i];
-
-        const line_style& ls1 = m_shape1->get_line_styles()[i];
-        const line_style& ls2 = m_shape2->get_line_styles()[i];
-
-        ls.set_lerp(ls1, ls2, ratio);
-    }
+    const LineStyles::const_iterator ls1 = m_shape1->lineStyles().begin();
+    const LineStyles::const_iterator ls2 = m_shape2->lineStyles().begin();
+
+    std::for_each(_line_styles.begin(), _line_styles.end(),
+            Lerp<LineStyles>(ls1, ls2, ratio));
 
     // This is used for cases in which number
     // of paths in start shape and end shape are not
@@ -148,23 +171,22 @@
     edge empty_edge;
 
     // shape
-    unsigned int k=0, n=0;
-    const std::vector<path>& paths1 = m_shape1->get_paths();
-    const std::vector<path>& paths2 = m_shape2->get_paths();
-    for (i=0; i < m_paths.size(); i++)
+    const Paths& paths1 = m_shape1->paths();
+    const Paths& paths2 = m_shape2->paths();
+    for (size_t i = 0, k = 0, n = 0; i < _paths.size(); i++)
     {
-        path& p = m_paths[i];
+        path& p = _paths[i];
         const path& p1 = i < paths1.size() ? paths1[i] : empty_path;
         const path& p2 = n < paths2.size() ? paths2[n] : empty_path;
 
-        float new_ax = utility::flerp(p1.ap.x, p2.ap.x, ratio);
-        float new_ay = utility::flerp(p1.ap.y, p2.ap.y, ratio);
+        const float new_ax = utility::flerp(p1.ap.x, p2.ap.x, ratio);
+        const float new_ay = utility::flerp(p1.ap.y, p2.ap.y, ratio);
 
         p.reset(new_ax, new_ay, p1.getLeftFill(),
                 p2.getRightFill(), p1.getLineStyle());
 
         //  edges;
-        size_t len = p1.size();
+        const size_t len = p1.size();
         p.m_edges.resize(len);
 
         for (size_t j=0; j < p.size(); j++)
@@ -177,19 +199,17 @@
             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)
-            {
-                k=0; n++;
+            ++k;
+
+            if (p2.size() <= k) {
+                k = 0;
+                ++n;
             }
         }
     }
 
-//  display
-
-{
-gnash::render::draw_shape_character(this, inst);
-}
+    //  display
+    render::draw_shape_character(this, inst);
 
 }
 
@@ -205,9 +225,7 @@
     bound1.read(in);
     bound2.read(in);
 
-    if (tag == SWF::DEFINEMORPHSHAPE2 ||
-            tag == SWF::DEFINEMORPHSHAPE2_)
-    {
+    if (tag == SWF::DEFINEMORPHSHAPE2 || tag == SWF::DEFINEMORPHSHAPE2_) {
         // TODO: Use these values.
         rect inner_bound1, inner_bound2;
         inner_bound1.read(in);
@@ -221,23 +239,22 @@
     }
 
     in.ensureBytes(4);
-    offset = in.read_u32();
+    // Offset. What is this for?
+    static_cast<void>(in.read_u32());
 
     // Next line will throw ParserException on malformed SWF
-    fill_style_count = in.read_variable_count();
-    int i;
+    const boost::uint16_t fillCount = in.read_variable_count();
+    
     fill_style fs1, fs2;
-    for (i = 0; i < fill_style_count; ++i)
-    {
+    for (size_t i = 0; i < fillCount; ++i) {
         fs1.read(in, tag, md, &fs2);
         m_shape1->addFillStyle(fs1);
         m_shape2->addFillStyle(fs2);
     }
 
-    line_style_count = in.read_variable_count();
+    const boost::uint16_t lineCount = in.read_variable_count();
     line_style ls1, ls2;
-    for (i = 0; i < line_style_count; ++i)
-    {
+    for (size_t i = 0; i < lineCount; ++i) {
         ls1.read_morph(in, tag, md, &ls2);
         m_shape1->addLineStyle(ls1);
         m_shape2->addLineStyle(ls2);
@@ -253,56 +270,50 @@
     m_shape1->set_bound(bound1);
     m_shape2->set_bound(bound2);
 
-    const shape_character_def::FillStyleVect& s1Fills = 
-        m_shape1->get_fill_styles();
-
-    const shape_character_def::LineStyleVect& s1Lines = 
-        m_shape1->get_line_styles();
-
-    assert(s1Fills.size() == m_shape2->get_fill_styles().size());
-    assert(s1Lines.size() == m_shape2->get_line_styles().size());
+    const shape_character_def::FillStyles& s1Fills = m_shape1->fillStyles();
+
+    const shape_character_def::LineStyles& s1Lines = m_shape1->lineStyles();
+
+    assert(s1Fills.size() == m_shape2->fillStyles().size());
+    assert(s1Lines.size() == m_shape2->lineStyles().size());
 
     // setup array size
-    m_fill_styles.resize(s1Fills.size());
-    unsigned int k;
-    for (k = 0; k < m_fill_styles.size(); k++)
-    {
-        fill_style& fs = m_fill_styles[k];
-        const fill_style& fs1 = s1Fills[k];
-        fs.m_gradients.resize(fs1.m_gradients.size());
+    _fill_styles.resize(s1Fills.size());
+    FillStyles::const_iterator s1 = s1Fills.begin();
+    for (FillStyles::iterator i = _fill_styles.begin(), e = _fill_styles.end();
+            i != e; ++i, ++s1) {
+
+        i->m_gradients.resize(s1->m_gradients.size());
     }
 
-    m_line_styles.resize(s1Lines.size());
-    m_paths.resize(m_shape1->get_paths().size());
+    _line_styles.resize(s1Lines.size());
+    _paths.resize(m_shape1->paths().size());
 
-    unsigned edges_count1 = PathList::computeNumberOfEdges(
-            m_shape1->get_paths());
-    unsigned edges_count2 = PathList::computeNumberOfEdges(
-            m_shape2->get_paths());
+    const unsigned edges1 = PathList::computeNumberOfEdges(m_shape1->paths());
+    const unsigned edges2 = PathList::computeNumberOfEdges(m_shape2->paths());
 
     IF_VERBOSE_PARSE(
       log_parse("morph: "
           "startShape(paths:%d, edges:%u), "
           "endShape(paths:%d, edges:%u)",
-          m_shape1->get_paths().size(), edges_count1,
-          m_shape2->get_paths().size(), edges_count2);
+          m_shape1->paths().size(), edges1,
+          m_shape2->paths().size(), edges2);
     );
 
     IF_VERBOSE_MALFORMED_SWF(
         // It is perfectly legal to have a different number of paths,
         // edges count should be the same instead
-        if ( edges_count1 != edges_count2 )
-        {
+        if (edges1 != edges2) {
             log_swferror(_("Different number of edges "
                 "in start (%u) and end (%u) shapes "
-                "of a morph"),
-                edges_count1, edges_count1);
+                "of a morph"), edges1, edges1);
         }
 
     );
 
 }
-}
+
+} // namespace gnash
 
 // Local Variables:
 // mode: C++

=== modified file 'libcore/parser/morph2_character_def.h'
--- a/libcore/parser/morph2_character_def.h     2009-01-05 09:32:03 +0000
+++ b/libcore/parser/morph2_character_def.h     2009-03-12 08:54:27 +0000
@@ -42,43 +42,37 @@
     void read(SWFStream& in, SWF::TagType tag, movie_definition& m);
 
     virtual void display(character* inst);
-    void lerp_matrix(SWFMatrix& t, const SWFMatrix& m1, const SWFMatrix& m2, 
const float ratio);
 
     // Question: What is the bound of a morph? Is this conceptually correct?
     /// TODO: optimize this by take ratio into consideration, to decrease some
     /// invalidated area when rendering morphs
     virtual const rect&        get_bound() const 
     { 
-        m_bound.expand_to_rect(m_shape1->get_bound());
-        m_bound.expand_to_rect(m_shape2->get_bound());
-        return m_bound;
+        _bound.expand_to_rect(m_shape1->get_bound());
+        _bound.expand_to_rect(m_shape2->get_bound());
+        return _bound;
     }
 
 protected:
 
 #ifdef GNASH_USE_GC
-/// Mark all reachable resources of a morph2_character_def, for the GC
-//
-/// Reachable resources are:
-///    - The start and end shapes (m_shape1, m_shape2)
-///
-virtual void markReachableResources() const
-{
-    if ( m_shape1 ) m_shape1->setReachable();
-    if ( m_shape2 ) m_shape2->setReachable();
-}
-#endif // GNASH_USE_GC
+    /// Reachable resources are:
+    ///        - The start and end shapes (m_shape1, m_shape2)
+    virtual void markReachableResources() const
+    {
+        if (m_shape1) m_shape1->setReachable();
+        if (m_shape2) m_shape2->setReachable();
+    }
+#endif 
 
 private:
     boost::intrusive_ptr<shape_character_def> m_shape1;
     boost::intrusive_ptr<shape_character_def> m_shape2;
-    unsigned int offset;
-    int fill_style_count;
-    int line_style_count;
-    float m_last_ratio;
-    mutable rect m_bound;
+    
+    mutable rect _bound;
+    
 };
-}
+} // namespace gnash
 
 
 #endif // GNASH_MORPH2_H

=== modified file 'libcore/parser/shape_character_def.cpp'
--- a/libcore/parser/shape_character_def.cpp    2009-03-10 20:43:50 +0000
+++ b/libcore/parser/shape_character_def.cpp    2009-03-12 07:54:13 +0000
@@ -110,19 +110,19 @@
 shape_character_def::shape_character_def()
     :
     character_def(),
-    m_fill_styles(),
-    m_line_styles(),
-    m_paths(),
-    m_bound()
+    _fill_styles(),
+    _line_styles(),
+    _paths(),
+    _bound()
 {  }
 
 shape_character_def::shape_character_def(const shape_character_def& o)
     :
     character_def(o),
-    m_fill_styles(o.m_fill_styles),
-    m_line_styles(o.m_line_styles),
-    m_paths(o.m_paths),
-    m_bound(o.m_bound)
+    _fill_styles(o._fill_styles),
+    _line_styles(o._line_styles),
+    _paths(o._paths),
+    _bound(o._bound)
     {
     }
 
@@ -136,10 +136,10 @@
 {
     if (with_style)
     {
-        m_bound.read(in);
+        _bound.read(in);
     
         IF_VERBOSE_PARSE(
-            std::string b = m_bound.toString();
+            std::string b = _bound.toString();
             log_parse(_("  bound rect: %s"), b.c_str());
         );
     
@@ -153,8 +153,8 @@
             LOG_ONCE(log_unimpl("DEFINESHAPE4 edge boundaries and scales"));
         }
     
-        read_fill_styles(m_fill_styles, in, tag, m);
-        read_line_styles(m_line_styles, in, tag, m);
+        read_fill_styles(_fill_styles, in, tag, m);
+        read_line_styles(_line_styles, in, tag, m);
     }
 
     /// Adding a dummy fill style is just needed to make the
@@ -232,7 +232,7 @@
                 // Store the current path if any.
                 if (! current_path.is_empty())
                 {
-                    m_paths.push_back(current_path);
+                    _paths.push_back(current_path);
                     current_path.m_edges.resize(0);
                 }
                 break;
@@ -242,7 +242,7 @@
                 // Store the current path if any, and prepare a fresh one.
                 if (! current_path.is_empty())
                 {
-                    m_paths.push_back(current_path);
+                    _paths.push_back(current_path);
                     current_path.m_edges.resize(0);
                 }
                 in.ensureBits(5);
@@ -269,7 +269,7 @@
                 // fill_style_0_change = 1;
                 if (! current_path.is_empty())
                 {
-                    m_paths.push_back(current_path);
+                    _paths.push_back(current_path);
                     current_path.m_edges.resize(0);
                     current_path.ap.x = x;
                     current_path.ap.y = y;
@@ -296,12 +296,12 @@
                 else
                 {
                     // 1-based index
-                    if ( style > m_fill_styles.size() )
+                    if ( style > _fill_styles.size() )
                     {
                         IF_VERBOSE_MALFORMED_SWF(
                              log_swferror(_("Invalid fill style %d in "
                                      "fillStyle0Change record - %d defined. "
-                                     "Set to 0."), style, 
m_fill_styles.size());
+                                     "Set to 0."), style, _fill_styles.size());
                         );
                         style = 0;
                     }
@@ -320,7 +320,7 @@
                 // fill_style_1_change = 1;
                 if (! current_path.is_empty())
                 {
-                    m_paths.push_back(current_path);
+                    _paths.push_back(current_path);
                     current_path.m_edges.resize(0);
                     current_path.ap.x = x;
                     current_path.ap.y = y;
@@ -347,12 +347,12 @@
                 else
                 {
                     // 1-based index
-                    if ( style > m_fill_styles.size() )
+                    if ( style > _fill_styles.size() )
                     {
                         IF_VERBOSE_MALFORMED_SWF(
                             log_swferror(_("Invalid fill style %d in "
                                     "fillStyle1Change record - %d defined. "
-                                    "Set to 0."), style, m_fill_styles.size());
+                                    "Set to 0."), style, _fill_styles.size());
                         );
                         style = 0;
                     }
@@ -370,7 +370,7 @@
                 // line_style_change = 1;
                 if (! current_path.is_empty())
                 {
-                    m_paths.push_back(current_path);
+                    _paths.push_back(current_path);
                     current_path.m_edges.resize(0);
                     current_path.ap.x = x;
                     current_path.ap.y = y;
@@ -393,15 +393,13 @@
                         style = 0;
                     }
                 }
-                else
-                {
+                else {
                     // 1-based index
-                    if ( style > m_line_styles.size() )
-                    {
+                    if (style > _line_styles.size()) {
                         IF_VERBOSE_MALFORMED_SWF(
                             log_swferror(_("Invalid fill style %d in "
                                     "lineStyleChange record - %d defined. "
-                                    "Set to 0."), style, m_line_styles.size());
+                                    "Set to 0."), style, _line_styles.size());
                         );
                         style = 0;
                     }
@@ -431,20 +429,20 @@
                 // Store the current path if any.
                 if (! current_path.is_empty())
                 {
-                    m_paths.push_back(current_path);
+                    _paths.push_back(current_path);
                     current_path.clear();
                 }
     
                 // Tack on an empty path signalling a new shape.
                 // @@ need better understanding of whether this is 
correct??!?!!
                 // @@ i.e., we should just start a whole new shape here, right?
-                m_paths.push_back(path());
-                m_paths.back().m_new_shape = true;
+                _paths.push_back(path());
+                _paths.back().m_new_shape = true;
     
-                fill_base = m_fill_styles.size();
-                line_base = m_line_styles.size();
-                read_fill_styles(m_fill_styles, in, tag, m);
-                read_line_styles(m_line_styles, in, tag, m);
+                fill_base = _fill_styles.size();
+                line_base = _line_styles.size();
+                read_fill_styles(_fill_styles, in, tag, m);
+                read_line_styles(_line_styles, in, tag, m);
     
                 in.ensureBits(8);
                 num_fill_bits = in.read_uint(4);
@@ -527,13 +525,13 @@
     {
         // TODO: performance would be improved by computing
         //       the bounds as edges are parsed.
-        compute_bound(&m_bound, m.get_version());
+        compute_bound(_bound, m.get_version());
     }
 #ifdef GNASH_DEBUG_SHAPE_BOUNDS
     else
     {
         rect computedBounds;
-        compute_bound(&computedBounds, m->get_version());
+        compute_bound(computedBounds, m->get_version());
         if ( computedBounds != m_bounds )
         {
             log_debug("Shape character read for tag %d contained embedded "
@@ -680,18 +678,18 @@
     //       the collision detection find you inside a self-crossing
     //       shape).
     //
-    if (m_bound.point_test(x, y) == false)
+    if (_bound.point_test(x, y) == false)
     {
         return false;
     }
 
-    unsigned npaths = m_paths.size();
+    unsigned npaths = _paths.size();
     int counter = 0;
 
     // browse all paths
     for (unsigned pno=0; pno<npaths; pno++)
     {
-        const path& pth = m_paths[pno];
+        const path& pth = _paths[pno];
         unsigned nedges = pth.m_edges.size();
 
         float next_pen_x = pth.ap.x;
@@ -714,8 +712,8 @@
         // If the path has a line style, check for strokes there
         if (pth.m_line != 0 )
         {
-            assert(m_line_styles.size() >= pth.m_line);
-            line_style& ls = m_line_styles[pth.m_line-1];
+            assert(_line_styles.size() >= pth.m_line);
+            line_style& ls = _line_styles[pth.m_line-1];
             double thickness = ls.getThickness();
             if (! thickness )
             {
@@ -838,20 +836,20 @@
 
 // Find the bounds of this shape, and store them in the given rectangle.
 void
-shape_character_def::compute_bound(rect* r, int swfVersion) const
+shape_character_def::compute_bound(rect& r, int swfVersion) const
 {
-    r->set_null();
+    r.set_null();
 
-    for (unsigned int i = 0; i < m_paths.size(); i++)
+    for (unsigned int i = 0; i < _paths.size(); i++)
     {
-        const path& p = m_paths[i];
+        const path& p = _paths[i];
 
         unsigned thickness = 0;
         if ( p.m_line )
         {
             // For glyph shapes m_line is allowed to be 1
             // while no defined line styles are allowed.
-            if ( m_line_styles.empty() )
+            if ( _line_styles.empty() )
             {
                 // This is either a Glyph, for which m_line==1 is valid
                 // or a bug in the parser, which we have no way to
@@ -860,10 +858,10 @@
             }
             else
             {
-                thickness = m_line_styles[p.m_line-1].getThickness();
+                thickness = _line_styles[p.m_line-1].getThickness();
             }
         }
-        p.expandBounds(*r, thickness, swfVersion);
+        p.expandBounds(r, thickness, swfVersion);
     }
 }
 
@@ -871,11 +869,8 @@
 void  shape_character_def::markReachableResources() const
 {
     assert(isReachable());
-    for (FillStyleVect::const_iterator i=m_fill_styles.begin(),
-            e=m_fill_styles.end(); i != e; ++i)
-    {
-        i->markReachableResources();
-    }
+    std::for_each(_fill_styles.begin(), _fill_styles.end(),
+            std::mem_fun_ref(&fill_style::markReachableResources));
 }
 #endif
 

=== modified file 'libcore/parser/shape_character_def.h'
--- a/libcore/parser/shape_character_def.h      2009-03-10 20:43:50 +0000
+++ b/libcore/parser/shape_character_def.h      2009-03-12 09:23:59 +0000
@@ -36,9 +36,9 @@
 {
 public:
 
-    typedef std::vector<fill_style> FillStyleVect;
-    typedef std::vector<line_style> LineStyleVect;
-    typedef std::vector<path> PathVect;
+    typedef std::vector<fill_style> FillStyles;
+    typedef std::vector<line_style> LineStyles;
+    typedef std::vector<path> Paths;
 
     shape_character_def();
     virtual ~shape_character_def();
@@ -81,27 +81,27 @@
             movie_definition& m);
 
     /// Get cached bounds of this shape.
-    const rect&        get_bound() const { return m_bound; }
+    const rect&        get_bound() const { return _bound; }
 
     /// Compute bounds by looking at the component paths
-    void compute_bound(rect* r, int swfVersion) const;
-
-    const FillStyleVect& get_fill_styles() const { return m_fill_styles; }
-    const LineStyleVect& get_line_styles() const { return m_line_styles; }
-
-    const std::vector<path>& get_paths() const { return m_paths; }
+    void compute_bound(rect& r, int swfVersion) const;
+
+    const FillStyles& fillStyles() const { return _fill_styles; }
+    const LineStyles& lineStyles() const { return _line_styles; }
+
+    const Paths& paths() const { return _paths; }
 
     // morph uses this
     // Should this be verified?
-    void set_bound(const rect& r) { m_bound = r; }
+    void set_bound(const rect& r) { _bound = r; }
 
     // Morph uses this.
     void addFillStyle(const fill_style& fs) {
-        m_fill_styles.push_back(fs);
+        _fill_styles.push_back(fs);
     }
 
     void addLineStyle(const line_style& fs) {
-        m_line_styles.push_back(fs);
+        _line_styles.push_back(fs);
     }
 
 protected:
@@ -110,17 +110,17 @@
     /// Mark reachable resources (for the GC)
     //
     /// Reachable resources are:
-    ///        - Associated fill styles (m_fill_styles).
+    ///        - Associated fill styles (_fill_styles).
     ///          These are not actual resources, but may contain some.
     ///
     virtual void markReachableResources() const;
 #endif // GNASH_USE_GC
 
     // derived morph classes changes these
-    FillStyleVect m_fill_styles;
-    LineStyleVect m_line_styles;
-    PathVect m_paths;
-    rect       m_bound;
+    FillStyles _fill_styles;
+    LineStyles _line_styles;
+    Paths _paths;
+    rect _bound;
 
     /// Copy a shape character definition
     shape_character_def(const shape_character_def& o);


reply via email to

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