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 [1/17] - in /incubator/ooo/trunk/main: ./ agg/inc/ agg/source/ solenv/config/
Date Sun, 16 Oct 2011 04:13:21 GMT
Author: pfg
Date: Sun Oct 16 04:13:16 2011
New Revision: 1184758

URL: http://svn.apache.org/viewvc?rev=1184758&view=rev
Log:
i118508 - Update Anti-Grain Geometry (AGG) to version 2.4. Disable in configure since this is not really used by anything.

Added:
    incubator/ooo/trunk/main/agg/inc/agg_image_accessors.h
    incubator/ooo/trunk/main/agg/inc/agg_path_length.h
    incubator/ooo/trunk/main/agg/inc/agg_rasterizer_cells_aa.h
    incubator/ooo/trunk/main/agg/inc/agg_rasterizer_compound_aa.h
    incubator/ooo/trunk/main/agg/inc/agg_rasterizer_sl_clip.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern_gray.h
Removed:
    incubator/ooo/trunk/main/agg/inc/agg_render_scanlines.h
    incubator/ooo/trunk/main/agg/inc/agg_span_generator.h
    incubator/ooo/trunk/main/agg/inc/agg_span_image_resample.h
    incubator/ooo/trunk/main/agg/inc/agg_span_image_resample_gray.h
    incubator/ooo/trunk/main/agg/inc/agg_span_image_resample_rgb.h
    incubator/ooo/trunk/main/agg/inc/agg_span_image_resample_rgba.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern_filter_gray.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern_filter_rgb.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern_filter_rgba.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern_resample_gray.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern_resample_rgb.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern_resample_rgba.h
    incubator/ooo/trunk/main/agg/source/agg_path_storage.cpp
    incubator/ooo/trunk/main/agg/source/agg_rasterizer_scanline_aa.cpp
Modified:
    incubator/ooo/trunk/main/agg/inc/agg_alpha_mask_u8.h
    incubator/ooo/trunk/main/agg/inc/agg_arc.h
    incubator/ooo/trunk/main/agg/inc/agg_array.h
    incubator/ooo/trunk/main/agg/inc/agg_arrowhead.h
    incubator/ooo/trunk/main/agg/inc/agg_basics.h
    incubator/ooo/trunk/main/agg/inc/agg_bezier_arc.h
    incubator/ooo/trunk/main/agg/inc/agg_bitset_iterator.h
    incubator/ooo/trunk/main/agg/inc/agg_bounding_rect.h
    incubator/ooo/trunk/main/agg/inc/agg_bspline.h
    incubator/ooo/trunk/main/agg/inc/agg_clip_liang_barsky.h
    incubator/ooo/trunk/main/agg/inc/agg_color_gray.h
    incubator/ooo/trunk/main/agg/inc/agg_color_rgba.h
    incubator/ooo/trunk/main/agg/inc/agg_config.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_adaptor_vcgen.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_adaptor_vpgen.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_bspline.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_clip_polygon.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_clip_polyline.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_close_polygon.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_concat.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_contour.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_curve.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_dash.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_gpc.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_marker.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_marker_adaptor.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_segmentator.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_shorten_path.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_smooth_poly1.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_stroke.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_transform.h
    incubator/ooo/trunk/main/agg/inc/agg_conv_unclose_polygon.h
    incubator/ooo/trunk/main/agg/inc/agg_curves.h
    incubator/ooo/trunk/main/agg/inc/agg_dda_line.h
    incubator/ooo/trunk/main/agg/inc/agg_ellipse.h
    incubator/ooo/trunk/main/agg/inc/agg_ellipse_bresenham.h
    incubator/ooo/trunk/main/agg/inc/agg_embedded_raster_fonts.h
    incubator/ooo/trunk/main/agg/inc/agg_font_cache_manager.h
    incubator/ooo/trunk/main/agg/inc/agg_gamma_functions.h
    incubator/ooo/trunk/main/agg/inc/agg_gamma_lut.h
    incubator/ooo/trunk/main/agg/inc/agg_glyph_raster_bin.h
    incubator/ooo/trunk/main/agg/inc/agg_gsv_text.h
    incubator/ooo/trunk/main/agg/inc/agg_image_filters.h
    incubator/ooo/trunk/main/agg/inc/agg_line_aa_basics.h
    incubator/ooo/trunk/main/agg/inc/agg_math.h
    incubator/ooo/trunk/main/agg/inc/agg_math_stroke.h
    incubator/ooo/trunk/main/agg/inc/agg_path_storage.h
    incubator/ooo/trunk/main/agg/inc/agg_path_storage_integer.h
    incubator/ooo/trunk/main/agg/inc/agg_pattern_filters_rgba.h
    incubator/ooo/trunk/main/agg/inc/agg_pixfmt_amask_adaptor.h
    incubator/ooo/trunk/main/agg/inc/agg_pixfmt_gray.h
    incubator/ooo/trunk/main/agg/inc/agg_pixfmt_rgb.h
    incubator/ooo/trunk/main/agg/inc/agg_pixfmt_rgb_packed.h
    incubator/ooo/trunk/main/agg/inc/agg_pixfmt_rgba.h
    incubator/ooo/trunk/main/agg/inc/agg_rasterizer_outline.h
    incubator/ooo/trunk/main/agg/inc/agg_rasterizer_outline_aa.h
    incubator/ooo/trunk/main/agg/inc/agg_rasterizer_scanline_aa.h
    incubator/ooo/trunk/main/agg/inc/agg_renderer_base.h
    incubator/ooo/trunk/main/agg/inc/agg_renderer_markers.h
    incubator/ooo/trunk/main/agg/inc/agg_renderer_mclip.h
    incubator/ooo/trunk/main/agg/inc/agg_renderer_outline_aa.h
    incubator/ooo/trunk/main/agg/inc/agg_renderer_outline_image.h
    incubator/ooo/trunk/main/agg/inc/agg_renderer_primitives.h
    incubator/ooo/trunk/main/agg/inc/agg_renderer_raster_text.h
    incubator/ooo/trunk/main/agg/inc/agg_renderer_scanline.h
    incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer.h
    incubator/ooo/trunk/main/agg/inc/agg_rendering_buffer_dynarow.h
    incubator/ooo/trunk/main/agg/inc/agg_rounded_rect.h
    incubator/ooo/trunk/main/agg/inc/agg_scanline_bin.h
    incubator/ooo/trunk/main/agg/inc/agg_scanline_boolean_algebra.h
    incubator/ooo/trunk/main/agg/inc/agg_scanline_p.h
    incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_aa.h
    incubator/ooo/trunk/main/agg/inc/agg_scanline_storage_bin.h
    incubator/ooo/trunk/main/agg/inc/agg_scanline_u.h
    incubator/ooo/trunk/main/agg/inc/agg_shorten_path.h
    incubator/ooo/trunk/main/agg/inc/agg_simul_eq.h
    incubator/ooo/trunk/main/agg/inc/agg_span_allocator.h
    incubator/ooo/trunk/main/agg/inc/agg_span_converter.h
    incubator/ooo/trunk/main/agg/inc/agg_span_gouraud.h
    incubator/ooo/trunk/main/agg/inc/agg_span_gouraud_gray.h
    incubator/ooo/trunk/main/agg/inc/agg_span_gouraud_rgba.h
    incubator/ooo/trunk/main/agg/inc/agg_span_gradient.h
    incubator/ooo/trunk/main/agg/inc/agg_span_gradient_alpha.h
    incubator/ooo/trunk/main/agg/inc/agg_span_image_filter.h
    incubator/ooo/trunk/main/agg/inc/agg_span_image_filter_gray.h
    incubator/ooo/trunk/main/agg/inc/agg_span_image_filter_rgb.h
    incubator/ooo/trunk/main/agg/inc/agg_span_image_filter_rgba.h
    incubator/ooo/trunk/main/agg/inc/agg_span_interpolator_adaptor.h
    incubator/ooo/trunk/main/agg/inc/agg_span_interpolator_linear.h
    incubator/ooo/trunk/main/agg/inc/agg_span_interpolator_persp.h
    incubator/ooo/trunk/main/agg/inc/agg_span_interpolator_trans.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern_rgb.h
    incubator/ooo/trunk/main/agg/inc/agg_span_pattern_rgba.h
    incubator/ooo/trunk/main/agg/inc/agg_span_solid.h
    incubator/ooo/trunk/main/agg/inc/agg_span_subdiv_adaptor.h
    incubator/ooo/trunk/main/agg/inc/agg_trans_affine.h
    incubator/ooo/trunk/main/agg/inc/agg_trans_bilinear.h
    incubator/ooo/trunk/main/agg/inc/agg_trans_double_path.h
    incubator/ooo/trunk/main/agg/inc/agg_trans_perspective.h
    incubator/ooo/trunk/main/agg/inc/agg_trans_single_path.h
    incubator/ooo/trunk/main/agg/inc/agg_trans_viewport.h
    incubator/ooo/trunk/main/agg/inc/agg_trans_warp_magnifier.h
    incubator/ooo/trunk/main/agg/inc/agg_vcgen_bspline.h
    incubator/ooo/trunk/main/agg/inc/agg_vcgen_contour.h
    incubator/ooo/trunk/main/agg/inc/agg_vcgen_dash.h
    incubator/ooo/trunk/main/agg/inc/agg_vcgen_markers_term.h
    incubator/ooo/trunk/main/agg/inc/agg_vcgen_smooth_poly1.h
    incubator/ooo/trunk/main/agg/inc/agg_vcgen_stroke.h
    incubator/ooo/trunk/main/agg/inc/agg_vcgen_vertex_sequence.h
    incubator/ooo/trunk/main/agg/inc/agg_vertex_sequence.h
    incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polygon.h
    incubator/ooo/trunk/main/agg/inc/agg_vpgen_clip_polyline.h
    incubator/ooo/trunk/main/agg/inc/agg_vpgen_segmentator.h
    incubator/ooo/trunk/main/agg/source/agg_arc.cpp
    incubator/ooo/trunk/main/agg/source/agg_arrowhead.cpp
    incubator/ooo/trunk/main/agg/source/agg_bezier_arc.cpp
    incubator/ooo/trunk/main/agg/source/agg_bspline.cpp
    incubator/ooo/trunk/main/agg/source/agg_curves.cpp
    incubator/ooo/trunk/main/agg/source/agg_embedded_raster_fonts.cpp
    incubator/ooo/trunk/main/agg/source/agg_gsv_text.cpp
    incubator/ooo/trunk/main/agg/source/agg_image_filters.cpp
    incubator/ooo/trunk/main/agg/source/agg_line_aa_basics.cpp
    incubator/ooo/trunk/main/agg/source/agg_line_profile_aa.cpp
    incubator/ooo/trunk/main/agg/source/agg_rounded_rect.cpp
    incubator/ooo/trunk/main/agg/source/agg_sqrt_tables.cpp
    incubator/ooo/trunk/main/agg/source/agg_trans_affine.cpp
    incubator/ooo/trunk/main/agg/source/agg_trans_double_path.cpp
    incubator/ooo/trunk/main/agg/source/agg_trans_single_path.cpp
    incubator/ooo/trunk/main/agg/source/agg_trans_warp_magnifier.cpp
    incubator/ooo/trunk/main/agg/source/agg_vcgen_bspline.cpp
    incubator/ooo/trunk/main/agg/source/agg_vcgen_contour.cpp
    incubator/ooo/trunk/main/agg/source/agg_vcgen_dash.cpp
    incubator/ooo/trunk/main/agg/source/agg_vcgen_markers_term.cpp
    incubator/ooo/trunk/main/agg/source/agg_vcgen_smooth_poly1.cpp
    incubator/ooo/trunk/main/agg/source/agg_vcgen_stroke.cpp
    incubator/ooo/trunk/main/agg/source/agg_vpgen_clip_polygon.cpp
    incubator/ooo/trunk/main/agg/source/agg_vpgen_clip_polyline.cpp
    incubator/ooo/trunk/main/agg/source/agg_vpgen_segmentator.cpp
    incubator/ooo/trunk/main/agg/source/makefile.mk
    incubator/ooo/trunk/main/configure.in
    incubator/ooo/trunk/main/solenv/config/sooo340.ini

