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 [12/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_scanline_p.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_scanline_p.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_scanline_p.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_scanline_p.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 
@@ -16,180 +16,312 @@
 // Class scanline_p - a general purpose scanline container with packed spans.
 //
 //----------------------------------------------------------------------------
+//
+// Adaptation for 32-bit screen coordinates (scanline32_p) has been sponsored by 
+// Liberty Technology Systems, Inc., visit http://lib-sys.com
+//
+// Liberty Technology Systems, Inc. is the provider of
+// PostScript and PDF technology for software developers.
+// 
+//----------------------------------------------------------------------------
 #ifndef AGG_SCANLINE_P_INCLUDED
 #define AGG_SCANLINE_P_INCLUDED
 
-#include "agg_basics.h"
+#include "agg_array.h"
 
 namespace agg
 {
 
-    //==============================================================scanline_p
+    //=============================================================scanline_p8
     // 
     // This is a general purpose scaline container which supports the interface 
-    // used in the rasterizer::render(). See description of agg_scanline_u
+    // used in the rasterizer::render(). See description of scanline_u8
     // for details.
     // 
     //------------------------------------------------------------------------
-    template<class T> class scanline_p
+    class scanline_p8
     {
     public:
-        typedef T cover_type;
+        typedef scanline_p8 self_type;
+        typedef int8u       cover_type;
+        typedef int16       coord_type;
 
+        //--------------------------------------------------------------------
         struct span
         {
-            int16    x;
-            int16    len; // If negative, it's a solid span, covers is valid
-            const T* covers;
+            coord_type        x;
+            coord_type        len; // If negative, it's a solid span, covers is valid
+            const cover_type* covers;
         };
 
         typedef span* iterator;
         typedef const span* const_iterator;
 
-        ~scanline_p()
-        {
-            delete [] m_spans;
-            delete [] m_covers;
-        }
-
-        scanline_p() :
-            m_max_len(0),
+        scanline_p8() :
             m_last_x(0x7FFFFFF0),
-            m_covers(0),
+            m_covers(),
             m_cover_ptr(0),
-            m_spans(0),
+            m_spans(),
             m_cur_span(0)
         {
         }
 
-        void reset(int min_x, int max_x);
-        void add_cell(int x, unsigned cover);
-        void add_cells(int x, unsigned len, const T* covers);
-        void add_span(int x, unsigned len, unsigned cover);
-        void finalize(int y_) { m_y = y_; }
-        void reset_spans();
+        //--------------------------------------------------------------------
+        void reset(int min_x, int max_x)
+        {
+            unsigned max_len = max_x - min_x + 3;
+            if(max_len > m_spans.size())
+            {
+                m_spans.resize(max_len);
+                m_covers.resize(max_len);
+            }
+            m_last_x    = 0x7FFFFFF0;
+            m_cover_ptr = &m_covers[0];
+            m_cur_span  = &m_spans[0];
+            m_cur_span->len = 0;
+        }
+
+        //--------------------------------------------------------------------
+        void add_cell(int x, unsigned cover)
+        {
+            *m_cover_ptr = (cover_type)cover;
+            if(x == m_last_x+1 && m_cur_span->len > 0)
+            {
+                m_cur_span->len++;
+            }
+            else
+            {
+                m_cur_span++;
+                m_cur_span->covers = m_cover_ptr;
+                m_cur_span->x = (int16)x;
+                m_cur_span->len = 1;
+            }
+            m_last_x = x;
+            m_cover_ptr++;
+        }
+
+        //--------------------------------------------------------------------
+        void add_cells(int x, unsigned len, const cover_type* covers)
+        {
+            memcpy(m_cover_ptr, covers, len * sizeof(cover_type));
+            if(x == m_last_x+1 && m_cur_span->len > 0)
+            {
+                m_cur_span->len += (int16)len;
+            }
+            else
+            {
+                m_cur_span++;
+                m_cur_span->covers = m_cover_ptr;
+                m_cur_span->x = (int16)x;
+                m_cur_span->len = (int16)len;
+            }
+            m_cover_ptr += len;
+            m_last_x = x + len - 1;
+        }
+
+        //--------------------------------------------------------------------
+        void add_span(int x, unsigned len, unsigned cover)
+        {
+            if(x == m_last_x+1 && 
+               m_cur_span->len < 0 && 
+               cover == *m_cur_span->covers)
+            {
+                m_cur_span->len -= (int16)len;
+            }
+            else
+            {
+                *m_cover_ptr = (cover_type)cover;
+                m_cur_span++;
+                m_cur_span->covers = m_cover_ptr++;
+                m_cur_span->x      = (int16)x;
+                m_cur_span->len    = (int16)(-int(len));
+            }
+            m_last_x = x + len - 1;
+        }
+
+        //--------------------------------------------------------------------
+        void finalize(int y) 
+        { 
+            m_y = y; 
+        }
 
+        //--------------------------------------------------------------------
+        void reset_spans()
+        {
+            m_last_x    = 0x7FFFFFF0;
+            m_cover_ptr = &m_covers[0];
+            m_cur_span  = &m_spans[0];
+            m_cur_span->len = 0;
+        }
+
+        //--------------------------------------------------------------------
         int            y()         const { return m_y; }
-        unsigned       num_spans() const { return unsigned(m_cur_span - m_spans); }
-        const_iterator begin()     const { return m_spans + 1; }
+        unsigned       num_spans() const { return unsigned(m_cur_span - &m_spans[0]); }
+        const_iterator begin()     const { return &m_spans[1]; }
 
     private:
-        scanline_p(const scanline_p<T>&);
-        const scanline_p<T>& operator = (const scanline_p<T>&);
+        scanline_p8(const self_type&);
+        const self_type& operator = (const self_type&);
 
-        unsigned m_max_len;
-        int      m_last_x;
-        int      m_y;
-        T*       m_covers;
-        T*       m_cover_ptr;
-        span*    m_spans;
-        span*    m_cur_span;
+        int                   m_last_x;
+        int                   m_y;
+        pod_array<cover_type> m_covers;
+        cover_type*           m_cover_ptr;
+        pod_array<span>       m_spans;
+        span*                 m_cur_span;
     };
 
 
-    //------------------------------------------------------------------------
-    template<class T> 
-    void scanline_p<T>::reset(int min_x, int max_x)
-    {
-        unsigned max_len = max_x - min_x + 3;
-        if(max_len > m_max_len)
-        {
-            delete [] m_spans;
-            delete [] m_covers;
-            m_covers  = new T [max_len];
-            m_spans   = new span [max_len];
-            m_max_len = max_len;
-        }
-        m_last_x    = 0x7FFFFFF0;
-        m_cover_ptr = m_covers;
-        m_cur_span  = m_spans;
-        m_cur_span->len = 0;
-    }
 
 
-    //------------------------------------------------------------------------
-    template<class T> 
-    void scanline_p<T>::reset_spans()
-    {
-        m_last_x    = 0x7FFFFFF0;
-        m_cover_ptr = m_covers;
-        m_cur_span  = m_spans;
-        m_cur_span->len = 0;
-    }
 
 
-    //------------------------------------------------------------------------
-    template<class T> 
-    void scanline_p<T>::add_cell(int x, unsigned cover)
+
+
+    //==========================================================scanline32_p8
+    class scanline32_p8
     {
-        *m_cover_ptr = (T)cover;
-        if(x == m_last_x+1 && m_cur_span->len > 0)
+    public:
+        typedef scanline32_p8 self_type;
+        typedef int8u         cover_type;
+        typedef int32         coord_type;
+
+        struct span
+        {
+            span() {}
+            span(coord_type x_, coord_type len_, const cover_type* covers_) :
+                x(x_), len(len_), covers(covers_) {}
+
+            coord_type x;
+            coord_type len; // If negative, it's a solid span, covers is valid
+            const cover_type* covers;
+        };
+        typedef pod_bvector<span, 4> span_array_type;
+
+
+        //--------------------------------------------------------------------
+        class const_iterator
+        {
+        public:
+            const_iterator(const span_array_type& spans) :
+                m_spans(spans),
+                m_span_idx(0)
+            {}
+
+            const span& operator*()  const { return m_spans[m_span_idx];  }
+            const span* operator->() const { return &m_spans[m_span_idx]; }
+
+            void operator ++ () { ++m_span_idx; }
+
+        private:
+            const span_array_type& m_spans;
+            unsigned               m_span_idx;
+        };
+
+        //--------------------------------------------------------------------
+        scanline32_p8() :
+            m_max_len(0),
+            m_last_x(0x7FFFFFF0),
+            m_covers(),
+            m_cover_ptr(0)
         {
-            m_cur_span->len++;
         }
-        else
+
+        //--------------------------------------------------------------------
+        void reset(int min_x, int max_x)
         {
-            m_cur_span++;
-            m_cur_span->covers = m_cover_ptr;
-            m_cur_span->x = (int16)x;
-            m_cur_span->len = 1;
+            unsigned max_len = max_x - min_x + 3;
+            if(max_len > m_covers.size())
+            {
+                m_covers.resize(max_len);
+            }
+            m_last_x    = 0x7FFFFFF0;
+            m_cover_ptr = &m_covers[0];
+            m_spans.remove_all();
         }
-        m_last_x = x;
-        m_cover_ptr++;
-    }
 
+        //--------------------------------------------------------------------
+        void add_cell(int x, unsigned cover)
+        {
+            *m_cover_ptr = cover_type(cover);
+            if(x == m_last_x+1 && m_spans.size() && m_spans.last().len > 0)
+            {
+                m_spans.last().len++;
+            }
+            else
+            {
+                m_spans.add(span(coord_type(x), 1, m_cover_ptr));
+            }
+            m_last_x = x;
+            m_cover_ptr++;
+        }
 
-    //------------------------------------------------------------------------
-    template<class T> 
-    void scanline_p<T>::add_cells(int x, unsigned len, const T* covers)
-    {
-        memcpy(m_cover_ptr, covers, len * sizeof(T));
-        if(x == m_last_x+1 && m_cur_span->len > 0)
+        //--------------------------------------------------------------------
+        void add_cells(int x, unsigned len, const cover_type* covers)
         {
-            m_cur_span->len += (int16)len;
+            memcpy(m_cover_ptr, covers, len * sizeof(cover_type));
+            if(x == m_last_x+1 && m_spans.size() && m_spans.last().len > 0)
+            {
+                m_spans.last().len += coord_type(len);
+            }
+            else
+            {
+                m_spans.add(span(coord_type(x), coord_type(len), m_cover_ptr));
+            }
+            m_cover_ptr += len;
+            m_last_x = x + len - 1;
         }
-        else
+
+        //--------------------------------------------------------------------
+        void add_span(int x, unsigned len, unsigned cover)
         {
-            m_cur_span++;
-            m_cur_span->covers = m_cover_ptr;
-            m_cur_span->x = (int16)x;
-            m_cur_span->len = (int16)len;
+            if(x == m_last_x+1 && 
+               m_spans.size() &&
+               m_spans.last().len < 0 && 
+               cover == *m_spans.last().covers)
+            {
+                m_spans.last().len -= coord_type(len);
+            }
+            else
+            {
+                *m_cover_ptr = cover_type(cover);
+                m_spans.add(span(coord_type(x), -coord_type(len), m_cover_ptr++));
+            }
+            m_last_x = x + len - 1;
         }
-        m_cover_ptr += len;
-        m_last_x = x + len - 1;
-    }
 
+        //--------------------------------------------------------------------
+        void finalize(int y) 
+        { 
+            m_y = y; 
+        }
 
-    //------------------------------------------------------------------------
-    template<class T> 
-    void scanline_p<T>::add_span(int x, unsigned len, unsigned cover)
-    {
-        if(x == m_last_x+1 && 
-           m_cur_span->len < 0 && 
-           cover == *m_cur_span->covers)
-        {
-            m_cur_span->len -= (int16)len;
-        }
-        else
-        {
-            *m_cover_ptr = (T)cover;
-            m_cur_span++;
-            m_cur_span->covers = m_cover_ptr++;
-            m_cur_span->x      = (int16)x;
-            m_cur_span->len    = -((int16)len);
+        //--------------------------------------------------------------------
+        void reset_spans()
+        {
+            m_last_x    = 0x7FFFFFF0;
+            m_cover_ptr = &m_covers[0];
+            m_spans.remove_all();
         }
-        m_last_x = x + len - 1;
-    }
 
+        //--------------------------------------------------------------------
+        int            y()         const { return m_y; }
+        unsigned       num_spans() const { return m_spans.size(); }
+        const_iterator begin()     const { return const_iterator(m_spans); }
 
-    //=============================================================scanline_p8
-    typedef scanline_p<int8u> scanline_p8;
+    private:
+        scanline32_p8(const self_type&);
+        const self_type& operator = (const self_type&);
+
+        unsigned              m_max_len;
+        int                   m_last_x;
+        int                   m_y;
+        pod_array<cover_type> m_covers;
+        cover_type*           m_cover_ptr;
+        span_array_type       m_spans;
+    };
 
-    //============================================================scanline_p16
-    typedef scanline_p<int16u> scanline_p16;
 
-    //============================================================scanline_p32
-    typedef scanline_p<int32u> scanline_p32;
 }
 
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_aa.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_aa.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_aa.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_aa.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 
@@ -12,6 +12,14 @@
 //          mcseemagg@yahoo.com
 //          http://www.antigrain.com
 //----------------------------------------------------------------------------
+//
+// Adaptation for 32-bit screen coordinates has been sponsored by 
+// Liberty Technology Systems, Inc., visit http://lib-sys.com
+//
+// Liberty Technology Systems, Inc. is the provider of
+// PostScript and PDF technology for software developers.
+// 
+//----------------------------------------------------------------------------
 
 #ifndef AGG_SCANLINE_STORAGE_AA_INCLUDED
 #define AGG_SCANLINE_STORAGE_AA_INCLUDED
@@ -20,7 +28,6 @@
 #include <stdlib.h>
 #include <math.h>
 #include "agg_array.h"
-#include "agg_render_scanlines.h"
 
 
 namespace agg
@@ -76,7 +83,8 @@ namespace agg
             int i;
             for(i = m_extra_storage.size()-1; i >= 0; --i)
             {
-                delete [] m_extra_storage[(unsigned)i].ptr;
+                pod_allocator<T>::deallocate(m_extra_storage[i].ptr,
+                                             m_extra_storage[i].len);
             }
             m_extra_storage.remove_all();
             m_cells.remove_all();
@@ -94,7 +102,7 @@ namespace agg
             }
             extra_span s;
             s.len = num_cells;
