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 [11/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_renderer_scanline.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_renderer_scanline.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_renderer_scanline.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_renderer_scanline.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,195 +18,303 @@
 
 #include "agg_basics.h"
 #include "agg_renderer_base.h"
-#include "agg_render_scanlines.h"
 
 namespace agg
 {
 
-    //====================================================renderer_scanline_aa
-    template<class BaseRenderer, class SpanGenerator> class renderer_scanline_aa
+    //================================================render_scanline_aa_solid
+    template<class Scanline, class BaseRenderer, class ColorT> 
+    void render_scanline_aa_solid(const Scanline& sl, 
+                                  BaseRenderer& ren, 
+                                  const ColorT& color)
     {
-    public:
-        typedef BaseRenderer base_ren_type;
+        int y = sl.y();
+        unsigned num_spans = sl.num_spans();
+        typename Scanline::const_iterator span = sl.begin();
 
-        //--------------------------------------------------------------------
-        renderer_scanline_aa(base_ren_type& ren, SpanGenerator& span_gen) :
-            m_ren(&ren),
-            m_span_gen(&span_gen)
+        for(;;)
         {
+            int x = span->x;
+            if(span->len > 0)
+            {
+                ren.blend_solid_hspan(x, y, (unsigned)span->len, 
+                                      color, 
+                                      span->covers);
+            }
+            else
+            {
+                ren.blend_hline(x, y, (unsigned)(x - span->len - 1), 
+                                color, 
+                                *(span->covers));
+            }
+            if(--num_spans == 0) break;
+            ++span;
         }
-        
-        //--------------------------------------------------------------------
-        void prepare(unsigned max_span_len) 
-        { 
-            m_span_gen->prepare(max_span_len); 
-        }
+    }
 
-        //--------------------------------------------------------------------
-        template<class Scanline> void render(const Scanline& sl)
+    //===============================================render_scanlines_aa_solid
+    template<class Rasterizer, class Scanline, 
+             class BaseRenderer, class ColorT>
+    void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl, 
+                                   BaseRenderer& ren, const ColorT& color)
+    {
+        if(ras.rewind_scanlines())
         {
-            int y = sl.y();
-            m_ren->first_clip_box();
-            do
+            // Explicitly convert "color" to the BaseRenderer color type.
+            // For example, it can be called with color type "rgba", while
+            // "rgba8" is needed. Otherwise it will be implicitly 
+            // converted in the loop many times.
+            //----------------------
+            typename BaseRenderer::color_type ren_color(color);
+
+            sl.reset(ras.min_x(), ras.max_x());
+            while(ras.sweep_scanline(sl))
             {
-                int xmin = m_ren->xmin();
-                int xmax = m_ren->xmax();
+                //render_scanline_aa_solid(sl, ren, ren_color);
+
+                // This code is equivalent to the above call (copy/paste). 
+                // It's just a "manual" optimization for old compilers,
+                // like Microsoft Visual C++ v6.0
+                //-------------------------------
+                int y = sl.y();
+                unsigned num_spans = sl.num_spans();
+                typename Scanline::const_iterator span = sl.begin();
 
-                if(y >= m_ren->ymin() && y <= m_ren->ymax())
+                for(;;)
                 {
-                    unsigned num_spans = sl.num_spans();
-                    typename Scanline::const_iterator span = sl.begin();
-                    do
+                    int x = span->x;
+                    if(span->len > 0)
                     {
-                        int x = span->x;
-                        int len = span->len;
-                        bool solid = false;
-                        const typename Scanline::cover_type* covers = span->covers;
-
-                        if(len < 0)
-                        {
-                            solid = true;
-                            len = -len;
-                        }
-
-                        if(x < xmin)
-                        {
-                            len -= xmin - x;
-                            if(!solid) 
-                            {
-                                covers += xmin - x;
-                            }
-                            x = xmin;
-                        }
-
-                        if(len > 0)
-                        {
-                            if(x + len > xmax)
-                            {
-                                len = xmax - x + 1;
-                            }
-                            if(len > 0)
-                            {
-                                m_ren->blend_color_hspan_no_clip(
-                                    x, y, len, 
-                                    m_span_gen->generate(x, y, len),
-                                    solid ? 0 : covers,
-                                    *covers);
-                            }
-                        }
-                        ++span;
+                        ren.blend_solid_hspan(x, y, (unsigned)span->len, 
+                                              ren_color, 
+                                              span->covers);
+                    }
+                    else
+                    {
+                        ren.blend_hline(x, y, (unsigned)(x - span->len - 1), 
+                                        ren_color, 
+                                        *(span->covers));
                     }
-                    while(--num_spans);
+                    if(--num_spans == 0) break;
+                    ++span;
                 }
             }
-            while(m_ren->next_clip_box());
+        }
+    }
+
+    //==============================================renderer_scanline_aa_solid
+    template<class BaseRenderer> class renderer_scanline_aa_solid
+    {
+    public:
+        typedef BaseRenderer base_ren_type;
+        typedef typename base_ren_type::color_type color_type;
+
+        //--------------------------------------------------------------------
+        renderer_scanline_aa_solid() : m_ren(0) {}
+        explicit renderer_scanline_aa_solid(base_ren_type& ren) : m_ren(&ren) {}
+        void attach(base_ren_type& ren)
+        {
+            m_ren = &ren;
+        }
+        
+        //--------------------------------------------------------------------
+        void color(const color_type& c) { m_color = c; }
+        const color_type& color() const { return m_color; }
+
+        //--------------------------------------------------------------------
+        void prepare() {}
+
+        //--------------------------------------------------------------------
+        template<class Scanline> void render(const Scanline& sl)
+        {
+            render_scanline_aa_solid(sl, *m_ren, m_color);
         }
         
     private:
         base_ren_type* m_ren;
-        SpanGenerator* m_span_gen;
+        color_type m_color;
     };
 
 
 
 
-    //==============================================renderer_scanline_aa_opaque
-    template<class BaseRenderer, class SpanGenerator> class renderer_scanline_aa_opaque
+
+
+
+
+
+
+
+
+
+    //======================================================render_scanline_aa
+    template<class Scanline, class BaseRenderer, 
+             class SpanAllocator, class SpanGenerator> 
+    void render_scanline_aa(const Scanline& sl, BaseRenderer& ren, 
+                            SpanAllocator& alloc, SpanGenerator& span_gen)
+    {
+        int y = sl.y();
+
+        unsigned num_spans = sl.num_spans();
+        typename Scanline::const_iterator span = sl.begin();
+        for(;;)
+        {
+            int x = span->x;
+            int len = span->len;
+            const typename Scanline::cover_type* covers = span->covers;
+
+            if(len < 0) len = -len;
+            typename BaseRenderer::color_type* colors = alloc.allocate(len);
+            span_gen.generate(colors, x, y, len);
+            ren.blend_color_hspan(x, y, len, colors, 
+                                  (span->len < 0) ? 0 : covers, *covers);
+
+            if(--num_spans == 0) break;
+            ++span;
+        }
+    }
+
+    //=====================================================render_scanlines_aa
+    template<class Rasterizer, class Scanline, class BaseRenderer, 
+             class SpanAllocator, class SpanGenerator>
+    void render_scanlines_aa(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, 
+                             SpanAllocator& alloc, SpanGenerator& span_gen)
+    {
+        if(ras.rewind_scanlines())
+        {
+            sl.reset(ras.min_x(), ras.max_x());
+            span_gen.prepare();
+            while(ras.sweep_scanline(sl))
+            {
+                render_scanline_aa(sl, ren, alloc, span_gen);
+            }
+        }
+    }
+
+    //====================================================renderer_scanline_aa
+    template<class BaseRenderer, class SpanAllocator, class SpanGenerator> 
+    class renderer_scanline_aa
     {
     public:
-        typedef BaseRenderer base_ren_type;
+        typedef BaseRenderer  base_ren_type;
+        typedef SpanAllocator alloc_type;
+        typedef SpanGenerator span_gen_type;
 
         //--------------------------------------------------------------------
-        renderer_scanline_aa_opaque(base_ren_type& ren, SpanGenerator& span_gen) :
+        renderer_scanline_aa() : m_ren(0), m_alloc(0), m_span_gen(0) {}
+        renderer_scanline_aa(base_ren_type& ren, 
+                             alloc_type& alloc, 
+                             span_gen_type& span_gen) :
             m_ren(&ren),
+            m_alloc(&alloc),
             m_span_gen(&span_gen)
+        {}
+        void attach(base_ren_type& ren, 
+                    alloc_type& alloc, 
+                    span_gen_type& span_gen)
         {
+            m_ren = &ren;
+            m_alloc = &alloc;
+            m_span_gen = &span_gen;
         }
         
         //--------------------------------------------------------------------
-        void prepare(unsigned max_span_len) 
-        { 
-            m_span_gen->prepare(max_span_len); 
-        }
+        void prepare() { m_span_gen->prepare(); }
 
         //--------------------------------------------------------------------
         template<class Scanline> void render(const Scanline& sl)
         {
-            int y = sl.y();
-            m_ren->first_clip_box();
-            do
-            {
-                int xmin = m_ren->xmin();
-                int xmax = m_ren->xmax();
+            render_scanline_aa(sl, *m_ren, *m_alloc, *m_span_gen);
+        }
 
-                if(y >= m_ren->ymin() && y <= m_ren->ymax())
-                {
-                    unsigned num_spans = sl.num_spans();
-                    typename Scanline::const_iterator span = sl.begin();
-                    do
-                    {
-                        int x = span->x;
-                        int len = span->len;
-                        bool solid = false;
-                        const typename Scanline::cover_type* covers = span->covers;
+    private:
+        base_ren_type* m_ren;
+        alloc_type*    m_alloc;
+        span_gen_type* m_span_gen;
+    };
 
-                        if(len < 0)
-                        {
-                            solid = true;
-                            len = -len;
-                        }
 
-                        if(x < xmin)
-                        {
-                            len -= xmin - x;
-                            if(!solid) 
-                            {
-                                covers += xmin - x;
-                            }
-                            x = xmin;
-                        }
 
-                        if(len > 0)
-                        {
-                            if(x + len > xmax)
-                            {
-                                len = xmax - x + 1;
-                            }
-                            if(len > 0)
-                            {
-                                m_ren->blend_opaque_color_hspan_no_clip(
-                                    x, y, len, 
-                                    m_span_gen->generate(x, y, len),
-                                    solid ? 0 : covers,
-                                    *covers);
-                            }
-                        }
-                        ++span;
-                    }
-                    while(--num_spans);
+
+
+
+    //===============================================render_scanline_bin_solid
+    template<class Scanline, class BaseRenderer, class ColorT> 
+    void render_scanline_bin_solid(const Scanline& sl, 
+                                   BaseRenderer& ren, 
+                                   const ColorT& color)
+    {
+        unsigned num_spans = sl.num_spans();
+        typename Scanline::const_iterator span = sl.begin();
+        for(;;)
+        {
+            ren.blend_hline(span->x, 
+                            sl.y(), 
+                            span->x - 1 + ((span->len < 0) ? 
+                                              -span->len : 
+                                               span->len), 
+                               color, 
+                               cover_full);
+            if(--num_spans == 0) break;
+            ++span;
+        }
+    }
+
+    //==============================================render_scanlines_bin_solid
+    template<class Rasterizer, class Scanline, 
+             class BaseRenderer, class ColorT>
+    void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl, 
+                                    BaseRenderer& ren, const ColorT& color)
+    {
+        if(ras.rewind_scanlines())
+        {
+            // Explicitly convert "color" to the BaseRenderer color type.
+            // For example, it can be called with color type "rgba", while
+            // "rgba8" is needed. Otherwise it will be implicitly 
+            // converted in the loop many times.
+            //----------------------
+            typename BaseRenderer::color_type ren_color(color);
+
+            sl.reset(ras.min_x(), ras.max_x());
+            while(ras.sweep_scanline(sl))
+            {
+                //render_scanline_bin_solid(sl, ren, ren_color);
+
+                // This code is equivalent to the above call (copy/paste). 
+                // It's just a "manual" optimization for old compilers,
+                // like Microsoft Visual C++ v6.0
+                //-------------------------------
+                unsigned num_spans = sl.num_spans();
+                typename Scanline::const_iterator span = sl.begin();
+                for(;;)
+                {
+                    ren.blend_hline(span->x, 
+                                    sl.y(), 
+                                    span->x - 1 + ((span->len < 0) ? 
+                                                      -span->len : 
+                                                       span->len), 
+                                       ren_color, 
+                                       cover_full);
+                    if(--num_spans == 0) break;
+                    ++span;
                 }
             }
-            while(m_ren->next_clip_box());
         }
-        
-    private:
-        base_ren_type* m_ren;
-        SpanGenerator* m_span_gen;
-    };
-
+    }
 
-
-    //==============================================renderer_scanline_aa_solid
-    template<class BaseRenderer> class renderer_scanline_aa_solid
+    //=============================================renderer_scanline_bin_solid
+    template<class BaseRenderer> class renderer_scanline_bin_solid
     {
     public:
         typedef BaseRenderer base_ren_type;
         typedef typename base_ren_type::color_type color_type;
 
         //--------------------------------------------------------------------
-        renderer_scanline_aa_solid(base_ren_type& ren) :
-            m_ren(&ren)
+        renderer_scanline_bin_solid() : m_ren(0) {}
+        explicit renderer_scanline_bin_solid(base_ren_type& ren) : m_ren(&ren) {}
+        void attach(base_ren_type& ren)
         {
+            m_ren = &ren;
         }
         
         //--------------------------------------------------------------------
@@ -214,33 +322,12 @@ namespace agg
         const color_type& color() const { return m_color; }
 
         //--------------------------------------------------------------------
-        void prepare(unsigned) {}
+        void prepare() {}
 
         //--------------------------------------------------------------------
         template<class Scanline> void render(const Scanline& sl)
         {
-            int y = sl.y();
-            unsigned num_spans = sl.num_spans();
-            typename Scanline::const_iterator span = sl.begin();
-
-            do
-            {
-                int x = span->x;
-                if(span->len > 0)
-                {
-                    m_ren->blend_solid_hspan(x, y, (unsigned)span->len, 
-                                             m_color, 
-                                             span->covers);
-                }
-                else
-                {
-                    m_ren->blend_hline(x, y, (unsigned)(x - span->len - 1), 
-                                       m_color, 
-                                       *(span->covers));
-                }
-                ++span;
-            }
-            while(--num_spans);
+            render_scanline_bin_solid(sl, *m_ren, m_color);
         }
         
     private:
@@ -254,196 +341,511 @@ namespace agg
 
 
 
-    //===================================================renderer_scanline_bin
-    template<class BaseRenderer, class SpanGenerator> class renderer_scanline_bin
+
+    //======================================================render_scanline_bin
+    template<class Scanline, class BaseRenderer, 
+             class SpanAllocator, class SpanGenerator> 
+    void render_scanline_bin(const Scanline& sl, BaseRenderer& ren, 
+                             SpanAllocator& alloc, SpanGenerator& span_gen)
+    {
+        int y = sl.y();
+
+        unsigned num_spans = sl.num_spans();
+        typename Scanline::const_iterator span = sl.begin();
+        for(;;)
+        {
+            int x = span->x;
+            int len = span->len;
+            if(len < 0) len = -len;
+            typename BaseRenderer::color_type* colors = alloc.allocate(len);
+            span_gen.generate(colors, x, y, len);
+            ren.blend_color_hspan(x, y, len, colors, 0, cover_full); 
+            if(--num_spans == 0) break;
+            ++span;
+        }
+    }
+
+    //=====================================================render_scanlines_bin
+    template<class Rasterizer, class Scanline, class BaseRenderer, 
+             class SpanAllocator, class SpanGenerator>
+    void render_scanlines_bin(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, 
+                              SpanAllocator& alloc, SpanGenerator& span_gen)
+    {
+        if(ras.rewind_scanlines())
+        {
+            sl.reset(ras.min_x(), ras.max_x());
+            span_gen.prepare();
+            while(ras.sweep_scanline(sl))
+            {
+                render_scanline_bin(sl, ren, alloc, span_gen);
+            }
+        }
+    }
+
+    //====================================================renderer_scanline_bin
+    template<class BaseRenderer, class SpanAllocator, class SpanGenerator> 
+    class renderer_scanline_bin
     {
     public:
-        typedef BaseRenderer base_ren_type;
+        typedef BaseRenderer  base_ren_type;
+        typedef SpanAllocator alloc_type;
+        typedef SpanGenerator span_gen_type;
 
         //--------------------------------------------------------------------
-        renderer_scanline_bin(base_ren_type& ren, SpanGenerator& span_gen) :
+        renderer_scanline_bin() : m_ren(0), m_alloc(0), m_span_gen(0) {}
+        renderer_scanline_bin(base_ren_type& ren, 
+                              alloc_type& alloc, 
+                              span_gen_type& span_gen) :
             m_ren(&ren),
+            m_alloc(&alloc),
             m_span_gen(&span_gen)
+        {}
+        void attach(base_ren_type& ren, 
+                    alloc_type& alloc, 
+                    span_gen_type& span_gen)
         {
+            m_ren = &ren;
+            m_alloc = &alloc;
+            m_span_gen = &span_gen;
         }
         
         //--------------------------------------------------------------------
-        void prepare(unsigned max_span_len) 
-        { 
-            m_span_gen->prepare(max_span_len); 
-        }
+        void prepare() { m_span_gen->prepare(); }
 
         //--------------------------------------------------------------------
         template<class Scanline> void render(const Scanline& sl)
         {
-            int y = sl.y();
-            m_ren->first_clip_box();
-            do
-            {
-                int xmin = m_ren->xmin();
-                int xmax = m_ren->xmax();
-
-                if(y >= m_ren->ymin() && y <= m_ren->ymax())
-                {
-                    unsigned num_spans = sl.num_spans();
-                    typename Scanline::const_iterator span = sl.begin();
-                    do
-                    {
-                        int x = span->x;
-                        int len = span->len;
-
-                        if(len < 0) len = -len;
-                        if(x < xmin)
-                        {
-                            len -= xmin - x;
-                            x = xmin;
-                        }
-                        if(len > 0)
-                        {
-                            if(x + len > xmax)
-                            {
-                                len = xmax - x + 1;
-                            }
-                            if(len > 0)
-                            {
-                                m_ren->blend_color_hspan_no_clip(
-                                    x, y, len, 
-                                    m_span_gen->generate(x, y, len),
-                                    0);
-                            }
-                        }
-                        ++span;
-                    }
-                    while(--num_spans);
-                }
-            }
-            while(m_ren->next_clip_box());
+            render_scanline_bin(sl, *m_ren, *m_alloc, *m_span_gen);
         }
-        
+
     private:
         base_ren_type* m_ren;
-        SpanGenerator* m_span_gen;
+        alloc_type*    m_alloc;
+        span_gen_type* m_span_gen;
     };
 
 
 
-    //===============================================renderer_scanline_bin_opaque
-    template<class BaseRenderer, class SpanGenerator> class renderer_scanline_bin_opaque
-    {
-    public:
-        typedef BaseRenderer base_ren_type;
 
-        //--------------------------------------------------------------------
-        renderer_scanline_bin_opaque(base_ren_type& ren, SpanGenerator& span_gen) :
-            m_ren(&ren),
-            m_span_gen(&span_gen)
+
+
+
+
+
+
+    //========================================================render_scanlines
+    template<class Rasterizer, class Scanline, class Renderer>
+    void render_scanlines(Rasterizer& ras, Scanline& sl, Renderer& ren)
+    {
+        if(ras.rewind_scanlines())
         {
+            sl.reset(ras.min_x(), ras.max_x());
+            ren.prepare();
+            while(ras.sweep_scanline(sl))
+            {
+                ren.render(sl);
+            }
         }
-        
-        //--------------------------------------------------------------------
-        void prepare(unsigned max_span_len) 
-        { 
-            m_span_gen->prepare(max_span_len); 
+    }
+
+    //========================================================render_all_paths
+    template<class Rasterizer, class Scanline, class Renderer, 
+             class VertexSource, class ColorStorage, class PathId>
+    void render_all_paths(Rasterizer& ras, 
+                          Scanline& sl,
+                          Renderer& r, 
+                          VertexSource& vs, 
+                          const ColorStorage& as, 
+                          const PathId& path_id,
+                          unsigned num_paths)
+    {
+        for(unsigned i = 0; i < num_paths; i++)
+        {
+            ras.reset();
+            ras.add_path(vs, path_id[i]);
+            r.color(as[i]);
+            render_scanlines(ras, sl, r);
         }
+    }
 
-        //--------------------------------------------------------------------
-        template<class Scanline> void render(const Scanline& sl)
+
+
+
+
+
+    //=============================================render_scanlines_compound
+    template<class Rasterizer, 
+             class ScanlineAA, 
+             class ScanlineBin, 
+             class BaseRenderer, 
+             class SpanAllocator,
+             class StyleHandler>
+    void render_scanlines_compound(Rasterizer& ras, 
+                                   ScanlineAA& sl_aa,
+                                   ScanlineBin& sl_bin,
+                                   BaseRenderer& ren,
+                                   SpanAllocator& alloc,
+                                   StyleHandler& sh)
+    {
+        if(ras.rewind_scanlines())
         {
-            int y = sl.y();
-            m_ren->first_clip_box();
-            do
+            int min_x = ras.min_x();
+            int len = ras.max_x() - min_x + 2;
+            sl_aa.reset(min_x, ras.max_x());
+            sl_bin.reset(min_x, ras.max_x());
+
+            typedef typename BaseRenderer::color_type color_type;
+            color_type* color_span = alloc.allocate(len * 2);
+            color_type* mix_buffer = color_span + len;
+            unsigned num_spans;
+
+            unsigned num_styles;
+            unsigned style;
+            bool     solid;
+            while((num_styles = ras.sweep_styles()) > 0)
             {
-                int xmin = m_ren->xmin();
-                int xmax = m_ren->xmax();
-
-                if(y >= m_ren->ymin() && y <= m_ren->ymax())
+                typename ScanlineAA::const_iterator span_aa;
+                if(num_styles == 1)
                 {
-                    unsigned num_spans = sl.num_spans();
-                    typename Scanline::const_iterator span = sl.begin();
-                    do
+                    // Optimization for a single style. Happens often
+                    //-------------------------
+                    if(ras.sweep_scanline(sl_aa, 0))
                     {
-                        int x = span->x;
-                        int len = span->len;
-
-                        if(len < 0) len = -len;
-                        if(x < xmin)
+                        style = ras.style(0);
+                        if(sh.is_solid(style))
                         {
-                            len -= xmin - x;
-                            x = xmin;
+                            // Just solid fill
+                            //-----------------------
+                            render_scanline_aa_solid(sl_aa, ren, sh.color(style));
                         }
-                        if(len > 0)
+                        else
                         {
-                            if(x + len > xmax)
+                            // Arbitrary span generator
+                            //-----------------------
+                            span_aa   = sl_aa.begin();
+                            num_spans = sl_aa.num_spans();
+                            for(;;)
                             {
-                                len = xmax - x + 1;
-                            }
-                            if(len > 0)
-                            {
-                                m_ren->blend_opaque_color_hspan_no_clip(
-                                    x, y, len, 
-                                    m_span_gen->generate(x, y, len),
-                                    0);
+                                len = span_aa->len;
+                                sh.generate_span(color_span, 
+                                                 span_aa->x, 
+                                                 sl_aa.y(), 
+                                                 len, 
+                                                 style);
+
+                                ren.blend_color_hspan(span_aa->x, 
+                                                      sl_aa.y(), 
+                                                      span_aa->len,
+                                                      color_span,
+                                                      span_aa->covers);
+                                if(--num_spans == 0) break;
+                                ++span_aa;
                             }
                         }
-                        ++span;
                     }
-                    while(--num_spans);
                 }
-            }
-            while(m_ren->next_clip_box());
-        }
-        
-    private:
-        base_ren_type* m_ren;
-        SpanGenerator* m_span_gen;
-    };
+                else
+                {
+                    if(ras.sweep_scanline(sl_bin, -1))
+                    {
+                        // Clear the spans of the mix_buffer
+                        //--------------------
+                        typename ScanlineBin::const_iterator span_bin = sl_bin.begin();
+                        num_spans = sl_bin.num_spans();
+                        for(;;)
+                        {
+                            memset(mix_buffer + span_bin->x - min_x, 
+                                   0, 
+                                   span_bin->len * sizeof(color_type));
 
+                            if(--num_spans == 0) break;
+                            ++span_bin;
+                        }
 
+                        unsigned i;
+                        for(i = 0; i < num_styles; i++)
+                        {
+                            style = ras.style(i);
+                            solid = sh.is_solid(style);
 
+                            if(ras.sweep_scanline(sl_aa, i))
+                            {
+                                color_type* colors;
+                                color_type* cspan;
+                                typename ScanlineAA::cover_type* covers;
+                                span_aa   = sl_aa.begin();
+                                num_spans = sl_aa.num_spans();
+                                if(solid)
+                                {
+                                    // Just solid fill
+                                    //-----------------------
+                                    for(;;)
+                                    {
+                                        color_type c = sh.color(style);
+                                        len    = span_aa->len;
+                                        colors = mix_buffer + span_aa->x - min_x;
+                                        covers = span_aa->covers;
+                                        do
+                                        {
+                                            if(*covers == cover_full) 
+                                            {
+                                                *colors = c;
+                                            }
+                                            else
+                                            {
+                                                colors->add(c, *covers);
+                                            }
+                                            ++colors;
+                                            ++covers;
+                                        }
+                                        while(--len);
+                                        if(--num_spans == 0) break;
+                                        ++span_aa;
+                                    }
+                                }
+                                else
+                                {
+                                    // Arbitrary span generator
+                                    //-----------------------
+                                    for(;;)
+                                    {
+                                        len = span_aa->len;
+                                        colors = mix_buffer + span_aa->x - min_x;
+                                        cspan  = color_span;
+                                        sh.generate_span(cspan, 
+                                                         span_aa->x, 
+                                                         sl_aa.y(), 
+                                                         len, 
+                                                         style);
+                                        covers = span_aa->covers;
+                                        do
+                                        {
+                                            if(*covers == cover_full) 
+                                            {
+                                                *colors = *cspan;
+                                            }
+                                            else
+                                            {
+                                                colors->add(*cspan, *covers);
+                                            }
+                                            ++cspan;
+                                            ++colors;
+                                            ++covers;
+                                        }
+                                        while(--len);
+                                        if(--num_spans == 0) break;
+                                        ++span_aa;
+                                    }
+                                }
+                            }
+                        }
 
-    //=============================================renderer_scanline_bin_solid
-    template<class BaseRenderer> class renderer_scanline_bin_solid
+                        // Emit the blended result as a color hspan
+                        //-------------------------
+                        span_bin = sl_bin.begin();
+                        num_spans = sl_bin.num_spans();
+                        for(;;)
+                        {
+                            ren.blend_color_hspan(span_bin->x, 
+                                                  sl_bin.y(), 
+                                                  span_bin->len,
+                                                  mix_buffer + span_bin->x - min_x,
+                                                  0,
+                                                  cover_full);
+                            if(--num_spans == 0) break;
+                            ++span_bin;
+                        }
+                    } // if(ras.sweep_scanline(sl_bin, -1))
+                } // if(num_styles == 1) ... else
+            } // while((num_styles = ras.sweep_styles()) > 0)
+        } // if(ras.rewind_scanlines())
+    }
+
+    //=======================================render_scanlines_compound_layered
+    template<class Rasterizer, 
+             class ScanlineAA, 
+             class BaseRenderer, 
+             class SpanAllocator,
+             class StyleHandler>
+    void render_scanlines_compound_layered(Rasterizer& ras, 
+                                           ScanlineAA& sl_aa,
+                                           BaseRenderer& ren,
+                                           SpanAllocator& alloc,
+                                           StyleHandler& sh)
     {
-    public:
-        typedef BaseRenderer base_ren_type;
-        typedef typename base_ren_type::color_type color_type;
-
-        //--------------------------------------------------------------------
-        renderer_scanline_bin_solid(base_ren_type& ren) :
-            m_ren(&ren)
+        if(ras.rewind_scanlines())
         {
-        }
-        
-        //--------------------------------------------------------------------
-        void color(const color_type& c) { m_color = c; }
-        const color_type& color() const { return m_color; }
+            int min_x = ras.min_x();
+            int len = ras.max_x() - min_x + 2;
+            sl_aa.reset(min_x, ras.max_x());
+
+            typedef typename BaseRenderer::color_type color_type;
+            color_type* color_span   = alloc.allocate(len * 2);
+            color_type* mix_buffer   = color_span + len;
+            cover_type* cover_buffer = ras.allocate_cover_buffer(len);
+            unsigned num_spans;
+
+            unsigned num_styles;
+            unsigned style;
+            bool     solid;
+            while((num_styles = ras.sweep_styles()) > 0)
+            {
+                typename ScanlineAA::const_iterator span_aa;
+                if(num_styles == 1)
+                {
+                    // Optimization for a single style. Happens often
+                    //-------------------------
+                    if(ras.sweep_scanline(sl_aa, 0))
+                    {
+                        style = ras.style(0);
+                        if(sh.is_solid(style))
+                        {
+                            // Just solid fill
+                            //-----------------------
+                            render_scanline_aa_solid(sl_aa, ren, sh.color(style));
+                        }
+                        else
+                        {
+                            // Arbitrary span generator
+                            //-----------------------
+                            span_aa   = sl_aa.begin();
+                            num_spans = sl_aa.num_spans();
+                            for(;;)
+                            {
+                                len = span_aa->len;
+                                sh.generate_span(color_span, 
+                                                 span_aa->x, 
+                                                 sl_aa.y(), 
+                                                 len, 
+                                                 style);
+
+                                ren.blend_color_hspan(span_aa->x, 
+                                                      sl_aa.y(), 
+                                                      span_aa->len,
+                                                      color_span,
+                                                      span_aa->covers);
+                                if(--num_spans == 0) break;
+                                ++span_aa;
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    int      sl_start = ras.scanline_start();
+                    unsigned sl_len   = ras.scanline_length();
 
-        //--------------------------------------------------------------------
-        void prepare(unsigned) {}
+                    if(sl_len)
+                    {
+                        memset(mix_buffer + sl_start - min_x, 
+                               0, 
+                               sl_len * sizeof(color_type));
+
+                        memset(cover_buffer + sl_start - min_x, 
+                               0, 
+                               sl_len * sizeof(cover_type));
+
+                        int sl_y = 0x7FFFFFFF;
+                        unsigned i;
+                        for(i = 0; i < num_styles; i++)
+                        {
+                            style = ras.style(i);
+                            solid = sh.is_solid(style);
+
+                            if(ras.sweep_scanline(sl_aa, i))
+                            {
+                                unsigned    cover;
+                                color_type* colors;
+                                color_type* cspan;
+                                cover_type* src_covers;
+                                cover_type* dst_covers;
+                                span_aa   = sl_aa.begin();
+                                num_spans = sl_aa.num_spans();
+                                sl_y      = sl_aa.y();
+                                if(solid)
+                                {
+                                    // Just solid fill
+                                    //-----------------------
+                                    for(;;)
+                                    {
+                                        color_type c = sh.color(style);
+                                        len    = span_aa->len;
+                                        colors = mix_buffer + span_aa->x - min_x;
+                                        src_covers = span_aa->covers;
+                                        dst_covers = cover_buffer + span_aa->x - min_x;
+                                        do
+                                        {
+                                            cover = *src_covers;
+                                            if(*dst_covers + cover > cover_full)
+                                            {
+                                                cover = cover_full - *dst_covers;
+                                            }
+                                            if(cover)
+                                            {
+                                                colors->add(c, cover);
+                                                *dst_covers += cover;
+                                            }
+                                            ++colors;
+                                            ++src_covers;
+                                            ++dst_covers;
+                                        }
+                                        while(--len);
+                                        if(--num_spans == 0) break;
+                                        ++span_aa;
+                                    }
+                                }
+                                else
+                                {
+                                    // Arbitrary span generator
+                                    //-----------------------
+                                    for(;;)
+                                    {
+                                        len = span_aa->len;
+                                        colors = mix_buffer + span_aa->x - min_x;
+                                        cspan  = color_span;
+                                        sh.generate_span(cspan, 
+                                                         span_aa->x, 
+                                                         sl_aa.y(), 
+                                                         len, 
+                                                         style);
+                                        src_covers = span_aa->covers;
+                                        dst_covers = cover_buffer + span_aa->x - min_x;
+                                        do
+                                        {
+                                            cover = *src_covers;
+                                            if(*dst_covers + cover > cover_full)
+                                            {
+                                                cover = cover_full - *dst_covers;
+                                            }
+                                            if(cover)
+                                            {
+                                                colors->add(*cspan, cover);
+                                                *dst_covers += cover;
+                                            }
+                                            ++cspan;
+                                            ++colors;
+                                            ++src_covers;
+                                            ++dst_covers;
+                                        }
+                                        while(--len);
+                                        if(--num_spans == 0) break;
+                                        ++span_aa;
+                                    }
+                                }
+                            }
+                        }
+                        ren.blend_color_hspan(sl_start, 
+                                              sl_y, 
+                                              sl_len,
+                                              mix_buffer + sl_start - min_x,
+                                              0,
+                                              cover_full);
+                    } //if(sl_len)
+                } //if(num_styles == 1) ... else
+            } //while((num_styles = ras.sweep_styles()) > 0)
+        } //if(ras.rewind_scanlines())
+    }
 
-        //--------------------------------------------------------------------
-        template<class Scanline> void render(const Scanline& sl)
-        {
-            unsigned num_spans = sl.num_spans();
-            typename Scanline::const_iterator span = sl.begin();
-            do
-            {
-                m_ren->blend_hline(span->x, 
-                                   sl.y(), 
-                                   span->x - 1 + ((span->len < 0) ? 
-                                                     -span->len : 
-                                                      span->len), 
-                                   m_color, 
-                                   cover_full);
-                ++span;
-            }
-            while(--num_spans);
-        }
-        
-    private:
-        base_ren_type* m_ren;
-        color_type m_color;
-    };
 
 }
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer.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 
@@ -20,119 +20,222 @@
 #ifndef AGG_RENDERING_BUFFER_INCLUDED
 #define AGG_RENDERING_BUFFER_INCLUDED
 
-#include "agg_basics.h"
+#include "agg_array.h"
 
 namespace agg
 {
 
-    //==========================================================row_ptr_cache
-    template<class T> class row_ptr_cache
+    //===========================================================row_accessor
+    template<class T> class row_accessor
     {
     public:
+        typedef const_row_info<T> row_data;
+
+        //-------------------------------------------------------------------
+        row_accessor() :
+            m_buf(0),
+            m_start(0),
+            m_width(0),
+            m_height(0),
+            m_stride(0)
+        {
+        }
+
         //--------------------------------------------------------------------
-        struct row_data
+        row_accessor(T* buf, unsigned width, unsigned height, int stride) :
+            m_buf(0),
+            m_start(0),
+            m_width(0),
+            m_height(0),
+            m_stride(0)
         {
-            int x1, x2;
-            const int8u* ptr;
-            row_data() {}
-            row_data(int x1_, int x2_, const int8u* ptr_) : 
-                x1(x1_), x2(x2_), ptr(ptr_) {}
-        };
+            attach(buf, width, height, stride);
+        }
 
-        //-------------------------------------------------------------------
-        ~row_ptr_cache()
+
+        //--------------------------------------------------------------------
+        void attach(T* buf, unsigned width, unsigned height, int stride)
+        {
+			m_buf = m_start = buf;
+			m_width = width;
+			m_height = height;
+			m_stride = stride;
+			if(stride < 0) 
+            { 
+				m_start = m_buf - int(height - 1) * stride;
+			}
+        }
+
+        //--------------------------------------------------------------------
+        AGG_INLINE       T* buf()          { return m_buf;    }
+        AGG_INLINE const T* buf()    const { return m_buf;    }
+        AGG_INLINE unsigned width()  const { return m_width;  }
+        AGG_INLINE unsigned height() const { return m_height; }
+        AGG_INLINE int      stride() const { return m_stride; }
+        AGG_INLINE unsigned stride_abs() const 
+        {
+            return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride); 
+        }
+
+        //--------------------------------------------------------------------
+		AGG_INLINE       T* row_ptr(int, int y, unsigned) 
+        { 
+            return m_start + y * m_stride; 
+        }
+		AGG_INLINE       T* row_ptr(int y)       { return m_start + y * m_stride; }
+		AGG_INLINE const T* row_ptr(int y) const { return m_start + y * m_stride; }
+		AGG_INLINE row_data row    (int y) const 
+        { 
+            return row_data(0, m_width-1, row_ptr(y)); 
+        }
+
+        //--------------------------------------------------------------------
+        template<class RenBuf>
+        void copy_from(const RenBuf& src)
+        {
+            unsigned h = height();
+            if(src.height() < h) h = src.height();
+        
+            unsigned l = stride_abs();
+            if(src.stride_abs() < l) l = src.stride_abs();
+        
+            l *= sizeof(T);
+
+            unsigned y;
+            unsigned w = width();
+            for (y = 0; y < h; y++)
+            {
+                memcpy(row_ptr(0, y, w), src.row_ptr(y), l);
+            }
+        }
+
+        //--------------------------------------------------------------------
+        void clear(T value)
         {
-            delete [] m_rows;
+            unsigned y;
+            unsigned w = width();
+            unsigned stride = stride_abs();
+            for(y = 0; y < height(); y++)
+            {
+                T* p = row_ptr(0, y, w);
+                unsigned x;
+                for(x = 0; x < stride; x++)
+                {
+                    *p++ = value;
+                }
+            }
         }
 
+    private:
+        //--------------------------------------------------------------------
+        T*            m_buf;    // Pointer to renrdering buffer
+        T*            m_start;  // Pointer to first pixel depending on stride 
+        unsigned      m_width;  // Width in pixels
+        unsigned      m_height; // Height in pixels
+        int           m_stride; // Number of bytes per row. Can be < 0
+    };
+
+
+
+
+    //==========================================================row_ptr_cache
+    template<class T> class row_ptr_cache
+    {
+    public:
+        typedef const_row_info<T> row_data;
+
         //-------------------------------------------------------------------
         row_ptr_cache() :
             m_buf(0),
-            m_rows(0),
+            m_rows(),
             m_width(0),
             m_height(0),
-            m_stride(0),
-            m_max_height(0)
+            m_stride(0)
         {
         }
 
         //--------------------------------------------------------------------
-        row_ptr_cache(T* _buf, unsigned _width, unsigned _height, int _stride) :
+        row_ptr_cache(T* buf, unsigned width, unsigned height, int stride) :
             m_buf(0),
-            m_rows(0),
+            m_rows(),
             m_width(0),
             m_height(0),
-            m_stride(0),
-            m_max_height(0)
+            m_stride(0)
         {
-            attach(_buf, _width, _height, _stride);
+            attach(buf, width, height, stride);
         }
 
         //--------------------------------------------------------------------
-        void attach(T* _buf, unsigned _width, unsigned _height, int _stride)
+        void attach(T* buf, unsigned width, unsigned height, int stride)
         {
-            m_buf = _buf;
-            m_width = _width;
-            m_height = _height;
-            m_stride = _stride;
-            if(_height > m_max_height)
+            m_buf = buf;
+            m_width = width;
+            m_height = height;
+            m_stride = stride;
+            if(height > m_rows.size())
             {
-                delete [] m_rows;
-                m_rows = new T* [m_max_height = _height];
+                m_rows.resize(height);
             }
 
             T* row_ptr = m_buf;
 
-            if(_stride < 0)
+            if(stride < 0)
             {
-                row_ptr = m_buf - int(_height - 1) * _stride;
+                row_ptr = m_buf - int(height - 1) * stride;
             }
 
-            T** _rows = m_rows;
+            T** rows = &m_rows[0];
 
-            while(_height--)
+            while(height--)
             {
-                *_rows++ = row_ptr;
-                row_ptr += _stride;
+                *rows++ = row_ptr;
+                row_ptr += stride;
             }
         }
 
         //--------------------------------------------------------------------
-        const T* buf()    const { return m_buf;    }
-        unsigned width()  const { return m_width;  }
-        unsigned height() const { return m_height; }
-        int      stride() const { return m_stride; }
-        unsigned stride_abs() const 
+        AGG_INLINE       T* buf()          { return m_buf;    }
+        AGG_INLINE const T* buf()    const { return m_buf;    }
+        AGG_INLINE unsigned width()  const { return m_width;  }
+        AGG_INLINE unsigned height() const { return m_height; }
+        AGG_INLINE int      stride() const { return m_stride; }
+        AGG_INLINE unsigned stride_abs() const 
         {
-            return (m_stride < 0) ? 
-                unsigned(-m_stride) : 
-                unsigned(m_stride); 
+            return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride); 
         }
 
         //--------------------------------------------------------------------
