gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog configure.ac backend/render_han...


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog configure.ac backend/render_han...
Date: Wed, 12 Mar 2008 03:46:04 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     08/03/12 03:46:04

Modified files:
        .              : ChangeLog configure.ac 
        backend        : render_handler_agg.cpp 
        libgeometry    : Point2d.h Range2d.h 
        server         : matrix.cpp matrix.h shape.cpp shape.h types.h 
        server/parser  : BitmapMovieDefinition.cpp 

Log message:
                * configure.ac: If --enable-visibility is specified, and no GCC 
bug
                was detected, compile with -fvisibility=hidden.
                * server/shape.{cpp, h}: Since SWF provides shape edges as 
integers,
                there's no need to store them as floats. Some renderers can 
improve
                performance here, especially when used on certain embedded 
platforms.
                To this end, path and edge are now templated classes Path<> and
                Edge<>, and the precision (int or float) can be specified with 
the
                template argument.
                * backend/render_handler_agg.cpp: The AGG renderer relies on 
                floating pointprecision in paths (after matrix conversion), so 
make
                sure that precision is preserved.
                * libgeometry/{Point2d.h, Range2d.h}: Allow easy conversion 
from float
                to int templates.
                * server/matrix.{cpp, h}: Allow transformations to take place 
on any
                kind of Point2d and Range2d.
                * server/types.h: Multiplication by 20 does not require a 
floating
                point annotation.
                * server/parser/BitmapMovieDefinition.cpp: Specify the "new 
subshape"
                argument to Path's constructor.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5879&r2=1.5880
http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&r1=1.493&r2=1.494
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/render_handler_agg.cpp?cvsroot=gnash&r1=1.131&r2=1.132
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/Point2d.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/libgeometry/Range2d.h?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.cpp?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/matrix.h?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/server/shape.cpp?cvsroot=gnash&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/gnash/server/shape.h?cvsroot=gnash&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/gnash/server/types.h?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/BitmapMovieDefinition.cpp?cvsroot=gnash&r1=1.17&r2=1.18

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5879
retrieving revision 1.5880
diff -u -b -r1.5879 -r1.5880
--- ChangeLog   11 Mar 2008 19:31:46 -0000      1.5879
+++ ChangeLog   12 Mar 2008 03:46:01 -0000      1.5880
@@ -1,3 +1,25 @@
+2008-03-11 Bastiaan Jacques <address@hidden>
+
+       * configure.ac: If --enable-visibility is specified, and no GCC bug
+       was detected, compile with -fvisibility=hidden.
+       * server/shape.{cpp, h}: Since SWF provides shape edges as integers,
+       there's no need to store them as floats. Some renderers can improve
+       performance here, especially when used on certain embedded platforms.
+       To this end, path and edge are now templated classes Path<> and
+       Edge<>, and the precision (int or float) can be specified with the
+       template argument.
+       * backend/render_handler_agg.cpp: The AGG renderer relies on
+       floating pointprecision in paths (after matrix conversion), so make
+       sure that precision is preserved.
+       * libgeometry/{Point2d.h, Range2d.h}: Allow easy conversion from float
+       to int templates.
+       * server/matrix.{cpp, h}: Allow transformations to take place on any
+       kind of Point2d and Range2d.
+       * server/types.h: Multiplication by 20 does not require a floating
+       point annotation.
+       * server/parser/BitmapMovieDefinition.cpp: Specify the "new subshape"
+       argument to Path's constructor.
+
 2008-03-11 Sandro Santilli <address@hidden>
 
        * testsuite/actionscript.all/*.as: re-add rcsids.

Index: configure.ac
===================================================================
RCS file: /sources/gnash/gnash/configure.ac,v
retrieving revision 1.493
retrieving revision 1.494
diff -u -b -r1.493 -r1.494
--- configure.ac        7 Mar 2008 01:35:03 -0000       1.493
+++ configure.ac        12 Mar 2008 03:46:02 -0000      1.494
@@ -1834,6 +1834,9 @@
     )
     if test x$gcc_visibility_bug = xno; then
       CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
+      if test x"$enable_visibility" != x"no"; then
+        CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
+      fi
     fi
   ]
 )

Index: backend/render_handler_agg.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/render_handler_agg.cpp,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -b -r1.131 -r1.132
--- backend/render_handler_agg.cpp      5 Mar 2008 03:55:49 -0000       1.131
+++ backend/render_handler_agg.cpp      12 Mar 2008 03:46:02 -0000      1.132
@@ -171,6 +171,8 @@
 #include "render_handler_agg_bitmap.h"
 #include "render_handler_agg_style.h"
 
+#include <boost/foreach.hpp>
+
 #ifndef round
 #define round(x) rint(x)
 #endif
@@ -836,7 +838,7 @@
   void draw_glyph(shape_character_def *def,
       const matrix& mat, const rgba& color, float /*pixel_scale*/) {
     
-    std::vector<path> paths;    
+    std::vector< Path<float> > paths;    
     apply_matrix_to_path(def->get_paths(), paths, mat);
     
     // convert to AGG paths
@@ -951,7 +953,8 @@
     if (!have_shape && !have_outline) 
       return; // invisible character
 
-    std::vector< path > paths;
+
+    std::vector< Path<float> > paths;
     std::vector< agg::path_storage > agg_paths;
     std::vector< agg::path_storage > agg_paths_rounded;
     
@@ -1045,51 +1048,20 @@
     
   }
 