-            s.ptr = new T [num_cells];
+            s.ptr = pod_allocator<T>::allocate(num_cells);
             memcpy(s.ptr, cells, sizeof(T) * num_cells);
             m_extra_storage.add(s);
             return -int(m_extra_storage.size());
@@ -135,14 +143,14 @@ namespace agg
                 const extra_span& src = v.m_extra_storage[i];
                 extra_span dst;
                 dst.len = src.len;
-                dst.ptr = new T [dst.len];
+                dst.ptr = pod_allocator<T>::allocate(dst.len);
                 memcpy(dst.ptr, src.ptr, dst.len * sizeof(T));
                 m_extra_storage.add(dst);
             }
         }
 
-        pod_deque<T, 12>         m_cells;
-        pod_deque<extra_span, 6> m_extra_storage;
+        pod_bvector<T, 12>         m_cells;
+        pod_bvector<extra_span, 6> m_extra_storage;
     };
 
 
@@ -159,8 +167,8 @@ namespace agg
         //---------------------------------------------------------------
         struct span_data
         {
-            int16 x;
-            int16 len;       // If negative, it's a solid span, covers is valid
+            int32 x;
+            int32 len;       // If negative, it's a solid span, covers is valid
             int   covers_id; // The index of the cells in the scanline_cell_storage
         };
 
@@ -184,11 +192,12 @@ namespace agg
             public:
                 struct span
                 {
-                    int16    x;
-                    int16    len; // If negative, it's a solid span, covers is valid
+                    int32    x;
+                    int32    len; // If negative, it's a solid span, covers is valid
                     const T* covers;
                 };
 
+                const_iterator() : m_storage(0) {}
                 const_iterator(const embedded_scanline& sl) :
                     m_storage(sl.m_storage),
                     m_span_idx(sl.m_scanline.start_span)
@@ -270,7 +279,7 @@ namespace agg
 
         // Renderer Interface
         //---------------------------------------------------------------
-        void prepare(unsigned)
+        void prepare()
         {
             m_covers.remove_all();
             m_scanlines.remove_all();
@@ -297,7 +306,7 @@ namespace agg
             typename Scanline::const_iterator span_iterator = sl.begin();
 
             unsigned num_spans = sl_this.num_spans;
-            do
+            for(;;)
             {
                 span_data sp;
 
@@ -312,9 +321,9 @@ namespace agg
                 int x2 = sp.x + len - 1;
                 if(x1 < m_min_x) m_min_x = x1;
                 if(x2 > m_max_x) m_max_x = x2;
+                if(--num_spans == 0) break;
                 ++span_iterator;
             }
-            while(--num_spans);
             m_scanlines.add(sl_this);
         }
 