Modified: incubator/ooo/trunk/main/agg/inc/agg_alpha_mask_u8.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_alpha_mask_u8.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_alpha_mask_u8.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_alpha_mask_u8.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 
@@ -49,7 +49,7 @@ namespace agg
     public:
         typedef int8u cover_type;
         typedef alpha_mask_u8<Step, Offset, MaskF> self_type;
-        enum 
+        enum cover_scale_e
         { 
             cover_shift = 8,
             cover_none  = 0,
@@ -57,7 +57,7 @@ namespace agg
         };
 
         alpha_mask_u8() : m_rbuf(0) {}
-        alpha_mask_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {}
+        explicit alpha_mask_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {}
 
         void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; }
 
@@ -70,10 +70,10 @@ namespace agg
         {
             if(x >= 0 && y >= 0 && 
                x < (int)m_rbuf->width() && 
-               y <= (int)m_rbuf->height())
+               y < (int)m_rbuf->height())
             {
                 return (cover_type)m_mask_function.calculate(
-                                        m_rbuf->row(y) + x * Step + Offset);
+                                        m_rbuf->row_ptr(y) + x * Step + Offset);
             }
             return 0;
         }
@@ -83,11 +83,11 @@ namespace agg
         {
             if(x >= 0 && y >= 0 && 
                x < (int)m_rbuf->width() && 
-               y <= (int)m_rbuf->height())
+               y < (int)m_rbuf->height())
             {
-                return (cover_type)((val * 
+                return (cover_type)((cover_full + val * 
                                      m_mask_function.calculate(
-                                        m_rbuf->row(y) + x * Step + Offset)) >> 
+                                        m_rbuf->row_ptr(y) + x * Step + Offset)) >> 
                                      cover_shift);
             }
             return 0;
@@ -134,7 +134,7 @@ namespace agg
                 memset(covers + count, 0, rest * sizeof(cover_type));
             }
 
-            const int8u* mask = m_rbuf->row(y) + x * Step + Offset;
+            const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
             do
             {
                 *covers++ = (cover_type)m_mask_function.calculate(mask);
@@ -184,10 +184,10 @@ namespace agg
                 memset(covers + count, 0, rest * sizeof(cover_type));
             }
 
