incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r1184758 [16/17] - in /incubator/ooo/trunk/main: ./ agg/inc/ agg/source/ solenv/config/
Date Sun, 16 Oct 2011 04:13:21 GMT
Modified: incubator/ooo/trunk/main/agg/inc/agg_span_solid.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_span_solid.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_span_solid.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_span_solid.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -21,36 +21,26 @@
 #define AGG_SPAN_SOLID_INCLUDED
 
 #include "agg_basics.h"
-#include "agg_span_generator.h"
 
 namespace agg
 {
     //--------------------------------------------------------------span_solid
-    template<class ColorT, class Allocator = span_allocator<ColorT> >
-    class span_solid : public span_generator<ColorT, Allocator>
+    template<class ColorT> class span_solid
     {
     public:
-        typedef Allocator alloc_type;
         typedef ColorT color_type;
-        typedef span_generator<color_type, alloc_type> base_type;
-
-        //--------------------------------------------------------------------
-        span_solid(alloc_type& alloc) : base_type(alloc) {}
 
         //--------------------------------------------------------------------
         void color(const color_type& c) { m_color = c; }
         const color_type& color() const { return m_color; }
 
         //--------------------------------------------------------------------
-        color_type* generate(int x, int y, unsigned len)
+        void prepare() {}
+
+        //--------------------------------------------------------------------
+        void generate(color_type* span, int x, int y, unsigned len)
         {   
-            color_type* span = base_type::allocator().span();
-            do
-            {
-                *span++ = m_color;
-            }
-            while(--len);
-            return base_type::allocator().span();
+            do { *span++ = m_color; } while(--len);
         }
 
     private:

Modified: incubator/ooo/trunk/main/agg/inc/agg_span_subdiv_adaptor.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_span_subdiv_adaptor.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_span_subdiv_adaptor.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_span_subdiv_adaptor.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -28,10 +28,10 @@ namespace agg
         typedef Interpolator interpolator_type;
         typedef typename interpolator_type::trans_type trans_type;
 
-        enum
+        enum sublixel_scale_e
         {
             subpixel_shift = SubpixelShift,
-            subpixel_size  = 1 << subpixel_shift
+            subpixel_scale = 1 << subpixel_shift
         };
 
 
@@ -87,7 +87,7 @@ namespace agg
         void begin(double x, double y, unsigned len)
         {
             m_pos   = 1;
-            m_src_x = int(x * subpixel_size) + subpixel_size;
+            m_src_x = iround(x * subpixel_scale) + subpixel_scale;
             m_src_y = y;
             m_len   = len;
             if(len > m_subdiv_size) len = m_subdiv_size;
@@ -102,12 +102,12 @@ namespace agg
             {
                 unsigned len = m_len;
                 if(len > m_subdiv_size) len = m_subdiv_size;
-                m_interpolator->resynchronize(double(m_src_x) / double(subpixel_size) + len, 
+                m_interpolator->resynchronize(double(m_src_x) / double(subpixel_scale) + len, 
                                               m_src_y, 
                                               len);
                 m_pos = 0;
             }
-            m_src_x += subpixel_size;
+            m_src_x += subpixel_scale;
             ++m_pos;
             --m_len;
         }

Modified: incubator/ooo/trunk/main/agg/inc/agg_trans_affine.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_trans_affine.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_trans_affine.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_trans_affine.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -24,7 +24,7 @@
 
 namespace agg
 {
-    const double affine_epsilon = 1e-14; // About of precision of doubles
+    const double affine_epsilon = 1e-14; 
 
     //============================================================trans_affine
     //
@@ -84,48 +84,58 @@ namespace agg
     // m *= agg::trans_affine_rotation(30.0 * 3.1415926 / 180.0);  // rotate
     // m *= agg::trans_affine_translation(100.0, 100.0);           // move back to (100,100)
     //----------------------------------------------------------------------
-    class trans_affine
+    struct trans_affine
     {
-    public:
+        double sx, shy, shx, sy, tx, ty;
+
         //------------------------------------------ Construction
-        // Construct an identity matrix - it does not transform anything
+        // Identity matrix
         trans_affine() :
-            m0(1.0), m1(0.0), m2(0.0), m3(1.0), m4(0.0), m5(0.0)
+            sx(1.0), shy(0.0), shx(0.0), sy(1.0), tx(0.0), ty(0.0)
         {}
 
-        // Construct a custom matrix. Usually used in derived classes
-        trans_affine(double v0, double v1, double v2, double v3, double v4, double v5) :
-            m0(v0), m1(v1), m2(v2), m3(v3), m4(v4), m5(v5)
+        // Custom matrix. Usually used in derived classes
+        trans_affine(double v0, double v1, double v2, 
+                     double v3, double v4, double v5) :
+            sx(v0), shy(v1), shx(v2), sy(v3), tx(v4), ty(v5)
         {}
 
-        // Construct a matrix to transform a parallelogram to another one.
-        trans_affine(const double* rect, const double* parl)
-        {
-            parl_to_parl(rect, parl);
-        }
+        // Custom matrix from m[6]
+        explicit trans_affine(const double* m) :
+            sx(m[0]), shy(m[1]), shx(m[2]), sy(m[3]), tx(m[4]), ty(m[5])
+        {}
 
-        // Construct a matrix to transform a rectangle to a parallelogram.
+        // Rectangle to a parallelogram.
         trans_affine(double x1, double y1, double x2, double y2, 
                      const double* parl)
         {
             rect_to_parl(x1, y1, x2, y2, parl);
         }
 
-        // Construct a matrix to transform a parallelogram to a rectangle.
+        // Parallelogram to a rectangle.
         trans_affine(const double* parl, 
                      double x1, double y1, double x2, double y2)
         {
             parl_to_rect(parl, x1, y1, x2, y2);
         }
 
+        // Arbitrary parallelogram transformation.
+        trans_affine(const double* src, const double* dst)
+        {
+            parl_to_parl(src, dst);
+        }
 
         //---------------------------------- Parellelogram transformations
-        // Calculate a matrix to transform a parallelogram to another one.
-        // src and dst are pointers to arrays of three points 
-        // (double[6], x,y,...) that identify three corners of the 
-        // parallelograms assuming implicit fourth points.
-        // There are also transformations rectangtle to parallelogram and 
-        // parellelogram to rectangle
+        // transform a parallelogram to another one. Src and dst are 
+        // pointers to arrays of three points (double[6], x1,y1,...) that 
+        // identify three corners of the parallelograms assuming implicit 
+        // fourth point. The arguments are arrays of double[6] mapped 
+        // to x1,y1, x2,y2, x3,y3  where the coordinates are:
+        //        *-----------------*
+        //       /          (x3,y3)/
+        //      /                 /
+        //     /(x1,y1)   (x2,y2)/
+        //    *-----------------*
         const trans_affine& parl_to_parl(const double* src, 
                                          const double* dst);
 
@@ -139,15 +149,27 @@ namespace agg
 
 
         //------------------------------------------ Operations
-        // Reset - actually load an identity matrix
+        // Reset - load an identity matrix
         const trans_affine& reset();
 
+        // Direct transformations operations
+        const trans_affine& translate(double x, double y);
+        const trans_affine& rotate(double a);
+        const trans_affine& scale(double s);
+        const trans_affine& scale(double x, double y);
+
         // Multiply matrix to another one
         const trans_affine& multiply(const trans_affine& m);
 
         // Multiply "m" to "this" and assign the result to "this"
         const trans_affine& premultiply(const trans_affine& m);
 
+        // Multiply matrix to inverse of another one
+        const trans_affine& multiply_inv(const trans_affine& m);
+
+        // Multiply inverse of "m" to "this" and assign the result to "this"
+        const trans_affine& premultiply_inv(const trans_affine& m);
+
         // Invert matrix. Do not try to invert degenerate matrices, 
         // there's no check for validity. If you set scale to 0 and 
         // then try to invert matrix, expect unpredictable result.
@@ -163,31 +185,44 @@ namespace agg
         // Store matrix to an array [6] of double
         void store_to(double* m) const
         {
-            *m++ = m0; *m++ = m1; *m++ = m2; *m++ = m3; *m++ = m4; *m++ = m5;
+            *m++ = sx; *m++ = shy; *m++ = shx; *m++ = sy; *m++ = tx; *m++ = ty;
         }
 
         // Load matrix from an array [6] of double
         const trans_affine& load_from(const double* m)
         {
-            m0 = *m++; m1 = *m++; m2 = *m++; m3 = *m++; m4 = *m++;  m5 = *m++;
+            sx = *m++; shy = *m++; shx = *m++; sy = *m++; tx = *m++;  ty = *m++;
             return *this;
         }
 
         //------------------------------------------- Operators
         
-        // Multiply current matrix to another one
+        // Multiply the matrix by another one
         const trans_affine& operator *= (const trans_affine& m)
         {
             return multiply(m);
         }
 
-        // Multiply current matrix to another one and return
+        // Multiply the matrix by inverse of another one
+        const trans_affine& operator /= (const trans_affine& m)
+        {
+            return multiply_inv(m);
+        }
+
+        // Multiply the matrix by another one and return
         // the result in a separete matrix.
         trans_affine operator * (const trans_affine& m)
         {
             return trans_affine(*this).multiply(m);
         }
 
+        // Multiply the matrix by inverse of another one 
+        // and return the result in a separete matrix.
+        trans_affine operator / (const trans_affine& m)
+        {
+            return trans_affine(*this).multiply_inv(m);
+        }
+
         // Calculate and return the inverse matrix
         trans_affine operator ~ () const
         {
@@ -208,19 +243,28 @@ namespace agg
         }
 
         //-------------------------------------------- Transformations
-        // Direct transformation x and y
+        // Direct transformation of x and y
         void transform(double* x, double* y) const;
 
-        // Inverse transformation x and y. It works slower than the 
-        // direct transformation, so if the performance is critical 
-        // it's better to invert() the matrix and then use transform()
+        // Direct transformation of x and y, 2x2 matrix only, no translation
+        void transform_2x2(double* x, double* y) const;
+
+        // Inverse transformation of x and y. It works slower than the 
+        // direct transformation. For massive operations it's better to 
+        // invert() the matrix and then use direct transformations. 
         void inverse_transform(double* x, double* y) const;
 
         //-------------------------------------------- Auxiliary
         // Calculate the determinant of matrix
         double determinant() const
         {
-            return 1.0 / (m0 * m3 - m1 * m2);
+            return sx * sy - shy * shx;
+        }
+
+        // Calculate the reciprocal of the determinant
+        double determinant_reciprocal() const
+        {
+            return 1.0 / (sx * sy - shy * shx);
         }
 
         // Get the average scale (by X and Y). 
@@ -228,57 +272,108 @@ namespace agg
         // decomposinting curves into line segments.
         double scale() const;
 
+        // Check to see if the matrix is not degenerate
+        bool is_valid(double epsilon = affine_epsilon) const;
+
         // Check to see if it's an identity matrix
         bool is_identity(double epsilon = affine_epsilon) const;
 
         // Check to see if two matrices are equal
         bool is_equal(const trans_affine& m, double epsilon = affine_epsilon) const;
 
-        // Determine the major parameters. Use carefully considering degenerate matrices
+        // Determine the major parameters. Use with caution considering 
+        // possible degenerate cases.
         double rotation() const;
         void   translation(double* dx, double* dy) const;
-        void   scaling(double* sx, double* sy) const;
-        void   scaling_abs(double* sx, double* sy) const
-        {
-            *sx = sqrt(m0*m0 + m2*m2);
-            *sy = sqrt(m1*m1 + m3*m3);
-        }
-
-    private:
-        double m0;
-        double m1;
-        double m2;
-        double m3;
-        double m4;
-        double m5;
+        void   scaling(double* x, double* y) const;
+        void   scaling_abs(double* x, double* y) const;
     };
 
     //------------------------------------------------------------------------
     inline void trans_affine::transform(double* x, double* y) const
     {
-        register double tx = *x;
-        *x = tx * m0 + *y * m2 + m4;
-        *y = tx * m1 + *y * m3 + m5;
+        register double tmp = *x;
+        *x = tmp * sx  + *y * shx + tx;
+        *y = tmp * shy + *y * sy  + ty;
+    }
+
+    //------------------------------------------------------------------------
+    inline void trans_affine::transform_2x2(double* x, double* y) const
+    {
+        register double tmp = *x;
+        *x = tmp * sx  + *y * shx;
+        *y = tmp * shy + *y * sy;
     }
 
     //------------------------------------------------------------------------
     inline void trans_affine::inverse_transform(double* x, double* y) const
     {
-        register double d = determinant();
-        register double a = (*x - m4) * d;
-        register double b = (*y - m5) * d;
-        *x = a * m3 - b * m2;
-        *y = b * m0 - a * m1;
+        register double d = determinant_reciprocal();
+        register double a = (*x - tx) * d;
+        register double b = (*y - ty) * d;
+        *x = a * sy - b * shx;
+        *y = b * sx - a * shy;
     }
 
     //------------------------------------------------------------------------
     inline double trans_affine::scale() const
     {
-        double x = 0.707106781 * m0 + 0.707106781 * m2;
-        double y = 0.707106781 * m1 + 0.707106781 * m3;
+        double x = 0.707106781 * sx  + 0.707106781 * shx;
+        double y = 0.707106781 * shy + 0.707106781 * sy;
         return sqrt(x*x + y*y);
     }
 
+    //------------------------------------------------------------------------
+    inline const trans_affine& trans_affine::translate(double x, double y) 
+    { 
+        tx += x;
+        ty += y; 
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_affine& trans_affine::rotate(double a) 
+    {
+        double ca = cos(a); 
+        double sa = sin(a);
+        double t0 = sx  * ca - shy * sa;
+        double t2 = shx * ca - sy * sa;
+        double t4 = tx  * ca - ty * sa;
+        shy = sx  * sa + shy * ca;
+        sy  = shx * sa + sy * ca; 
+        ty  = tx  * sa + ty * ca;
+        sx  = t0;
+        shx = t2;
+        tx  = t4;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_affine& trans_affine::scale(double x, double y) 
+    {
+        double mm0 = x; // Possible hint for the optimizer
+        double mm3 = y; 
+        sx  *= mm0;
+        shx *= mm0;
+        tx  *= mm0;
+        shy *= mm3;
+        sy  *= mm3;
+        ty  *= mm3;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_affine& trans_affine::scale(double s) 
+    {
+        double m = s; // Possible hint for the optimizer
+        sx  *= m;
+        shx *= m;
+        tx  *= m;
+        shy *= m;
+        sy  *= m;
+        ty  *= m;
+        return *this;
+    }
 
     //------------------------------------------------------------------------
     inline const trans_affine& trans_affine::premultiply(const trans_affine& m)
@@ -287,6 +382,31 @@ namespace agg
         return *this = t.multiply(*this);
     }
 
+    //------------------------------------------------------------------------
+    inline const trans_affine& trans_affine::multiply_inv(const trans_affine& m)
+    {
+        trans_affine t = m;
+        t.invert();
+        return multiply(t);
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_affine& trans_affine::premultiply_inv(const trans_affine& m)
+    {
+        trans_affine t = m;
+        t.invert();
+        return *this = t.multiply(*this);
+    }
+
+    //------------------------------------------------------------------------
+    inline void trans_affine::scaling_abs(double* x, double* y) const
+    {
+        // Used to calculate scaling coefficients in image resampling. 
+        // When there is considerable shear this method gives us much
+        // better estimation than just sx, sy.
+        *x = sqrt(sx  * sx  + shx * shx);
+        *y = sqrt(shy * shy + sy  * sy);
+    }
 
     //====================================================trans_affine_rotation
     // Rotation matrix. sin() and cos() are calculated twice for the same angle.
@@ -302,12 +422,12 @@ namespace agg
     };
 
     //====================================================trans_affine_scaling
-    // Scaling matrix. sx, sy - scale coefficients by X and Y respectively
+    // Scaling matrix. x, y - scale coefficients by X and Y respectively
     class trans_affine_scaling : public trans_affine
     {
     public:
-        trans_affine_scaling(double sx, double sy) : 
-          trans_affine(sx, 0.0, 0.0, sy, 0.0, 0.0)
+        trans_affine_scaling(double x, double y) : 
+          trans_affine(x, 0.0, 0.0, y, 0.0, 0.0)
         {}
 
         trans_affine_scaling(double s) : 
@@ -320,8 +440,8 @@ namespace agg
     class trans_affine_translation : public trans_affine
     {
     public:
-        trans_affine_translation(double tx, double ty) : 
-          trans_affine(1.0, 0.0, 0.0, 1.0, tx, ty)
+        trans_affine_translation(double x, double y) : 
+          trans_affine(1.0, 0.0, 0.0, 1.0, x, y)
         {}
     };
 
@@ -330,12 +450,66 @@ namespace agg
     class trans_affine_skewing : public trans_affine
     {
     public:
-        trans_affine_skewing(double sx, double sy) : 
-          trans_affine(1.0, tan(sy), tan(sx), 1.0, 0.0, 0.0)
+        trans_affine_skewing(double x, double y) : 
+          trans_affine(1.0, tan(y), tan(x), 1.0, 0.0, 0.0)
+        {}
+    };
+
+
+    //===============================================trans_affine_line_segment
+    // Rotate, Scale and Translate, associating 0...dist with line segment 
+    // x1,y1,x2,y2
+    class trans_affine_line_segment : public trans_affine
+    {
+    public:
+        trans_affine_line_segment(double x1, double y1, double x2, double y2, 
+                                  double dist)
+        {
+            double dx = x2 - x1;
+            double dy = y2 - y1;
+            if(dist > 0.0)
+            {
+                multiply(trans_affine_scaling(sqrt(dx * dx + dy * dy) / dist));
+            }
+            multiply(trans_affine_rotation(atan2(dy, dx)));
+            multiply(trans_affine_translation(x1, y1));
+        }
+    };
+
+
+    //============================================trans_affine_reflection_unit
+    // Reflection matrix. Reflect coordinates across the line through 
+    // the origin containing the unit vector (ux, uy).
+    // Contributed by John Horigan
+    class trans_affine_reflection_unit : public trans_affine
+    {
+    public:
+        trans_affine_reflection_unit(double ux, double uy) :
+          trans_affine(2.0 * ux * ux - 1.0, 
+                       2.0 * ux * uy, 
+                       2.0 * ux * uy, 
+                       2.0 * uy * uy - 1.0, 
+                       0.0, 0.0)
         {}
     };
 
 
+    //=================================================trans_affine_reflection
+    // Reflection matrix. Reflect coordinates across the line through 
+    // the origin at the angle a or containing the non-unit vector (x, y).
+    // Contributed by John Horigan
+    class trans_affine_reflection : public trans_affine_reflection_unit
+    {
+    public:
+        trans_affine_reflection(double a) :
+          trans_affine_reflection_unit(cos(a), sin(a))
+        {}
+
+
+        trans_affine_reflection(double x, double y) :
+          trans_affine_reflection_unit(x / sqrt(x * x + y * y), y / sqrt(x * x + y * y))
+        {}
+    };
 
 }
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_trans_bilinear.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_trans_bilinear.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_trans_bilinear.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_trans_bilinear.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 

Modified: incubator/ooo/trunk/main/agg/inc/agg_trans_double_path.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_trans_double_path.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_trans_double_path.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_trans_double_path.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 

Modified: incubator/ooo/trunk/main/agg/inc/agg_trans_perspective.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_trans_perspective.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_trans_perspective.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_trans_perspective.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -19,125 +19,212 @@
 #ifndef AGG_TRANS_PERSPECTIVE_INCLUDED
 #define AGG_TRANS_PERSPECTIVE_INCLUDED
 
-#include "agg_basics.h"
-#include "agg_simul_eq.h"
+#include "agg_trans_affine.h"
 
 namespace agg
 {
     //=======================================================trans_perspective
-    class trans_perspective
+    struct trans_perspective
     {
-    public:
-        //--------------------------------------------------------------------
-        trans_perspective() : m_valid(false) {}
+        double sx, shy, w0, shx, sy, w1, tx, ty, w2;
 
+        //------------------------------------------------------- Construction
+        // Identity matrix
+        trans_perspective() : 
+            sx (1), shy(0), w0(0), 
+            shx(0), sy (1), w1(0), 
+            tx (0), ty (0), w2(1) {}
+
+        // Custom matrix
+        trans_perspective(double v0, double v1, double v2, 
+                          double v3, double v4, double v5,
+                          double v6, double v7, double v8) :
+           sx (v0), shy(v1), w0(v2), 
+           shx(v3), sy (v4), w1(v5), 
+           tx (v6), ty (v7), w2(v8) {}
+
+        // Custom matrix from m[9]
+        explicit trans_perspective(const double* m) :
+           sx (m[0]), shy(m[1]), w0(m[2]), 
+           shx(m[3]), sy (m[4]), w1(m[5]), 
+           tx (m[6]), ty (m[7]), w2(m[8]) {}
+
+        // From affine
+        explicit trans_perspective(const trans_affine& a) : 
+           sx (a.sx ), shy(a.shy), w0(0), 
+           shx(a.shx), sy (a.sy ), w1(0), 
+           tx (a.tx ), ty (a.ty ), w2(1) {}
 
-        //--------------------------------------------------------------------
-        // Arbitrary quadrangle transformations
-        trans_perspective(const double* src, const double* dst) 
-        {
-            quad_to_quad(src, dst);
-        }
+        // Rectangle to quadrilateral
+        trans_perspective(double x1, double y1, double x2, double y2, 
+                          const double* quad);
 
+        // Quadrilateral to rectangle
+        trans_perspective(const double* quad, 
+                          double x1, double y1, double x2, double y2);
 
-        //--------------------------------------------------------------------
-        // Direct transformations 
-        trans_perspective(double x1, double y1, double x2, double y2, 
-                          const double* quad)
-        {
-            rect_to_quad(x1, y1, x2, y2, quad);
-        }
+        // Arbitrary quadrilateral transformations
+        trans_perspective(const double* src, const double* dst);
 
+        //-------------------------------------- Quadrilateral transformations
+        // The arguments are double[8] that are mapped to quadrilaterals:
+        // x1,y1, x2,y2, x3,y3, x4,y4
+        bool quad_to_quad(const double* qs, const double* qd);
 
-        //--------------------------------------------------------------------
-        // Reverse transformations 
-        trans_perspective(const double* quad, 
-                          double x1, double y1, double x2, double y2)
-        {
-            quad_to_rect(quad, x1, y1, x2, y2);
-        }
+        bool rect_to_quad(double x1, double y1, 
+                          double x2, double y2,
+                          const double* q);
 
+        bool quad_to_rect(const double* q,
+                          double x1, double y1, 
+                          double x2, double y2);
 
-        //--------------------------------------------------------------------
-        // Set the transformations using two arbitrary quadrangles.
-        void quad_to_quad(const double* src, const double* dst)
-        {
+        // Map square (0,0,1,1) to the quadrilateral and vice versa
+        bool square_to_quad(const double* q);
+        bool quad_to_square(const double* q);
 
-            double left[8][8];
-            double right[8][1];
 
-            unsigned i;
-            for (i = 0; i < 4; i++)
-            {
-                unsigned ix = i * 2;
-                unsigned iy = ix + 1;
+        //--------------------------------------------------------- Operations
+        // Reset - load an identity matrix
+        const trans_perspective& reset();
 
-                left[ix][0]  =  1.0;
-                left[ix][1]  =  src[ix];
-                left[ix][2]  =  src[iy];
-                left[ix][3]  =  0.0;
-                left[ix][4]  =  0.0;
-                left[ix][5]  =  0.0;
-                left[ix][6]  = -src[ix] * dst[ix];
-                left[ix][7]  = -src[iy] * dst[ix];
-                right[ix][0] =  dst[ix];
-
-                left[iy][0]  =  0.0;
-                left[iy][1]  =  0.0;
-                left[iy][2]  =  0.0;
-                left[iy][3]  =  1.0;
-                left[iy][4]  =  src[ix];
-                left[iy][5]  =  src[iy];
-                left[iy][6]  = -src[ix] * dst[iy];
-                left[iy][7]  = -src[iy] * dst[iy];
-                right[iy][0] =  dst[iy];
-            }
-            m_valid = simul_eq<8, 1>::solve(left, right, m_mtx);
+        // Invert matrix. Returns false in degenerate case
+        bool invert();
+
+        // Direct transformations operations
+        const trans_perspective& translate(double x, double y);
+        const trans_perspective& rotate(double a);
+        const trans_perspective& scale(double s);
+        const trans_perspective& scale(double x, double y);
+
+        // Multiply the matrix by another one
+        const trans_perspective& multiply(const trans_perspective& m);
+
+        // Multiply "m" by "this" and assign the result to "this"
+        const trans_perspective& premultiply(const trans_perspective& m);
+
+        // Multiply matrix to inverse of another one
+        const trans_perspective& multiply_inv(const trans_perspective& m);
+
+        // Multiply inverse of "m" by "this" and assign the result to "this"
+        const trans_perspective& premultiply_inv(const trans_perspective& m);
+
+        // Multiply the matrix by another one
+        const trans_perspective& multiply(const trans_affine& m);
+
+        // Multiply "m" by "this" and assign the result to "this"
+        const trans_perspective& premultiply(const trans_affine& m);
+
+        // Multiply the matrix by inverse of another one
+        const trans_perspective& multiply_inv(const trans_affine& m);
+
+        // Multiply inverse of "m" by "this" and assign the result to "this"
+        const trans_perspective& premultiply_inv(const trans_affine& m);
+
+        //--------------------------------------------------------- Load/Store
+        void store_to(double* m) const;
+        const trans_perspective& load_from(const double* m);
+
+        //---------------------------------------------------------- Operators
+        // Multiply the matrix by another one
+        const trans_perspective& operator *= (const trans_perspective& m)
+        {
+            return multiply(m);
+        }
+        const trans_perspective& operator *= (const trans_affine& m)
+        {
+            return multiply(m);
         }
 
+        // Multiply the matrix by inverse of another one
+        const trans_perspective& operator /= (const trans_perspective& m)
+        {
+            return multiply_inv(m);
+        }
+        const trans_perspective& operator /= (const trans_affine& m)
+        {
+            return multiply_inv(m);
+        }
 
-        //--------------------------------------------------------------------
-        // Set the direct transformations, i.e., rectangle -> quadrangle
-        void rect_to_quad(double x1, double y1, double x2, double y2, 
-                          const double* quad)
-        {
-            double src[8];
-            src[0] = src[6] = x1;
-            src[2] = src[4] = x2;
-            src[1] = src[3] = y1;
-            src[5] = src[7] = y2;
-            quad_to_quad(src, quad);
+        // Multiply the matrix by another one and return
+        // the result in a separete matrix.
+        trans_perspective operator * (const trans_perspective& m)
+        {
+            return trans_perspective(*this).multiply(m);
+        }
+        trans_perspective operator * (const trans_affine& m)
+        {
+            return trans_perspective(*this).multiply(m);
         }
 
+        // Multiply the matrix by inverse of another one 
+        // and return the result in a separete matrix.
+        trans_perspective operator / (const trans_perspective& m)
+        {
+            return trans_perspective(*this).multiply_inv(m);
+        }
+        trans_perspective operator / (const trans_affine& m)
+        {
+            return trans_perspective(*this).multiply_inv(m);
+        }
 
-        //--------------------------------------------------------------------
-        // Set the reverse transformations, i.e., quadrangle -> rectangle
-        void quad_to_rect(const double* quad, 
-                          double x1, double y1, double x2, double y2)
-        {
-            double dst[8];
-            dst[0] = dst[6] = x1;
-            dst[2] = dst[4] = x2;
-            dst[1] = dst[3] = y1;
-            dst[5] = dst[7] = y2;
-            quad_to_quad(quad, dst);
+        // Calculate and return the inverse matrix
+        trans_perspective operator ~ () const
+        {
+            trans_perspective ret = *this;
+            ret.invert();
+            return ret;
         }
 
-        //--------------------------------------------------------------------
-        // Check if the equations were solved successfully
-        bool is_valid() const { return m_valid; }
+        // Equal operator with default epsilon
+        bool operator == (const trans_perspective& m) const
+        {
+            return is_equal(m, affine_epsilon);
+        }
 
-        //--------------------------------------------------------------------
-        // Transform a point (x, y)
-        void transform(double* x, double* y) const
+        // Not Equal operator with default epsilon
+        bool operator != (const trans_perspective& m) const
         {
-            double tx = *x;
-            double ty = *y;
-            double d = 1.0 / (m_mtx[6][0] * tx + m_mtx[7][0] * ty + 1.0);
-            *x = (m_mtx[0][0] + m_mtx[1][0] * tx + m_mtx[2][0] * ty) * d;
-            *y = (m_mtx[3][0] + m_mtx[4][0] * tx + m_mtx[5][0] * ty) * d;
+            return !is_equal(m, affine_epsilon);
         }
 
+        //---------------------------------------------------- Transformations
+        // Direct transformation of x and y
+        void transform(double* x, double* y) const;
+
+        // Direct transformation of x and y, affine part only
+        void transform_affine(double* x, double* y) const;
+
+        // Direct transformation of x and y, 2x2 matrix only, no translation
+        void transform_2x2(double* x, double* y) const;
+
+        // Inverse transformation of x and y. It works slow because
+        // it explicitly inverts the matrix on every call. For massive 
+        // operations it's better to invert() the matrix and then use 
+        // direct transformations. 
+        void inverse_transform(double* x, double* y) const;
+
+
+        //---------------------------------------------------------- Auxiliary
+        const trans_perspective& from_affine(const trans_affine& a);
+        double determinant() const;
+        double determinant_reciprocal() const;
+
+        bool is_valid(double epsilon = affine_epsilon) const;
+        bool is_identity(double epsilon = affine_epsilon) const;
+        bool is_equal(const trans_perspective& m, 
+                      double epsilon = affine_epsilon) const;
+
+        // Determine the major affine parameters. Use with caution 
+        // considering possible degenerate cases.
+        double scale() const;
+        double rotation() const;
+        void   translation(double* dx, double* dy) const;
+        void   scaling(double* x, double* y) const;
+        void   scaling_abs(double* x, double* y) const;
+
+
+
         //--------------------------------------------------------------------
         class iterator_x
         {
@@ -153,17 +240,16 @@ namespace agg
             double y;
 
             iterator_x() {}
-            iterator_x(double tx, double ty, double step, const double m[8][1]) :
-                den(m[6][0] * tx + m[7][0] * ty + 1.0),
-                den_step(m[6][0] * step),
-                nom_x(m[0][0] + m[1][0] * tx + m[2][0] * ty),
-                nom_x_step(m[1][0] * step),
-                nom_y(m[3][0] + m[4][0] * tx + m[5][0] * ty),
-                nom_y_step(m[4][0] * step),
+            iterator_x(double px, double py, double step, const trans_perspective& m) :
+                den(px * m.w0 + py * m.w1 + m.w2),
+                den_step(m.w0 * step),
+                nom_x(px * m.sx + py * m.shx + m.tx),
+                nom_x_step(step * m.sx),
+                nom_y(px * m.shy + py * m.sy + m.ty),
+                nom_y_step(step * m.shy),
                 x(nom_x / den),
                 y(nom_y / den)
-            {
-            }
+            {}
 
             void operator ++ ()
             {
@@ -179,14 +265,467 @@ namespace agg
         //--------------------------------------------------------------------
         iterator_x begin(double x, double y, double step) const
         {
-            return iterator_x(x, y, step, m_mtx);
+            return iterator_x(x, y, step, *this);
         }
-
-    private:
-        double m_mtx[8][1];
-        bool   m_valid;
     };
 
+
+
+
+
+
+
+
+
+   
+
+
+
+
+    //------------------------------------------------------------------------
+    inline bool trans_perspective::square_to_quad(const double* q)
+    {
+        double dx = q[0] - q[2] + q[4] - q[6];
+        double dy = q[1] - q[3] + q[5] - q[7];
+        if(dx == 0.0 && dy == 0.0)
+        {   
+            // Affine case (parallelogram)
+            //---------------
+            sx  = q[2] - q[0];
+            shy = q[3] - q[1];
+            w0  = 0.0;
+            shx = q[4] - q[2];
+            sy  = q[5] - q[3];
+            w1  = 0.0;
+            tx  = q[0];
+            ty  = q[1];
+            w2  = 1.0;
+        }
+        else
+        {
+            double dx1 = q[2] - q[4];
+            double dy1 = q[3] - q[5];
+            double dx2 = q[6] - q[4];
+            double dy2 = q[7] - q[5];
+            double den = dx1 * dy2 - dx2 * dy1;
+            if(den == 0.0)
+            {
+                // Singular case
+                //---------------
+                sx = shy = w0 = shx = sy = w1 = tx = ty = w2 = 0.0;
+                return false;
+            }
+            // General case
+            //---------------
+            double u = (dx * dy2 - dy * dx2) / den;
+            double v = (dy * dx1 - dx * dy1) / den;
+            sx  = q[2] - q[0] + u * q[2];
+            shy = q[3] - q[1] + u * q[3];
+            w0  = u;
+            shx = q[6] - q[0] + v * q[6];
+            sy  = q[7] - q[1] + v * q[7];
+            w1  = v;
+            tx  = q[0];
+            ty  = q[1];
+            w2  = 1.0;
+        }
+        return true;
+    }
+
+    //------------------------------------------------------------------------
+    inline bool trans_perspective::invert()
+    {
+        double d0 = sy  * w2 - w1  * ty;
+        double d1 = w0  * ty - shy * w2;
+        double d2 = shy * w1 - w0  * sy;
+        double d  = sx  * d0 + shx * d1 + tx * d2;
+        if(d == 0.0) 
+        {
+            sx = shy = w0 = shx = sy = w1 = tx = ty = w2 = 0.0;
+            return false;
+        }
+        d = 1.0 / d;
+        trans_perspective a = *this;
+        sx  = d * d0;
+        shy = d * d1;
+        w0  = d * d2;
+        shx = d * (a.w1 *a.tx  - a.shx*a.w2);
+        sy  = d * (a.sx *a.w2  - a.w0 *a.tx);
+        w1  = d * (a.w0 *a.shx - a.sx *a.w1);
+        tx  = d * (a.shx*a.ty  - a.sy *a.tx);
+        ty  = d * (a.shy*a.tx  - a.sx *a.ty);
+        w2  = d * (a.sx *a.sy  - a.shy*a.shx);
+        return true;
+    }
+
+    //------------------------------------------------------------------------
+    inline bool trans_perspective::quad_to_square(const double* q)
+    {
+        if(!square_to_quad(q)) return false;
+        invert();
+        return true;
+    }
+
+    //------------------------------------------------------------------------
+    inline bool trans_perspective::quad_to_quad(const double* qs, 
+                                                const double* qd)
+    {
+        trans_perspective p;
+        if(!  quad_to_square(qs)) return false;
+        if(!p.square_to_quad(qd)) return false;
+        multiply(p);
+        return true;
+    }
+
+    //------------------------------------------------------------------------
+    inline bool trans_perspective::rect_to_quad(double x1, double y1, 
+                                                double x2, double y2,
+                                                const double* q)
+    {
+        double r[8];
+        r[0] = r[6] = x1;
+        r[2] = r[4] = x2;
+        r[1] = r[3] = y1;
+        r[5] = r[7] = y2;
+        return quad_to_quad(r, q);
+    }
+
+    //------------------------------------------------------------------------
+    inline bool trans_perspective::quad_to_rect(const double* q,
+                                                double x1, double y1, 
+                                                double x2, double y2)
+    {
+        double r[8];
+        r[0] = r[6] = x1;
+        r[2] = r[4] = x2;
+        r[1] = r[3] = y1;
+        r[5] = r[7] = y2;
+        return quad_to_quad(q, r);
+    }
+
+    //------------------------------------------------------------------------
+    inline trans_perspective::trans_perspective(double x1, double y1, 
+                                                double x2, double y2, 
+                                                const double* quad)
+    {
+        rect_to_quad(x1, y1, x2, y2, quad);
+    }
+
+    //------------------------------------------------------------------------
+    inline trans_perspective::trans_perspective(const double* quad, 
+                                                double x1, double y1, 
+                                                double x2, double y2)
+    {
+        quad_to_rect(quad, x1, y1, x2, y2);
+    }
+
+    //------------------------------------------------------------------------
+    inline trans_perspective::trans_perspective(const double* src, 
+                                                const double* dst) 
+    {
+        quad_to_quad(src, dst);
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& trans_perspective::reset()
+    {
+        sx  = 1; shy = 0; w0 = 0; 
+        shx = 0; sy  = 1; w1 = 0;
+        tx  = 0; ty  = 0; w2 = 1;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& 
+    trans_perspective::multiply(const trans_perspective& a)
+    {
+        trans_perspective b = *this;
+        sx  = a.sx *b.sx  + a.shx*b.shy + a.tx*b.w0;
+        shx = a.sx *b.shx + a.shx*b.sy  + a.tx*b.w1;
+        tx  = a.sx *b.tx  + a.shx*b.ty  + a.tx*b.w2;
+        shy = a.shy*b.sx  + a.sy *b.shy + a.ty*b.w0;
+        sy  = a.shy*b.shx + a.sy *b.sy  + a.ty*b.w1;
+        ty  = a.shy*b.tx  + a.sy *b.ty  + a.ty*b.w2;
+        w0  = a.w0 *b.sx  + a.w1 *b.shy + a.w2*b.w0;
+        w1  = a.w0 *b.shx + a.w1 *b.sy  + a.w2*b.w1;
+        w2  = a.w0 *b.tx  + a.w1 *b.ty  + a.w2*b.w2;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& 
+    trans_perspective::multiply(const trans_affine& a)
+    {
+        trans_perspective b = *this;
+        sx  = a.sx *b.sx  + a.shx*b.shy + a.tx*b.w0;
+        shx = a.sx *b.shx + a.shx*b.sy  + a.tx*b.w1;
+        tx  = a.sx *b.tx  + a.shx*b.ty  + a.tx*b.w2;
+        shy = a.shy*b.sx  + a.sy *b.shy + a.ty*b.w0;
+        sy  = a.shy*b.shx + a.sy *b.sy  + a.ty*b.w1;
+        ty  = a.shy*b.tx  + a.sy *b.ty  + a.ty*b.w2;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& 
+    trans_perspective::premultiply(const trans_perspective& b)
+    {
+        trans_perspective a = *this;
+        sx  = a.sx *b.sx  + a.shx*b.shy + a.tx*b.w0;
+        shx = a.sx *b.shx + a.shx*b.sy  + a.tx*b.w1;
+        tx  = a.sx *b.tx  + a.shx*b.ty  + a.tx*b.w2;
+        shy = a.shy*b.sx  + a.sy *b.shy + a.ty*b.w0;
+        sy  = a.shy*b.shx + a.sy *b.sy  + a.ty*b.w1;
+        ty  = a.shy*b.tx  + a.sy *b.ty  + a.ty*b.w2;
+        w0  = a.w0 *b.sx  + a.w1 *b.shy + a.w2*b.w0;
+        w1  = a.w0 *b.shx + a.w1 *b.sy  + a.w2*b.w1;
+        w2  = a.w0 *b.tx  + a.w1 *b.ty  + a.w2*b.w2;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& 
+    trans_perspective::premultiply(const trans_affine& b)
+    {
+        trans_perspective a = *this;
+        sx  = a.sx *b.sx  + a.shx*b.shy;
+        shx = a.sx *b.shx + a.shx*b.sy;
+        tx  = a.sx *b.tx  + a.shx*b.ty  + a.tx;
+        shy = a.shy*b.sx  + a.sy *b.shy;
+        sy  = a.shy*b.shx + a.sy *b.sy;
+        ty  = a.shy*b.tx  + a.sy *b.ty  + a.ty;
+        w0  = a.w0 *b.sx  + a.w1 *b.shy;
+        w1  = a.w0 *b.shx + a.w1 *b.sy;
+        w2  = a.w0 *b.tx  + a.w1 *b.ty  + a.w2;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    const trans_perspective& 
+    trans_perspective::multiply_inv(const trans_perspective& m)
+    {
+        trans_perspective t = m;
+        t.invert();
+        return multiply(t);
+    }
+
+    //------------------------------------------------------------------------
+    const trans_perspective&
+    trans_perspective::multiply_inv(const trans_affine& m)
+    {
+        trans_affine t = m;
+        t.invert();
+        return multiply(t);
+    }
+
+    //------------------------------------------------------------------------
+    const trans_perspective&
+    trans_perspective::premultiply_inv(const trans_perspective& m)
+    {
+        trans_perspective t = m;
+        t.invert();
+        return *this = t.multiply(*this);
+    }
+
+    //------------------------------------------------------------------------
+    const trans_perspective&
+    trans_perspective::premultiply_inv(const trans_affine& m)
+    {
+        trans_perspective t(m);
+        t.invert();
+        return *this = t.multiply(*this);
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& 
+    trans_perspective::translate(double x, double y)
+    {
+        tx += x;
+        ty += y;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& trans_perspective::rotate(double a)
+    {
+        multiply(trans_affine_rotation(a));
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& trans_perspective::scale(double s)
+    {
+        multiply(trans_affine_scaling(s));
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& trans_perspective::scale(double x, double y)
+    {
+        multiply(trans_affine_scaling(x, y));
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline void trans_perspective::transform(double* px, double* py) const
+    {
+        double x = *px;
+        double y = *py;
+        double m = 1.0 / (x*w0 + y*w1 + w2);
+        *px = m * (x*sx  + y*shx + tx);
+        *py = m * (x*shy + y*sy  + ty);
+    }
+
+    //------------------------------------------------------------------------
+    inline void trans_perspective::transform_affine(double* x, double* y) const
+    {
+        double tmp = *x;
+        *x = tmp * sx  + *y * shx + tx;
+        *y = tmp * shy + *y * sy  + ty;
+    }
+
+    //------------------------------------------------------------------------
+    inline void trans_perspective::transform_2x2(double* x, double* y) const
+    {
+        double tmp = *x;
+        *x = tmp * sx  + *y * shx;
+        *y = tmp * shy + *y * sy;
+    }
+
+    //------------------------------------------------------------------------
+    inline void trans_perspective::inverse_transform(double* x, double* y) const
+    {
+        trans_perspective t(*this);
+        if(t.invert()) t.transform(x, y);
+    }
+
+    //------------------------------------------------------------------------
+    inline void trans_perspective::store_to(double* m) const
+    {
+        *m++ = sx;  *m++ = shy; *m++ = w0; 
+        *m++ = shx; *m++ = sy;  *m++ = w1;
+        *m++ = tx;  *m++ = ty;  *m++ = w2;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& trans_perspective::load_from(const double* m)
+    {
+        sx  = *m++; shy = *m++; w0 = *m++; 
+        shx = *m++; sy  = *m++; w1 = *m++;
+        tx  = *m++; ty  = *m++; w2 = *m++;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline const trans_perspective& 
+    trans_perspective::from_affine(const trans_affine& a)
+    {
+        sx  = a.sx;  shy = a.shy; w0 = 0; 
+        shx = a.shx; sy  = a.sy;  w1 = 0;
+        tx  = a.tx;  ty  = a.ty;  w2 = 1;
+        return *this;
+    }
+
+    //------------------------------------------------------------------------
+    inline double trans_perspective::determinant() const
+    {
+        return sx  * (sy  * w2 - ty  * w1) +
+               shx * (ty  * w0 - shy * w2) +
+               tx  * (shy * w1 - sy  * w0);
+    }
+  
+    //------------------------------------------------------------------------
+    inline double trans_perspective::determinant_reciprocal() const
+    {
+        return 1.0 / determinant();
+    }
+
+    //------------------------------------------------------------------------
+    inline bool trans_perspective::is_valid(double epsilon) const
+    {
+        return fabs(sx) > epsilon && fabs(sy) > epsilon && fabs(w2) > epsilon;
+    }
+
+    //------------------------------------------------------------------------
+    inline bool trans_perspective::is_identity(double epsilon) const
+    {
+        return is_equal_eps(sx,  1.0, epsilon) &&
+               is_equal_eps(shy, 0.0, epsilon) &&
+               is_equal_eps(w0,  0.0, epsilon) &&
+               is_equal_eps(shx, 0.0, epsilon) && 
+               is_equal_eps(sy,  1.0, epsilon) &&
+               is_equal_eps(w1,  0.0, epsilon) &&
+               is_equal_eps(tx,  0.0, epsilon) &&
+               is_equal_eps(ty,  0.0, epsilon) &&
+               is_equal_eps(w2,  1.0, epsilon);
+    }
+
+    //------------------------------------------------------------------------
+    inline bool trans_perspective::is_equal(const trans_perspective& m, 
+                                            double epsilon) const
+    {
+        return is_equal_eps(sx,  m.sx,  epsilon) &&
+               is_equal_eps(shy, m.shy, epsilon) &&
+               is_equal_eps(w0,  m.w0,  epsilon) &&
+               is_equal_eps(shx, m.shx, epsilon) && 
+               is_equal_eps(sy,  m.sy,  epsilon) &&
+               is_equal_eps(w1,  m.w1,  epsilon) &&
+               is_equal_eps(tx,  m.tx,  epsilon) &&
+               is_equal_eps(ty,  m.ty,  epsilon) &&
+               is_equal_eps(w2,  m.w2,  epsilon);
+    }
+
+    //------------------------------------------------------------------------
+    inline double trans_perspective::scale() const
+    {
+        double x = 0.707106781 * sx  + 0.707106781 * shx;
+        double y = 0.707106781 * shy + 0.707106781 * sy;
+        return sqrt(x*x + y*y);
+    }
+
+    //------------------------------------------------------------------------
+    inline double trans_perspective::rotation() const
+    {
+        double x1 = 0.0;
+        double y1 = 0.0;
+        double x2 = 1.0;
+        double y2 = 0.0;
+        transform(&x1, &y1);
+        transform(&x2, &y2);
+        return atan2(y2-y1, x2-x1);
+    }
+
+    //------------------------------------------------------------------------
+    void trans_perspective::translation(double* dx, double* dy) const
+    {
+        *dx = tx;
+        *dy = ty;
+    }
+
+    //------------------------------------------------------------------------
+    void trans_perspective::scaling(double* x, double* y) const
+    {
+        double x1 = 0.0;
+        double y1 = 0.0;
+        double x2 = 1.0;
+        double y2 = 1.0;
+        trans_perspective t(*this);
+        t *= trans_affine_rotation(-rotation());
+        t.transform(&x1, &y1);
+        t.transform(&x2, &y2);
+        *x = x2 - x1;
+        *y = y2 - y1;
+    }
+
+    //------------------------------------------------------------------------
+    void trans_perspective::scaling_abs(double* x, double* y) const
+    {
+        *x = sqrt(sx  * sx  + shx * shx);
+        *y = sqrt(shy * shy + sy  * sy);
+    }
+
+
 }
 
 #endif
+

Modified: incubator/ooo/trunk/main/agg/inc/agg_trans_single_path.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_trans_single_path.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_trans_single_path.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_trans_single_path.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 

Modified: incubator/ooo/trunk/main/agg/inc/agg_trans_viewport.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_trans_viewport.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_trans_viewport.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_trans_viewport.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -22,7 +22,7 @@
 #define AGG_TRANS_VIEWPORT_INCLUDED
 
 #include <string.h>
-#include "agg_basics.h"
+#include "agg_trans_affine.h"
 
 
 namespace agg
@@ -51,6 +51,7 @@ namespace agg
             m_device_x2(1.0),
             m_device_y2(1.0),
             m_aspect(aspect_ratio_stretch),
+            m_is_valid(true),
             m_align_x(0.5),
             m_align_y(0.5),
             m_wx1(0.0),
@@ -123,6 +124,7 @@ namespace agg
         }
 
         //-------------------------------------------------------------------
+        bool   is_valid()             const { return m_is_valid; }
         double align_x()              const { return m_align_x; }
         double align_y()              const { return m_align_y; }
         aspect_ratio_e aspect_ratio() const { return m_aspect; }
@@ -135,6 +137,13 @@ namespace agg
         }
 
         //-------------------------------------------------------------------
+        void transform_scale_only(double* x, double* y) const
+        {
+            *x *= m_kx;
+            *y *= m_ky;
+        }
+
+        //-------------------------------------------------------------------
         void inverse_transform(double* x, double* y) const
         {
             *x = (*x - m_dx1) / m_kx + m_wx1;
@@ -142,6 +151,17 @@ namespace agg
         }
 
         //-------------------------------------------------------------------
+        void inverse_transform_scale_only(double* x, double* y) const
+        {
+            *x /= m_kx;
+            *y /= m_ky;
+        }
+
+        //-------------------------------------------------------------------
+        double device_dx() const { return m_dx1 - m_wx1 * m_kx; }
+        double device_dy() const { return m_dy1 - m_wy1 * m_ky; }
+
+        //-------------------------------------------------------------------
         double scale_x() const
         {
             return m_kx;
@@ -159,76 +179,35 @@ namespace agg
             return (m_kx + m_ky) * 0.5;
         }
 
+        //-------------------------------------------------------------------
+        trans_affine to_affine() const
+        {
+            trans_affine mtx = trans_affine_translation(-m_wx1, -m_wy1);
+            mtx *= trans_affine_scaling(m_kx, m_ky);
+            mtx *= trans_affine_translation(m_dx1, m_dy1);
+            return mtx;
+        }
+
+        //-------------------------------------------------------------------
+        trans_affine to_affine_scale_only() const
+        {
+            return trans_affine_scaling(m_kx, m_ky);
+        }
 
         //-------------------------------------------------------------------
         unsigned byte_size() const
         {
-            return 
-                sizeof(m_world_x1) +
-                sizeof(m_world_y1) +
-                sizeof(m_world_x2) +
-                sizeof(m_world_y2) +
-                sizeof(m_device_x1) +
-                sizeof(m_device_y1) +
-                sizeof(m_device_x2) +
-                sizeof(m_device_y2) +
-                sizeof(m_aspect) +
-                sizeof(m_align_x) +
-                sizeof(m_align_y) +
-                sizeof(m_wx1) +
-                sizeof(m_wy1) +
-                sizeof(m_wx2) +
-                sizeof(m_wy2) +
-                sizeof(m_dx1) +
-                sizeof(m_dy1) +
-                sizeof(m_kx) +
-                sizeof(m_ky);
+            return sizeof(*this);
         }
 
         void serialize(int8u* ptr) const
         {
-            memcpy(ptr, &m_world_x1,  sizeof(m_world_x1));  ptr += sizeof(m_world_x1); 
-            memcpy(ptr, &m_world_y1,  sizeof(m_world_y1));  ptr += sizeof(m_world_y1);
-            memcpy(ptr, &m_world_x2,  sizeof(m_world_x2));  ptr += sizeof(m_world_x2);
-            memcpy(ptr, &m_world_y2,  sizeof(m_world_y2));  ptr += sizeof(m_world_y2);
-            memcpy(ptr, &m_device_x1, sizeof(m_device_x1)); ptr += sizeof(m_device_x1);
-            memcpy(ptr, &m_device_y1, sizeof(m_device_y1)); ptr += sizeof(m_device_y1);
-            memcpy(ptr, &m_device_x2, sizeof(m_device_x2)); ptr += sizeof(m_device_x2);
-            memcpy(ptr, &m_device_y2, sizeof(m_device_y2)); ptr += sizeof(m_device_y2);
-            memcpy(ptr, &m_aspect,    sizeof(m_aspect));    ptr += sizeof(m_aspect);
-            memcpy(ptr, &m_align_x,   sizeof(m_align_x));   ptr += sizeof(m_align_x);
-            memcpy(ptr, &m_align_y,   sizeof(m_align_y));   ptr += sizeof(m_align_y);
-            memcpy(ptr, &m_wx1,       sizeof(m_wx1));       ptr += sizeof(m_wx1);
-            memcpy(ptr, &m_wy1,       sizeof(m_wy1));       ptr += sizeof(m_wy1);
-            memcpy(ptr, &m_wx2,       sizeof(m_wx2));       ptr += sizeof(m_wx2);
-            memcpy(ptr, &m_wy2,       sizeof(m_wy2));       ptr += sizeof(m_wy2);
-            memcpy(ptr, &m_dx1,       sizeof(m_dx1));       ptr += sizeof(m_dx1);
-            memcpy(ptr, &m_dy1,       sizeof(m_dy1));       ptr += sizeof(m_dy1);
-            memcpy(ptr, &m_kx,        sizeof(m_kx));        ptr += sizeof(m_kx);
-            memcpy(ptr, &m_ky,        sizeof(m_ky));        ptr += sizeof(m_ky);
+            memcpy(ptr, this, sizeof(*this)); 
         }
 
         void deserialize(const int8u* ptr)
         {
-            memcpy(&m_world_x1,  ptr, sizeof(m_world_x1));  ptr += sizeof(m_world_x1); 
-            memcpy(&m_world_y1,  ptr, sizeof(m_world_y1));  ptr += sizeof(m_world_y1);
-            memcpy(&m_world_x2,  ptr, sizeof(m_world_x2));  ptr += sizeof(m_world_x2);
-            memcpy(&m_world_y2,  ptr, sizeof(m_world_y2));  ptr += sizeof(m_world_y2);
-            memcpy(&m_device_x1, ptr, sizeof(m_device_x1)); ptr += sizeof(m_device_x1);
-            memcpy(&m_device_y1, ptr, sizeof(m_device_y1)); ptr += sizeof(m_device_y1);
-            memcpy(&m_device_x2, ptr, sizeof(m_device_x2)); ptr += sizeof(m_device_x2);
-            memcpy(&m_device_y2, ptr, sizeof(m_device_y2)); ptr += sizeof(m_device_y2);
-            memcpy(&m_aspect,    ptr, sizeof(m_aspect));    ptr += sizeof(m_aspect);
-            memcpy(&m_align_x,   ptr, sizeof(m_align_x));   ptr += sizeof(m_align_x);
-            memcpy(&m_align_y,   ptr, sizeof(m_align_y));   ptr += sizeof(m_align_y);
-            memcpy(&m_wx1,       ptr, sizeof(m_wx1));       ptr += sizeof(m_wx1);
-            memcpy(&m_wy1,       ptr, sizeof(m_wy1));       ptr += sizeof(m_wy1);
-            memcpy(&m_wx2,       ptr, sizeof(m_wx2));       ptr += sizeof(m_wx2);
-            memcpy(&m_wy2,       ptr, sizeof(m_wy2));       ptr += sizeof(m_wy2);
-            memcpy(&m_dx1,       ptr, sizeof(m_dx1));       ptr += sizeof(m_dx1);
-            memcpy(&m_dy1,       ptr, sizeof(m_dy1));       ptr += sizeof(m_dy1);
-            memcpy(&m_kx,        ptr, sizeof(m_kx));        ptr += sizeof(m_kx);
-            memcpy(&m_ky,        ptr, sizeof(m_ky));        ptr += sizeof(m_ky);
+            memcpy(this,  ptr, sizeof(*this));
         }
 
     private:
@@ -243,6 +222,7 @@ namespace agg
         double         m_device_x2;
         double         m_device_y2;
         aspect_ratio_e m_aspect;
+        bool           m_is_valid;
         double         m_align_x;
         double         m_align_y;
         double         m_wx1;
@@ -260,6 +240,24 @@ namespace agg
     //-----------------------------------------------------------------------
     inline void trans_viewport::update()
     {
+        const double epsilon = 1e-30;
+        if(fabs(m_world_x1  - m_world_x2)  < epsilon ||
+           fabs(m_world_y1  - m_world_y2)  < epsilon ||
+           fabs(m_device_x1 - m_device_x2) < epsilon ||
+           fabs(m_device_y1 - m_device_y2) < epsilon)
+        {
+            m_wx1 = m_world_x1;
+            m_wy1 = m_world_y1;
+            m_wx2 = m_world_x1 + 1.0;
+            m_wy2 = m_world_y2 + 1.0;
+            m_dx1 = m_device_x1;
+            m_dy1 = m_device_y1;
+            m_kx  = 1.0;
+            m_ky  = 1.0;
+            m_is_valid = false;
+            return;
+        }
+
         double world_x1  = m_world_x1;
         double world_y1  = m_world_y1;
         double world_x2  = m_world_x2;
@@ -295,6 +293,7 @@ namespace agg
         m_dy1 = device_y1;
         m_kx  = (device_x2 - device_x1) / (world_x2 - world_x1);
         m_ky  = (device_y2 - device_y1) / (world_y2 - world_y1);
+        m_is_valid = true;
     }
 
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_trans_warp_magnifier.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_trans_warp_magnifier.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_trans_warp_magnifier.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_trans_warp_magnifier.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -33,6 +33,11 @@ namespace agg
         void magnification(double m)    { m_magn = m;         }
         void radius(double r)           { m_radius = r;       }
 
+        double xc()            const { return m_xc; }
+        double yc()            const { return m_yc; }
+        double magnification() const { return m_magn;   }
+        double radius()        const { return m_radius; }
+
         void transform(double* x, double* y) const;
         void inverse_transform(double* x, double* y) const;
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_vcgen_bspline.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vcgen_bspline.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vcgen_bspline.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vcgen_bspline.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -37,7 +37,7 @@ namespace agg
         };
 
     public:
-        typedef pod_deque<point_type, 6> vertex_storage;
+        typedef pod_bvector<point_d, 6> vertex_storage;
 
         vcgen_bspline();
 
@@ -49,7 +49,7 @@ namespace agg
         void add_vertex(double x, double y, unsigned cmd);
 
         // Vertex Source Interface
-        void     rewind(unsigned id);
+        void     rewind(unsigned path_id);
         unsigned vertex(double* x, double* y);
 
     private:

Modified: incubator/ooo/trunk/main/agg/inc/agg_vcgen_contour.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vcgen_contour.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vcgen_contour.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vcgen_contour.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -17,7 +17,6 @@
 #define AGG_VCGEN_CONTOUR_INCLUDED
 
 #include "agg_math_stroke.h"
-#include "agg_vertex_iterator.h"
 
 namespace agg
 {
@@ -40,55 +39,54 @@ namespace agg
 
     public:
         typedef vertex_sequence<vertex_dist, 6> vertex_storage;
-        typedef pod_deque<point_type, 6>        coord_storage;
+        typedef pod_bvector<point_d, 6>         coord_storage;
 
         vcgen_contour();
 
-        void line_join(line_join_e lj) { m_line_join = lj; }
-        void inner_line_join(line_join_e lj) { m_inner_line_join = lj; }
-        void width(double w) { m_width = w * 0.5; }
-        void miter_limit(double ml) { m_miter_limit = ml; }
-        void miter_limit_theta(double t);
-        void inner_miter_limit(double ml) { m_inner_miter_limit = ml; }
-        void approximation_scale(double as) { m_approx_scale = as; }
-        void auto_detect_orientation(bool v) { m_auto_detect = v; }
+        void line_cap(line_cap_e lc)     { m_stroker.line_cap(lc); }
+        void line_join(line_join_e lj)   { m_stroker.line_join(lj); }
+        void inner_join(inner_join_e ij) { m_stroker.inner_join(ij); }
+
+        line_cap_e   line_cap()   const { return m_stroker.line_cap(); }
+        line_join_e  line_join()  const { return m_stroker.line_join(); }
+        inner_join_e inner_join() const { return m_stroker.inner_join(); }
+
+        void width(double w) { m_stroker.width(m_width = w); }
+        void miter_limit(double ml) { m_stroker.miter_limit(ml); }
+        void miter_limit_theta(double t) { m_stroker.miter_limit_theta(t); }
+        void inner_miter_limit(double ml) { m_stroker.inner_miter_limit(ml); }
+        void approximation_scale(double as) { m_stroker.approximation_scale(as); }
+
+        double width() const { return m_width; }
+        double miter_limit() const { return m_stroker.miter_limit(); }
+        double inner_miter_limit() const { return m_stroker.inner_miter_limit(); }
+        double approximation_scale() const { return m_stroker.approximation_scale(); }
 
-        line_join_e line_join() const { return m_line_join; }
-        line_join_e inner_line_join() const { return m_inner_line_join; }
-        double width() const { return m_width * 2.0; }
-        double miter_limit() const { return m_miter_limit; }
-        double inner_miter_limit() const { return m_inner_miter_limit; }
-        double approximation_scale() const { return m_approx_scale; }
-        bool   auto_detect_orientation() const { return m_auto_detect; }
+        void auto_detect_orientation(bool v) { m_auto_detect = v; }
+        bool auto_detect_orientation() const { return m_auto_detect; }
 
         // Generator interface
         void remove_all();
         void add_vertex(double x, double y, unsigned cmd);
 
         // Vertex Source Interface
-        void     rewind(unsigned id);
+        void     rewind(unsigned path_id);
         unsigned vertex(double* x, double* y);
 
     private:
         vcgen_contour(const vcgen_contour&);
         const vcgen_contour& operator = (const vcgen_contour&);
 
-        vertex_storage m_src_vertices;
-        coord_storage  m_out_vertices;
-        double         m_width;
-        line_join_e    m_line_join;
-        line_join_e    m_inner_line_join;
-        double         m_approx_scale;
-        double         m_abs_width;
-        double         m_signed_width;
-        double         m_miter_limit;
-        double         m_inner_miter_limit;
-        status_e       m_status;
-        unsigned       m_src_vertex;
-        unsigned       m_out_vertex;
-        unsigned       m_closed;
-        unsigned       m_orientation;
-        bool           m_auto_detect;
+        math_stroke<coord_storage> m_stroker;
+        double                     m_width;
+        vertex_storage             m_src_vertices;
+        coord_storage              m_out_vertices;
+        status_e                   m_status;
+        unsigned                   m_src_vertex;
+        unsigned                   m_out_vertex;
+        unsigned                   m_closed;
+        unsigned                   m_orientation;
+        bool                       m_auto_detect;
     };
 
 }

Modified: incubator/ooo/trunk/main/agg/inc/agg_vcgen_dash.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vcgen_dash.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vcgen_dash.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vcgen_dash.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -21,7 +21,6 @@
 
 #include "agg_basics.h"
 #include "agg_vertex_sequence.h"
-#include "agg_vertex_iterator.h"
 
 namespace agg
 {
@@ -32,7 +31,7 @@ namespace agg
     //
     class vcgen_dash
     {
-        enum
+        enum max_dashes_e
         {
             max_dashes = 32
         };
@@ -62,14 +61,9 @@ namespace agg
         void add_vertex(double x, double y, unsigned cmd);
 
         // Vertex Source Interface
-        void     rewind(unsigned id);
+        void     rewind(unsigned path_id);
         unsigned vertex(double* x, double* y);
 
-        typedef vcgen_dash source_type;
-        typedef vertex_iterator<source_type> iterator;
-        iterator begin(unsigned id) { return iterator(*this, id); }
-        iterator end() { return iterator(path_cmd_stop); }
-
     private:
         vcgen_dash(const vcgen_dash&);
         const vcgen_dash& operator = (const vcgen_dash&);

Modified: incubator/ooo/trunk/main/agg/inc/agg_vcgen_markers_term.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vcgen_markers_term.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vcgen_markers_term.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vcgen_markers_term.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -18,7 +18,6 @@
 
 #include "agg_basics.h"
 #include "agg_vertex_sequence.h"
-#include "agg_vertex_iterator.h"
 
 namespace agg
 {
@@ -39,14 +38,9 @@ namespace agg
         void add_vertex(double x, double y, unsigned cmd);
 
         // Vertex Source Interface
-        void rewind(unsigned id);
+        void rewind(unsigned path_id);
         unsigned vertex(double* x, double* y);
 
-        typedef vcgen_markers_term source_type;
-        typedef vertex_iterator<source_type> iterator;
-        iterator begin(unsigned id) { return iterator(*this, id); }
-        iterator end() { return iterator(path_cmd_stop); }
-
     private:
         vcgen_markers_term(const vcgen_markers_term&);
         const vcgen_markers_term& operator = (const vcgen_markers_term&);
@@ -59,7 +53,7 @@ namespace agg
             coord_type(double x_, double y_) : x(x_), y(y_) {}
         };
 
-        typedef pod_deque<coord_type, 6> coord_storage;
+        typedef pod_bvector<coord_type, 6> coord_storage; 
 
         coord_storage m_markers;
         unsigned      m_curr_id;

Modified: incubator/ooo/trunk/main/agg/inc/agg_vcgen_smooth_poly1.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vcgen_smooth_poly1.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vcgen_smooth_poly1.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vcgen_smooth_poly1.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -57,7 +57,7 @@ namespace agg
         void add_vertex(double x, double y, unsigned cmd);
 
         // Vertex Source Interface
-        void     rewind(unsigned id);
+        void     rewind(unsigned path_id);
         unsigned vertex(double* x, double* y);
 
     private:

Modified: incubator/ooo/trunk/main/agg/inc/agg_vcgen_stroke.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vcgen_stroke.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vcgen_stroke.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vcgen_stroke.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -17,7 +17,6 @@
 #define AGG_VCGEN_STROKE_INCLUDED
 
 #include "agg_math_stroke.h"
-#include "agg_vertex_iterator.h"
 
 
 namespace agg
@@ -48,28 +47,28 @@ namespace agg
 
     public:
         typedef vertex_sequence<vertex_dist, 6> vertex_storage;
-        typedef pod_deque<point_type, 6>        coord_storage;
+        typedef pod_bvector<point_d, 6>         coord_storage;
 
         vcgen_stroke();
 
-        void line_cap(line_cap_e lc) { m_line_cap = lc; }
-        void line_join(line_join_e lj) { m_line_join = lj; }
-        void inner_line_join(line_join_e lj) { m_inner_line_join = lj; }
-
-        line_cap_e line_cap() const { return m_line_cap; }
-        line_join_e line_join() const { return m_line_join; }
-        line_join_e inner_line_join() const { return m_inner_line_join; }
-
-        void width(double w) { m_width = w * 0.5; }
-        void miter_limit(double ml) { m_miter_limit = ml; }
-        void miter_limit_theta(double t);
-        void inner_miter_limit(double ml) { m_inner_miter_limit = ml; }
-        void approximation_scale(double as) { m_approx_scale = as; }
-
-        double width() const { return m_width * 2.0; }
-        double miter_limit() const { return m_miter_limit; }
-        double inner_miter_limit() const { return m_inner_miter_limit; }
-        double approximation_scale() const { return m_approx_scale; }
+        void line_cap(line_cap_e lc)     { m_stroker.line_cap(lc); }
+        void line_join(line_join_e lj)   { m_stroker.line_join(lj); }
+        void inner_join(inner_join_e ij) { m_stroker.inner_join(ij); }
+
+        line_cap_e   line_cap()   const { return m_stroker.line_cap(); }
+        line_join_e  line_join()  const { return m_stroker.line_join(); }
+        inner_join_e inner_join() const { return m_stroker.inner_join(); }
+
+        void width(double w) { m_stroker.width(w); }
+        void miter_limit(double ml) { m_stroker.miter_limit(ml); }
+        void miter_limit_theta(double t) { m_stroker.miter_limit_theta(t); }
+        void inner_miter_limit(double ml) { m_stroker.inner_miter_limit(ml); }
+        void approximation_scale(double as) { m_stroker.approximation_scale(as); }
+
+        double width() const { return m_stroker.width(); }
+        double miter_limit() const { return m_stroker.miter_limit(); }
+        double inner_miter_limit() const { return m_stroker.inner_miter_limit(); }
+        double approximation_scale() const { return m_stroker.approximation_scale(); }
 
         void shorten(double s) { m_shorten = s; }
         double shorten() const { return m_shorten; }
@@ -79,33 +78,22 @@ namespace agg
         void add_vertex(double x, double y, unsigned cmd);
 
         // Vertex Source Interface
-        void     rewind(unsigned id);
+        void     rewind(unsigned path_id);
         unsigned vertex(double* x, double* y);
 
-        typedef vcgen_stroke source_type;
-        typedef vertex_iterator<source_type> iterator;
-        iterator begin(unsigned id) { return iterator(*this, id); }
-        iterator end() { return iterator(path_cmd_stop); }
-
     private:
         vcgen_stroke(const vcgen_stroke&);
         const vcgen_stroke& operator = (const vcgen_stroke&);
 
-        vertex_storage m_src_vertices;
-        coord_storage  m_out_vertices;
-        double         m_width;
-        double         m_miter_limit;
-        double         m_inner_miter_limit;
-        double         m_approx_scale;
-        double         m_shorten;
-        line_cap_e     m_line_cap;
-        line_join_e    m_line_join;
-        line_join_e    m_inner_line_join;
-        unsigned       m_closed;
-        status_e       m_status;
-        status_e       m_prev_status;
-        unsigned       m_src_vertex;
-        unsigned       m_out_vertex;
+        math_stroke<coord_storage> m_stroker;
+        vertex_storage             m_src_vertices;
+        coord_storage              m_out_vertices;
+        double                     m_shorten;
+        unsigned                   m_closed;
+        status_e                   m_status;
+        status_e                   m_prev_status;
+        unsigned                   m_src_vertex;
+        unsigned                   m_out_vertex;
     };
 
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_vcgen_vertex_sequence.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vcgen_vertex_sequence.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vcgen_vertex_sequence.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vcgen_vertex_sequence.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -43,7 +43,7 @@ namespace agg
         void add_vertex(double x, double y, unsigned cmd);
 
         // Vertex Source Interface
-        void     rewind(unsigned id);
+        void     rewind(unsigned path_id);
         unsigned vertex(double* x, double* y);
 
         void shorten(double s) { m_shorten = s; }

Modified: incubator/ooo/trunk/main/agg/inc/agg_vertex_sequence.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vertex_sequence.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vertex_sequence.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vertex_sequence.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -27,10 +27,10 @@ namespace agg
 {
 
     //----------------------------------------------------------vertex_sequence
-    // Modified agg::pod_deque. The data is interpreted as a sequence of vertices.
-    // It means that the type T must expose:
+    // Modified agg::pod_bvector. The data is interpreted as a sequence 
+    // of vertices. It means that the type T must expose:
     //
-    // bool operator() (const T& val)
+    // bool T::operator() (const T& val)
     // 
     // that is called every time new vertex is being added. The main purpose
     // of this operator is the possibility to calculate some values during 
@@ -64,10 +64,10 @@ namespace agg
     // necessary.
     //------------------------------------------------------------------------
     template<class T, unsigned S=6> 
-    class vertex_sequence : public pod_deque<T, S>
+    class vertex_sequence : public pod_bvector<T, S>
     {
     public:
-        typedef pod_deque<T, S> base_type;
+        typedef pod_bvector<T, S> base_type;
 
         void add(const T& val);
         void modify_last(const T& val);
@@ -124,10 +124,6 @@ namespace agg
     }
 
 
-
-    // Coinciding points maximal distance (Epsilon)
-    const double vertex_dist_epsilon = 1e-14;
-
     //-------------------------------------------------------------vertex_dist
     // Vertex (x, y) with the distance to the next one. The last vertex has 
     // distance between the last and the first points if the polygon is closed

Modified: incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polygon.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polygon.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polygon.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polygon.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -39,12 +39,12 @@ namespace agg
         {
         }
 
-        void clip_box(double _x1, double _y1, double _x2, double _y2)
+        void clip_box(double x1, double y1, double x2, double y2)
         {
-            m_clip_box.x1 = _x1;
-            m_clip_box.y1 = _y1;
-            m_clip_box.x2 = _x2;
-            m_clip_box.y2 = _y2;
+            m_clip_box.x1 = x1;
+            m_clip_box.y1 = y1;
+            m_clip_box.x2 = x2;
+            m_clip_box.y2 = y2;
             m_clip_box.normalize();
         }
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polyline.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polyline.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polyline.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polyline.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -32,25 +32,21 @@ namespace agg
             m_clip_box(0, 0, 1, 1),
             m_x1(0),
             m_y1(0),
-            m_f1(0),
-            m_x2(0),
-            m_y2(0),
-            m_f2(0),
             m_num_vertices(0),
-            m_vertex(0)
+            m_vertex(0),
+            m_move_to(false)
         {
         }
 
-        void clip_box(double _x1, double _y1, double _x2, double _y2)
+        void clip_box(double x1, double y1, double x2, double y2)
         {
-            m_clip_box.x1 = _x1;
-            m_clip_box.y1 = _y1;
-            m_clip_box.x2 = _x2;
-            m_clip_box.y2 = _y2;
+            m_clip_box.x1 = x1;
+            m_clip_box.y1 = y1;
+            m_clip_box.x2 = x2;
+            m_clip_box.y2 = y2;
             m_clip_box.normalize();
         }
 
-
         double x1() const { return m_clip_box.x1; }
         double y1() const { return m_clip_box.y1; }
         double x2() const { return m_clip_box.x2; }
@@ -65,54 +61,15 @@ namespace agg
         unsigned vertex(double* x, double* y);
 
     private:
-        enum clipping_flags_def
-        {
-            clip_x1 = 1,
-            clip_x2 = 2,
-            clip_y1 = 4,
-            clip_y2 = 8
-        };
-
-        // Determine the clipping code of the vertex according to the 
-        // Cyrus-Beck line clipping algorithm
-        //--------------------------------------------------------------------
-        unsigned clipping_flags_x(double x)
-        {
-            unsigned f = 0;
-            if(x < m_clip_box.x1) f |= clip_x1;
-            if(x > m_clip_box.x2) f |= clip_x2;
-            return f;
-        }
-
-        unsigned clipping_flags_y(double y)
-        {
-            unsigned f = 0;
-            if(y < m_clip_box.y1) f |= clip_y1;
-            if(y > m_clip_box.y2) f |= clip_y2;
-            return f;
-        }
-
-        unsigned clipping_flags(double x, double y)
-        {
-            return clipping_flags_x(x) | clipping_flags_y(y);
-        }
-
-        bool move_point(double& x, double& y, unsigned& flags);
-        void clip_line_segment();
-
-    private:
         rect_d        m_clip_box;
         double        m_x1;
         double        m_y1;
-        unsigned      m_f1;
-        double        m_x2;
-        double        m_y2;
-        unsigned      m_f2;
         double        m_x[2];
         double        m_y[2];
         unsigned      m_cmd[2];
         unsigned      m_num_vertices;
         unsigned      m_vertex;
+        bool          m_move_to;
     };
 
 }

Modified: incubator/ooo/trunk/main/agg/inc/agg_vpgen_segmentator.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_vpgen_segmentator.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_vpgen_segmentator.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_vpgen_segmentator.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 



Mime
View raw message