-
   /// Takes a path and translates it using the given matrix. The new path
   /// is stored in paths_out.  
   void apply_matrix_to_path(const std::vector<path> &paths_in, 
-    std::vector<path> &paths_out, const matrix &source_mat) {
-    
-    int pcount, ecount;
-    int pno, eno;
+    std::vector< Path<float> > &paths_out, const matrix &source_mat) {
 
     matrix mat = stage_matrix;
     mat.concatenate(source_mat);
     
-    // copy path
-    paths_out = paths_in;    
-    pcount = paths_out.size();
-        
-    
-    for (pno=0; pno<pcount; pno++) {
-    
-      path &the_path = paths_out[pno];     
-      point oldpnt(the_path.ap.x, the_path.ap.y);
-      point newpnt;
-      mat.transform(&newpnt, oldpnt);
-      the_path.ap.x = newpnt.x;    
-      the_path.ap.y = newpnt.y;
-      
-      ecount = the_path.m_edges.size();
-      for (eno=0; eno<ecount; eno++) {
-      
-        edge &the_edge = the_path.m_edges[eno];
-        
-        oldpnt.x = the_edge.ap.x;
-        oldpnt.y = the_edge.ap.y;
-        mat.transform(&newpnt, oldpnt);
-        the_edge.ap.x = newpnt.x;
-        the_edge.ap.y = newpnt.y;
-        
-        oldpnt.x = the_edge.cp.x;
-        oldpnt.y = the_edge.cp.y;
-        mat.transform(&newpnt, oldpnt);
-        the_edge.cp.x = newpnt.x;
-        the_edge.cp.y = newpnt.y;
-      
-      }          
+    paths_out.reserve(paths_in.size());
       
+    BOOST_FOREACH(const path& in_path, paths_in) {
+      Path<float> floating_path = in_path;
+      floating_path.transform(mat);
+      paths_out.push_back(floating_path);
     } 
     
   } // apply_matrix
@@ -1100,14 +1072,14 @@
   /// layers of the same frame count. Flash combines them to one single shape.
   /// The problem with sub-shapes is, that outlines can be hidden by other
   /// layers so they must be rendered separately. 
-  unsigned int count_sub_shapes(const std::vector<path> &paths)
+  unsigned int count_sub_shapes(const std::vector< Path<float> > &paths)
   {
     unsigned int sscount=1;
     
     size_t pcount = paths.size();
     
     for (size_t pno=0; pno<pcount; pno++) {
-      const path &this_path = paths[pno];
+      const Path<float>& this_path = paths[pno];
       
       if (this_path.m_new_shape)
         sscount++;
@@ -1120,7 +1092,7 @@
   /// Transposes Gnash paths to AGG paths, which can be used for both outlines
   /// and shapes. Subshapes are ignored (ie. all paths are converted). 
Converts 
   /// TWIPS to pixels on the fly.
-  void build_agg_paths(std::vector<agg::path_storage>& dest, const 
std::vector<path>& paths) {
+  void build_agg_paths(std::vector<agg::path_storage>& dest, const 
std::vector< Path<float> >& paths) {
   
     // Shift all coordinates a half pixel for correct results (the middle of
     // a pixel is at .5 / .5, ie. it's subpixel center) 
@@ -1132,7 +1104,7 @@
     
     for (size_t pno=0; pno<pcount; pno++) {
       
-      const gnash::path& this_path = paths[pno];
+      const Path<float>& this_path = paths[pno];
       agg::path_storage& new_path = dest[pno];
       
       new_path.move_to(this_path.ap.x + subpixel_offset, 
@@ -1142,7 +1114,7 @@
       
       for (size_t eno=0; eno<ecount; eno++) {
         
-        const edge& this_edge = this_path.m_edges[eno];
+        const Edge<float>& this_edge = this_path.m_edges[eno];
         
         if (this_edge.is_straight())
           new_path.line_to(this_edge.ap.x + subpixel_offset, 
@@ -1172,7 +1144,7 @@
   // TODO: Flash never aligns lines that are wider than 1 pixel on *screen*,
   // but we currently don't check the width.  
   void build_agg_paths_rounded(std::vector<agg::path_storage>& dest, 
-    const std::vector<path>& paths) {
+    const std::vector< Path<float> >& paths) {
   
     // Shift all coordinates a half pixel for correct results (the middle of
     // a pixel is at .5 / .5, ie. it's subpixel center) 
@@ -1184,7 +1156,7 @@
     
     for (size_t pno=0; pno<pcount; pno++) {
       
-      const gnash::path& this_path = paths[pno];
+      const Path<float>& this_path = paths[pno];
       agg::path_storage& new_path = dest[pno];
       
       float prev_ax = this_path.ap.x;
@@ -1196,7 +1168,7 @@
       
       for (size_t eno=0; eno<ecount; eno++) {
         
-        const edge& this_edge = this_path.m_edges[eno];
+        const Edge<float>& this_edge = this_path.m_edges[eno];
         
         float this_ax = this_edge.ap.x;  
         float this_ay = this_edge.ap.y;  
@@ -1293,7 +1265,7 @@
   // WARNING 2 : Strokes vector returns pointers which are never freed.
   void build_agg_strokes(std::vector<stroke_type*>& dest, 
     std::vector<agg::path_storage>& agg_paths,
-    const std::vector<path> &paths,
+    const std::vector< Path<float> > &paths,
     const std::vector<line_style> &line_styles,
     const matrix& linestyle_matrix) {
     
@@ -1314,7 +1286,7 @@
       agg::conv_curve<agg::path_storage> curve(agg_paths[pno]);
       stroke_type* this_stroke = new stroke_type(curve);
       
-      const gnash::path &this_path_gnash = paths[pno];
+      const Path<float>& this_path_gnash = paths[pno];
        
       const line_style& lstyle = line_styles[this_path_gnash.m_line-1];
           
@@ -1438,7 +1410,7 @@
   /// @param subshape_id
   ///    Defines which subshape to draw. -1 means all subshapes.
   ///
-  void draw_shape(int subshape_id, const std::vector<path> &paths,
+  void draw_shape(int subshape_id, const std::vector< Path<float> > &paths,
     const std::vector<agg::path_storage>& agg_paths,  
     agg_style_handler& sh, int even_odd) {
     
@@ -1472,7 +1444,7 @@
   /// one with and one without an alpha mask. This makes drawing without masks
   /// much faster.  
   template <class scanline_type>
-  void draw_shape_impl(int subshape_id, const std::vector<path> &paths,
+  void draw_shape_impl(int subshape_id, const std::vector< Path<float> > 
&paths,
     const std::vector<agg::path_storage>& agg_paths,
     agg_style_handler& sh, int even_odd, scanline_type& sl) {
     /*
@@ -1519,7 +1491,7 @@
   
       for (size_t pno=0; pno<pcount; pno++) {
       
-        const gnash::path &this_path_gnash = paths[pno];
+        const Path<float> &this_path_gnash = paths[pno];
         agg::path_storage &this_path_agg = 
           const_cast<agg::path_storage&>(agg_paths[pno]);
         agg::conv_curve< agg::path_storage > curve(this_path_agg);        
@@ -1561,7 +1533,7 @@
 
   // very similar to draw_shape but used for generating masks. There are no
   // fill styles nor subshapes and such. Just render plain solid shapes.
-  void draw_mask_shape(const std::vector<path> &paths, int even_odd) {
+  void draw_mask_shape(const std::vector< Path<float> > &paths, int even_odd) {
   
     unsigned int mask_count = m_alpha_mask.size();
     
@@ -1592,7 +1564,7 @@
   
   
   template <class scanline_type>
-  void draw_mask_shape_impl(const std::vector<path> &paths, int even_odd,
+  void draw_mask_shape_impl(const std::vector< Path<float> > &paths, int 
even_odd,
     scanline_type& sl) {
     
     typedef agg::pixfmt_gray8 pixfmt;
@@ -1633,7 +1605,7 @@
 
     for (size_t pno=0, pcount=paths.size(); pno < pcount; pno++) {
     
-      const gnash::path& this_path = paths[pno];
+      const Path<float>& this_path = paths[pno];
       path.remove_all();
       
       // reduce everything to just one fill style!
@@ -1646,7 +1618,7 @@
       unsigned int ecount = this_path.m_edges.size();
       for (unsigned int eno=0; eno<ecount; eno++) {
       
-        const edge &this_edge = this_path.m_edges[eno];
+        const Edge<float> &this_edge = this_path.m_edges[eno];
 
         if (this_edge.is_straight())
           path.line_to(this_edge.ap.x, this_edge.ap.y);
@@ -1672,7 +1644,7 @@
 
 
   /// Just like draw_shapes() except that it draws an outline.
-  void draw_outlines(int subshape_id, const std::vector<path> &paths,
+  void draw_outlines(int subshape_id, const std::vector< Path<float> > &paths,
     const std::vector<agg::path_storage>& agg_paths,
     const std::vector<line_style> &line_styles, const cxform& cx,
     const matrix& linestyle_matrix) {
@@ -1706,7 +1678,7 @@
 
   /// Template for draw_outlines(), see draw_shapes_impl().
   template <class scanline_type>
-  void draw_outlines_impl(int subshape_id, const std::vector<path> &paths,
+  void draw_outlines_impl(int subshape_id, const std::vector< Path<float> > 
&paths,
     const std::vector<agg::path_storage>& agg_paths,
     const std::vector<line_style> &line_styles, const cxform& cx, 
     const matrix& linestyle_matrix, scanline_type& sl) {
@@ -1748,7 +1720,7 @@
 
       for (size_t pno=0, pcount=paths.size(); pno<pcount; pno++) {
         
-        const gnash::path& this_path_gnash = paths[pno];
+        const Path<float>& this_path_gnash = paths[pno];
         agg::path_storage &this_path_agg = 
           const_cast<agg::path_storage&>(agg_paths[pno]);
         

Index: libgeometry/Point2d.h
===================================================================
RCS file: /sources/gnash/gnash/libgeometry/Point2d.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- libgeometry/Point2d.h       5 Mar 2008 03:55:53 -0000       1.6
+++ libgeometry/Point2d.h       12 Mar 2008 03:46:02 -0000      1.7
@@ -82,8 +82,8 @@
        /// @param p1 second point
        /// @param t interpolation factor, between 0 and 1
        ///
-       //template <typename U>
-       Point2d(const Point2d<T>& p0, const Point2d<T>& p1, float t)
+       template <typename U>
+       Point2d(const Point2d<U>& p0, const Point2d<U>& p1, float t)
                :
                x( p0.x + (p1.x - p0.x) * t ),
                y( p0.y + (p1.y - p0.y) * t )
@@ -118,8 +118,9 @@
        }
 
        /// Return square distance between two points
+       template <typename U>
        static
-       float squareDistance(const Point2d<T>& p0, const Point2d<T>& p1)
+       float squareDistance(const Point2d<T>& p0, const Point2d<U>& p1)
        {
                float hside = p1.x - p0.x;
                float vside = p1.y - p0.y;
@@ -128,7 +129,8 @@
        }
 
        /// Return square distance between this and the given point
-       float squareDistance(const Point2d<T>& p) const
+       template <typename U>
+       float squareDistance(const Point2d<U>& p) const
        {
                return squareDistance(*this, p);
        }
@@ -139,9 +141,10 @@
                return sqrtf(squareDistance(p));
        }
 
-       bool operator== (const Point2d<T>& p) const
+       template <typename U>
+       bool operator== (const Point2d<U>& p) const
        {
-               return x == p.x && y == p.y;
+               return x == (T)p.x && y == (T)p.y;
        }
 
        bool operator!=(const Point2d<T>& p) const
@@ -163,6 +166,8 @@
 
 // for backward compatibility
 typedef geometry::Point2d<float> point;
+typedef geometry::Point2d<float> float_point;
+typedef geometry::Point2d<int> int_point;
 
 } // namespace gnash
 

Index: libgeometry/Range2d.h
===================================================================
RCS file: /sources/gnash/gnash/libgeometry/Range2d.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- libgeometry/Range2d.h       5 Mar 2008 03:55:53 -0000       1.21
+++ libgeometry/Range2d.h       12 Mar 2008 03:46:02 -0000      1.22
@@ -255,7 +255,8 @@
        /// Note that WORLD rectangles contain every point
        /// and NULL rectangles contain no point.
        ///
-       bool contains(T x, T y) const
+       template <typename U>
+       bool contains(U x, U y) const
        {
                if ( isNull() ) return false;
                if ( isWorld() ) return true;

Index: server/matrix.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/matrix.cpp   5 Mar 2008 03:55:59 -0000       1.26
+++ server/matrix.cpp   12 Mar 2008 03:46:03 -0000      1.27
@@ -255,6 +255,7 @@
        log_parse("| %4.4f %4.4f %4.4f |", m_[1][0], m_[1][1], 
TWIPS_TO_PIXELS(m_[1][2]));
 }
 
+
 void
 matrix::transform(point* result, const point& p) const
 // Transform point 'p' by our matrix.  Put the result in
@@ -267,23 +268,6 @@
 }
 
 void
-matrix::transform(point& p) const
-// Transform point 'p' by our matrix.
-{
-       transform(p.x, p.y);
-}
-
-void
-matrix::transform(float& x, float& y) const
-// Transform point 'x,y' by our matrix.
-{
-       float nx = m_[0][0] * x + m_[0][1] * y + m_[0][2];
-       float ny = m_[1][0] * x + m_[1][1] * y + m_[1][2];
-       x = nx;
-       y = ny;
-}
-
-void
 matrix::transform(geometry::Range2d<float>& r) const
 {
        if ( ! r.isFinite() ) return;

Index: server/matrix.h
===================================================================
RCS file: /sources/gnash/gnash/server/matrix.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- server/matrix.h     5 Mar 2008 03:55:59 -0000       1.16
+++ server/matrix.h     12 Mar 2008 03:46:03 -0000      1.17
@@ -157,14 +157,27 @@
        ///
        void    transform(point* result, const point& p) const;
 
-       /// Transform point 'p' by our matrix. 
-       void    transform(point& p) const;
+       // Transform point 'p' by our matrix.
+       template <typename T>
+       void transform(geometry::Point2d<T>& p) const
+       {
+               transform(p.x, p.y);
+       }
 
        /// Transform point 'p' by the inverse of our matrix. 
        void    transform_by_inverse(point& p) const;
 
        /// Transform point 'x,y' by our matrix. 
-       void    transform(float& x, float& y) const;
+       template <typename T>
+       void
+       transform(T& x, T& y) const
+       // Transform point 'x,y' by our matrix.
+       {
+               float nx = m_[0][0] * x + m_[0][1] * y + m_[0][2];
+               float ny = m_[1][0] * x + m_[1][1] * y + m_[1][2];
+               x = nx;
+               y = ny;
+       }
 
        /// Transform vector 'v' by our matrix. Doesn't apply translation.
        //

Index: server/shape.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/shape.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- server/shape.cpp    21 Jan 2008 20:55:52 -0000      1.53
+++ server/shape.cpp    12 Mar 2008 03:46:03 -0000      1.54
@@ -17,411 +17,6 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-
-#include "shape.h"
-
-#include "tu_file.h"
-#include "rect.h"
-#include "log.h"
-
-#include <cfloat>
-#include <map>
-
-#ifdef DEBUG_POINT_ON_CURVE
-# include <sstream>
-#endif
-
-#include <boost/bind.hpp>
-
-
-namespace gnash {
-
-//
-// edge
-//
-
-/* public static */
-point
-edge::pointOnCurve(const point& A, const point& C, const point& B, float t)
-{
-       // See 
http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Quadratic_B.C3.A9zier_curves
-
-       if ( t == 0.0 ) return A;
-       else if ( t == 1.0 ) return B;
-
-       point Q1(A, C, t);
-       point Q2(C, B, t);
-       point R = point(Q1, Q2, t);
-
-#ifdef DEBUG_POINT_ON_CURVE
-       std::stringstream ss;
-       ss <<  "A:" << A << " C:" << C << " B:" << B
-               << " T:" << t
-               << " Q1:" << Q1 << " Q2:" << Q2
-               << " R:" << R;
-       log_debug("%s", ss.str().c_str());
-#endif
-
-       return R;
-}
-
-float
-edge::distancePtSeg(const point& pt, const point& A, const point& B)
-{
-       float square = squareDistancePtSeg(pt, A, B);
-       return sqrt(square);
-}
-
-float
-edge::squareDistancePtSeg(const point& p, const point& A, const point& B)
-{
-       float dx = B.x - A.x;
-       float dy = B.y - A.y;
-
-        /* if start==end, then use pt distance */
-        if ( dx == 0 && dy == 0 ) return p.squareDistance(A); 
-
-       float pdx = p.x - A.x;
-       float pdy = p.y - A.y;
-
-        float u = (pdx * dx + pdy * dy) / (dx*dx + dy*dy);
-
-        if (u<0)
-       {
-               //cout << "R was < 0 " << endl;
-               return p.squareDistance(A); 
-       }
-
-        if (u>1)
-       {
-               //cout << "R was > 1 " << endl;
-               return p.squareDistance(B);
-       }
-
-       point px;
-       px.x = A.x + u * (B.x - A.x);
-       px.y = A.y + u * (B.y - A.y);
-
-       //cout << "R was between 0 and 1, u is " << u << " px : " << px.x << 
"," << px.y << endl;
-
-       return p.squareDistance(px);
-}
-
-void
-edge::transform(const matrix& mat)
-{
-  mat.transform(ap);
-  mat.transform(cp);
-}
-
-
-
-//
-// path
-//
-
-
-path::path(bool newShape)
-    :
-    m_new_shape(newShape)
-{
-    reset(0, 0, 0, 0, 0);
-}
-
-path::path(float ax, float ay, int fill0, int fill1, int line, bool newShape)
-    :
-    m_new_shape(newShape)
-{
-    reset(ax, ay, fill0, fill1, line);
-}
-
-
-void   path::reset(float ax, float ay, int fill0, int fill1, int line)
-    // Reset all our members to the given values, and clear our edge list.
-{
-    ap.x = ax;
-    ap.y = ay;
-    m_fill0 = fill0;
-    m_fill1 = fill1;
-    m_line = line;
-
-    m_edges.resize(0);
-
-    assert(is_empty());
-}
-
-
-bool   path::is_empty() const
-    // Return true if we have no edges.
-{
-    return m_edges.size() == 0;
-}
-
-void
-path::expandBounds(rect& r, unsigned int thickness) const
-{
-        const path&    p = *this;
-
-        size_t nedges = m_edges.size();
-        if ( ! nedges ) return; // this path adds nothing
-
-        if (thickness)
-       {
-               // NOTE: Half of thickness would be enough (and correct) for
-               // radius, but that would not match how Flash calculates the
-               // bounds using the drawing API.                        
-               float radius = thickness;
-
-               r.expand_to_circle(ap.x, ap.y, radius);
-               for (unsigned int j = 0; j<nedges; j++)
-               {
-                       r.expand_to_circle(m_edges[j].ap.x, m_edges[j].ap.y, 
radius);
-                       r.expand_to_circle(m_edges[j].cp.x, m_edges[j].cp.y, 
radius);
-               }
-
-               return;
-       }
-
-       r.expand_to_point(ap.x, ap.y);
-       for (unsigned int j = 0; j<nedges; j++)
-       {
-               r.expand_to_point(m_edges[j].ap.x, p.m_edges[j].ap.y);
-                r.expand_to_point(m_edges[j].cp.x, p.m_edges[j].cp.y);
-       }
-}
-
-void
-path::ray_crossing(int& ray_crossings, float x, float y) const
-{
-    if ( m_edges.empty() ) return;
-
-    // Shoot a horizontal ray from (x,y) to the right, and
-    // count the number of edge crossings.  An even number
-    // of crossings means the point is outside; an odd
-    // number means it's inside.
-
-    float x0 = ap.x;
-    float y0 = ap.y;
-
-    for (int i = 0, n = m_edges.size(); i < n; i++) {
-       const edge& e = m_edges[i];
-       
-       float x1 = e.ap.x;
-       float y1 = e.ap.y;
-       
-       if (e.isStraight()) {
-           // Straight-line case.
-           
-           // See if (x0,y0)-(x1,y1) crosses (x,y)-(infinity,y)
-           
-           // Does the segment straddle the horizontal ray?
-           bool cross_up = (y0 < y && y1 > y);
-           bool cross_down = (!cross_up) && (y0 > y && y1 < y);
-           if (cross_up || cross_down) {
-               // Straddles.
-               
-               // Is the crossing point to the right of x?
-               float dy = y1 - y0;
-
-               // x_intercept = x0 + (x1 - x0) * (y - y0) / dy;
-               float x_intercept_times_dy = x0 * dy + (x1 - x0) * (y - y0);
-
-               // text x_intercept > x
-                               
-               // factor out the division; two cases depending on sign of dy
-               if (cross_up) {
-                   assert(dy > 0);
-                   if (x_intercept_times_dy > x * dy) {
-                       ray_crossings++;
-                   }
-               } else {
-                   // dy is negative; reverse the inequality test
-                   assert(dy < 0);
-                   if (x_intercept_times_dy < x * dy) {
-                       ray_crossings++;
-                   }
-               }
-           }
-       } else {
-           // Curve case.
-           float cx = e.cp.x;
-           float cy = e.cp.y;
-
-           // Find whether & where the curve crosses y
-           if ((y0 < y && y1 < y && cy < y)
-               || (y0 > y && y1 > y && cy > y)) {
-               // All above or all below -- no possibility of crossing.
-           } else if (x0 < x && x1 < x && cx < x) {
-               // All to the left -- no possibility of crossing to the right.
-           } else {
-               // Find points where the curve crosses y.
-               
-               // Quadratic bezier is:
-               //
-               // p = (1-t)^2 * a0 + 2t(1-t) * c + t^2 * a1
-               //
-               // We need to solve for x at y.
-               
-               // Use the quadratic formula.
-               
-               // Numerical Recipes suggests this variation:
-               // q = -0.5 [b +sgn(b) sqrt(b^2 - 4ac)]
-               // x1 = q/a;  x2 = c/q;
-
-               float A = y1 + y0 - 2 * cy;
-               float B = 2 * (cy - y0);
-               float C = y0 - y;
-
-               float rad = B * B - 4 * A * C;
-               if (rad < 0) {
-                   // No real solutions.
-               } else {
-                   float q;
-                   float sqrt_rad = sqrtf(rad);
-                   if (B < 0) {
-                       q = -0.5f * (B - sqrt_rad);
-                   } else {
-                       q = -0.5f * (B + sqrt_rad);
-                   }
-
-                   // The old-school way.
-                   // float t0 = (-B + sqrt_rad) / (2 * A);
-                   // float t1 = (-B - sqrt_rad) / (2 * A);
-
-                   if (A != 0) {
-                       float t0 = q / A;
-                       if (t0 >= 0 && t0 < 1) {
-                           float x_at_t0 =
-                               x0 + 2 * (cx - x0) * t0 + (x1 + x0 - 2 * cx) * 
t0 * t0;
-                           if (x_at_t0 > x) {
-                               ray_crossings++;
-                           }
-                       }
-                   }
-
-                   if (q != 0) {
-                       float t1 = C / q;
-                       if (t1 >= 0 && t1 < 1) {
-                           float x_at_t1 =
-                               x0 + 2 * (cx - x0) * t1 + (x1 + x0 - 2 * cx) * 
t1 * t1;
-                           if (x_at_t1 > x) {
-                               ray_crossings++;
-                           }
-                       }
-                   }
-               }
-           }
-       }
-
-       x0 = x1;
-       y0 = y1;
-    }
-
-    return;
-}
-
-void 
-path::drawLineTo(float dx, float dy)
-{
-       m_edges.push_back(edge(dx, dy, dx, dy)); 
-}
-
-void 
-path::drawCurveTo(float cdx, float cdy, float adx, float ady)
-{
-       m_edges.push_back(edge(cdx, cdy, adx, ady)); 
-}
-
-void
-path::close()
-{
-       // nothing to do if path there are no edges
-       if ( m_edges.empty() ) return;
-
-       // Close it with a straight edge if needed
-       const edge& lastedge = m_edges.back();
-       if ( lastedge.ap.x != ap.x || lastedge.ap.y != ap.y )
-       {
-               edge newedge(ap.x, ap.y, ap.x, ap.y);
-               m_edges.push_back(newedge);
-       }
-}
-
-bool
-path::withinSquareDistance(const point& p, float dist) const
-{
-       size_t nedges = m_edges.size();
-
-       if ( ! nedges ) return false;
-
-       point px(ap.x, ap.y);
-       for (size_t i=0; i<nedges; ++i)
-       {
-               const edge& e = m_edges[i];
-               point np(e.ap.x, e.ap.y);
-
-               if ( e.isStraight() )
-               {
-                       float d = edge::squareDistancePtSeg(p, px, np);
-                       if ( d < dist ) return true;
-               }
-               else
-               {
-                       // It's a curve !
-
-                       const point& A = px;
-                       const point& C = e.cp;
-                       const point& B = e.ap;
-
-                       // TODO: early break if point is NOT in the area
-                       //       defined by the triangle ACB and it's square 
-                       //       distance from it is > then the requested one
-
-                       // Approximate the curve to segCount segments
-                       // and compute distance of query point from each
-                       // segment.
-                       //
-                       // TODO: find an apprpriate value for segCount based
-                       //       on rendering scale ?
-                       //
-                       int segCount = 10; 
-                       point p0 = A;
-                       for (int i=1; i<=segCount; ++i)
-                       {
-                               float t1 = (float)i/segCount;
-                               point p1 = edge::pointOnCurve(A, C, B, t1);
-
-                               // distance from point and segment being an 
approximation
-                               // of the curve 
-                               float d = edge::squareDistancePtSeg(p, p0, p1);
-
-                               //float d = edge::squareDistancePtCurve(A, C, 
B, p, t);
-                               //log_debug("Factor %26.26g, distance %g (asked 
%g)", t, sqrt(d), sqrt(dist));
-                               if ( d <= dist ) return true;
-
-                               p0 = p1;
-                       }
-               }
-
-               px = np;
-       }
-
-       return false;
-}
-
-void
-path::transform(const matrix& mat)
-{
-  using namespace boost;
-  
-  mat.transform(ap);
-  std::for_each(m_edges.begin(), m_edges.end(),
-                bind(&edge::transform, _1, ref(mat)));                
-}
-
-}      // end namespace gnash
-
-
 // Local Variables:
 // mode: C++
 // indent-tabs-mode: t

Index: server/shape.h
===================================================================
RCS file: /sources/gnash/gnash/server/shape.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- server/shape.h      6 Mar 2008 05:22:53 -0000       1.38
+++ server/shape.h      12 Mar 2008 03:46:03 -0000      1.39
@@ -1,9 +1,19 @@
-// shape.h     -- Thatcher Ulrich <address@hidden> 2003
-
-// This source code has been donated to the Public Domain.  Do
-// whatever you want with it.
-
-// Quadratic bezier outline shapes, the basis for most SWF rendering.
+//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
 
 
 #ifndef GNASH_SHAPE_H
@@ -13,6 +23,9 @@
 #include "styles.h"
 
 #include <vector> // for path composition
+#include "rect.h"
+#include <boost/bind.hpp>  
+#include <algorithm>
 
 
 // Forward declarations
@@ -21,34 +34,54 @@
 }
 
 namespace gnash {
+  using namespace geometry;
 
        /// \brief
        /// Together with the previous anchor,
        /// defines a quadratic curve segment.
-       class edge
+  template <typename T>
+  class Edge
        {
        public:
-               edge()
-                       :
-                       cp(),
-                       ap()
+    Edge()
                {
                }
 
-               edge(float cx, float cy, float ax, float ay)
+    Edge(T cx, T cy, T ax, T ay)
                        :
                        cp(cx, cy),
                        ap(ax, ay)
                {
                }
 
-               edge(point ncp, point nap)
+    Edge(const Edge<T>& from)
+      : cp(from.cp),
+        ap(from.ap)
+    {
+    }
+
+    template <typename U>
+    Edge(const Edge<U>& from)
+      : cp(from.cp.x, from.cp.y),
+        ap(from.ap.x, from.ap.y)
+    {
+    }
+
+    Edge(const Point2d<T>& ncp, const Point2d<T>& nap)
                        :
                        cp(ncp),
                        ap(nap)
                {
                }
 
+    template <typename U>
+    Edge(const Point2d<U>& ncp, const Point2d<U>& nap)
+      :
+      cp(ncp.x, ncp.y),
+      ap(nap.y, nap.y)
+    {
+    }
+
                bool isStraight() const
                {
                        return cp == ap;
@@ -57,13 +90,61 @@
                bool is_straight() const { return isStraight(); }
                
                /// Transform the edge according to the given matrix.
-               void transform(const matrix& mat);
+    void
+    transform(const matrix& mat)
+    {
+      mat.transform(ap);
+      mat.transform(cp);
+    }
 
                /// Return squared distance between point pt and segment A-B
-               static float squareDistancePtSeg(const point& pt, const point& 
A, const point& B);
+    template <typename U, typename V, typename W>
+    static float
+    squareDistancePtSeg(const Point2d<U>& p, const Point2d<V>& A,
+            const Point2d<W>& B)
+    {
+      float dx = B.x - A.x;
+      float dy = B.y - A.y;
+
+            /* if start==end, then use pt distance */
+            if ( dx == 0 && dy == 0 ) {
+        return p.squareDistance(A);
+      }
+
+      float pdx = p.x - A.x;
+      float pdy = p.y - A.y;
+
+            float u = (pdx * dx + pdy * dy) / float(dx*dx + dy*dy);
+
+            if (u<0)
+      {
+        //cout << "R was < 0 " << endl;
+        return p.squareDistance(A); 
+      }
+
+            if (u>1)
+      {
+        //cout << "R was > 1 " << endl;
+        return p.squareDistance(B);
+      }
+
+      Point2d<float> px;
+      px.x = A.x + u * (B.x - A.x);
+      px.y = A.y + u * (B.y - A.y);
+
+      //cout << "R was between 0 and 1, u is " << u << " px : " << px.x << "," 
<< px.y << endl;
+  
+      return p.squareDistance(px);
+    }
 
                /// Return distance between point pt and segment A-B
-               static float distancePtSeg(const point& pt, const point& A, 
const point& B);
+    template <typename U>
+    static float
+    distancePtSeg(const Point2d<U>& pt, const Point2d<U>& A, const Point2d<U>& 
B)
+    {
+      float square = squareDistancePtSeg(pt, A, B);
+      return sqrt(square);
+    }
 
                /// Find point of the quadratic curve defined by points A,C,B
                //
@@ -73,7 +154,31 @@
                /// @param ret The point to write result into
                /// @param t the step factor between 0 and 1
                ///
-               static point pointOnCurve(const point& A, const point& C, const 
point& B, float t);
+
+    template <typename U>
+    static geometry::Point2d<float>
+    pointOnCurve(const Point2d<U>& A,
+           const Point2d<U>& C,
+           const Point2d<U>& B, float t)
+    {
+      if ( t == 0.0 ) return Point2d<float>(A.x, A.y);
+      else if ( t == 1.0 ) return Point2d<float>(B.x, B.y);
+
+      Point2d<float> Q1(A, C, t);
+      Point2d<float> Q2(C, B, t);
+       Point2d<float> R(Q1, Q2, t);
+
+#ifdef DEBUG_POINT_ON_CURVE
+      std::stringstream ss;
+      ss <<  "A:" << A << " C:" << C << " B:" << B
+        << " T:" << t
+        << " Q1:" << Q1 << " Q2:" << Q2
+        << " R:" << R;
+      log_debug("%s", ss.str().c_str());
+#endif
+
+      return R;
+    }
 
                /// Return square distance between point pt and the point on 
curve found by
                /// applying the T parameter to the quadratic bezier curve 
function
@@ -84,30 +189,65 @@
                /// @param p The point we want to compute distance from 
                /// @param t the step factor between 0 and 1
                ///
-               static float squareDistancePtCurve(const point& A, const point& 
C, const point& B, const point& p, float t)
+    template <typename U>
+    static float squareDistancePtCurve(const Point2d<U>& A,
+               const Point2d<U>& C,
+               const Point2d<U>& B,
+               const Point2d<U>& p, float t)
                {
                        return p.squareDistance( pointOnCurve(A, C, B, t) );
                }
                
        //private:
                // *quadratic* bezier: point = p0 * t^2 + p1 * 2t(1-t) + p2 * 
(1-t)^2
-               point cp; // "control" point
-               point ap; // "anchor" point
+    Point2d<T> cp; // "control" point
+    Point2d<T> ap; // "anchor" point
        };
 
+  typedef Edge<int> edge;
+
 
        /// \brief
        /// A subset of a shape -- a series of edges sharing a single set
-       /// of styles.
-       class DSOEXPORT path
+  /// of styles. The template argument defines the data type to be used for
+  /// coordinates; this can be either a fixed or floating point type.
+  template <typename T>
+  class DSOEXPORT Path
        {
        public:
+
                /// Default constructor
                //
                /// @param newShape
                ///     True if this path starts a new subshape
                ///
-               path(bool newShape=false);
+    Path(bool newShape = false)
+      : m_new_shape(newShape)
+    {
+      reset(0, 0, 0, 0, 0);
+    }
+
+    template <typename U>
+    Path(const Path<T>& from)
+      : m_fill0(from.m_fill0),
+        m_fill1(from.m_fill1),
+        m_line(from.m_line),
+        ap(from.ap),
+        m_edges(from.m_edges),
+        m_new_shape(from.m_new_shape)        
+    {
+    }
+
+    template <typename U>
+    Path(const Path<U>& from)
+      : m_fill0(from.m_fill0),
+        m_fill1(from.m_fill1),
+        m_line(from.m_line),
+        ap(from.ap.x, from.ap.y),
+        m_edges(from.m_edges.begin(), from.m_edges.end()),
+        m_new_shape(from.m_new_shape)        
+    {
+    }
 
                /// Initialize a path 
                //
@@ -131,9 +271,12 @@
                ///
                /// @param newShape
                ///     True if this path starts a new subshape
-               ///
-               ///
-               path(float ax, float ay, int fill0, int fill1, int line, bool 
newShape=false);
+    Path(T ax, T ay, int fill0, int fill1, int line, bool newShape)
+      :
+      m_new_shape(newShape)
+    {
+      reset(ax, ay, fill0, fill1, line);
+    }
 
                /// Re-initialize a path, maintaining the "new shape" flag 
untouched
                //
@@ -152,39 +295,68 @@
                /// @param line
                ///     Line style index for right fill
                ///
-               void    reset(float ax, float ay, int fill0, int fill1, int 
line);
-
-               /// Set this path as the start of a new (sub)shape
-               void setNewShape() { m_new_shape=true; }
+    void  reset(T ax, T ay, int fill0, int fill1, int line)
+        // Reset all our members to the given values, and clear our edge list.
+    {
+      ap.x = ax;
+      ap.y = ay;
+      m_fill0 = fill0;
+      m_fill1 = fill1;
+      m_line = line;
 
-               /// Return true if this path starts a new (sub)shape
-               bool getNewShape() const { return m_new_shape; }
+      m_edges.resize(0);
+      assert(is_empty());
+    }
 
-               /// Return true if this path contains no edges
-               bool    is_empty() const;
+    /// Return true if we have no edges.
+    bool  
+    is_empty() const
 
-               /// Return true if this path contains no edges
-               bool    empty() const
                {
-                       return is_empty();
+        return m_edges.empty();
                }
 
-               /// Ray crossing count. (OBSOLETE)
+    /// Expand given rect to include bounds of this path
                //
-               /// Update ray crossing for the given query point using
-               /// edges in this path. Was used to detect point in shape,
-    /// but now we're using a different method.
-               ///
-               /// @param ray_crossings
-               ///     Number of crossings, updated by this method.
-               ///
-               /// @param x
-               ///     X ordinate of the query point, in local coordinate 
space.
+    /// @param r
+    ///  The rectangle to expand with our own bounds
                ///
-               /// @param y
-               ///     Y ordinate of the query point, in local coordinate 
space.
+    /// @param thickness
+    ///  The thickess of our lines, half the thickness will
+    ///  be added in all directions
                ///
-               void ray_crossing(int& ray_crossings, float x, float y) const;
+    void
+    expandBounds(rect& r, unsigned int thickness) const
+    {
+      const Path<T>&  p = *this;
+
+      size_t nedges = m_edges.size();
+      if ( ! nedges ) return; // this path adds nothing
+
+      if (thickness)
+      {
+        // NOTE: Half of thickness would be enough (and correct) for
+        // radius, but that would not match how Flash calculates the
+        // bounds using the drawing API.                        
+        unsigned int radius = thickness;
+
+        r.expand_to_circle(ap.x, ap.y, radius);
+        for (unsigned int j = 0; j<nedges; j++)
+        {
+          r.expand_to_circle(m_edges[j].ap.x, m_edges[j].ap.y, radius);
+          r.expand_to_circle(m_edges[j].cp.x, m_edges[j].cp.y, radius);
+        }
+
+        return;
+      }
+
+      r.expand_to_point(ap.x, ap.y);
+      for (unsigned int j = 0; j<nedges; j++)
+      {
+        r.expand_to_point(m_edges[j].ap.x, p.m_edges[j].ap.y);
+                    r.expand_to_point(m_edges[j].cp.x, p.m_edges[j].cp.y);
+      }
+    }
 
                /// @{ Primitives for the Drawing API
                ///
@@ -202,7 +374,11 @@
                /// @param y
                ///     Y coordinate in TWIPS
                ///
-               void drawLineTo(float x, float y);
+    void 
+    drawLineTo(T dx, T dy)
+    {
+      m_edges.push_back(Edge<T>(dx, dy, dx, dy)); 
+    }
 
                /// Draw a curve.
                //
@@ -221,7 +397,11 @@
                /// @param ay
                ///     Anchor point's Y ordinate.
                ///
-               void drawCurveTo(float cx, float cy, float ax, float ay);
+    void 
+    drawCurveTo(T cdx, T cdy, T adx, T ady)
+    {
+      m_edges.push_back(Edge<T>(cdx, cdy, adx, ady)); 
+    }
 
                /// Remove all edges and reset style infomation 
                void clear()
@@ -232,6 +412,118 @@
 
                /// @} Primitives for the Drawing API
 
+
+
+    /// Close this path with a straight line, if not already closed
+    void
+    close()
+    {
+      // nothing to do if path there are no edges
+      if ( m_edges.empty() ) return;
+
+      // Close it with a straight edge if needed
+      const Edge<T>& lastedge = m_edges.back();
+      if ( lastedge.ap != ap )
+      {
+        Edge<T> newedge(ap, ap);
+        m_edges.push_back(newedge);
+      }
+    }
+
+
+    /// \brief
+    /// Return true if the given point is withing the given squared distance
+    /// from this path edges.
+    //
+    /// NOTE: if the path is empty, false is returned.
+    ///
+    bool
+    withinSquareDistance(const Point2d<float>& p, float dist) const
+    {
+      size_t nedges = m_edges.size();
+
+      if ( ! nedges ) return false;
+
+      int_point px(ap);
+      for (size_t i=0; i<nedges; ++i)
+      {
+        const Edge<T>& e = m_edges[i];
+        int_point np(e.ap);
+
+        if ( e.isStraight() )
+        {
+          float d = Edge<float>::squareDistancePtSeg(p, px, np);
+          if ( d < dist ) return true;
+        }
+        else
+        {
+          // It's a curve !
+
+          const int_point& A = px;
+          const int_point& C = e.cp;
+          const int_point& B = e.ap;
+
+          // TODO: early break if point is NOT in the area
+          //       defined by the triangle ACB and it's square 
+          //       distance from it is > then the requested one
+
+          // Approximate the curve to segCount segments
+          // and compute distance of query point from each
+          // segment.
+          //
+          // TODO: find an apprpriate value for segCount based
+          //       on rendering scale ?
+          //
+          int segCount = 10; 
+          float_point p0(A.x, A.y);
+          for (int i=1; i<=segCount; ++i)
+          {
+            float t1 = (float)i/segCount;
+            float_point p1 = Edge<T>::pointOnCurve(A, C, B, t1);
+
+            // distance from point and segment being an approximation
+            // of the curve 
+            float d = Edge<T>::squareDistancePtSeg(p, p0, p1);
+
+            //float d = edge::squareDistancePtCurve(A, C, B, p, t);
+            //log_debug("Factor %26.26g, distance %g (asked %g)", t, sqrt(d), 
sqrt(dist));
+            if ( d <= dist ) return true;
+
+            p0.setTo(p1.x, p1.y);
+          }
+        }
+
+        px = np;
+      }
+
+      return false;
+    }
+
+
+
+    /// Transform all path coordinates according to the given matrix.
+    void
+    transform(const matrix& mat)
+    {
+      using namespace boost;
+
+      mat.transform(ap);
+      std::for_each(m_edges.begin(), m_edges.end(),
+                    bind(&Edge<T>::transform, _1, ref(mat)));                
+    }    
+
+    /// Set this path as the start of a new (sub)shape
+    void setNewShape() { m_new_shape=true; }
+
+    /// Return true if this path starts a new (sub)shape
+    bool getNewShape() const { return m_new_shape; }
+
+    /// Return true if this path contains no edges
+    bool  empty() const
+    {
+      return is_empty();
+    }
+
                /// Set the fill to use on the left side
                //
                /// @param f
@@ -296,47 +588,23 @@
                }
 
                /// Return a reference to the Nth edge 
-               edge& operator[] (size_t n)
+    Edge<T>& operator[] (size_t n)
                {
                        return m_edges[n];
                }
 
                /// Return a const reference to the Nth edge 
-               const edge& operator[] (size_t n) const
+    const Edge<T>& operator[] (size_t n) const
                {
                        return m_edges[n];
                }
 
-               /// Close this path with a straight line, if not already closed
-               void close();
-
-               /// \brief
-               /// Return true if the given point is withing the given squared 
distance
-               /// from this path edges.
-               //
-               /// NOTE: if the path is empty, false is returned.
-               ///
-               bool withinSquareDistance(const point& p, float dist) const;
-
-
-               /// Expand given rect to include bounds of this path
-               //
-               /// @param r
-               ///     The rectangle to expand with our own bounds
-               ///
-               /// @param thickness
-               ///     The thickess of our lines, half the thickness will
-               ///     be added in all directions
-               ///
-               void expandBounds(rect& r, unsigned int thickness) const;
-
+    /// Returns true if this path begins a new subshape. <-- VERIFYME
                bool isNewShape() const
                {
                        return m_new_shape;
                }
                
-               /// Transform all path coordinates according to the given 
matrix.
-               void transform(const matrix& mat);
 
        //private:
 
@@ -350,19 +618,20 @@
                unsigned m_line;
 
                /// Path/shape origin 
-               point ap; 
+    Point2d<T> ap; 
 
                /// Edges forming the path
-               std::vector<edge> m_edges;
+    std::vector< Edge<T> > m_edges;
 
                /// This flag is set when the path is the first one of a new 
"sub-shape".
                /// All paths with a higher index in the list belong to the 
same 
                /// shape unless they have m_new_shape==true on their own.
                /// Sub-shapes affect the order in which outlines and shapes 
are rendered.
                bool m_new_shape;
-
        };
 
+  typedef Path<int> path;
+
 }      // end namespace gnash
 
 

Index: server/types.h
===================================================================
RCS file: /sources/gnash/gnash/server/types.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/types.h      12 Dec 2007 10:07:01 -0000      1.19
+++ server/types.h      12 Mar 2008 03:46:03 -0000      1.20
@@ -23,7 +23,7 @@
 
 
 #define TWIPS_TO_PIXELS(x)     ((x) / 20.f)
-#define PIXELS_TO_TWIPS(x)     ((x) * 20.f)
+#define PIXELS_TO_TWIPS(x)     ((x) * 20)
 
 
 namespace gnash {

Index: server/parser/BitmapMovieDefinition.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/BitmapMovieDefinition.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/parser/BitmapMovieDefinition.cpp     19 Feb 2008 19:20:56 -0000      
1.17
+++ server/parser/BitmapMovieDefinition.cpp     12 Mar 2008 03:46:04 -0000      
1.18
@@ -66,7 +66,7 @@
 
        log_parse(_("Creating a shape_definition wrapping a %g x %g bitmap"), 
w, h);
 
-       path bmPath(w, h, fillLeft, 0, 0);
+       path bmPath(w, h, fillLeft, 0, 0, false);
        bmPath.drawLineTo(w, 0);
        bmPath.drawLineTo(0, 0);
        bmPath.drawLineTo(0, h);




reply via email to

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