-        T* row(unsigned y) { return m_rows[y]; }
-        const T* row(unsigned y) const { return m_rows[y]; }
-
-        T* next_row(void* p) { return (T*)p + m_stride; }
-        const T* next_row(const void* p) const { return (T*)p + m_stride; }
+        AGG_INLINE       T* row_ptr(int, int y, unsigned) 
+        { 
+            return m_rows[y]; 
+        }
+        AGG_INLINE       T* row_ptr(int y)       { return m_rows[y]; }
+        AGG_INLINE const T* row_ptr(int y) const { return m_rows[y]; }
+        AGG_INLINE row_data row    (int y) const 
+        { 
+            return row_data(0, m_width-1, m_rows[y]); 
+        }
 
-        T const* const* rows() const { return m_rows; }
+        //--------------------------------------------------------------------
+        T const* const* rows() const { return &m_rows[0]; }
 
         //--------------------------------------------------------------------
-        void copy_from(const row_ptr_cache<T>& mtx)
+        template<class RenBuf>
+        void copy_from(const RenBuf& src)
         {
             unsigned h = height();
-            if(mtx.height() < h) h = mtx.height();
+            if(src.height() < h) h = src.height();
         
             unsigned l = stride_abs();
-            if(mtx.stride_abs() < l) l = mtx.stride_abs();
+            if(src.stride_abs() < l) l = src.stride_abs();
         
             l *= sizeof(T);
 
             unsigned y;
+            unsigned w = width();
             for (y = 0; y < h; y++)
             {
-                memcpy(row(y), mtx.row(y), l);
+                memcpy(row_ptr(0, y, w), src.row_ptr(y), l);
             }
         }
 
