Tim,

Attached is a patch you can apply to mapagg.cpp - if you can't apply
it I'll mail you the whole file.

it basically switches to aliased rendering if you use
SYMBOL
TYPE SIMPLE
ANTIALIASED FALSE
NAME 'aliased'
END

it'll work *only* on line and polygon layers, if you specify a
STYLE
NAME 'aliased'
COLOR  r g b
END

nothing other is supported (line widths, or polygon outlines)

I'd be interested to hear about timings if you can try it

tb
Index: mapagg.cpp
===================================================================
--- mapagg.cpp  (revision 6894)
+++ mapagg.cpp  (working copy)
@@ -101,7 +101,6 @@
 #endif
 
 
-
 typedef agg::rgba8 color_type;
 typedef agg::font_engine_freetype_int16 font_engine_type;
 typedef agg::font_cache_manager<font_engine_type> font_manager_type;
@@ -113,6 +112,8 @@
 typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_aa;
 typedef agg::renderer_outline_aa<renderer_base> renderer_oaa;
 typedef agg::renderer_primitives<renderer_base> renderer_prim;
+typedef agg::renderer_scanline_bin_solid<renderer_base> renderer_bin;
+
 typedef agg::rasterizer_outline_aa<renderer_oaa> rasterizer_outline_aa;
 typedef agg::rasterizer_outline <renderer_prim> rasterizer_outline;
 typedef agg::rasterizer_scanline_aa<> rasterizer_scanline;
@@ -228,6 +229,9 @@
         ren_base(thePixelFormat),
         ren_base_pre(thePixelFormat_pre),
         ren_aa(ren_base),
+        ren_prim(ren_base),
+        ren_bin(ren_base),
+        ras_oa(ren_prim),
         m_fman(m_feng)
         {
             
@@ -279,7 +283,7 @@
         ras_aa.reset();
         ras_aa.filling_rule(agg::fill_non_zero);
         ren_aa.color(msToAGGColor(c));
-
+        
         if (dashstylelength <= 0) {
             agg::conv_stroke<agg::path_storage> stroke(p);  
             stroke.width(width);
@@ -301,6 +305,14 @@
         agg::render_scanlines(ras_aa, sl, ren_aa);     
     }
     
+    ///render an aliased 1 pixel width polyline
+    ///@param p the path_storage containing the vertexes of the polyline
+    ///@param c the color of the line
+    void renderPolylineFast(agg::path_storage &p,colorObj *c) {
+        ren_prim.line_color(msToAGGColor(c));
+        ras_oa.add_path(p);
+    }
+    
     ///brush a polyline with a vector symbol. draws the vector symbol in a temporary
     ///image that will be used as a brush for rendering the polyline. this function
     ///doesn't do any actual rendering, it only creates the brush and forwards to the
@@ -393,6 +405,18 @@
             agg::render_scanlines ( ras_aa, sl, ren_aa );
         }
     }
+    
+    ///render a non antialiased shape represented by an agg::path_storage 
+    ///@param path the path containing the geometry to render
+    ///@param color fill color or null for no fill
+    void renderPathSolidFast(agg::path_storage &path, colorObj *color) {
+        ras_aa.reset();
+        ren_bin.color(msToAGGColor(color));
+        ras_aa.add_path(path);
+        agg::render_scanlines(ras_aa, m_sl_bin, ren_bin);
+    }
+    
+    
 
     ///render a fill pattern clipped by a shape
     ///this has only been tested when pattern is a stroke, and clipper a path.
@@ -720,8 +744,12 @@
     renderer_base ren_base;
     renderer_base_pre ren_base_pre;
     renderer_aa ren_aa;
+    renderer_prim ren_prim;
+    renderer_bin ren_bin;
     scanline sl;
+    agg::scanline_bin m_sl_bin;
     rasterizer_scanline ras_aa;
+    rasterizer_outline ras_oa;
     font_engine_type m_feng;
     font_manager_type m_fman;
     agg::rgba msToAGGColor(colorObj *c) {
@@ -762,6 +790,8 @@
     return pNewImage;
 }
 
+
+
 ///internally used function to get the cached AGG renderer.
 AGGMapserverRenderer* getAGGRenderer(imageObj *image) {
     return (AGGMapserverRenderer*)image->imageextra;
@@ -767,6 +797,7 @@
     return (AGGMapserverRenderer*)image->imageextra;
 }
 
+
 // ----------------------------------------------------------------------
 // Utility function to initialize the color of an image.  The background
 // color is passed, but the outputFormatObj is consulted to see if the
@@ -1483,7 +1514,10 @@
         else
             nwidth=width;
         //render the polyline with optional dashing
-        ren->renderPolyline(line,color,nwidth,symbol->patternlength,symbol->pattern);
+        if(symbol->type==MS_SYMBOL_SIMPLE && symbol->antialias==MS_FALSE && symbol->patternlength<=0)
+            ren->renderPolylineFast(line,color);
+        else
+            ren->renderPolyline(line,color,nwidth,symbol->patternlength,symbol->pattern);
     }
     else if(symbol->type==MS_SYMBOL_TRUETYPE) {
         //specific function that treats truetype symbols
@@ -1602,6 +1636,10 @@
 
     AGGMapserverRenderer* ren = getAGGRenderer(image);
     agg::path_storage polygon = shapePolygonToPath(p,0,0);
+    if(symbol->type==MS_SYMBOL_SIMPLE &&symbol->antialias==MS_FALSE) { // solid fill
+                ren->renderPathSolidFast(polygon,&(style->color));
+                return; // done simple case
+    }
     if(style->symbol == 0 || symbol->type==MS_SYMBOL_SIMPLE) {
         // simply draw a solid fill and outline of the specified colors
         if(MS_VALID_COLOR(style->outlinecolor))

Reply via email to