@@ -388,11 +397,11 @@ namespace agg
         unsigned byte_size() const
         {
             unsigned i;
-            unsigned size = sizeof(int16) * 4; // min_x, min_y, max_x, max_y
+            unsigned size = sizeof(int32) * 4; // min_x, min_y, max_x, max_y
 
             for(i = 0; i < m_scanlines.size(); ++i)
             {
-                size += sizeof(int16) * 3; // scanline size in bytes, Y, num_spans
+                size += sizeof(int32) * 3; // scanline size in bytes, Y, num_spans
 
                 const scanline_data& sl_this = m_scanlines[i];
 
@@ -402,7 +411,7 @@ namespace agg
                 {
                     const span_data& sp = m_spans[span_idx++];
 
-                    size += sizeof(int16) * 2;                // X, span_len
+                    size += sizeof(int32) * 2;                // X, span_len
                     if(sp.len < 0)
                     {
                         size += sizeof(T);                    // cover
@@ -419,10 +428,12 @@ namespace agg
 
 
         //---------------------------------------------------------------
-        static void write_int16(int8u* dst, int16 val)
+        static void write_int32(int8u* dst, int32 val)
         {
             dst[0] = ((const int8u*)&val)[0];
             dst[1] = ((const int8u*)&val)[1];
+            dst[2] = ((const int8u*)&val)[2];
+            dst[3] = ((const int8u*)&val)[3];
         }
 
 
@@ -431,27 +442,27 @@ namespace agg
         {
             unsigned i;
 
-            write_int16(data, int16u(min_x())); // min_x
-            data += sizeof(int16u);
-            write_int16(data, int16u(min_y())); // min_y
-            data += sizeof(int16u);
-            write_int16(data, int16u(max_x())); // max_x
-            data += sizeof(int16u);
-            write_int16(data, int16u(max_y())); // max_y
-            data += sizeof(int16u);
+            write_int32(data, min_x()); // min_x
+            data += sizeof(int32);
+            write_int32(data, min_y()); // min_y
+            data += sizeof(int32);
+            write_int32(data, max_x()); // max_x
+            data += sizeof(int32);
+            write_int32(data, max_y()); // max_y
+            data += sizeof(int32);
 
             for(i = 0; i < m_scanlines.size(); ++i)
             {
                 const scanline_data& sl_this = m_scanlines[i];
                 
                 int8u* size_ptr = data;
-                data += sizeof(int16);  // Reserve space for scanline size in bytes
+                data += sizeof(int32);  // Reserve space for scanline size in bytes
 
-                write_int16(data, int16(sl_this.y));            // Y
-                data += sizeof(int16);
+                write_int32(data, sl_this.y);            // Y
+                data += sizeof(int32);
 
-                write_int16(data, int16(sl_this.num_spans));    // num_spans
-                data += sizeof(int16);
+                write_int32(data, sl_this.num_spans);    // num_spans
+                data += sizeof(int32);
 
                 unsigned num_spans = sl_this.num_spans;
                 unsigned span_idx  = sl_this.start_span;
@@ -460,11 +471,11 @@ namespace agg
                     const span_data& sp = m_spans[span_idx++];
                     const T* covers = covers_by_index(sp.covers_id);
 
-                    write_int16(data, int16(sp.x));            // X
-                    data += sizeof(int16);
+                    write_int32(data, sp.x);            // X
+                    data += sizeof(int32);
 
-                    write_int16(data, int16(sp.len));          // span_len
-                    data += sizeof(int16);
+                    write_int32(data, sp.len);          // span_len
+                    data += sizeof(int32);
 
                     if(sp.len < 0)
                     {
@@ -478,7 +489,7 @@ namespace agg
                     }
                 }
                 while(--num_spans);
-                write_int16(size_ptr, int16(unsigned(data - size_ptr)));
+                write_int32(size_ptr, int32(unsigned(data - size_ptr)));
             }
         }
 
@@ -502,9 +513,9 @@ namespace agg
         }
 
     private:
-        scanline_cell_storage<T>    m_covers;
-        pod_deque<span_data, 10>    m_spans;
-        pod_deque<scanline_data, 8> m_scanlines;
+        scanline_cell_storage<T>      m_covers;
+        pod_bvector<span_data, 10>    m_spans;
+        pod_bvector<scanline_data, 8> m_scanlines;
         span_data     m_fake_span;
         scanline_data m_fake_scanline;
         int           m_min_x;
@@ -540,11 +551,12 @@ namespace agg
             public:
                 struct span
                 {
-                    int16    x;
-                    int16    len; // If negative, it's a solid span, "covers" is valid
+                    int32    x;
+                    int32    len; // If negative, it's a solid span, "covers" is valid
                     const T* covers; 
                 };
 
+                const_iterator() : m_ptr(0) {}
                 const_iterator(const embedded_scanline& sl) :
                     m_ptr(sl.m_ptr),
                     m_dx(sl.m_dx)
@@ -569,18 +581,20 @@ namespace agg
                 }
 
             private:
-                int read_int16()
+                int read_int32()
                 {
-                    int16 val;
+                    int32 val;
                     ((int8u*)&val)[0] = *m_ptr++;
                     ((int8u*)&val)[1] = *m_ptr++;
+                    ((int8u*)&val)[2] = *m_ptr++;
+                    ((int8u*)&val)[3] = *m_ptr++;
                     return val;
                 }
 
                 void init_span()
                 {
-                    m_span.x      = read_int16() + m_dx;
-                    m_span.len    = read_int16();
+                    m_span.x      = read_int32() + m_dx;
+                    m_span.len    = read_int32();
                     m_span.covers = m_ptr;
                 }
 
@@ -604,11 +618,13 @@ namespace agg
 
         private:
             //-----------------------------------------------------------------
-            int read_int16()
+            int read_int32()
             {
-                int16 val;
+                int32 val;
                 ((int8u*)&val)[0] = *m_ptr++;
                 ((int8u*)&val)[1] = *m_ptr++;
+                ((int8u*)&val)[2] = *m_ptr++;
+                ((int8u*)&val)[3] = *m_ptr++;
                 return val;
             }
 
@@ -617,8 +633,8 @@ namespace agg
             void init(const int8u* ptr, int dx, int dy)
             {
                 m_ptr       = ptr;
-                m_y         = read_int16() + dy;
-                m_num_spans = unsigned(read_int16());
+                m_y         = read_int32() + dy;
+                m_num_spans = unsigned(read_int32());
                 m_dx        = dx;
             }
 
@@ -651,8 +667,8 @@ namespace agg
             m_data(data),
             m_end(data + size),
             m_ptr(data),
-            m_dx(int(floor(dx + 0.5))),
-            m_dy(int(floor(dy + 0.5))),
+            m_dx(iround(dx)),
+            m_dy(iround(dy)),
             m_min_x(0x7FFFFFFF),
             m_min_y(0x7FFFFFFF),
             m_max_x(-0x7FFFFFFF),
@@ -665,8 +681,8 @@ namespace agg
             m_data  = data;
             m_end   = data + size;
             m_ptr   = data;
-            m_dx    = int(floor(dx + 0.5));
-            m_dy    = int(floor(dy + 0.5));
+            m_dx    = iround(dx);
+            m_dy    = iround(dy);
             m_min_x = 0x7FFFFFFF;
             m_min_y = 0x7FFFFFFF;
             m_max_x = -0x7FFFFFFF;
@@ -675,20 +691,24 @@ namespace agg
 
     private:
         //--------------------------------------------------------------------
-        int read_int16()
+        int read_int32()
         {
-            int16 val;
+            int32 val;
             ((int8u*)&val)[0] = *m_ptr++;
             ((int8u*)&val)[1] = *m_ptr++;
+            ((int8u*)&val)[2] = *m_ptr++;
+            ((int8u*)&val)[3] = *m_ptr++;
             return val;
         }
 
         //--------------------------------------------------------------------
-        unsigned read_int16u()
+        unsigned read_int32u()
         {
-            int16u val;
+            int32u val;
             ((int8u*)&val)[0] = *m_ptr++;
             ((int8u*)&val)[1] = *m_ptr++;
+            ((int8u*)&val)[2] = *m_ptr++;
+            ((int8u*)&val)[3] = *m_ptr++;
             return val;
         }
         
@@ -700,13 +720,12 @@ namespace agg
             m_ptr = m_data;
             if(m_ptr < m_end)
             {
-                m_min_x = read_int16() + m_dx; 
-                m_min_y = read_int16() + m_dy;
-                m_max_x = read_int16() + m_dx;
-                m_max_y = read_int16() + m_dy;
-                return true;
+                m_min_x = read_int32() + m_dx; 
+                m_min_y = read_int32() + m_dy;
+                m_max_x = read_int32() + m_dx;
+                m_max_y = read_int32() + m_dy;
             }
-            return false;
+            return m_ptr < m_end;
         }
 
         //--------------------------------------------------------------------