@@ -140,38 +243,56 @@ namespace agg
         void clear(T value)
         {
             unsigned y;
+            unsigned w = width();
+            unsigned stride = stride_abs();
             for(y = 0; y < height(); y++)
             {
-                T* p = row(y);
+                T* p = row_ptr(0, y, w);
                 unsigned x;
-                for(x = 0; x < stride_abs(); x++)
+                for(x = 0; x < stride; x++)
                 {
                     *p++ = value;
                 }
             }
         }
 
-
     private:
         //--------------------------------------------------------------------
-        // Prohibit copying
-        row_ptr_cache(const row_ptr_cache<T>&);
-        const row_ptr_cache<T>& operator = (const row_ptr_cache<T>&);
-
-    private:
-        //--------------------------------------------------------------------
-        T*       m_buf;        // Pointer to renrdering buffer
-        T**      m_rows;       // Pointers to each row of the buffer
-        unsigned m_width;      // Width in pixels
-        unsigned m_height;     // Height in pixels
-        int      m_stride;     // Number of bytes per row. Can be < 0
-        unsigned m_max_height; // The maximal height (currently allocated)
+        T*            m_buf;        // Pointer to renrdering buffer
+        pod_array<T*> m_rows;       // Pointers to each row of the buffer
+        unsigned      m_width;      // Width in pixels
+        unsigned      m_height;     // Height in pixels
+        int           m_stride;     // Number of bytes per row. Can be < 0
     };
 
 
 