-            const int8u* mask = m_rbuf->row(y) + x * Step + Offset;
+            const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
             do
             {
-                *covers = (cover_type)(((*covers) * 
+                *covers = (cover_type)((cover_full + (*covers) * 
                                        m_mask_function.calculate(mask)) >> 
                                        cover_shift);
                 ++covers;
@@ -236,7 +236,7 @@ namespace agg
                 memset(covers + count, 0, rest * sizeof(cover_type));
             }
 
-            const int8u* mask = m_rbuf->row(y) + x * Step + Offset;
+            const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
             do
             {
                 *covers++ = (cover_type)m_mask_function.calculate(mask);
@@ -285,10 +285,10 @@ namespace agg
                 memset(covers + count, 0, rest * sizeof(cover_type));
             }
 
-            const int8u* mask = m_rbuf->row(y) + x * Step + Offset;
+            const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
             do
             {
-                *covers = (cover_type)(((*covers) * 
+                *covers = (cover_type)((cover_full + (*covers) * 
                                        m_mask_function.calculate(mask)) >> 
                                        cover_shift);
                 ++covers;
@@ -353,7 +353,7 @@ namespace agg
     public:
         typedef int8u cover_type;
         typedef amask_no_clip_u8<Step, Offset, MaskF> self_type;
-        enum 
+        enum cover_scale_e
         { 
             cover_shift = 8,
             cover_none  = 0,
@@ -361,7 +361,7 @@ namespace agg
         };
 
         amask_no_clip_u8() : m_rbuf(0) {}
-        amask_no_clip_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {}
+        explicit amask_no_clip_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {}
 
         void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; }
 
@@ -373,16 +373,16 @@ namespace agg
         cover_type pixel(int x, int y) const
         {
             return (cover_type)m_mask_function.calculate(
-                                   m_rbuf->row(y) + x * Step + Offset);
+                                   m_rbuf->row_ptr(y) + x * Step + Offset);
         }
 
         
         //--------------------------------------------------------------------
         cover_type combine_pixel(int x, int y, cover_type val) const
         {
-            return (cover_type)((val * 
+            return (cover_type)((cover_full + val * 
                                  m_mask_function.calculate(
-                                    m_rbuf->row(y) + x * Step + Offset)) >> 
+                                    m_rbuf->row_ptr(y) + x * Step + Offset)) >> 
                                  cover_shift);
         }
 
@@ -390,7 +390,7 @@ namespace agg
         //--------------------------------------------------------------------
         void fill_hspan(int x, int y, cover_type* dst, int num_pix) const
         {
-            const int8u* mask = m_rbuf->row(y) + x * Step + Offset;
+            const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
             do
             {
                 *dst++ = (cover_type)m_mask_function.calculate(mask);
@@ -404,10 +404,10 @@ namespace agg
         //--------------------------------------------------------------------
         void combine_hspan(int x, int y, cover_type* dst, int num_pix) const
         {
-            const int8u* mask = m_rbuf->row(y) + x * Step + Offset;
+            const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
             do
             {
-                *dst = (cover_type)(((*dst) * 
+                *dst = (cover_type)((cover_full + (*dst) * 
                                     m_mask_function.calculate(mask)) >> 
                                     cover_shift);
                 ++dst;
@@ -420,7 +420,7 @@ namespace agg
         //--------------------------------------------------------------------
         void fill_vspan(int x, int y, cover_type* dst, int num_pix) const
         {
-            const int8u* mask = m_rbuf->row(y) + x * Step + Offset;
+            const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
             do
             {
                 *dst++ = (cover_type)m_mask_function.calculate(mask);
@@ -433,10 +433,10 @@ namespace agg
         //--------------------------------------------------------------------
         void combine_vspan(int x, int y, cover_type* dst, int num_pix) const
         {
-            const int8u* mask = m_rbuf->row(y) + x * Step + Offset;
+            const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset;
             do
             {
-                *dst = (cover_type)(((*dst) * 
+                *dst = (cover_type)((cover_full + (*dst) * 
                                     m_mask_function.calculate(mask)) >> 
                                     cover_shift);
                 ++dst;

Modified: incubator/ooo/trunk/main/agg/inc/agg_arc.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_arc.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_arc.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_arc.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_array.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_array.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_array.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_array.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,26 +22,27 @@
 namespace agg
 {
 
-
-
     //-------------------------------------------------------pod_array_adaptor
     template<class T> class pod_array_adaptor
     {
     public:
         typedef T value_type;
-        pod_array_adaptor(T* array, unsigned _size) : 
-            m_array(array), m_size(_size) {}
+        pod_array_adaptor(T* array, unsigned size) : 
+            m_array(array), m_size(size) {}
 
         unsigned size() const { return m_size; }
-        const T& operator [] (unsigned idx) const { return m_array[idx]; }
-              T& operator [] (unsigned idx)       { return m_array[idx]; }
+        const T& operator [] (unsigned i) const { return m_array[i]; }
+              T& operator [] (unsigned i)       { return m_array[i]; }
+        const T& at(unsigned i) const           { return m_array[i]; }
+              T& at(unsigned i)                 { return m_array[i]; }
+        T  value_at(unsigned i) const           { return m_array[i]; }
+
     private:
         T*       m_array;
         unsigned m_size;
     };
 
 
-
     //---------------------------------------------------------pod_auto_array
     template<class T, unsigned Size> class pod_auto_array
     {
@@ -64,46 +65,148 @@ namespace agg
         static unsigned size() { return Size; }
         const T& operator [] (unsigned i) const { return m_array[i]; }
               T& operator [] (unsigned i)       { return m_array[i]; }
+        const T& at(unsigned i) const           { return m_array[i]; }
+              T& at(unsigned i)                 { return m_array[i]; }
+        T  value_at(unsigned i) const           { return m_array[i]; }
+
     private:
         T m_array[Size];
     };
 
 
+    //--------------------------------------------------------pod_auto_vector
+    template<class T, unsigned Size> class pod_auto_vector
+    {
+    public:
+        typedef T value_type;
+        typedef pod_auto_vector<T, Size> self_type;
+
+        pod_auto_vector() : m_size(0) {}
+
+        void remove_all()            { m_size = 0; }
+        void clear()                 { m_size = 0; }
+        void add(const T& v)         { m_array[m_size++] = v; }
+        void push_back(const T& v)   { m_array[m_size++] = v; }
+        void inc_size(unsigned size) { m_size += size; }
+        
+        unsigned size() const { return m_size; }
+        const T& operator [] (unsigned i) const { return m_array[i]; }
+              T& operator [] (unsigned i)       { return m_array[i]; }
+        const T& at(unsigned i) const           { return m_array[i]; }
+              T& at(unsigned i)                 { return m_array[i]; }
+        T  value_at(unsigned i) const           { return m_array[i]; }
 
+    private:
+        T m_array[Size];
+        unsigned m_size;
+    };
 
 
     //---------------------------------------------------------------pod_array
+    template<class T> class pod_array
+    {
+    public:
+        typedef T value_type;
+        typedef pod_array<T> self_type;
+
+        ~pod_array() { pod_allocator<T>::deallocate(m_array, m_size); }
+        pod_array() : m_array(0), m_size(0) {}
+
+        pod_array(unsigned size) : 
+            m_array(pod_allocator<T>::allocate(size)), 
+            m_size(size) 
+        {}
+
+        pod_array(const self_type& v) : 
+            m_array(pod_allocator<T>::allocate(v.m_size)), 
+            m_size(v.m_size) 
+        {
+            memcpy(m_array, v.m_array, sizeof(T) * m_size);
+        }
+
+        void resize(unsigned size)
+        {
+            if(size != m_size)
+            {
+                pod_allocator<T>::deallocate(m_array, m_size);
+                m_array = pod_allocator<T>::allocate(m_size = size);
+            }
+        }
+        const self_type& operator = (const self_type& v)
+        {
+            resize(v.size());
+            memcpy(m_array, v.m_array, sizeof(T) * m_size);
+            return *this;
+        }
+
+        unsigned size() const { return m_size; }
+        const T& operator [] (unsigned i) const { return m_array[i]; }
+              T& operator [] (unsigned i)       { return m_array[i]; }
+        const T& at(unsigned i) const           { return m_array[i]; }
+              T& at(unsigned i)                 { return m_array[i]; }
+        T  value_at(unsigned i) const           { return m_array[i]; }
+
+        const T* data() const { return m_array; }
+              T* data()       { return m_array; }
+    private:
+        T*       m_array;
+        unsigned m_size;
+    };
+
+
+
+    //--------------------------------------------------------------pod_vector
     // A simple class template to store Plain Old Data, a vector
     // of a fixed size. The data is continous in memory
     //------------------------------------------------------------------------
-    template<class T> class pod_array
+    template<class T> class pod_vector
     {
     public:
         typedef T value_type;
 
-        ~pod_array() { delete [] m_array; }
-        pod_array() : m_size(0), m_capacity(0), m_array(0) {}
-        pod_array(unsigned cap, unsigned extra_tail=0);
+        ~pod_vector() { pod_allocator<T>::deallocate(m_array, m_capacity); }
+        pod_vector() : m_size(0), m_capacity(0), m_array(0) {}
+        pod_vector(unsigned cap, unsigned extra_tail=0);
 
         // Copying
-        pod_array(const pod_array<T>&);
-        const pod_array<T>& operator = (const pod_array<T>&);
+        pod_vector(const pod_vector<T>&);
+        const pod_vector<T>& operator = (const pod_vector<T>&);
 
-        unsigned capacity() const { return m_capacity; }
+        // Set new capacity. All data is lost, size is set to zero.
         void capacity(unsigned cap, unsigned extra_tail=0);
+        unsigned capacity() const { return m_capacity; }
+
+        // Allocate n elements. All data is lost, 
+        // but elements can be accessed in range 0...size-1. 
+        void allocate(unsigned size, unsigned extra_tail=0);
 
+        // Resize keeping the content.
         void resize(unsigned new_size);
 
-        void add(const T& v)  { m_array[m_size++] = v; }
-        void inc_size(unsigned _size) { m_size += _size; } 
-        unsigned size()      const { return m_size; }
-        unsigned byte_size() const { return m_size * sizeof(T); }
+        void zero()
+        {
+            memset(m_array, 0, sizeof(T) * m_size);
+        }
+
+        void add(const T& v)         { m_array[m_size++] = v; }
+        void push_back(const T& v)   { m_array[m_size++] = v; }
+        void insert_at(unsigned pos, const T& val);
+        void inc_size(unsigned size) { m_size += size; }
+        unsigned size()      const   { return m_size; }
+        unsigned byte_size() const   { return m_size * sizeof(T); }
         void serialize(int8u* ptr) const;
         void deserialize(const int8u* data, unsigned byte_size);
-        const T& operator [] (unsigned idx) const { return m_array[idx]; }
-              T& operator [] (unsigned idx)       { return m_array[idx]; }
+        const T& operator [] (unsigned i) const { return m_array[i]; }
+              T& operator [] (unsigned i)       { return m_array[i]; }
+        const T& at(unsigned i) const           { return m_array[i]; }
+              T& at(unsigned i)                 { return m_array[i]; }
+        T  value_at(unsigned i) const           { return m_array[i]; }
+
+        const T* data() const { return m_array; }
+              T* data()       { return m_array; }
 
         void remove_all()         { m_size = 0; }
+        void clear()              { m_size = 0; }
         void cut_at(unsigned num) { if(num < m_size) m_size = num; }
 
     private:
@@ -114,28 +217,37 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T> 
-    void pod_array<T>::capacity(unsigned cap, unsigned extra_tail)
+    void pod_vector<T>::capacity(unsigned cap, unsigned extra_tail)
     {
         m_size = 0;
         if(cap > m_capacity)
         {
-            delete [] m_array;
+            pod_allocator<T>::deallocate(m_array, m_capacity);
             m_capacity = cap + extra_tail;
-            m_array = m_capacity ? new T [m_capacity] : 0;
+            m_array = m_capacity ? pod_allocator<T>::allocate(m_capacity) : 0;
         }
     }
 
     //------------------------------------------------------------------------
     template<class T> 
-    void pod_array<T>::resize(unsigned new_size)
+    void pod_vector<T>::allocate(unsigned size, unsigned extra_tail)
+    {
+        capacity(size, extra_tail);
+        m_size = size;
+    }
+
+
+    //------------------------------------------------------------------------
+    template<class T> 
+    void pod_vector<T>::resize(unsigned new_size)
     {
         if(new_size > m_size)
         {
             if(new_size > m_capacity)
             {
-                T* data = new T[new_size];
+                T* data = pod_allocator<T>::allocate(new_size);
                 memcpy(data, m_array, m_size * sizeof(T));
-                delete [] m_array;
+                pod_allocator<T>::deallocate(m_array, m_capacity);
                 m_array = data;
             }
         }
@@ -146,47 +258,61 @@ namespace agg
     }
 
     //------------------------------------------------------------------------
-    template<class T> pod_array<T>::pod_array(unsigned cap, unsigned extra_tail) :
-        m_size(cap), m_capacity(cap + extra_tail), m_array(new T[m_capacity]) {}
+    template<class T> pod_vector<T>::pod_vector(unsigned cap, unsigned extra_tail) :
+        m_size(0), 
+        m_capacity(cap + extra_tail), 
+        m_array(pod_allocator<T>::allocate(m_capacity)) {}
 
     //------------------------------------------------------------------------
-    template<class T> pod_array<T>::pod_array(const pod_array<T>& v) :
+    template<class T> pod_vector<T>::pod_vector(const pod_vector<T>& v) :
         m_size(v.m_size),
         m_capacity(v.m_capacity),
-        m_array(v.m_capacity ? new T [v.m_capacity] : 0)
+        m_array(v.m_capacity ? pod_allocator<T>::allocate(v.m_capacity) : 0)
     {
         memcpy(m_array, v.m_array, sizeof(T) * v.m_size);
     }
 
     //------------------------------------------------------------------------
-    template<class T> const pod_array<T>& 
-    pod_array<T>::operator = (const pod_array<T>&v)
+    template<class T> const pod_vector<T>& 
+    pod_vector<T>::operator = (const pod_vector<T>&v)
     {
-        capacity(v.m_capacity);
+        allocate(v.m_size);
         if(v.m_size) memcpy(m_array, v.m_array, sizeof(T) * v.m_size);
         return *this;
     }
 
     //------------------------------------------------------------------------
-    template<class T> void pod_array<T>::serialize(int8u* ptr) const
+    template<class T> void pod_vector<T>::serialize(int8u* ptr) const
     { 
         if(m_size) memcpy(ptr, m_array, m_size * sizeof(T)); 
     }
 
     //------------------------------------------------------------------------
     template<class T> 
-    void pod_array<T>::deserialize(const int8u* data, unsigned _byte_size)
+    void pod_vector<T>::deserialize(const int8u* data, unsigned byte_size)
     {
-        _byte_size /= sizeof(T);
-        capacity(_byte_size);
-        if(_byte_size) memcpy(m_array, data, _byte_size * sizeof(T));
+        byte_size /= sizeof(T);
+        allocate(byte_size);
+        if(byte_size) memcpy(m_array, data, byte_size * sizeof(T));
     }
 
+    //------------------------------------------------------------------------
+    template<class T> 
+    void pod_vector<T>::insert_at(unsigned pos, const T& val)
+    {
+        if(pos >= m_size) 
+        {
+            m_array[m_size] = val;
+        }
+        else
+        {
+            memmove(m_array + pos + 1, m_array + pos, (m_size - pos) * sizeof(T));
+            m_array[pos] = val;
+        }
+        ++m_size;
+    }
 
-
-
-
-    //---------------------------------------------------------------pod_deque
+    //---------------------------------------------------------------pod_bvector
     // A simple class template to store Plain Old Data, similar to std::deque
     // It doesn't reallocate memory but instead, uses blocks of data of size 
     // of (1 << S), that is, power of two. The data is NOT contiguous in memory, 
@@ -197,10 +323,10 @@ namespace agg
     // of increment to reallocate the pointer buffer. See the second constructor.
     // By default, the incremeent value equals (1 << S), i.e., the block size.
     //------------------------------------------------------------------------
-    template<class T, unsigned S=6> class pod_deque
+    template<class T, unsigned S=6> class pod_bvector
     {
     public:
-        enum 
+        enum block_scale_e
         {   
             block_shift = S,
             block_size  = 1 << block_shift,
@@ -209,18 +335,20 @@ namespace agg
 
         typedef T value_type;
 
-        ~pod_deque();
-        pod_deque();
-        pod_deque(unsigned block_ptr_inc);
+        ~pod_bvector();
+        pod_bvector();
+        pod_bvector(unsigned block_ptr_inc);
 
         // Copying
-        pod_deque(const pod_deque<T, S>& v);
-        const pod_deque<T, S>& operator = (const pod_deque<T, S>& v);
+        pod_bvector(const pod_bvector<T, S>& v);
+        const pod_bvector<T, S>& operator = (const pod_bvector<T, S>& v);
 
         void remove_all() { m_size = 0; }
-        void free_all() { free_tail(0); }
+        void clear()      { m_size = 0; }
+        void free_all()   { free_tail(0); }
         void free_tail(unsigned size);
         void add(const T& val);
+        void push_back(const T& val) { add(val); }
         void modify_last(const T& val);
         void remove_last();
 
@@ -243,21 +371,36 @@ namespace agg
             }
         }
 
-        void cut_at(unsigned _size)
+        void cut_at(unsigned size)
         {
-            if(_size < m_size) m_size = _size;
+            if(size < m_size) m_size = size;
         }
 
         unsigned size() const { return m_size; }
 
-        const T& operator [] (unsigned idx) const
+        const T& operator [] (unsigned i) const
         {
-            return m_blocks[idx >> block_shift][idx & block_mask];
+            return m_blocks[i >> block_shift][i & block_mask];
         }
 
-        T& operator [] (unsigned idx)
+        T& operator [] (unsigned i)
         {
-            return m_blocks[idx >> block_shift][idx & block_mask];
+            return m_blocks[i >> block_shift][i & block_mask];
+        }
+
+        const T& at(unsigned i) const
+        { 
+            return m_blocks[i >> block_shift][i & block_mask];
+        }
+
+        T& at(unsigned i) 
+        { 
+            return m_blocks[i >> block_shift][i & block_mask];
+        }
+
+        T value_at(unsigned i) const
+        { 
+            return m_blocks[i >> block_shift][i & block_mask];
         }
 
         const T& curr(unsigned idx) const
@@ -368,39 +511,45 @@ namespace agg
 
 
     //------------------------------------------------------------------------
-    template<class T, unsigned S> pod_deque<T, S>::~pod_deque()
+    template<class T, unsigned S> pod_bvector<T, S>::~pod_bvector()
     {
         if(m_num_blocks)
         {
             T** blk = m_blocks + m_num_blocks - 1;
             while(m_num_blocks--)
             {
-                delete [] *blk;
+                pod_allocator<T>::deallocate(*blk, block_size);
                 --blk;
             }
-            delete [] m_blocks;
         }
+        pod_allocator<T*>::deallocate(m_blocks, m_max_blocks);
     }
 
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    void pod_deque<T, S>::free_tail(unsigned _size)
+    void pod_bvector<T, S>::free_tail(unsigned size)
     {
-        if(_size < m_size)
+        if(size < m_size)
         {
-            unsigned nb = (_size + block_mask) >> block_shift;
+            unsigned nb = (size + block_mask) >> block_shift;
             while(m_num_blocks > nb)
             {
-                delete [] m_blocks[--m_num_blocks];
+                pod_allocator<T>::deallocate(m_blocks[--m_num_blocks], block_size);
+            }
+            if(m_num_blocks == 0)
+            {
+                pod_allocator<T*>::deallocate(m_blocks, m_max_blocks);
+                m_blocks = 0;
+                m_max_blocks = 0;
             }
-            m_size = _size;
+            m_size = size;
         }
     }
 
 
     //------------------------------------------------------------------------
-    template<class T, unsigned S> pod_deque<T, S>::pod_deque() :
+    template<class T, unsigned S> pod_bvector<T, S>::pod_bvector() :
         m_size(0),
         m_num_blocks(0),
         m_max_blocks(0),
@@ -412,7 +561,7 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    pod_deque<T, S>::pod_deque(unsigned block_ptr_inc) :
+    pod_bvector<T, S>::pod_bvector(unsigned block_ptr_inc) :
         m_size(0),
         m_num_blocks(0),
         m_max_blocks(0),
@@ -424,17 +573,19 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    pod_deque<T, S>::pod_deque(const pod_deque<T, S>& v) :
+    pod_bvector<T, S>::pod_bvector(const pod_bvector<T, S>& v) :
         m_size(v.m_size),
         m_num_blocks(v.m_num_blocks),
         m_max_blocks(v.m_max_blocks),
-        m_blocks(v.m_max_blocks ? new T* [v.m_max_blocks] : 0),
+        m_blocks(v.m_max_blocks ? 
+                 pod_allocator<T*>::allocate(v.m_max_blocks) : 
+                 0),
         m_block_ptr_inc(v.m_block_ptr_inc)
     {
         unsigned i;
         for(i = 0; i < v.m_num_blocks; ++i)
         {
-            m_blocks[i] = new T [block_size];
+            m_blocks[i] = pod_allocator<T>::allocate(block_size);
             memcpy(m_blocks[i], v.m_blocks[i], block_size * sizeof(T));
         }
     }
@@ -442,7 +593,8 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    const pod_deque<T, S>& pod_deque<T, S>::operator = (const pod_deque<T, S>& v)
+    const pod_bvector<T, S>& 
+    pod_bvector<T, S>::operator = (const pod_bvector<T, S>& v)
     {
         unsigned i;
         for(i = m_num_blocks; i < v.m_num_blocks; ++i)
@@ -460,11 +612,11 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S>
-    void pod_deque<T, S>::allocate_block(unsigned nb)
+    void pod_bvector<T, S>::allocate_block(unsigned nb)
     {
         if(nb >= m_max_blocks) 
         {
-            T** new_blocks = new T* [m_max_blocks + m_block_ptr_inc];
+            T** new_blocks = pod_allocator<T*>::allocate(m_max_blocks + m_block_ptr_inc);
 
             if(m_blocks)
             {
@@ -472,12 +624,12 @@ namespace agg
                        m_blocks, 
                        m_num_blocks * sizeof(T*));
 
-                delete [] m_blocks;
+                pod_allocator<T*>::deallocate(m_blocks, m_max_blocks);
             }
             m_blocks = new_blocks;
             m_max_blocks += m_block_ptr_inc;
         }
-        m_blocks[nb] = new T [block_size];
+        m_blocks[nb] = pod_allocator<T>::allocate(block_size);
         m_num_blocks++;
     }
 
@@ -485,7 +637,7 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S>
-    inline T* pod_deque<T, S>::data_ptr()
+    inline T* pod_bvector<T, S>::data_ptr()
     {
         unsigned nb = m_size >> block_shift;
         if(nb >= m_num_blocks)
@@ -499,7 +651,7 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    inline void pod_deque<T, S>::add(const T& val)
+    inline void pod_bvector<T, S>::add(const T& val)
     {
         *data_ptr() = val;
         ++m_size;
@@ -508,7 +660,7 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    inline void pod_deque<T, S>::remove_last()
+    inline void pod_bvector<T, S>::remove_last()
     {
         if(m_size) --m_size;
     }
@@ -516,7 +668,7 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    void pod_deque<T, S>::modify_last(const T& val)
+    void pod_bvector<T, S>::modify_last(const T& val)
     {
         remove_last();
         add(val);
@@ -525,7 +677,7 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    int pod_deque<T, S>::allocate_continuous_block(unsigned num_elements)
+    int pod_bvector<T, S>::allocate_continuous_block(unsigned num_elements)
     {
         if(num_elements < block_size)
         {
@@ -555,7 +707,7 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    unsigned pod_deque<T, S>::byte_size() const
+    unsigned pod_bvector<T, S>::byte_size() const
     {
         return m_size * sizeof(T);
     }
@@ -563,7 +715,7 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    void pod_deque<T, S>::serialize(int8u* ptr) const
+    void pod_bvector<T, S>::serialize(int8u* ptr) const
     {
         unsigned i;
         for(i = 0; i < m_size; i++)
@@ -575,11 +727,11 @@ namespace agg
 
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    void pod_deque<T, S>::deserialize(const int8u* data, unsigned _byte_size)
+    void pod_bvector<T, S>::deserialize(const int8u* data, unsigned byte_size)
     {
         remove_all();
-        _byte_size /= sizeof(T);
-        for(unsigned i = 0; i < _byte_size; ++i)
+        byte_size /= sizeof(T);
+        for(unsigned i = 0; i < byte_size; ++i)
         {
             T* ptr = data_ptr();
             memcpy(ptr, data, sizeof(T));
@@ -592,16 +744,16 @@ namespace agg
     // Replace or add a number of elements starting from "start" position
     //------------------------------------------------------------------------
     template<class T, unsigned S> 
-    void pod_deque<T, S>::deserialize(unsigned start, const T& empty_val, 
-                                      const int8u* data, unsigned _byte_size)
+    void pod_bvector<T, S>::deserialize(unsigned start, const T& empty_val, 
+                                        const int8u* data, unsigned byte_size)
     {
         while(m_size < start)
         {
             add(empty_val);
         }
 
-        _byte_size /= sizeof(T);
-        for(unsigned i = 0; i < _byte_size; ++i)
+        byte_size /= sizeof(T);
+        for(unsigned i = 0; i < byte_size; ++i)
         {
             if(start + i < m_size)
             {
@@ -618,7 +770,7 @@ namespace agg
     }
 
 
-    //-----------------------------------------------------------pod_allocator
+    //---------------------------------------------------------block_allocator
     // Allocator for arbitrary POD data. Most usable in different cache
     // systems for efficient memory allocations. 
     // Memory is allocated with blocks of fixed size ("block_size" in
@@ -626,20 +778,26 @@ namespace agg
     // creates a new block of the required size. However, the most efficient
     // use is when the average reqired size is much less than the block size. 
     //------------------------------------------------------------------------
-    class pod_allocator
+    class block_allocator
     {
+        struct block_type
+        {
+            int8u*   data;
+            unsigned size;
+        };
+
     public:
         void remove_all()
         {
             if(m_num_blocks)
             {
-                int8u** blk = m_blocks + m_num_blocks - 1;
+                block_type* blk = m_blocks + m_num_blocks - 1;
                 while(m_num_blocks--)
                 {
-                    delete [] *blk;
+                    pod_allocator<int8u>::deallocate(blk->data, blk->size);
                     --blk;
                 }
-                delete [] m_blocks;
+                pod_allocator<block_type>::deallocate(m_blocks, m_max_blocks);
             }
             m_num_blocks = 0;
             m_max_blocks = 0;
@@ -648,12 +806,12 @@ namespace agg
             m_rest = 0;
         }
 
-        ~pod_allocator()
+        ~block_allocator()
         {
             remove_all();
         }
 
-        pod_allocator(unsigned block_size, unsigned block_ptr_inc=256-8) :
+        block_allocator(unsigned block_size, unsigned block_ptr_inc=256-8) :
             m_block_size(block_size),
             m_block_ptr_inc(block_ptr_inc),
             m_num_blocks(0),
@@ -673,7 +831,9 @@ namespace agg
                 int8u* ptr = m_buf_ptr;
                 if(alignment > 1)
                 {
-                    unsigned align = (alignment - unsigned((size_t)ptr) % alignment) % alignment;
+                    unsigned align = 
+                        (alignment - unsigned((size_t)ptr) % alignment) % alignment;
+
                     size += align;
                     ptr += align;
                     if(size <= m_rest)
@@ -700,31 +860,36 @@ namespace agg
             if(size < m_block_size) size = m_block_size;
             if(m_num_blocks >= m_max_blocks) 
             {
-                int8u** new_blocks = new int8u* [m_max_blocks + m_block_ptr_inc];
+                block_type* new_blocks = 
+                    pod_allocator<block_type>::allocate(m_max_blocks + m_block_ptr_inc);
 
                 if(m_blocks)
                 {
                     memcpy(new_blocks, 
                            m_blocks, 
-                           m_num_blocks * sizeof(int8u*));
-
-                    delete [] m_blocks;
+                           m_num_blocks * sizeof(block_type));
+                    pod_allocator<block_type>::deallocate(m_blocks, m_max_blocks);
                 }
                 m_blocks = new_blocks;
                 m_max_blocks += m_block_ptr_inc;
             }
-            m_blocks[m_num_blocks] = m_buf_ptr = new int8u [size];
+
+            m_blocks[m_num_blocks].size = size;
+            m_blocks[m_num_blocks].data = 
+                m_buf_ptr =
+                pod_allocator<int8u>::allocate(size);
+
             m_num_blocks++;
             m_rest = size;
         }
 
-        unsigned m_block_size;
-        unsigned m_block_ptr_inc;
-        unsigned m_num_blocks;
-        unsigned m_max_blocks;
-        int8u**  m_blocks;
-        int8u*   m_buf_ptr;
-        unsigned m_rest;
+        unsigned    m_block_size;
+        unsigned    m_block_ptr_inc;
+        unsigned    m_num_blocks;
+        unsigned    m_max_blocks;
+        block_type* m_blocks;
+        int8u*      m_buf_ptr;
+        unsigned    m_rest;
     };
 
 
@@ -735,7 +900,7 @@ namespace agg
 
 
     //------------------------------------------------------------------------
-    enum
+    enum quick_sort_threshold_e
     {
         quick_sort_threshold = 9
     };
@@ -859,7 +1024,7 @@ namespace agg
 
 
     //------------------------------------------------------remove_duplicates
-    // Remove duplicates from a sorted array. It doesn't cut the the 
+    // Remove duplicates from a sorted array. It doesn't cut the 
     // tail of the array, it just returns the number of remaining elements.
     //-----------------------------------------------------------------------
     template<class Array, class Equal>
@@ -879,9 +1044,76 @@ namespace agg
         return j;
     }
 
+    //--------------------------------------------------------invert_container
+    template<class Array> void invert_container(Array& arr)
+    {
+        int i = 0;
+        int j = arr.size() - 1;
+        while(i < j)
+        {
+            swap_elements(arr[i++], arr[j--]);
+        }
+    }
+
+    //------------------------------------------------------binary_search_pos
+    template<class Array, class Value, class Less>
+    unsigned binary_search_pos(const Array& arr, const Value& val, Less less)
+    {
+        if(arr.size() == 0) return 0;
+
+        unsigned beg = 0;
+        unsigned end = arr.size() - 1;
+
+        if(less(val, arr[0])) return 0;
+        if(less(arr[end], val)) return end + 1;
+
+        while(end - beg > 1)
+        {
+            unsigned mid = (end + beg) >> 1;
+            if(less(val, arr[mid])) end = mid; 
+            else                    beg = mid;
+        }
+
+        //if(beg <= 0 && less(val, arr[0])) return 0;
+        //if(end >= arr.size() - 1 && less(arr[end], val)) ++end;
+
+        return end;
+    }
+
+    //----------------------------------------------------------range_adaptor
+    template<class Array> class range_adaptor
+    {
+    public:
+        typedef typename Array::value_type value_type;
+
+        range_adaptor(Array& array, unsigned start, unsigned size) :
+            m_array(array), m_start(start), m_size(size)
+        {}
+
+        unsigned size() const { return m_size; }
+        const value_type& operator [] (unsigned i) const { return m_array[m_start + i]; }
+              value_type& operator [] (unsigned i)       { return m_array[m_start + i]; }
+        const value_type& at(unsigned i) const           { return m_array[m_start + i]; }
+              value_type& at(unsigned i)                 { return m_array[m_start + i]; }
+        value_type  value_at(unsigned i) const           { return m_array[m_start + i]; }
+
+    private:
+        Array& m_array;
+        unsigned m_start;
+        unsigned m_size;
+    };
+
+    //---------------------------------------------------------------int_less
+    inline bool int_less(int a, int b) { return a < b; }
 
+    //------------------------------------------------------------int_greater
+    inline bool int_greater(int a, int b) { return a > b; }
 
+    //----------------------------------------------------------unsigned_less
+    inline bool unsigned_less(unsigned a, unsigned b) { return a < b; }
 
+    //-------------------------------------------------------unsigned_greater
+    inline bool unsigned_greater(unsigned a, unsigned b) { return a > b; }
 }
 
 #endif

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

Modified: incubator/ooo/trunk/main/agg/inc/agg_basics.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_basics.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_basics.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_basics.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,8 +16,46 @@
 #ifndef AGG_BASICS_INCLUDED
 #define AGG_BASICS_INCLUDED
 
+#include <math.h>
 #include "agg_config.h"
 
+//---------------------------------------------------------AGG_CUSTOM_ALLOCATOR
+#ifdef AGG_CUSTOM_ALLOCATOR
+#include "agg_allocator.h"
+#else
+namespace agg
+{
+    // The policy of all AGG containers and memory allocation strategy 
+    // in general is that no allocated data requires explicit construction.
+    // It means that the allocator can be really simple; you can even
+    // replace new/delete to malloc/free. The constructors and destructors 
+    // won't be called in this case, however everything will remain working. 
+    // The second argument of deallocate() is the size of the allocated 
+    // block. You can use this information if you wish.
+    //------------------------------------------------------------pod_allocator
+    template<class T> struct pod_allocator
+    {
+        static T*   allocate(unsigned num)       { return new T [num]; }
+        static void deallocate(T* ptr, unsigned) { delete [] ptr;      }
+    };
+
+    // Single object allocator. It's also can be replaced with your custom
+    // allocator. The difference is that it can only allocate a single 
+    // object and the constructor and destructor must be called. 
+    // In AGG there is no need to allocate an array of objects with
+    // calling their constructors (only single ones). So that, if you
+    // replace these new/delete to malloc/free make sure that the in-place
+    // new is called and take care of calling the destructor too.
+    //------------------------------------------------------------obj_allocator
+    template<class T> struct obj_allocator
+    {
+        static T*   allocate()         { return new T; }
+        static void deallocate(T* ptr) { delete ptr;   }
+    };
+}
+#endif
+
+
 //-------------------------------------------------------- Default basic types
 //
 // If the compiler has different capacity of the basic types you can redefine
@@ -49,7 +87,7 @@
 #endif
 
 #ifndef AGG_INT64
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 #define AGG_INT64 signed __int64
 #else
 #define AGG_INT64 signed long long
@@ -57,7 +95,7 @@
 #endif
 
 #ifndef AGG_INT64U
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__BORLANDC__)
 #define AGG_INT64U unsigned __int64
 #else
 #define AGG_INT64U unsigned long long
@@ -87,9 +125,92 @@ namespace agg
     typedef AGG_INT64  int64;        //----int64
     typedef AGG_INT64U int64u;       //----int64u
 
+#if defined(AGG_FISTP)
+#pragma warning(push)
+#pragma warning(disable : 4035) //Disable warning "no return value"
+    AGG_INLINE int iround(double v)              //-------iround
+    {
+        int t;
+        __asm fld   qword ptr [v]
+        __asm fistp dword ptr [t]
+        __asm mov eax, dword ptr [t]
+    }
+    AGG_INLINE unsigned uround(double v)         //-------uround
+    {
+        unsigned t;
+        __asm fld   qword ptr [v]
+        __asm fistp dword ptr [t]
+        __asm mov eax, dword ptr [t]
+    }
+#pragma warning(pop)
+    AGG_INLINE unsigned ufloor(double v)         //-------ufloor
+    {
+        return unsigned(floor(v));
+    }
+    AGG_INLINE unsigned uceil(double v)          //--------uceil
+    {
+        return unsigned(ceil(v));
+    }
+#elif defined(AGG_QIFIST)
+    AGG_INLINE int iround(double v)
+    {
+        return int(v);
+    }
+    AGG_INLINE int uround(double v)
+    {
+        return unsigned(v);
+    }
+    AGG_INLINE unsigned ufloor(double v)
+    {
+        return unsigned(floor(v));
+    }
+    AGG_INLINE unsigned uceil(double v)
+    {
+        return unsigned(ceil(v));
+    }
+#else
+    AGG_INLINE int iround(double v)
+    {
+        return int((v < 0.0) ? v - 0.5 : v + 0.5);
+    }
+    AGG_INLINE int uround(double v)
+    {
+        return unsigned(v + 0.5);
+    }
+    AGG_INLINE unsigned ufloor(double v)
+    {
+        return unsigned(v);
+    }
+    AGG_INLINE unsigned uceil(double v)
+    {
+        return unsigned(ceil(v));
+    }
+#endif
+
+    //---------------------------------------------------------------saturation
+    template<int Limit> struct saturation
+    {
+        AGG_INLINE static int iround(double v)
+        {
+            if(v < double(-Limit)) return -Limit;
+            if(v > double( Limit)) return  Limit;
+            return agg::iround(v);
+        }
+    };
+
+    //------------------------------------------------------------------mul_one
+    template<unsigned Shift> struct mul_one
+    {
+        AGG_INLINE static unsigned mul(unsigned a, unsigned b)
+        {
+            register unsigned q = a * b + (1 << (Shift-1));
+            return (q + (q >> Shift)) >> Shift;
+        }
+    };
+
     //-------------------------------------------------------------------------
     typedef unsigned char cover_type;    //----cover_type
-    enum
+    enum cover_scale_e
     {
         cover_shift = 8,                 //----cover_shift
         cover_size  = 1 << cover_shift,  //----cover_size 
@@ -98,6 +219,25 @@ namespace agg
         cover_full  = cover_mask         //----cover_full 
     };
 
+    //----------------------------------------------------poly_subpixel_scale_e
+    // These constants determine the subpixel accuracy, to be more precise, 
+    // the number of bits of the fractional part of the coordinates. 
+    // The possible coordinate capacity in bits can be calculated by formula:
+    // sizeof(int) * 8 - poly_subpixel_shift, i.e, for 32-bit integers and
+    // 8-bits fractional part the capacity is 24 bits.
+    enum poly_subpixel_scale_e
+    {
+        poly_subpixel_shift = 8,                      //----poly_subpixel_shift
+        poly_subpixel_scale = 1<<poly_subpixel_shift, //----poly_subpixel_scale 
+        poly_subpixel_mask  = poly_subpixel_scale-1,  //----poly_subpixel_mask 
+    };
+
+    //----------------------------------------------------------filling_rule_e
+    enum filling_rule_e
+    {
+        fill_non_zero,
+        fill_even_odd
+    };
 
     //-----------------------------------------------------------------------pi
     const double pi = 3.14159265358979323846;
@@ -117,16 +257,19 @@ namespace agg
     //----------------------------------------------------------------rect_base
     template<class T> struct rect_base
     {
+        typedef T            value_type;
         typedef rect_base<T> self_type;
-        T x1;
-        T y1;
-        T x2;
-        T y2;
+        T x1, y1, x2, y2;
 
         rect_base() {}
         rect_base(T x1_, T y1_, T x2_, T y2_) :
             x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}
 
+        void init(T x1_, T y1_, T x2_, T y2_) 
+        {
+            x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_; 
+        }
+
         const self_type& normalize()
         {
             T t;
@@ -148,6 +291,11 @@ namespace agg
         {
             return x1 <= x2 && y1 <= y2;
         }
+
+        bool hit_test(T x, T y) const
+        {
+            return (x >= x1 && x <= x2 && y >= y1 && y <= y2);
+        }
     };
 
     //-----------------------------------------------------intersect_rectangles
@@ -181,7 +329,8 @@ namespace agg
         return r;
     }
 
-    typedef rect_base<int>    rect;   //----rect
+    typedef rect_base<int>    rect_i; //----rect_i
+    typedef rect_base<float>  rect_f; //----rect_f
     typedef rect_base<double> rect_d; //----rect_d
 
     //---------------------------------------------------------path_commands_e
@@ -192,7 +341,10 @@ namespace agg
         path_cmd_line_to  = 2,        //----path_cmd_line_to 
         path_cmd_curve3   = 3,        //----path_cmd_curve3  
         path_cmd_curve4   = 4,        //----path_cmd_curve4  
-        path_cmd_end_poly = 6,        //----path_cmd_end_poly
+        path_cmd_curveN   = 5,        //----path_cmd_curveN
+        path_cmd_catrom   = 6,        //----path_cmd_catrom
+        path_cmd_ubspline = 7,        //----path_cmd_ubspline
+        path_cmd_end_poly = 0x0F,     //----path_cmd_end_poly
         path_cmd_mask     = 0x0F      //----path_cmd_mask    
     };
 
@@ -212,6 +364,12 @@ namespace agg
         return c >= path_cmd_move_to && c < path_cmd_end_poly;
     }
 
+    //--------------------------------------------------------------is_drawing
+    inline bool is_drawing(unsigned c)
+    {
+        return c >= path_cmd_line_to && c < path_cmd_end_poly;
+    }
+
     //-----------------------------------------------------------------is_stop
     inline bool is_stop(unsigned c)
     { 
@@ -258,7 +416,7 @@ namespace agg
     inline bool is_close(unsigned c)
     {
         return (c & ~(path_flags_cw | path_flags_ccw)) ==
-               (((bool)path_cmd_end_poly) | ((bool)path_flags_close)); 
+               (path_cmd_end_poly | path_flags_close); 
     }
 
     //------------------------------------------------------------is_next_poly
@@ -315,26 +473,55 @@ namespace agg
         return clear_orientation(c) | o;
     }
 
-    //--------------------------------------------------------------point_type
-    struct point_type
+    //--------------------------------------------------------------point_base
+    template<class T> struct point_base
     {
-        double x, y;
-
-        point_type() {}
-        point_type(double x_, double y_) : x(x_), y(y_) {}
+        typedef T value_type;
+        T x,y;
+        point_base() {}
+        point_base(T x_, T y_) : x(x_), y(y_) {}
     };
+    typedef point_base<int>    point_i; //-----point_i
+    typedef point_base<float>  point_f; //-----point_f
+    typedef point_base<double> point_d; //-----point_d
 
-    //-------------------------------------------------------------vertex_type
-    struct vertex_type
+    //-------------------------------------------------------------vertex_base
+    template<class T> struct vertex_base
     {
-        double   x, y;
+        typedef T value_type;
+        T x,y;
         unsigned cmd;
+        vertex_base() {}
+        vertex_base(T x_, T y_, unsigned cmd_) : x(x_), y(y_), cmd(cmd_) {}
+    };
+    typedef vertex_base<int>    vertex_i; //-----vertex_i
+    typedef vertex_base<float>  vertex_f; //-----vertex_f
+    typedef vertex_base<double> vertex_d; //-----vertex_d
+
+    //----------------------------------------------------------------row_info
+    template<class T> struct row_info
+    {
+        int x1, x2;
+        T* ptr;
+        row_info() {}
+        row_info(int x1_, int x2_, T* ptr_) : x1(x1_), x2(x2_), ptr(ptr_) {}
+    };
 
-        vertex_type() {}
-        vertex_type(double x_, double y_, unsigned cmd_) : 
-            x(x_), y(y_), cmd(cmd_) {}
+    //----------------------------------------------------------const_row_info
+    template<class T> struct const_row_info
+    {
+        int x1, x2;
+        const T* ptr;
+        const_row_info() {}
+        const_row_info(int x1_, int x2_, const T* ptr_) : 
+            x1(x1_), x2(x2_), ptr(ptr_) {}
     };
 
+    //------------------------------------------------------------is_equal_eps
+    template<class T> inline bool is_equal_eps(T v1, T v2, T epsilon)
+    {
+        return fabs(v1 - v2) <= double(epsilon);
+    }
 
 }
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_bezier_arc.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_bezier_arc.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_bezier_arc.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_bezier_arc.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 
@@ -40,7 +40,7 @@ namespace agg
     {
     public:
         //--------------------------------------------------------------------
-        bezier_arc() : m_vertex(26) {}
+        bezier_arc() : m_vertex(26), m_num_vertices(0), m_cmd(path_cmd_line_to) {}
         bezier_arc(double x,  double y, 
                    double rx, double ry, 
                    double start_angle, 
@@ -68,7 +68,7 @@ namespace agg
             *x = m_vertices[m_vertex];
             *y = m_vertices[m_vertex + 1];
             m_vertex += 2;
-            return (m_vertex == 2) ? path_cmd_move_to : path_cmd_curve4;
+            return (m_vertex == 2) ? path_cmd_move_to : m_cmd;
         }
 
         // Supplemantary functions. num_vertices() actually returns doubled 
@@ -82,6 +82,7 @@ namespace agg
         unsigned m_vertex;
         unsigned m_num_vertices;
         double   m_vertices[26];
+        unsigned m_cmd;
     };
 
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_bitset_iterator.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_bitset_iterator.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_bitset_iterator.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_bitset_iterator.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_bounding_rect.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_bounding_rect.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_bounding_rect.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_bounding_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 

Modified: incubator/ooo/trunk/main/agg/inc/agg_bspline.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_bspline.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_bspline.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_bspline.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -20,7 +20,7 @@
 #ifndef AGG_BSPLINE_INCLUDED
 #define AGG_BSPLINE_INCLUDED
 
-#include "agg_basics.h"
+#include "agg_array.h"
 
 namespace agg
 {
@@ -40,7 +40,6 @@ namespace agg
     class bspline 
     {
     public:
-        ~bspline();
         bspline();
         bspline(int num);
         bspline(int num, const double* x, const double* y);
@@ -63,12 +62,12 @@ namespace agg
         double extrapolation_right(double x) const;
         double interpolation(double x, int i) const;
 
-        int     m_max;
-        int     m_num;
-        double* m_x;
-        double* m_y;
-        double* m_am;
-        mutable int m_last_idx;
+        int               m_max;
+        int               m_num;
+        double*           m_x;
+        double*           m_y;
+        pod_array<double> m_am;
+        mutable int       m_last_idx;
     };
 
 

Modified: incubator/ooo/trunk/main/agg/inc/agg_clip_liang_barsky.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_clip_liang_barsky.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_clip_liang_barsky.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_clip_liang_barsky.h Sun Oct 16 04:13:16 2011
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// Anti-Grain Geometry - Version 2.3
+// Anti-Grain Geometry - Version 2.4
 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
 //
 // Permission to copy, use, modify, sell and distribute this software 
@@ -24,6 +24,17 @@
 namespace agg
 {
 
+    //------------------------------------------------------------------------
+    enum clipping_flags_e
+    {
+        clipping_flags_x1_clipped = 4,
+        clipping_flags_x2_clipped = 1,
+        clipping_flags_y1_clipped = 8,
+        clipping_flags_y2_clipped = 2,
+        clipping_flags_x_clipped = clipping_flags_x1_clipped | clipping_flags_x2_clipped,
+        clipping_flags_y_clipped = clipping_flags_y1_clipped | clipping_flags_y2_clipped
+    };
+
     //----------------------------------------------------------clipping_flags
     // Determine the clipping code of the vertex according to the 
     // Cyrus-Beck line clipping algorithm
@@ -51,11 +62,25 @@ namespace agg
                ((y < clip_box.y1) << 3);
     }
 
+    //--------------------------------------------------------clipping_flags_x
+    template<class T>
+    inline unsigned clipping_flags_x(T x, const rect_base<T>& clip_box)
+    {
+        return  (x > clip_box.x2) | ((x < clip_box.x1) << 2);
+    }
+
+
+    //--------------------------------------------------------clipping_flags_y
+    template<class T>
+    inline unsigned clipping_flags_y(T y, const rect_base<T>& clip_box)
+    {
+        return ((y > clip_box.y2) << 1) | ((y < clip_box.y1) << 3);
+    }
 
 
     //-------------------------------------------------------clip_liang_barsky
     template<class T>
-    /*inline*/ unsigned clip_liang_barsky(T x1, T y1, T x2, T y2,
+    inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2,
                                       const rect_base<T>& clip_box,
                                       T* x, T* y)
     {
@@ -202,8 +227,107 @@ namespace agg
         }
         return np;
     }
-    
+
+
+    //----------------------------------------------------------------------------
+    template<class T>
+    bool clip_move_point(T x1, T y1, T x2, T y2, 
+                         const rect_base<T>& clip_box, 
+                         T* x, T* y, unsigned flags)
+    {
+       T bound;
+
+       if(flags & clipping_flags_x_clipped)
+       {
+           if(x1 == x2)
+           {
+               return false;
+           }
+           bound = (flags & clipping_flags_x1_clipped) ? clip_box.x1 : clip_box.x2;
+           *y = (T)(double(bound - x1) * (y2 - y1) / (x2 - x1) + y1);
+           *x = bound;
+       }
+
+       flags = clipping_flags_y(*y, clip_box);
+       if(flags & clipping_flags_y_clipped)
+       {
+           if(y1 == y2)
+           {
+               return false;
+           }
+           bound = (flags & clipping_flags_y1_clipped) ? clip_box.y1 : clip_box.y2;
+           *x = (T)(double(bound - y1) * (x2 - x1) / (y2 - y1) + x1);
+           *y = bound;
+       }
+       return true;
+    }
+
+    //-------------------------------------------------------clip_line_segment
+    // Returns: ret >= 4        - Fully clipped
+    //          (ret & 1) != 0  - First point has been moved
+    //          (ret & 2) != 0  - Second point has been moved
+    //
+    template<class T>
+    unsigned clip_line_segment(T* x1, T* y1, T* x2, T* y2,
+                               const rect_base<T>& clip_box)
+    {
+        unsigned f1 = clipping_flags(*x1, *y1, clip_box);
+        unsigned f2 = clipping_flags(*x2, *y2, clip_box);
+        unsigned ret = 0;
+
+        if((f2 | f1) == 0)
+        {
+            // Fully visible
+            return 0;
+        }
+
+        if((f1 & clipping_flags_x_clipped) != 0 && 
+           (f1 & clipping_flags_x_clipped) == (f2 & clipping_flags_x_clipped))
+        {
+            // Fully clipped
+            return 4;
+        }
+
+        if((f1 & clipping_flags_y_clipped) != 0 && 
+           (f1 & clipping_flags_y_clipped) == (f2 & clipping_flags_y_clipped))
+        {
+            // Fully clipped
+            return 4;
+        }
+
+        T tx1 = *x1;
+        T ty1 = *y1;
+        T tx2 = *x2;
+        T ty2 = *y2;
+        if(f1) 
+        {   
+            if(!clip_move_point(tx1, ty1, tx2, ty2, clip_box, x1, y1, f1)) 
+            {
+                return 4;
+            }
+            if(*x1 == *x2 && *y1 == *y2) 
+            {
+                return 4;
+            }
+            ret |= 1;
+        }
+        if(f2) 
+        {
+            if(!clip_move_point(tx1, ty1, tx2, ty2, clip_box, x2, y2, f2))
+            {
+                return 4;
+            }
+            if(*x1 == *x2 && *y1 == *y2) 
+            {
+                return 4;
+            }
+            ret |= 2;
+        }
+        return ret;
+    }
+
 
 }
 
+
 #endif

Modified: incubator/ooo/trunk/main/agg/inc/agg_color_gray.h
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/agg/inc/agg_color_gray.h?rev=1184758&r1=1184757&r2=1184758&view=diff
==============================================================================
--- incubator/ooo/trunk/main/agg/inc/agg_color_gray.h (original)
+++ incubator/ooo/trunk/main/agg/inc/agg_color_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 
@@ -40,11 +40,11 @@ namespace agg
         typedef int8u  value_type;
         typedef int32u calc_type;
         typedef int32  long_type;
-        enum
+        enum base_scale_e
         {
             base_shift = 8,
-            base_size  = 1 << base_shift,
-            base_mask  = base_size - 1
+            base_scale = 1 << base_shift,
+            base_mask  = base_scale - 1
         };
         typedef gray8 self_type;
 
@@ -64,13 +64,13 @@ namespace agg
 
         //--------------------------------------------------------------------
         gray8(const rgba& c) :
-            v(value_type((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask) + 0.5)),
-            a(value_type(c.a * double(base_mask))) {}
+            v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))),
+            a((value_type)uround(c.a * double(base_mask))) {}
 
         //--------------------------------------------------------------------
         gray8(const rgba& c, double a_) :
-            v(value_type((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask) + 0.5)),
-            a(value_type(a_ * double(base_mask))) {}
+            v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))),
+            a((value_type)uround(a_ * double(base_mask))) {}
 
         //--------------------------------------------------------------------
         gray8(const rgba8& c) :
@@ -100,7 +100,7 @@ namespace agg
         {
             if(a_ < 0.0) a_ = 0.0;
             if(a_ > 1.0) a_ = 1.0;
-            a = value_type(a_ * double(base_mask));
+            a = (value_type)uround(a_ * double(base_mask));
         }
 
         //--------------------------------------------------------------------
@@ -148,7 +148,7 @@ namespace agg
                 return *this;
             }
             calc_type v_ = (calc_type(v) * base_mask) / a;
-            v = value_type((v_ > base_mask) ? base_mask : v_);
+            v = value_type((v_ > base_mask) ? (value_type)base_mask : v_);
             return *this;
         }
 
@@ -156,13 +156,38 @@ namespace agg
         self_type gradient(self_type c, double k) const
         {
             self_type ret;
-            calc_type ik = calc_type(k * base_size);
+            calc_type ik = uround(k * base_scale);
             ret.v = value_type(calc_type(v) + (((calc_type(c.v) - v) * ik) >> base_shift));
             ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift));
             return ret;
         }
 
         //--------------------------------------------------------------------
+        AGG_INLINE void add(const self_type& c, unsigned cover)
+        {
+            calc_type cv, ca;
+            if(cover == cover_mask)
+            {
+                if(c.a == base_mask) 
+                {
+                    *this = c;
+                }
+                else
+                {
+                    cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
+                    ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
+                }
+            }
+            else
+            {
+                cv = v + ((c.v * cover + cover_mask/2) >> cover_shift);
+                ca = a + ((c.a * cover + cover_mask/2) >> cover_shift);
+                v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
+                a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
+            }
+        }
+
+        //--------------------------------------------------------------------
         static self_type no_color() { return self_type(0,0); }
     };
 
@@ -202,11 +227,11 @@ namespace agg
         typedef int16u value_type;
         typedef int32u calc_type;
         typedef int64  long_type;
-        enum
+        enum base_scale_e
         {
             base_shift = 16,
-            base_size  = 1 << base_shift,
-            base_mask  = base_size - 1
+            base_scale = 1 << base_shift,
+            base_mask  = base_scale - 1
         };
         typedef gray16 self_type;
 
@@ -226,13 +251,13 @@ namespace agg
 
         //--------------------------------------------------------------------
         gray16(const rgba& c) :
-            v(value_type((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask) + 0.5)),
-            a(value_type(c.a * double(base_mask))) {}
+            v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))),
+            a((value_type)uround(c.a * double(base_mask))) {}
 
         //--------------------------------------------------------------------
         gray16(const rgba& c, double a_) :
-            v(value_type((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask) + 0.5)),
-            a(value_type(a_ * double(base_mask))) {}
+            v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))),
+            a((value_type)uround(a_ * double(base_mask))) {}
 
         //--------------------------------------------------------------------
         gray16(const rgba8& c) :
@@ -262,7 +287,7 @@ namespace agg
         {
             if(a_ < 0.0) a_ = 0.0;
             if(a_ > 1.0) a_ = 1.0;
-            a = value_type(a_ * double(base_mask));
+            a = (value_type)uround(a_ * double(base_mask));
         }
 
         //--------------------------------------------------------------------
@@ -318,13 +343,38 @@ namespace agg
         self_type gradient(self_type c, double k) const
         {
             self_type ret;
-            calc_type ik = calc_type(k * base_size);
+            calc_type ik = uround(k * base_scale);
             ret.v = value_type(calc_type(v) + (((calc_type(c.v) - v) * ik) >> base_shift));
             ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift));
             return ret;
         }
 
         //--------------------------------------------------------------------
+        AGG_INLINE void add(const self_type& c, unsigned cover)
+        {
+            calc_type cv, ca;
+            if(cover == cover_mask)
+            {
+                if(c.a == base_mask) 
+                {
+                    *this = c;
+                }
+                else
+                {
+                    cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
+                    ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
+                }
+            }
+            else
+            {
+                cv = v + ((c.v * cover + cover_mask/2) >> cover_shift);
+                ca = a + ((c.a * cover + cover_mask/2) >> cover_shift);
+                v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
+                a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
+            }
+        }
+
+        //--------------------------------------------------------------------
         static self_type no_color() { return self_type(0,0); }
     };
 



Mime
View raw message