@@ -723,14 +742,14 @@ namespace agg
             {
                 if(m_ptr >= m_end) return false;
 
-                read_int16();      // Skip scanline size in bytes
-                int y = read_int16() + m_dy;
-                unsigned num_spans = read_int16();
+                read_int32();      // Skip scanline size in bytes
+                int y = read_int32() + m_dy;
+                unsigned num_spans = read_int32();
 
                 do
                 {
-                    int x = read_int16() + m_dx;
-                    int len = read_int16();
+                    int x = read_int32() + m_dx;
+                    int len = read_int32();
 
                     if(len < 0)
                     {
@@ -763,9 +782,9 @@ namespace agg
             {
                 if(m_ptr >= m_end) return false;
 
-                unsigned byte_size = read_int16u();
+                unsigned byte_size = read_int32u();
                 sl.init(m_ptr, m_dx, m_dy);
-                m_ptr += byte_size - sizeof(int16);
+                m_ptr += byte_size - sizeof(int32);
             }
             while(sl.num_spans() == 0);
             return true;

Modified: incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_bin.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_bin.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_bin.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_bin.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 
@@ -12,6 +12,15 @@
 //          mcseemagg@yahoo.com
 //          http://www.antigrain.com
 //----------------------------------------------------------------------------
+//
+// Adaptation for 32-bit screen coordinates has been sponsored by 
+// Liberty Technology Systems, Inc., visit http://lib-sys.com
+//
+// Liberty Technology Systems, Inc. is the provider of
+// PostScript and PDF technology for software developers.
+// 
+//----------------------------------------------------------------------------
+
 
 #ifndef AGG_SCANLINE_STORAGE_BIN_INCLUDED
 #define AGG_SCANLINE_STORAGE_BIN_INCLUDED
@@ -20,7 +29,6 @@
 #include <stdlib.h>
 #include <math.h>
 #include "agg_array.h"
-#include "agg_render_scanlines.h"
 
 
 namespace agg
@@ -33,8 +41,8 @@ namespace agg
         //---------------------------------------------------------------
         struct span_data
         {
-            int16 x;
-            int16 len;
+            int32 x;
+            int32 len;
         };
 
         //---------------------------------------------------------------
@@ -55,6 +63,7 @@ namespace agg
             class const_iterator
             {
             public:
+                const_iterator() : m_storage(0) {}
                 const_iterator(const embedded_scanline& sl) :
                     m_storage(sl.m_storage),
                     m_span_idx(sl.m_scanline.start_span)
@@ -126,7 +135,7 @@ namespace agg
 
         // Renderer Interface
         //---------------------------------------------------------------
-        void prepare(unsigned)
+        void prepare()
         {
             m_scanlines.remove_all();
             m_spans.remove_all();
@@ -152,19 +161,19 @@ namespace agg
             typename Scanline::const_iterator span_iterator = sl.begin();
 
             unsigned num_spans = sl_this.num_spans;
-            do
+            for(;;)
             {
                 span_data sp;
                 sp.x   = span_iterator->x;
-                sp.len = (int16)abs((int)(span_iterator->len));
+                sp.len = (int32)abs((int)(span_iterator->len));
                 m_spans.add(sp);
                 int x1 = sp.x;
                 int x2 = sp.x + sp.len - 1;
                 if(x1 < m_min_x) m_min_x = x1;
                 if(x2 > m_max_x) m_max_x = x2;
+                if(--num_spans == 0) break;
                 ++span_iterator;
             }
-            while(--num_spans);
             m_scanlines.add(sl_this);
         }
 
@@ -232,22 +241,24 @@ namespace agg
         unsigned byte_size() const
         {
             unsigned i;
-            unsigned size = sizeof(int16) * 4; // min_x, min_y, max_x, max_y
+            unsigned size = sizeof(int32) * 4; // min_x, min_y, max_x, max_y
 
             for(i = 0; i < m_scanlines.size(); ++i)
             {
-                size += sizeof(int16) * 2 + // Y, num_spans
-                        unsigned(m_scanlines[i].num_spans) * sizeof(int16) * 2; // X, span_len
+                size += sizeof(int32) * 2 + // Y, num_spans
+                        unsigned(m_scanlines[i].num_spans) * sizeof(int32) * 2; // X, span_len
             }
             return size;
         }
 
 
         //---------------------------------------------------------------
-        static void write_int16(int8u* dst, int16 val)
+        static void write_int32(int8u* dst, int32 val)
         {
             dst[0] = ((const int8u*)&val)[0];
             dst[1] = ((const int8u*)&val)[1];
+            dst[2] = ((const int8u*)&val)[2];
+            dst[3] = ((const int8u*)&val)[3];
         }
 
 
@@ -256,24 +267,24 @@ namespace agg
         {
             unsigned i;
 
-            write_int16(data, int16u(min_x())); // min_x
-            data += sizeof(int16u);
-            write_int16(data, int16u(min_y())); // min_y
-            data += sizeof(int16u);
-            write_int16(data, int16u(max_x())); // max_x
-            data += sizeof(int16u);
-            write_int16(data, int16u(max_y())); // max_y
-            data += sizeof(int16u);
+            write_int32(data, min_x()); // min_x
+            data += sizeof(int32);
+            write_int32(data, min_y()); // min_y
+            data += sizeof(int32);
+            write_int32(data, max_x()); // max_x
+            data += sizeof(int32);
+            write_int32(data, max_y()); // max_y
+            data += sizeof(int32);
 
             for(i = 0; i < m_scanlines.size(); ++i)
             {
                 const scanline_data& sl_this = m_scanlines[i];
 
-                write_int16(data, int16(sl_this.y));            // Y
-                data += sizeof(int16);
+                write_int32(data, sl_this.y);            // Y
+                data += sizeof(int32);
 
-                write_int16(data, int16(sl_this.num_spans));    // num_spans
-                data += sizeof(int16);
+                write_int32(data, sl_this.num_spans);    // num_spans
+                data += sizeof(int32);
 
                 unsigned num_spans = sl_this.num_spans;
                 unsigned span_idx  = sl_this.start_span;
@@ -281,11 +292,11 @@ namespace agg
                 {
                     const span_data& sp = m_spans[span_idx++];
 
-                    write_int16(data, int16(sp.x));             // X
-                    data += sizeof(int16);
+                    write_int32(data, sp.x);             // X
+                    data += sizeof(int32);
 
-                    write_int16(data, int16(sp.len));           // len
-                    data += sizeof(int16);
+                    write_int32(data, sp.len);           // len
+                    data += sizeof(int32);
                 }
                 while(--num_spans);
             }
@@ -306,8 +317,8 @@ namespace agg
 
 
     private:
-        pod_deque<span_data, 10>    m_spans;
-        pod_deque<scanline_data, 8> m_scanlines;
+        pod_bvector<span_data, 10>    m_spans;
+        pod_bvector<scanline_data, 8> m_scanlines;
         span_data     m_fake_span;
         scanline_data m_fake_scanline;
         int           m_min_x;
@@ -346,16 +357,17 @@ namespace agg
             public:
                 struct span
                 {
-                    int16 x;
-                    int16 len;
+                    int32 x;
+                    int32 len;
                 };
 
+                const_iterator() : m_ptr(0) {}
                 const_iterator(const embedded_scanline& sl) :
                     m_ptr(sl.m_ptr),
                     m_dx(sl.m_dx)
                 {
-                    m_span.x   = read_int16() + m_dx;
-                    m_span.len = read_int16();
+                    m_span.x   = read_int32() + m_dx;
+                    m_span.len = read_int32();
                 }
 
                 const span& operator*()  const { return m_span;  }
@@ -363,16 +375,18 @@ namespace agg
 
                 void operator ++ ()
                 {
-                    m_span.x   = read_int16() + m_dx;
-                    m_span.len = read_int16();
+                    m_span.x   = read_int32() + m_dx;
+                    m_span.len = read_int32();
                 }
 
             private:
-                int read_int16()
+                int read_int32()
                 {
-                    int16 val;
+                    int32 val;
                     ((int8u*)&val)[0] = *m_ptr++;
                     ((int8u*)&val)[1] = *m_ptr++;
+                    ((int8u*)&val)[2] = *m_ptr++;
+                    ((int8u*)&val)[3] = *m_ptr++;
                     return val;
                 }
 
@@ -396,11 +410,13 @@ namespace agg
 
         private:
             //----------------------------------------------------------------
-            int read_int16()
+            int read_int32()
             {
-                int16 val;
+                int32 val;
                 ((int8u*)&val)[0] = *m_ptr++;
                 ((int8u*)&val)[1] = *m_ptr++;
+                ((int8u*)&val)[2] = *m_ptr++;
+                ((int8u*)&val)[3] = *m_ptr++;
                 return val;
             }
 
@@ -409,8 +425,8 @@ namespace agg
             void init(const int8u* ptr, int dx, int dy)
             {
                 m_ptr       = ptr;
-                m_y         = read_int16() + dy;
-                m_num_spans = unsigned(read_int16());
+                m_y         = read_int32() + dy;
+                m_num_spans = unsigned(read_int32());
                 m_dx        = dx;
             }
 
@@ -443,8 +459,8 @@ namespace agg
             m_data(data),
             m_end(data + size),
             m_ptr(data),
-            m_dx(int(floor(dx + 0.5))),
-            m_dy(int(floor(dy + 0.5))),
+            m_dx(iround(dx)),
+            m_dy(iround(dy)),
             m_min_x(0x7FFFFFFF),
             m_min_y(0x7FFFFFFF),
             m_max_x(-0x7FFFFFFF),
@@ -457,8 +473,8 @@ namespace agg
             m_data  = data;
             m_end   = data + size;
             m_ptr   = data;
-            m_dx    = int(floor(dx + 0.5));
-            m_dy    = int(floor(dy + 0.5));
+            m_dx    = iround(dx);
+            m_dy    = iround(dy);
             m_min_x = 0x7FFFFFFF;
             m_min_y = 0x7FFFFFFF;
             m_max_x = -0x7FFFFFFF;
@@ -467,11 +483,13 @@ namespace agg
 
     private:
         //--------------------------------------------------------------------
-        int read_int16()
+        int read_int32()
         {
-            int16 val;
+            int32 val;
             ((int8u*)&val)[0] = *m_ptr++;
             ((int8u*)&val)[1] = *m_ptr++;
+            ((int8u*)&val)[2] = *m_ptr++;
+            ((int8u*)&val)[3] = *m_ptr++;
             return val;
         }
        
@@ -483,13 +501,12 @@ namespace agg
             m_ptr = m_data;
             if(m_ptr < m_end)
             {
-                m_min_x = read_int16() + m_dx; 
-                m_min_y = read_int16() + m_dy;
-                m_max_x = read_int16() + m_dx;
-                m_max_y = read_int16() + m_dy;
-                return true;
+                m_min_x = read_int32() + m_dx; 
+                m_min_y = read_int32() + m_dy;
+                m_max_x = read_int32() + m_dx;
+                m_max_y = read_int32() + m_dy;
             }
-            return false;
+            return m_ptr < m_end;
         }
 
         //--------------------------------------------------------------------
@@ -506,13 +523,13 @@ namespace agg
             {
                 if(m_ptr >= m_end) return false;
 
-                int y = read_int16() + m_dy;
-                unsigned num_spans = read_int16();
+                int y = read_int32() + m_dy;
+                unsigned num_spans = read_int32();
 
                 do
                 {
-                    int x = read_int16() + m_dx;
-                    int len = read_int16();
+                    int x = read_int32() + m_dx;
+                    int len = read_int32();
 
                     if(len < 0) len = -len;
                     sl.add_span(x, unsigned(len), cover_full);
@@ -541,9 +558,9 @@ namespace agg
 
                 // Jump to the next scanline
                 //--------------------------
-                read_int16();                    // Y
-                int num_spans = read_int16();    // num_spans
-                m_ptr += num_spans * sizeof(int16) * 2;
+                read_int32();                    // Y
+                int num_spans = read_int32();    // num_spans
+                m_ptr += num_spans * sizeof(int32) * 2;
             }
             while(sl.num_spans() == 0);
             return true;

Modified: incubator/ooo/trunk/main/agg/inc/agg_scanline_u.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_scanline_u.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_scanline_u.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_scanline_u.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 
@@ -12,20 +12,27 @@
 //          mcseemagg@yahoo.com
 //          http://www.antigrain.com
 //----------------------------------------------------------------------------
+//
+// Adaptation for 32-bit screen coordinates (scanline32_u) has been sponsored by 
+// Liberty Technology Systems, Inc., visit http://lib-sys.com
+//
+// Liberty Technology Systems, Inc. is the provider of
+// PostScript and PDF technology for software developers.
+// 
+//----------------------------------------------------------------------------
 
 #ifndef AGG_SCANLINE_U_INCLUDED
 #define AGG_SCANLINE_U_INCLUDED
 
-#include <string.h>
-#include "agg_basics.h"
+#include "agg_array.h"
 
 namespace agg
 {
-    //==============================================================scanline_u
+    //=============================================================scanline_u8
     //
     // Unpacked scanline container class
     //
-    // This class is used to transfer data from a scanline rastyerizer 
+    // This class is used to transfer data from a scanline rasterizer 
     // to the rendering buffer. It's organized very simple. The class stores 
     // information of horizontal spans to render it into a pixel-map buffer. 
     // Each span has staring X, length, and an array of bytes that determine the 
@@ -94,21 +101,23 @@ namespace agg
     //
     // The question is: why should we accumulate the whole scanline when we
     // could render just separate spans when they're ready?
-    // That's because using the scaline is generally faster. When is consists 
+    // That's because using the scanline is generally faster. When is consists 
     // of more than one span the conditions for the processor cash system
     // are better, because switching between two different areas of memory 
-    // (that can be very large) occures less frequently.
+    // (that can be very large) occurs less frequently.
     //------------------------------------------------------------------------
-    template<class T> class scanline_u
+    class scanline_u8
     {
     public:
-        typedef T cover_type;
+        typedef scanline_u8 self_type;
+        typedef int8u       cover_type;
+        typedef int16       coord_type;
 
         //--------------------------------------------------------------------
         struct span
         {
-            int16 x;
-            int16 len;
+            coord_type  x;
+            coord_type  len;
             cover_type* covers;
         };
 
@@ -116,181 +125,360 @@ namespace agg
         typedef const span* const_iterator;
 
         //--------------------------------------------------------------------
-        ~scanline_u();
-        scanline_u();
+        scanline_u8() :
+            m_min_x(0),
+            m_last_x(0x7FFFFFF0),
+            m_cur_span(0)
+        {}
+
+        //--------------------------------------------------------------------
+        void reset(int min_x, int max_x)
+        {
+            unsigned max_len = max_x - min_x + 2;
+            if(max_len > m_spans.size())
+            {
+                m_spans.resize(max_len);
+                m_covers.resize(max_len);
+            }
+            m_last_x   = 0x7FFFFFF0;
+            m_min_x    = min_x;
+            m_cur_span = &m_spans[0];
+        }
 
-        void     reset(int min_x, int max_x);
-        void     add_cell(int x, unsigned cover);
-        void     add_cells(int x, unsigned len, const T* covers);
-        void     add_span(int x, unsigned len, unsigned cover);
-        void     finalize(int y) { m_y = y; }
-        void     reset_spans();
+        //--------------------------------------------------------------------
+        void add_cell(int x, unsigned cover)
+        {
+            x -= m_min_x;
+            m_covers[x] = (cover_type)cover;
+            if(x == m_last_x+1)
+            {
+                m_cur_span->len++;
+            }
+            else
+            {
+                m_cur_span++;
+                m_cur_span->x      = (coord_type)(x + m_min_x);
+                m_cur_span->len    = 1;
+                m_cur_span->covers = &m_covers[x];
+            }
+            m_last_x = x;
+        }
 
+        //--------------------------------------------------------------------
+        void add_cells(int x, unsigned len, const cover_type* covers)
+        {
+            x -= m_min_x;
+            memcpy(&m_covers[x], covers, len * sizeof(cover_type));
+            if(x == m_last_x+1)
+            {
+                m_cur_span->len += (coord_type)len;
+            }
+            else
+            {
+                m_cur_span++;
+                m_cur_span->x      = (coord_type)(x + m_min_x);
+                m_cur_span->len    = (coord_type)len;
+                m_cur_span->covers = &m_covers[x];
+            }
+            m_last_x = x + len - 1;
+        }
+
+        //--------------------------------------------------------------------
+        void add_span(int x, unsigned len, unsigned cover)
+        {
+            x -= m_min_x;
+            memset(&m_covers[x], cover, len);
+            if(x == m_last_x+1)
+            {
+                m_cur_span->len += (coord_type)len;
+            }
+            else
+            {
+                m_cur_span++;
+                m_cur_span->x      = (coord_type)(x + m_min_x);
+                m_cur_span->len    = (coord_type)len;
+                m_cur_span->covers = &m_covers[x];
+            }
+            m_last_x = x + len - 1;
+        }
+
+        //--------------------------------------------------------------------
+        void finalize(int y) 
+        { 
+            m_y = y; 
+        }
+
+        //--------------------------------------------------------------------
+        void reset_spans()
+        {
+            m_last_x    = 0x7FFFFFF0;
+            m_cur_span  = &m_spans[0];
+        }
+
+        //--------------------------------------------------------------------
         int      y()           const { return m_y; }
-        unsigned num_spans()   const { return unsigned(m_cur_span - m_spans); }
-        const_iterator begin() const { return m_spans + 1; }
-        iterator       begin()       { return m_spans + 1; }
+        unsigned num_spans()   const { return unsigned(m_cur_span - &m_spans[0]); }
+        const_iterator begin() const { return &m_spans[1]; }
+        iterator       begin()       { return &m_spans[1]; }
 
     private:
-        scanline_u<T>(const scanline_u<T>&);
-        const scanline_u<T>& operator = (const scanline_u<T>&);
+        scanline_u8(const self_type&);
+        const self_type& operator = (const self_type&);
 
     private:
-        int           m_min_x;
-        unsigned      m_max_len;
-        int           m_last_x;
-        int           m_y;
-        cover_type*   m_covers;
-        span*         m_spans;
-        span*         m_cur_span;
+        int                   m_min_x;
+        int                   m_last_x;
+        int                   m_y;
+        pod_array<cover_type> m_covers;
+        pod_array<span>       m_spans;
+        span*                 m_cur_span;
     };
 
 
 
-    //------------------------------------------------------------------------
-    template<class T> scanline_u<T>::~scanline_u()
-    {
-        delete [] m_spans;
-        delete [] m_covers;
-    }
-
 
+    //==========================================================scanline_u8_am
+    // 
+    // The scanline container with alpha-masking
+    // 
     //------------------------------------------------------------------------
-    template<class T> scanline_u<T>::scanline_u() :
-        m_min_x(0),
-        m_max_len(0),
-        m_last_x(0x7FFFFFF0),
-        m_covers(0),
-        m_spans(0),
-        m_cur_span(0)
+    template<class AlphaMask> 
+    class scanline_u8_am : public scanline_u8
     {
-    }
+    public:
+        typedef scanline_u8           base_type;
+        typedef AlphaMask             alpha_mask_type;
+        typedef base_type::cover_type cover_type;
+        typedef base_type::coord_type coord_type;
 
+        scanline_u8_am() : base_type(), m_alpha_mask(0) {}
+        scanline_u8_am(const AlphaMask& am) : base_type(), m_alpha_mask(&am) {}
 
-    //------------------------------------------------------------------------
-    template<class T> void scanline_u<T>::reset(int min_x, int max_x)
-    {
-        unsigned max_len = max_x - min_x + 2;
-        if(max_len > m_max_len)
+        //--------------------------------------------------------------------
+        void finalize(int span_y)
         {
-            delete [] m_spans;
-            delete [] m_covers;
-            m_covers  = new cover_type [max_len];
-            m_spans   = new span       [max_len];
-            m_max_len = max_len;
-        }
-        m_last_x        = 0x7FFFFFF0;
-        m_min_x         = min_x;
-        m_cur_span      = m_spans;
-    }
+            base_type::finalize(span_y);
+            if(m_alpha_mask)
+            {
+                typename base_type::iterator span = base_type::begin();
+                unsigned count = base_type::num_spans();
+                do
+                {
+                    m_alpha_mask->combine_hspan(span->x, 
+                                                base_type::y(), 
+                                                span->covers, 
+                                                span->len);
+                    ++span;
+                }
+                while(--count);
+            }
+        }
+
+    private:
+        const AlphaMask* m_alpha_mask;
+    };
 
 
-    //------------------------------------------------------------------------
-    template<class T> inline void scanline_u<T>::reset_spans()
-    {
-        m_last_x    = 0x7FFFFFF0;
-        m_cur_span  = m_spans;
-    }
 
 
-    //------------------------------------------------------------------------
-    template<class T> inline void scanline_u<T>::add_cell(int x, unsigned cover)
+    //===========================================================scanline32_u8
+    class scanline32_u8
     {
-        x -= m_min_x;
-        m_covers[x] = (unsigned char)cover;
-        if(x == m_last_x+1)
+    public:
+        typedef scanline32_u8 self_type;
+        typedef int8u         cover_type;
+        typedef int32         coord_type;
+
+        //--------------------------------------------------------------------
+        struct span
         {
-            m_cur_span->len++;
-        }
-        else
+            span() {}
+            span(coord_type x_, coord_type len_, cover_type* covers_) :
+                x(x_), len(len_), covers(covers_) {}
+
+            coord_type  x;
+            coord_type  len;
+            cover_type* covers;
+        };
+
+        typedef pod_bvector<span, 4> span_array_type;
+
+        //--------------------------------------------------------------------
+        class const_iterator
         {
-            m_cur_span++;
-            m_cur_span->x      = (int16)(x + m_min_x);
-            m_cur_span->len    = 1;
-            m_cur_span->covers = m_covers + x;
-        }
-        m_last_x = x;
-    }
+        public:
+            const_iterator(const span_array_type& spans) :
+                m_spans(spans),
+                m_span_idx(0)
+            {}
+
+            const span& operator*()  const { return m_spans[m_span_idx];  }
+            const span* operator->() const { return &m_spans[m_span_idx]; }
+
+            void operator ++ () { ++m_span_idx; }
+
+        private:
+            const span_array_type& m_spans;
+            unsigned               m_span_idx;
+        };
 
+        //--------------------------------------------------------------------
+        class iterator
+        {
+        public:
+            iterator(span_array_type& spans) :
+                m_spans(spans),
+                m_span_idx(0)
+            {}
+
+            span& operator*()  { return m_spans[m_span_idx];  }
+            span* operator->() { return &m_spans[m_span_idx]; }
+
+            void operator ++ () { ++m_span_idx; }
+
+        private:
+            span_array_type& m_spans;
+            unsigned         m_span_idx;
+        };
 
-    //------------------------------------------------------------------------
-    template<class T> void scanline_u<T>::add_cells(int x, unsigned len, const T* covers)
-    {
-        x -= m_min_x;
-        memcpy(m_covers + x, covers, len * sizeof(T));
-        if(x == m_last_x+1)
+
+
+        //--------------------------------------------------------------------
+        scanline32_u8() :
+            m_min_x(0),
+            m_last_x(0x7FFFFFF0),
+            m_covers()
+        {}
+
+        //--------------------------------------------------------------------
+        void reset(int min_x, int max_x)
         {
-            m_cur_span->len += (int16)len;
+            unsigned max_len = max_x - min_x + 2;
+            if(max_len > m_covers.size())
+            {
+                m_covers.resize(max_len);
+            }
+            m_last_x = 0x7FFFFFF0;
+            m_min_x  = min_x;
+            m_spans.remove_all();
         }
-        else
+
+        //--------------------------------------------------------------------
+        void add_cell(int x, unsigned cover)
         {
-            m_cur_span++;
-            m_cur_span->x      = (int16)(x + m_min_x);
-            m_cur_span->len    = (int16)len;
-            m_cur_span->covers = m_covers + x;
+            x -= m_min_x;
+            m_covers[x] = cover_type(cover);
+            if(x == m_last_x+1)
+            {
+                m_spans.last().len++;
+            }
+            else
+            {
+                m_spans.add(span(coord_type(x + m_min_x), 1, &m_covers[x]));
+            }
+            m_last_x = x;
         }
-        m_last_x = x + len - 1;
-    }
 
+        //--------------------------------------------------------------------
+        void add_cells(int x, unsigned len, const cover_type* covers)
+        {
+            x -= m_min_x;
+            memcpy(&m_covers[x], covers, len * sizeof(cover_type));
+            if(x == m_last_x+1)
+            {
+                m_spans.last().len += coord_type(len);
+            }
+            else
+            {
+                m_spans.add(span(coord_type(x + m_min_x), 
+                                 coord_type(len), 
+                                 &m_covers[x]));
+            }
+            m_last_x = x + len - 1;
+        }
 
-    //------------------------------------------------------------------------
-    template<class T> void scanline_u<T>::add_span(int x, unsigned len, unsigned cover)
-    {
-        x -= m_min_x;
-        memset(m_covers + x, cover, len);
-        if(x == m_last_x+1)
+        //--------------------------------------------------------------------
+        void add_span(int x, unsigned len, unsigned cover)
         {
-            m_cur_span->len += (int16)len;
+            x -= m_min_x;
+            memset(&m_covers[x], cover, len);
+            if(x == m_last_x+1)
+            {
+                m_spans.last().len += coord_type(len);
+            }
+            else
+            {
+                m_spans.add(span(coord_type(x + m_min_x), 
+                                 coord_type(len), 
+                                 &m_covers[x]));
+            }
+            m_last_x = x + len - 1;
+        }
+
+        //--------------------------------------------------------------------
+        void finalize(int y) 
+        { 
+            m_y = y; 
         }
-        else
+
+        //--------------------------------------------------------------------
+        void reset_spans()
         {
-            m_cur_span++;
-            m_cur_span->x      = (int16)(x + m_min_x);
-            m_cur_span->len    = (int16)len;
-            m_cur_span->covers = m_covers + x;
+            m_last_x = 0x7FFFFFF0;
+            m_spans.remove_all();
         }
-        m_last_x = x + len - 1;
-    }
 
+        //--------------------------------------------------------------------
+        int      y()           const { return m_y; }
+        unsigned num_spans()   const { return m_spans.size(); }
+        const_iterator begin() const { return const_iterator(m_spans); }
+        iterator       begin()       { return iterator(m_spans); }
 
-    //=============================================================scanline_u8
-    typedef scanline_u<int8u> scanline_u8;
+    private:
+        scanline32_u8(const self_type&);
+        const self_type& operator = (const self_type&);
+
+    private:
+        int                   m_min_x;
+        int                   m_last_x;
+        int                   m_y;
+        pod_array<cover_type> m_covers;
+        span_array_type       m_spans;
+    };
 
-    //============================================================scanline_u16
-    typedef scanline_u<int16u> scanline_u16;
 
-    //============================================================scanline_u32
-    typedef scanline_u<int32u> scanline_u32;
 
 
-    //=============================================================scanline_am
+    //========================================================scanline32_u8_am
     // 
     // The scanline container with alpha-masking
     // 
     //------------------------------------------------------------------------
-    template<class AlphaMask, class CoverT> 
-    class scanline_am : public scanline_u<CoverT>
+    template<class AlphaMask> 
+    class scanline32_u8_am : public scanline32_u8
     {
     public:
-        typedef AlphaMask alpha_mask_type;
-        typedef CoverT cover_type;
-        typedef scanline_u<CoverT> scanline_type;
+        typedef scanline_u8           base_type;
+        typedef AlphaMask             alpha_mask_type;
+        typedef base_type::cover_type cover_type;
+        typedef base_type::coord_type coord_type;
+
 
-        scanline_am() : scanline_type(), m_alpha_mask(0) {}
-        scanline_am(const AlphaMask& am) : scanline_type(), m_alpha_mask(&am) {}
+        scanline32_u8_am() : base_type(), m_alpha_mask(0) {}
+        scanline32_u8_am(const AlphaMask& am) : base_type(), m_alpha_mask(&am) {}
 
         //--------------------------------------------------------------------
         void finalize(int span_y)
         {
-            scanline_u<CoverT>::finalize(span_y);
+            base_type::finalize(span_y);
             if(m_alpha_mask)
             {
-                typename scanline_type::iterator span = scanline_type::begin();
-                unsigned count = scanline_type::num_spans();
+                typename base_type::iterator span = base_type::begin();
+                unsigned count = base_type::num_spans();
                 do
                 {
                     m_alpha_mask->combine_hspan(span->x, 
-                                                scanline_type::y(), 
+                                                base_type::y(), 
                                                 span->covers, 
                                                 span->len);
                     ++span;
@@ -304,18 +492,6 @@ namespace agg
     };
 
 
-    //==========================================================scanline_u8_am
-    template<class AlphaMask> 
-    class scanline_u8_am : public scanline_am<AlphaMask, int8u>
-    {
-    public:
-        typedef AlphaMask alpha_mask_type;
-        typedef int8u cover_type;
-        typedef scanline_am<alpha_mask_type, cover_type> self_type;
-
-        scanline_u8_am() : self_type() {}
-        scanline_u8_am(const AlphaMask& am) : self_type(am) {}
-    };
 
 }
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_shorten_path.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_shorten_path.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_shorten_path.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_shorten_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_simul_eq.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_simul_eq.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_simul_eq.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_simul_eq.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_span_allocator.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_span_allocator.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_span_allocator.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_span_allocator.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 
@@ -16,7 +16,7 @@
 #ifndef AGG_SPAN_ALLOCATOR_INCLUDED
 #define AGG_SPAN_ALLOCATOR_INCLUDED
 
-#include "agg_basics.h"
+#include "agg_array.h"
 
 namespace agg
 {
@@ -27,42 +27,24 @@ namespace agg
         typedef ColorT color_type;
 
         //--------------------------------------------------------------------
-        ~span_allocator()
+        AGG_INLINE color_type* allocate(unsigned span_len)
         {
-            delete [] m_span;
-        }
-
-        //--------------------------------------------------------------------
-        span_allocator() :
-            m_max_span_len(0),
-            m_span(0)
-        {
-        }
-
-        //--------------------------------------------------------------------
-        color_type* allocate(unsigned max_span_len)
-        {
-            if(max_span_len > m_max_span_len)
+            if(span_len > m_span.size())
             {
-                delete [] m_span;
-                m_span = new color_type[m_max_span_len = max_span_len];
+                // To reduce the number of reallocs we align the 
+                // span_len to 256 color elements. 
+                // Well, I just like this number and it looks reasonable.
+                //-----------------------
+                m_span.resize(((span_len + 255) >> 8) << 8);
             }
-            return m_span;
+            return &m_span[0];
         }
 
-        //--------------------------------------------------------------------
-        color_type* span()
-        { 
-            return m_span; 
-        }
+        AGG_INLINE color_type* span()               { return &m_span[0]; }
+        AGG_INLINE unsigned    max_span_len() const { return m_span.size(); }
 
     private:
-        //--------------------------------------------------------------------
-        span_allocator(const span_allocator<ColorT>&);
-        const span_allocator<ColorT>& operator = (const span_allocator<ColorT>&);
-
-        unsigned    m_max_span_len;
-        color_type* m_span;
+        pod_array<color_type> m_span;
     };
 }
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_span_converter.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_span_converter.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_span_converter.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_span_converter.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,31 +21,34 @@
 namespace agg
 {
     //----------------------------------------------------------span_converter
-    template<class SpanGenerator, class Conv> class span_converter
+    template<class SpanGenerator, class SpanConverter> class span_converter
     {
     public:
         typedef typename SpanGenerator::color_type color_type;
 
-        span_converter(SpanGenerator& span_gen, Conv& conv) : 
-            m_span_gen(&span_gen), m_conv(&conv) {}
+        span_converter(SpanGenerator& span_gen, SpanConverter& span_cnv) : 
+            m_span_gen(&span_gen), m_span_cnv(&span_cnv) {}
+
+        void attach_generator(SpanGenerator& span_gen) { m_span_gen = &span_gen; }
+        void attach_converter(SpanConverter& span_cnv) { m_span_cnv = &span_cnv; }
 
         //--------------------------------------------------------------------
-        void prepare(unsigned max_span_len) 
-        {
-            m_span_gen->prepare(max_span_len);
+        void prepare() 
+        { 
+            m_span_gen->prepare(); 
+            m_span_cnv->prepare();
         }
 
         //--------------------------------------------------------------------
-        color_type* generate(int x, int y, unsigned len)
+        void generate(color_type* span, int x, int y, unsigned len)
         {
-            color_type* span = m_span_gen->generate(x, y, len);
-            m_conv->convert(span, x, y, len);
-            return span;
+            m_span_gen->generate(span, x, y, len);
+            m_span_cnv->generate(span, x, y, len);
         }
 
     private:
         SpanGenerator* m_span_gen;
-        Conv*          m_conv;
+        SpanConverter* m_span_cnv;
     };
 
 }

Modified: incubator/ooo/trunk/main/agg/inc/agg_span_gouraud.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_span_gouraud.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_span_gouraud.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_span_gouraud.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,18 +18,15 @@
 
 #include "agg_basics.h"
 #include "agg_math.h"
-#include "agg_span_generator.h"
 
 namespace agg
 {
 
     //============================================================span_gouraud
-    template<class ColorT, class Allocator> 
-    class span_gouraud : public span_generator<ColorT, Allocator>
+    template<class ColorT> class span_gouraud
     {
     public:
         typedef ColorT color_type;
-        typedef Allocator alloc_type;
 
         struct coord_type
         {
@@ -39,23 +36,21 @@ namespace agg
         };
 
         //--------------------------------------------------------------------
-        span_gouraud(alloc_type& alloc) : 
-            span_generator<color_type, alloc_type>(alloc),
+        span_gouraud() : 
             m_vertex(0)
         {
             m_cmd[0] = path_cmd_stop;
         }
 
         //--------------------------------------------------------------------
-        span_gouraud(alloc_type& alloc,
-                     const color_type& c1,
+        span_gouraud(const color_type& c1,
                      const color_type& c2,
                      const color_type& c3,
                      double x1, double y1,
                      double x2, double y2,
                      double x3, double y3,
                      double d) : 
-            span_generator<color_type, alloc_type>(alloc)
+            m_vertex(0)
         {
             colors(c1, c2, c3);
             triangle(x1, y1, x2, y2, x3, y3, d);
@@ -132,8 +127,6 @@ namespace agg
             return m_cmd[m_vertex++];
         }
 
-
-
     protected:
         //--------------------------------------------------------------------
         void arrange_vertices(coord_type* coord) const
@@ -164,7 +157,6 @@ namespace agg
             }
        }
 
-
     private:
         //--------------------------------------------------------------------
         coord_type m_coord[3];

Modified: incubator/ooo/trunk/main/agg/inc/agg_span_gouraud_gray.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_span_gouraud_gray.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_span_gouraud_gray.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_span_gouraud_gray.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,15 +33,18 @@ namespace agg
 {
 
     //=======================================================span_gouraud_gray
-    template<class ColorT, class Allocator = span_allocator<ColorT> >
-    class span_gouraud_gray : public span_gouraud<ColorT, Allocator>
+    template<class ColorT> class span_gouraud_gray : public span_gouraud<ColorT>
     {
     public:
-        typedef Allocator alloc_type;
         typedef ColorT color_type;
         typedef typename color_type::value_type value_type;
-        typedef span_gouraud<color_type, alloc_type> base_type;
+        typedef span_gouraud<color_type> base_type;
         typedef typename base_type::coord_type coord_type;
+        enum subpixel_scale_e
+        { 
+            subpixel_shift = 4, 
+            subpixel_scale = 1 << subpixel_shift
+        };
 
     private:
         //--------------------------------------------------------------------
@@ -49,30 +52,31 @@ namespace agg
         {
             void init(const coord_type& c1, const coord_type& c2)
             {
-                m_x1 = c1.x;
-                m_y1 = c1.y;
-                m_dx = c2.x - c1.x;
-                m_dy = 1.0 / (c2.y - c1.y);
+                m_x1  = c1.x - 0.5;
+                m_y1  = c1.y - 0.5;
+                m_dx  = c2.x - c1.x;
+                double dy = c2.y - c1.y;
+                m_1dy = (fabs(dy) < 1e-10) ? 1e10 : 1.0 / dy;
                 m_v1 = c1.color.v;
                 m_a1 = c1.color.a;
                 m_dv = c2.color.v - m_v1;
                 m_da = c2.color.a - m_a1;
             }
 
-            void calc(int y)
+            void calc(double y)
             {
-                double k = 0.0;
-                if(y > m_y1) k = (y - m_y1) * m_dy;
-                gray8 c;
-                m_v = m_v1 + int(m_dv * k);
-                m_a = m_a1 + int(m_da * k);
-                m_x = int(m_x1 + m_dx * k);
+                double k = (y - m_y1) * m_1dy;
+                if(k < 0.0) k = 0.0;
+                if(k > 1.0) k = 1.0;
+                m_v = m_v1 + iround(m_dv * k);
+                m_a = m_a1 + iround(m_da * k);
+                m_x = iround((m_x1 + m_dx * k) * subpixel_scale);
             }
 
             double m_x1;
             double m_y1;
             double m_dx;
-            double m_dy;
+            double m_1dy;
             int    m_v1;
             int    m_a1;
             int    m_dv;
@@ -85,33 +89,28 @@ namespace agg
 
     public:
         //--------------------------------------------------------------------
-        span_gouraud_gray(alloc_type& alloc) : base_type(alloc) {}
-
-        //--------------------------------------------------------------------
-        span_gouraud_gray(alloc_type& alloc, 
-                          const color_type& c1, 
+        span_gouraud_gray() {}
+        span_gouraud_gray(const color_type& c1, 
                           const color_type& c2, 
                           const color_type& c3,
                           double x1, double y1, 
                           double x2, double y2,
                           double x3, double y3, 
                           double d = 0) : 
-            base_type(alloc, c1, c2, c3, x1, y1, x2, y2, x3, y3, d)
+            base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d)
         {}
 
         //--------------------------------------------------------------------
-        void prepare(unsigned max_span_len)
+        void prepare()
         {
-            base_type::prepare(max_span_len);
-
             coord_type coord[3];
-            arrange_vertices(coord);
+            base_type::arrange_vertices(coord);
 
             m_y2 = int(coord[1].y);
 
-            m_swap = calc_point_location(coord[0].x, coord[0].y, 
-                                         coord[2].x, coord[2].y,
-                                         coord[1].x, coord[1].y) < 0.0;
+            m_swap = cross_product(coord[0].x, coord[0].y, 
+                                   coord[2].x, coord[2].y,
+                                   coord[1].x, coord[1].y) < 0.0;
 
             m_c1.init(coord[0], coord[2]);
             m_c2.init(coord[0], coord[1]);
@@ -119,7 +118,7 @@ namespace agg
         }
 
         //--------------------------------------------------------------------
-        color_type* generate(int x, int y, unsigned len)
+        void generate(color_type* span, int x, int y, unsigned len)
         {
             m_c1.calc(y);
             const gray_calc* pc1 = &m_c1;
@@ -127,47 +126,104 @@ namespace agg
 
             if(y < m_y2)
             {
-                m_c2.calc(y+1);
+                // Bottom part of the triangle (first subtriangle)
+                //-------------------------
+                m_c2.calc(y + m_c2.m_1dy);
             }
             else
             {
-                m_c3.calc(y);
+                // Upper part (second subtriangle)
+                //-------------------------
+                m_c3.calc(y - m_c3.m_1dy);
                 pc2 = &m_c3;
             }
 
             if(m_swap)
             {
+                // It means that the triangle is oriented clockwise, 
+                // so that we need to swap the controlling structures
+                //-------------------------
                 const gray_calc* t = pc2;
                 pc2 = pc1;
                 pc1 = t;
             }
 
-            int nx = pc1->m_x;
-            unsigned nlen = pc2->m_x - pc1->m_x + 1;
-
-            if(nlen < len) nlen = len;
+            // Get the horizontal length with subpixel accuracy
+            // and protect it from division by zero
+            //-------------------------
+            int nlen = abs(pc2->m_x - pc1->m_x);
+            if(nlen <= 0) nlen = 1;
 
             dda_line_interpolator<14> v(pc1->m_v, pc2->m_v, nlen);
             dda_line_interpolator<14> a(pc1->m_a, pc2->m_a, nlen);
 
-            if(nx < x)
-            {
-                unsigned d = unsigned(x - nx);
-                v += d; 
-                a += d;
+            // Calculate the starting point of the gradient with subpixel 
+            // accuracy and correct (roll back) the interpolators.
+            // This operation will also clip the beginning of the span
+            // if necessary.
+            //-------------------------
+            int start = pc1->m_x - (x << subpixel_shift);
+            v    -= start; 
+            a    -= start;
+            nlen += start;
+
+            int vv, va;
+            enum lim_e { lim = color_type::base_mask };
+
+            // Beginning part of the span. Since we rolled back the 
+            // interpolators, the color values may have overflow.
+            // So that, we render the beginning part with checking 
+            // for overflow. It lasts until "start" is positive;
+            // typically it's 1-2 pixels, but may be more in some cases.
+            //-------------------------
+            while(len && start > 0)
+            {
+                vv = v.y();
+                va = a.y();
+                if(vv < 0) vv = 0; if(vv > lim) vv = lim;
+                if(va < 0) va = 0; if(va > lim) va = lim;
+                span->v = (value_type)vv;
+                span->a = (value_type)va;
+                v     += subpixel_scale; 
+                a     += subpixel_scale;
+                nlen  -= subpixel_scale;
+                start -= subpixel_scale;
+                ++span;
+                --len;
             }
 
-            color_type* span = base_type::allocator().span();
-            do
+            // Middle part, no checking for overflow.
+            // Actual spans can be longer than the calculated length
+            // because of anti-aliasing, thus, the interpolators can 
+            // overflow. But while "nlen" is positive we are safe.
+            //-------------------------
+            while(len && nlen > 0)
             {
                 span->v = (value_type)v.y();
                 span->a = (value_type)a.y();
-                ++v; 
-                ++a;
+                v    += subpixel_scale; 
+                a    += subpixel_scale;
+                nlen -= subpixel_scale;
+                ++span;
+                --len;
+            }
+
+            // Ending part; checking for overflow.
+            // Typically it's 1-2 pixels, but may be more in some cases.
+            //-------------------------
+            while(len)
+            {
+                vv = v.y();
+                va = a.y();
+                if(vv < 0) vv = 0; if(vv > lim) vv = lim;
+                if(va < 0) va = 0; if(va > lim) va = lim;
+                span->v = (value_type)vv;
+                span->a = (value_type)va;
+                v += subpixel_scale; 
+                a += subpixel_scale;
                 ++span;
+                --len;
             }
-            while(--len);
-            return base_type::allocator().span();
         }
 
 



Mime
View raw message