+
     //========================================================rendering_buffer
-    typedef row_ptr_cache<int8u> rendering_buffer;
+    // 
+    // The definition of the main type for accessing the rows in the frame 
+    // buffer. It provides functionality to navigate to the rows in a 
+    // rectangular matrix, from top to bottom or from bottom to top depending 
+    // on stride.
+    //
+    // row_accessor is cheap to create/destroy, but performs one multiplication
+    // when calling row_ptr().
+    // 
+    // row_ptr_cache creates an array of pointers to rows, so, the access 
+    // via row_ptr() may be faster. But it requires memory allocation 
+    // when creating. For example, on typical Intel Pentium hardware 
+    // row_ptr_cache speeds span_image_filter_rgb_nn up to 10%
+    //
+    // It's used only in short hand typedefs like pixfmt_rgba32 and can be 
+    // redefined in agg_config.h
+    // In real applications you can use both, depending on your needs
+    //------------------------------------------------------------------------
+#ifdef AGG_RENDERING_BUFFER
+    typedef AGG_RENDERING_BUFFER rendering_buffer;
+#else
+//  typedef row_ptr_cache<int8u> rendering_buffer;
+    typedef row_accessor<int8u> rendering_buffer;
+#endif
 
 }
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer_dynarow.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer_dynarow.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer_dynarow.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer_dynarow.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 
@@ -20,7 +20,7 @@
 #ifndef AGG_RENDERING_BUFFER_DYNAROW_INCLUDED
 #define AGG_RENDERING_BUFFER_DYNAROW_INCLUDED
 
-#include "agg_basics.h"
+#include "agg_array.h"
 
 namespace agg
 {
@@ -32,110 +32,68 @@ namespace agg
     // Generally it's more efficient to use this class as a temporary buffer
     // for rendering a few lines and then to blend it with another buffer.
     //
-    template<unsigned PixWidth> class rendering_buffer_dynarow
+    class rendering_buffer_dynarow
     {
     public:
-        //-------------------------------------------------------------------
-        struct row_data
-        {
-            int8u*   ptr;
-            int      x1;
-            int      x2;
-        };
+        typedef row_info<int8u> row_data;
 
         //-------------------------------------------------------------------
         ~rendering_buffer_dynarow()
         {
-            init(0,0);
+            init(0,0,0);
         }
 
         //-------------------------------------------------------------------
         rendering_buffer_dynarow() :
-            m_rows(0),
+            m_rows(),
             m_width(0),
-            m_height(0)
+            m_height(0),
+            m_byte_width(0)
         {
         }
 
         // Allocate and clear the buffer
         //--------------------------------------------------------------------
-        rendering_buffer_dynarow(unsigned width, unsigned height) :
-            m_rows(new row_data[height]),
+        rendering_buffer_dynarow(unsigned width, unsigned height, 
+                                 unsigned byte_width) :
+            m_rows(height),
             m_width(width),
-            m_height(height)
+            m_height(height),
+            m_byte_width(byte_width)
         {
-            memset(m_rows, 0, sizeof(row_data) * height);
+            memset(&m_rows[0], 0, sizeof(row_data) * height);
         }
 
         // Allocate and clear the buffer
         //--------------------------------------------------------------------
-        void init(unsigned width, unsigned height)
+        void init(unsigned width, unsigned height, unsigned byte_width)
         {
             unsigned i;
-            for(i = 0; i < m_height; ++i) delete [] m_rows[i].ptr;
-            delete [] m_rows;
-            m_rows = 0;
+            for(i = 0; i < m_height; ++i) 
+            {
+                pod_allocator<int8u>::deallocate((int8u*)m_rows[i].ptr, m_byte_width);
+            }
             if(width && height)
             {
                 m_width  = width;
                 m_height = height;
-                m_rows = new row_data[height];
-                memset(m_rows, 0, sizeof(row_data) * height);
+                m_byte_width = byte_width;
+                m_rows.resize(height);
+                memset(&m_rows[0], 0, sizeof(row_data) * height);
             }
         }
 
         //--------------------------------------------------------------------
-        unsigned width()  const { return m_width;  }
-        unsigned height() const { return m_height; }
-
-        // Get pointer to the beginning of the row. Memory for the row
-        // is allocated as needed.
-        //--------------------------------------------------------------------
-        int8u* row(int y)
-        {
-            row_data* r = m_rows + y;
-            if(r->ptr == 0)
-            {
-                r->ptr = new int8u [m_width * PixWidth];
-                memset(r->ptr, 0, m_width * PixWidth);
-            }
-            return r->ptr;
-        }
-
-        // Get const pointer to the row. The caller must check it for null.
-        //--------------------------------------------------------------------
-        const int8u* row(int y) const
-        {
-            return m_rows[y].ptr;
-        }
-
-        // Get the Y-th span. The pointer r.ptr is automatically adjusted
-        // to the actual beginning of the span. Use this function as follows:
-        //
-        // rendering_buffer_dynarow::row_data r = rbuf.span(x, y);
-        // if(r.ptr)
-        // {
-        //    do { blend(r.ptr); r.ptr += PixWidth } while(++r.x1 < r.x2);
-        // }
-        //--------------------------------------------------------------------
-        row_data span(int x, int y) const 
-        { 
-            row_data r = m_rows[y];
-            if(r.ptr)
-            {
-                if(x < r.x1) x = r.x1;
-                r.ptr += x * PixWidth;
-            }
-            return r; 
-        }
-
+        unsigned width()      const { return m_width;  }
+        unsigned height()     const { return m_height; }
+        unsigned byte_width() const { return m_byte_width; }
 
         // The main function used for rendering. Returns pointer to the 
         // pre-allocated span. Memory for the row is allocated as needed.
         //--------------------------------------------------------------------
-        int8u* span_ptr(int x, int y, unsigned len)
+        int8u* row_ptr(int x, int y, unsigned len)
         {
-            row_data* r = m_rows + y;
+            row_data* r = &m_rows[y];
             int x2 = x + len - 1;
             if(r->ptr)
             {
@@ -144,37 +102,32 @@ namespace agg
             }
             else
             {
-                r->ptr = new int8u [m_width * PixWidth];
-                r->x1 = x;
-                r->x2 = x2;
-                memset(r->ptr, 0, m_width * PixWidth);
+                int8u* p = pod_allocator<int8u>::allocate(m_byte_width);
+                r->ptr = p;
+                r->x1  = x;
+                r->x2  = x2;
+                memset(p, 0, m_byte_width);
             }
-            return r->ptr + x * PixWidth;
+            return (int8u*)r->ptr;
         }
 
-        // Get const pointer to the span. Used mostly in GetPixel function
-        // The caller must check the returned pointer for null.
         //--------------------------------------------------------------------
-        const int8u* span_ptr(int x, int y, unsigned) const
-        {
-            row_data* r = m_rows + y;
-            return r->ptr ? r->ptr + x * PixWidth : 0;
-        }
-
-
+        const int8u* row_ptr(int y) const { return m_rows[y].ptr; }
+              int8u* row_ptr(int y)       { return row_ptr(0, y, m_width); }
+        row_data     row    (int y) const { return m_rows[y]; }
 
     private:
         //--------------------------------------------------------------------
         // Prohibit copying
-        rendering_buffer_dynarow(const rendering_buffer_dynarow<PixWidth>&);
-        const rendering_buffer_dynarow<PixWidth>& 
-            operator = (const rendering_buffer_dynarow<PixWidth>&);
+        rendering_buffer_dynarow(const rendering_buffer_dynarow&);
+        const rendering_buffer_dynarow& operator = (const rendering_buffer_dynarow&);
 
     private:
         //--------------------------------------------------------------------
-        row_data* m_rows;       // Pointers to each row of the buffer
-        unsigned  m_width;      // Width in pixels
-        unsigned  m_height;     // Height in pixels
+        pod_array<row_data> m_rows;       // Pointers to each row of the buffer
+        unsigned            m_width;      // Width in pixels
+        unsigned            m_height;     // Height in pixels
+        unsigned            m_byte_width; // Width in bytes
     };
 
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_rounded_rect.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_rounded_rect.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_rounded_rect.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_rounded_rect.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,8 +22,6 @@
 
 #include "agg_basics.h"
 #include "agg_arc.h"
-#include "agg_vertex_iterator.h"
-
 
 namespace agg
 {
@@ -51,11 +49,6 @@ namespace agg
         void rewind(unsigned);
         unsigned vertex(double* x, double* y);
 
-        typedef rounded_rect source_type;
-        typedef vertex_iterator<source_type> iterator;
-        iterator begin(unsigned id) { return iterator(*this, id); }
-        iterator end() { return iterator(path_cmd_stop); }
-
     private:
         double m_x1;
         double m_y1;

Modified: incubator/ooo/trunk/main/agg/inc/agg_scanline_bin.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_scanline_bin.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_scanline_bin.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_scanline_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 
@@ -16,10 +16,19 @@
 // Class scanline_bin - binary scanline.
 //
 //----------------------------------------------------------------------------
+//
+// Adaptation for 32-bit screen coordinates (scanline32_bin) 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_BIN_INCLUDED
 #define AGG_SCANLINE_BIN_INCLUDED
 
-#include "agg_basics.h"
+#include "agg_array.h"
 
 namespace agg
 {
@@ -30,36 +39,12 @@ namespace agg
     // used in the rasterizer::render(). See description of agg_scanline_u8 
     // for details.
     // 
-    // Rendering:
-    //-------------------------------------------------------------------------
-    //  
-    //  int y = sl.y();
-    //  
-    // ************************************
-    // ...Perform vertical clipping here...
-    // ************************************
-    //
-    //  unsigned num_spans = sl.num_spans();
-    //  const agg::scanline_bin::span* cur_span = sl.spans();
-    //
-    //  do
-    //  {
-    //      x = cur_span->x;
-    //      len = cur_span->len;
-    // 
-    //      **************************************
-    //      ...Perform horizontal clipping here...
-    //      **************************************
-    //      
-    //      hor_line(x, y, len)
-    //      ++cur_span;
-    //  }
-    //  while(--num_spans);
-    // 
     //------------------------------------------------------------------------
     class scanline_bin
     {
     public:
+        typedef int32 coord_type;
+
         struct span
         {
             int16 x;
@@ -68,103 +53,211 @@ namespace agg
 
         typedef const span* const_iterator;
 
-        ~scanline_bin()
+        //--------------------------------------------------------------------
+        scanline_bin() :
+            m_last_x(0x7FFFFFF0),
+            m_spans(),
+            m_cur_span(0)
+        {
+        }
+
+        //--------------------------------------------------------------------
+        void reset(int min_x, int max_x)
         {
-            delete [] m_spans;
+            unsigned max_len = max_x - min_x + 3;
+            if(max_len > m_spans.size())
+            {
+                m_spans.resize(max_len);
+            }
+            m_last_x   = 0x7FFFFFF0;
+            m_cur_span = &m_spans[0];
         }
 
-        scanline_bin() :
-            m_max_len(0),
-            m_last_x(0x7FFF),
-            m_spans(0),
-            m_cur_span(0)
+        //--------------------------------------------------------------------
+        void add_cell(int x, unsigned)
         {
+            if(x == m_last_x+1)
+            {
+                m_cur_span->len++;
+            }
+            else
+            {
+                ++m_cur_span;
+                m_cur_span->x = (int16)x;
+                m_cur_span->len = 1;
+            }
+            m_last_x = x;
         }
 
-        void reset(int min_x, int max_x);
-        void add_cell(int x, unsigned);
-        void add_cells(int x, unsigned len, const void*);
-        void add_span(int x, unsigned len, unsigned);
-        void finalize(int y) { m_y = y; }
-        void reset_spans();
+        //--------------------------------------------------------------------
+        void add_span(int x, unsigned len, unsigned)
+        {
+            if(x == m_last_x+1)
+            {
+                m_cur_span->len = (int16)(m_cur_span->len + len);
+            }
+            else
+            {
+                ++m_cur_span;
+                m_cur_span->x = (int16)x;
+                m_cur_span->len = (int16)len;
+            }
+            m_last_x = x + len - 1;
+        }
 
+        //--------------------------------------------------------------------
+        void add_cells(int x, unsigned len, const void*)
+        {
+            add_span(x, len, 0);
+        }
+
+        //--------------------------------------------------------------------
+        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; }
+        unsigned       num_spans() const { return unsigned(m_cur_span - &m_spans[0]); }
+        const_iterator begin()     const { return &m_spans[1]; }
 
     private:
         scanline_bin(const scanline_bin&);
         const scanline_bin operator = (const scanline_bin&);
 
-        unsigned  m_max_len;
-        int       m_last_x;
-        int       m_y;
-        span*     m_spans;
-        span*     m_cur_span;
+        int             m_last_x;
+        int             m_y;
+        pod_array<span> m_spans;
+        span*           m_cur_span;
     };
 
 
-    //------------------------------------------------------------------------
-    inline void scanline_bin::reset(int min_x, int max_x)
+
+
+
+
+    //===========================================================scanline32_bin
+    class scanline32_bin
     {
-        unsigned max_len = max_x - min_x + 3;
-        if(max_len > m_max_len)
+    public:
+        typedef int32 coord_type;
+
+        //--------------------------------------------------------------------
+        struct span
         {
-            delete [] m_spans;
-            m_spans   = new span [max_len];
-            m_max_len = max_len;
-        }
-        m_last_x    = 0x7FFF;
-        m_cur_span  = m_spans;
-    }
+            span() {}
+            span(coord_type x_, coord_type len_) : x(x_), len(len_) {}
 
+            coord_type x;
+            coord_type len;
+        };
+        typedef pod_bvector<span, 4> span_array_type;
 
-    //------------------------------------------------------------------------
-    inline void scanline_bin::reset_spans()
-    {
-        m_last_x    = 0x7FFF;
-        m_cur_span  = m_spans;
-    }
 
+        //--------------------------------------------------------------------
+        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;
+        };
 
-    //------------------------------------------------------------------------
-    inline void scanline_bin::add_cell(int x, unsigned)
-    {
-        if(x == m_last_x+1)
+
+        //--------------------------------------------------------------------
+        scanline32_bin() : m_max_len(0), m_last_x(0x7FFFFFF0) {}
+
+        //--------------------------------------------------------------------
+        void reset(int min_x, int max_x)
         {
-            m_cur_span->len++;
+            m_last_x = 0x7FFFFFF0;
+            m_spans.remove_all();
         }
-        else
+
+        //--------------------------------------------------------------------
+        void add_cell(int x, unsigned)
         {
-            ++m_cur_span;
-            m_cur_span->x = (int16)x;
-            m_cur_span->len = 1;
+            if(x == m_last_x+1)
+            {
+                m_spans.last().len++;
+            }
+            else
+            {
+                m_spans.add(span(coord_type(x), 1));
+            }
+            m_last_x = x;
         }
-        m_last_x = x;
-    }
 
+        //--------------------------------------------------------------------
+        void add_span(int x, unsigned len, unsigned)
+        {
+            if(x == m_last_x+1)
+            {
+                m_spans.last().len += coord_type(len);
+            }
+            else
+            {
+                m_spans.add(span(coord_type(x), coord_type(len)));
+            }
+            m_last_x = x + len - 1;
+        }
 
-    //------------------------------------------------------------------------
-    inline void scanline_bin::add_span(int x, unsigned len, unsigned)
-    {
-        if(x == m_last_x+1)
+        //--------------------------------------------------------------------
+        void add_cells(int x, unsigned len, const void*)
         {
-            m_cur_span->len = (int16)(m_cur_span->len + len);
+            add_span(x, len, 0);
         }
-        else
+
+        //--------------------------------------------------------------------
+        void finalize(int y) 
+        { 
+            m_y = y; 
+        }
+
+        //--------------------------------------------------------------------
+        void reset_spans()
         {
-            ++m_cur_span;
-            m_cur_span->x = (int16)x;
-            m_cur_span->len = (int16)len;
+            m_last_x = 0x7FFFFFF0;
+            m_spans.remove_all();
         }
-        m_last_x = x + len - 1;
-    }
 
-    //------------------------------------------------------------------------
-    inline void scanline_bin::add_cells(int x, unsigned len, const void*)
-    {
-        add_span(x, len, 0);
-    }
+        //--------------------------------------------------------------------
+        int            y()         const { return m_y; }
+        unsigned       num_spans() const { return m_spans.size(); }
+        const_iterator begin()     const { return const_iterator(m_spans); }
+
+    private:
+        scanline32_bin(const scanline32_bin&);
+        const scanline32_bin operator = (const scanline32_bin&);
+
+        unsigned        m_max_len;
+        int             m_last_x;
+        int             m_y;
+        span_array_type m_spans;
+    };
+
+
+
+
+
 }
 
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_scanline_boolean_algebra.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_scanline_boolean_algebra.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_scanline_boolean_algebra.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_scanline_boolean_algebra.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 
@@ -141,7 +141,7 @@ namespace agg
              unsigned CoverShift = cover_shift> 
     struct sbool_intersect_spans_aa
     {
-        enum
+        enum cover_scale_e
         {
             cover_shift = CoverShift,
             cover_size  = 1 << cover_shift,
@@ -253,7 +253,7 @@ namespace agg
              unsigned CoverShift = cover_shift> 
     struct sbool_unite_spans_aa
     {
-        enum
+        enum cover_scale_e
         {
             cover_shift = CoverShift,
             cover_size  = 1 << cover_shift,
@@ -362,7 +362,7 @@ namespace agg
     template<unsigned CoverShift = cover_shift> 
     struct sbool_xor_formula_linear
     {
-        enum
+        enum cover_scale_e
         {
             cover_shift = CoverShift,
             cover_size  = 1 << cover_shift,
@@ -382,7 +382,7 @@ namespace agg
     template<unsigned CoverShift = cover_shift> 
     struct sbool_xor_formula_saddle
     {
-        enum
+        enum cover_scale_e
         {
             cover_shift = CoverShift,
             cover_size  = 1 << cover_shift,
@@ -424,7 +424,7 @@ namespace agg
              unsigned CoverShift = cover_shift> 
     struct sbool_xor_spans_aa
     {
-        enum
+        enum cover_scale_e
         {
             cover_shift = CoverShift,
             cover_size  = 1 << cover_shift,
@@ -513,7 +513,7 @@ namespace agg
              unsigned CoverShift = cover_shift> 
     struct sbool_subtract_spans_aa
     {
-        enum
+        enum cover_scale_e
         {
             cover_shift = CoverShift,
             cover_size  = 1 << cover_shift,
@@ -629,14 +629,14 @@ namespace agg
                                     AddSpanFunctor add_span)
     {
         sl.reset_spans();
-        typename Scanline::const_iterator span = sl1.begin();
+        typename Scanline1::const_iterator span = sl1.begin();
         unsigned num_spans = sl1.num_spans();
-        do
+        for(;;)
         {
             add_span(span, span->x, abs((int)span->len), sl);
+            if(--num_spans == 0) break;
             ++span;
         }
-        while(--num_spans);
         sl.finalize(sl1.y());
         ren.render(sl);
     }
@@ -671,8 +671,8 @@ namespace agg
         unsigned num2 = sl2.num_spans();
         if(num2 == 0) return;
 
-        typename Scanline::const_iterator span1 = sl1.begin();
-        typename Scanline::const_iterator span2 = sl2.begin();
+        typename Scanline1::const_iterator span1 = sl1.begin();
+        typename Scanline2::const_iterator span2 = sl2.begin();
 
         while(num1 && num2)
         {
@@ -705,20 +705,20 @@ namespace agg
             {
                 --num1;
                 --num2;
-                ++span1;
-                ++span2;
+                if(num1) ++span1;
+                if(num2) ++span2;
             }
             else
             {
                 if(advance_span1)
                 {
                     --num1;
-                    ++span1;
+                    if(num1) ++span1;
                 }
                 else
                 {
                     --num2;
-                    ++span2;
+                    if(num2) ++span2;
                 }
             }
         }
@@ -765,13 +765,13 @@ namespace agg
 
         // Get the bounding boxes
         //----------------
-        rect r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y());
-        rect r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y());
+        rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y());
+        rect_i r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y());
 
         // Calculate the intersection of the bounding 
         // boxes and return if they don't intersect.
         //-----------------
-        rect ir = intersect_rectangles(r1, r2);
+        rect_i ir = intersect_rectangles(r1, r2);
         if(!ir.is_valid()) return;
 
         // Reset the scanlines and get two first ones
@@ -782,7 +782,7 @@ namespace agg
         if(!sg1.sweep_scanline(sl1)) return;
         if(!sg2.sweep_scanline(sl2)) return;
 
-        ren.prepare(unsigned(ir.x2 - ir.x1 + 2));
+        ren.prepare();
 
         // The main loop
         // Here we synchronize the scanlines with 
@@ -850,10 +850,14 @@ namespace agg
         unsigned num1 = sl1.num_spans();
         unsigned num2 = sl2.num_spans();
 
-        typename Scanline::const_iterator span1;
-        typename Scanline::const_iterator span2;
+        typename Scanline1::const_iterator span1;// = sl1.begin();
+        typename Scanline2::const_iterator span2;// = sl2.begin();
 
-        enum { invalid_b = 0xFFFFFFF, invalid_e = invalid_b - 1 };
+        enum invalidation_e 
+        { 
+            invalid_b = 0xFFFFFFF, 
+            invalid_e = invalid_b - 1 
+        };
 
         // Initialize the spans as invalid
         //---------------
@@ -1037,15 +1041,19 @@ namespace agg
 
         // Get the bounding boxes
         //----------------
-        rect r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y());
-        rect r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y());
+        rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y());
+        rect_i r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y());
 
         // Calculate the union of the bounding boxes
         //-----------------
-        rect ur = unite_rectangles(r1, r2);
+        rect_i ur(1,1,0,0);
+             if(flag1 && flag2) ur = unite_rectangles(r1, r2);
+        else if(flag1)          ur = r1;
+        else if(flag2)          ur = r2;
+
         if(!ur.is_valid()) return;
 
-        ren.prepare(unsigned(ur.x2 - ur.x2 + 2));
+        ren.prepare();
 
         // Reset the scanlines and get two first ones
         //-----------------
@@ -1158,7 +1166,7 @@ namespace agg
 
         // Get the bounding box
         //----------------
-        rect r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y());
+        rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y());
 
         // Reset the scanlines and get two first ones
         //-----------------
@@ -1169,10 +1177,10 @@ namespace agg
 
         if(flag2) flag2 = sg2.sweep_scanline(sl2);
 
-        ren.prepare(unsigned(sg1.max_x() - sg1.min_x() + 2));
+        ren.prepare();
 
         // A fake span2 processor
-        sbool_add_span_empty<Scanline1, Scanline> add_span2;
+        sbool_add_span_empty<Scanline2, Scanline> add_span2;
 
         // The main loop
         // Here we synchronize the scanlines with 



Mime
View raw message