[mapserver-commits] r10262 - sandbox/mapserver6

svn at osgeo.org svn at osgeo.org
Tue Jun 29 11:26:14 EDT 2010


Author: tbonfort
Date: 2010-06-29 15:26:14 +0000 (Tue, 29 Jun 2010)
New Revision: 10262

Modified:
   sandbox/mapserver6/configure
   sandbox/mapserver6/configure.in
   sandbox/mapserver6/mapagg2.cpp
   sandbox/mapserver6/mapcairo.c
   sandbox/mapserver6/mapgdal.c
   sandbox/mapserver6/mapoutput.c
   sandbox/mapserver6/maprendering.c
   sandbox/mapserver6/mapresample.c
   sandbox/mapserver6/maputil.c
Log:
restore gdal output


Modified: sandbox/mapserver6/configure
===================================================================
--- sandbox/mapserver6/configure	2010-06-29 13:08:39 UTC (rev 10261)
+++ sandbox/mapserver6/configure	2010-06-29 15:26:14 UTC (rev 10262)
@@ -12952,8 +12952,8 @@
 echo "${ECHO_T}        Enabling debug features: -g in CFLAGS." >&6
 
 else
-  CXXFLAGS=`echo "$CXXFLAGS " | sed "s/-g //"`
-  CFLAGS=`echo "$CFLAGS " | sed "s/-g //"`
+  CXXFLAGS=`echo "$CXXFLAGS -DNDEBUG " | sed "s/-g //"`
+  CFLAGS=`echo "$CFLAGS -DNDEBUG " | sed "s/-g //"`
 fi
 
 DEBUG_FLAGS=$DEBUG_FLAGS

Modified: sandbox/mapserver6/configure.in
===================================================================
--- sandbox/mapserver6/configure.in	2010-06-29 13:08:39 UTC (rev 10261)
+++ sandbox/mapserver6/configure.in	2010-06-29 15:26:14 UTC (rev 10262)
@@ -2425,8 +2425,8 @@
   AC_MSG_RESULT([        Enabling debug features: -g in CFLAGS.])
 
 else
-  CXXFLAGS=`echo "$CXXFLAGS " | sed "s/-g //"`
-  CFLAGS=`echo "$CFLAGS " | sed "s/-g //"`
+  CXXFLAGS=`echo "$CXXFLAGS -DNDEBUG " | sed "s/-g //"`
+  CFLAGS=`echo "$CFLAGS -DNDEBUG " | sed "s/-g //"`
 fi
 
 AC_SUBST(DEBUG_FLAGS, $DEBUG_FLAGS)

Modified: sandbox/mapserver6/mapagg2.cpp
===================================================================
--- sandbox/mapserver6/mapagg2.cpp	2010-06-29 13:08:39 UTC (rev 10261)
+++ sandbox/mapserver6/mapagg2.cpp	2010-06-29 15:26:14 UTC (rev 10262)
@@ -793,6 +793,7 @@
    renderer->supports_imagecache = 0;
    
    agg2InitCache(&(MS_RENDERER_CACHE(renderer)));
+   renderer->cleanup = agg2Cleanup;
    renderer->renderLine = &agg2RenderLine;
 
    renderer->renderPolygon = &agg2RenderPolygon;

Modified: sandbox/mapserver6/mapcairo.c
===================================================================
--- sandbox/mapserver6/mapcairo.c	2010-06-29 13:08:39 UTC (rev 10261)
+++ sandbox/mapserver6/mapcairo.c	2010-06-29 15:26:14 UTC (rev 10262)
@@ -75,7 +75,10 @@
 	cairo_t *dummycr;
 } cairoCacheData;
 
-void initializeCache(cairoCacheData *cache) {
+void initializeCache(void **vcache) {
+   cairoCacheData *cache = (cairoCacheData*)malloc(sizeof(cairoCacheData));
+   *vcache = cache;
+       
 	cache->facecache = NULL;
 	FT_Init_FreeType(&(cache->library));
 	/* dummy surface and context */
@@ -104,6 +107,7 @@
 	}
 	if(ccache->library)
 		FT_Done_FreeType(ccache->library);
+	free(ccache);
 	return MS_SUCCESS;
 }
 
@@ -841,8 +845,7 @@
     renderer->supports_imagecache=0;
     renderer->supports_pixel_buffer=1;
     renderer->supports_transparent_layers = 0;
-    MS_RENDERER_CACHE(renderer) = malloc(sizeof(cairoCacheData));
-    initializeCache(MS_RENDERER_CACHE(renderer));
+    initializeCache(&MS_RENDERER_CACHE(renderer));
     renderer->startLayer = startLayerRasterCairo;
     renderer->endLayer = closeLayerRasterCairo;
     renderer->renderLine=&renderLineCairo;
@@ -881,8 +884,7 @@
     renderer->supports_imagecache=0;
     renderer->supports_pixel_buffer=0;
     renderer->supports_transparent_layers = 1;
-    MS_RENDERER_CACHE(renderer) = malloc(sizeof(cairoCacheData));
-    initializeCache(MS_RENDERER_CACHE(renderer));
+    initializeCache(&MS_RENDERER_CACHE(renderer));
     renderer->startLayer = startLayerVectorCairo;
     renderer->endLayer = closeLayerVectorCairo;
     renderer->renderLine=&renderLineCairo;

Modified: sandbox/mapserver6/mapgdal.c
===================================================================
--- sandbox/mapserver6/mapgdal.c	2010-06-29 13:08:39 UTC (rev 10261)
+++ sandbox/mapserver6/mapgdal.c	2010-06-29 15:26:14 UTC (rev 10262)
@@ -128,9 +128,11 @@
     GByte       *pabyAlphaLine = NULL;
     char        **papszOptions = NULL;
     outputFormatObj *format = image->format;
+    rasterBufferObj rb;
     GDALDataType eDataType = GDT_Byte;
 
     msGDALInitialize();
+    memset(&rb,0,sizeof(rasterBufferObj));
 
 /* -------------------------------------------------------------------- */
 /*      Identify the proposed output driver.                            */
@@ -184,21 +186,21 @@
 /*      Establish the characteristics of our memory, and final          */
 /*      dataset.                                                        */
 /* -------------------------------------------------------------------- */
-#ifdef TBT
+
     if( format->imagemode == MS_IMAGEMODE_RGB )
     {
         nBands = 3;
-        assert( gdImageTrueColor( image->img.gd ) );
+        assert( MS_RENDERER_PLUGIN(format) && format->vtable->supports_pixel_buffer );
+        format->vtable->getRasterBufferHandle(image,&rb);
     }
     else if( format->imagemode == MS_IMAGEMODE_RGBA )
     {
         pabyAlphaLine = (GByte *) calloc(image->width,1);
         nBands = 4;
-        assert( gdImageTrueColor( image->img.gd ) );
+        assert( MS_RENDERER_PLUGIN(format) && format->vtable->supports_pixel_buffer );
+        format->vtable->getRasterBufferHandle(image,&rb);
     }
-    else
-#endif
-    if( format->imagemode == MS_IMAGEMODE_INT16 )
+    else if( format->imagemode == MS_IMAGEMODE_INT16 )
     {
         nBands = format->bands;
         eDataType = GDT_Int16;
@@ -213,13 +215,11 @@
         nBands = format->bands;
         eDataType = GDT_Byte;
     }
-#ifdef TBT
     else
     {
         assert( format->imagemode == MS_IMAGEMODE_PC256
-                && !gdImageTrueColor( image->img.gd ) );
+                && format->renderer == MS_RENDER_WITH_GD );
     }
-#endif //TBT
 
 /* -------------------------------------------------------------------- */
 /*      Create a memory dataset which we can use as a source for a      */
@@ -278,78 +278,62 @@
                               + iBand * image->width * image->height,
                               image->width, 1, GDT_Byte, 1, 0 );
             }
-#ifdef TBT
-#if GD2_VERS > 1
-            else if( nBands > 1 && iBand < 3 )
-            {
-                GByte *pabyData;
-#ifdef CPL_MSB
-
-                pabyData = ((GByte *) image->img.gd->tpixels[iLine])+iBand+1;
-#else
-                pabyData = ((GByte *) image->img.gd->tpixels[iLine])+(2-iBand);
-#endif
-                GDALRasterIO( hBand, GF_Write, 0, iLine, image->width, 1, 
-                              pabyData, image->width, 1, GDT_Byte, 4, 0 );
-            }
-            else if( nBands > 1 && iBand == 3 ) /* Alpha band */
-            {
-                int x;
-#ifdef CPL_MSB
-                GByte *pabySrc = ((GByte *) image->img.gd->tpixels[iLine]);
-#else
-                GByte *pabySrc = ((GByte *) image->img.gd->tpixels[iLine])+3;
-#endif
-
-                for( x = 0; x < image->width; x++ )
-                {
-                    if( *pabySrc == 127 )
-                        pabyAlphaLine[x] = 0;
-                    else
-                        pabyAlphaLine[x] = 255 - 2 * *pabySrc;
-
-                    pabySrc += 4;
-                }
-
-                GDALRasterIO( hBand, GF_Write, 0, iLine, image->width, 1, 
-                              pabyAlphaLine, image->width, 1, GDT_Byte, 1, 0 );
-            }
-#endif
-            else
-            {
-                GDALRasterIO( hBand, GF_Write, 0, iLine, image->width, 1, 
-                              image->img.gd->pixels[iLine], 
+            else if(format->renderer == MS_RENDER_WITH_GD) {
+               gdImagePtr img = (gdImagePtr)image->img.plugin;
+               GDALRasterIO( hBand, GF_Write, 0, iLine, image->width, 1, 
+                              img->pixels[iLine], 
                               image->width, 1, GDT_Byte, 0, 0 );
             }
-#endif //TBT
+            else {
+               GByte *pabyData;
+               unsigned char *pixptr = NULL;
+               assert( rb.type == MS_BUFFER_BYTE_RGBA );
+               switch(iBand) {
+               case 0:
+                  pixptr = rb.data.rgba.r;
+                  break;
+               case 1:
+                  pixptr = rb.data.rgba.g;
+                  break;
+               case 2:
+                  pixptr = rb.data.rgba.b;
+                  break;
+               case 3:
+                  pixptr = rb.data.rgba.a;
+                  break;
+               }
+               assert(pixptr);
+               pabyData = (GByte *)(pixptr + iLine*rb.data.rgba.row_step);
+               GDALRasterIO( hBand, GF_Write, 0, iLine, image->width, 1, 
+                             pabyData, image->width, 1, GDT_Byte, rb.data.rgba.pixel_step, 0 );
+            }
         }
     }
 
     if( pabyAlphaLine != NULL )
         free( pabyAlphaLine );
 
-#ifdef TBT
 /* -------------------------------------------------------------------- */
 /*      Attach the palette if appropriate.                              */
 /* -------------------------------------------------------------------- */
-    if( format->imagemode == MS_IMAGEMODE_PC256 )
+    if( format->renderer == MS_RENDER_WITH_GD )
     {
         GDALColorEntry sEntry;
         int  iColor;
         GDALColorTableH hCT;
-
+        gdImagePtr img = (gdImagePtr)image->img.plugin;
         hCT = GDALCreateColorTable( GPI_RGB );
 
-        for( iColor = 0; iColor < image->img.gd->colorsTotal; iColor++ )
+        for( iColor = 0; iColor < img->colorsTotal; iColor++ )
         {
-            sEntry.c1 = image->img.gd->red[iColor];
-            sEntry.c2 = image->img.gd->green[iColor];
-            sEntry.c3 = image->img.gd->blue[iColor];
+            sEntry.c1 = img->red[iColor];
+            sEntry.c2 = img->green[iColor];
+            sEntry.c3 = img->blue[iColor];
 
-            if( iColor == gdImageGetTransparent( image->img.gd ) )
+            if( iColor == gdImageGetTransparent( img ) )
                 sEntry.c4 = 0;
             else if( iColor == 0 
-                     && gdImageGetTransparent( image->img.gd ) == -1 
+                     && gdImageGetTransparent( img ) == -1 
                      && format->transparent )
                 sEntry.c4 = 0;
             else
@@ -385,7 +369,6 @@
             GDALGetRasterBand( hMemDS, 4 ), GCI_AlphaBand );
     }
 #endif
-#endif //TBT
 
 /* -------------------------------------------------------------------- */
 /*      Assign the projection and coordinate system to the memory       */
@@ -559,7 +542,7 @@
 /*      Initialize the object.                                          */
 /* -------------------------------------------------------------------- */
     format->imagemode = MS_IMAGEMODE_RGB;
-    format->renderer = MS_RENDER_WITH_GD;
+    format->renderer = MS_RENDER_WITH_AGG;
 
     /* Eventually we should have a way of deriving the mime type and extension */
     /* from the driver. */

Modified: sandbox/mapserver6/mapoutput.c
===================================================================
--- sandbox/mapserver6/mapoutput.c	2010-06-29 13:08:39 UTC (rev 10261)
+++ sandbox/mapserver6/mapoutput.c	2010-06-29 15:26:14 UTC (rev 10262)
@@ -288,9 +288,7 @@
     if( format != NULL )
         format->inmapfile = MS_FALSE;
     
-    if( format!= NULL && MS_RENDERER_PLUGIN(format) ) {
-        msInitializeRendererVTable(format);
-    }
+    
     return format;
 }
 
@@ -363,17 +361,15 @@
 {
     if( format == NULL )
         return;
-    if(MS_RENDERER_PLUGIN(format)) {
-        	format->vtable->cleanup(MS_RENDERER_CACHE(format->vtable));
-        }
+    if(MS_RENDERER_PLUGIN(format) && format->vtable) {
+       format->vtable->cleanup(MS_RENDERER_CACHE(format->vtable));
+       free( format->vtable );
+    }
     msFree( format->name );
     msFree( format->mimetype );
     msFree( format->driver );
     msFree( format->extension );
     msFreeCharArray( format->formatoptions, format->numformatoptions );
-    /* msFreeRendererVTable( format->vtable ); */
-    
-    msFree( format->vtable );
     msFree( format );
 }
 
@@ -642,6 +638,10 @@
 
     *target = format;
     format->refcount++;
+    if( MS_RENDERER_PLUGIN(format) ) {
+       msInitializeRendererVTable(format);
+    }
+    
 
     if( formatToFree )
         msFreeOutputFormat( formatToFree );
@@ -686,12 +686,6 @@
 
     dst->inmapfile = src->inmapfile;
     
-    
-    if( MS_RENDERER_PLUGIN(dst) ) 
-    {
-        msInitializeRendererVTable(dst);
-    }
-    
     return dst;
 }
 
@@ -1013,7 +1007,6 @@
            msDebug( "OUTPUTFORMAT %s has IMAGEMODE RGB/RGBA, which is not supported for GD drivers.",
                  format->name );
        format->renderer = MS_RENDER_WITH_AGG;
-       msInitializeRendererVTable(format);
     }
 
     return result;

Modified: sandbox/mapserver6/maprendering.c
===================================================================
--- sandbox/mapserver6/maprendering.c	2010-06-29 13:08:39 UTC (rev 10261)
+++ sandbox/mapserver6/maprendering.c	2010-06-29 15:26:14 UTC (rev 10262)
@@ -544,8 +544,11 @@
             }
             goto cleanup; /*finished plain polygon*/
          } else if(symbol->type == MS_SYMBOL_HATCH){
+            if(MS_VALID_COLOR(style->backgroundcolor)) {
+               renderer->renderPolygon(image,offsetPolygon, &style->backgroundcolor);
+            }
             double width = (style->width <= 0)?scalefactor:style->width*scalefactor;
-            style->color.alpha = MS_NINT(style->opacity*2.55);;
+            style->color.alpha = MS_NINT(style->opacity*2.55);
             double spacing = (style->size <= 0)?scalefactor:style->size*scalefactor;
             ret = msHatchPolygon(image,offsetPolygon,spacing,width,style->angle, &style->color);
          }

Modified: sandbox/mapserver6/mapresample.c
===================================================================
--- sandbox/mapserver6/mapresample.c	2010-06-29 13:08:39 UTC (rev 10261)
+++ sandbox/mapserver6/mapresample.c	2010-06-29 15:26:14 UTC (rev 10262)
@@ -1503,6 +1503,7 @@
 /* -------------------------------------------------------------------- */
     if( MS_RENDERER_PLUGIN(sDummyMap.outputformat) ) {
     	assert(rb);
+    	msInitializeRendererVTable(sDummyMap.outputformat);
     	if( rb->type == MS_BUFFER_GD ) {
     		assert( !gdImageTrueColor( rb->data.gd_img ) );
 			sDummyMap.outputformat->transparent = MS_TRUE;
@@ -1521,11 +1522,7 @@
 	
 			sDummyMap.outputformat->transparent = MS_TRUE;
 			sDummyMap.outputformat->imagemode = MS_IMAGEMODE_RGBA;
-	
-			sDummyMap.imagecolor.red = map->imagecolor.red;
-			sDummyMap.imagecolor.green = map->imagecolor.green;
-			sDummyMap.imagecolor.blue = map->imagecolor.blue;
-			sDummyMap.imagecolor.alpha = map->imagecolor.alpha;
+			MS_INIT_COLOR(sDummyMap.imagecolor,-1,-1,-1);
 		}
     }
 

Modified: sandbox/mapserver6/maputil.c
===================================================================
--- sandbox/mapserver6/maputil.c	2010-06-29 13:08:39 UTC (rev 10261)
+++ sandbox/mapserver6/maputil.c	2010-06-29 15:26:14 UTC (rev 10262)
@@ -664,9 +664,21 @@
 
     if (img)
     {
-        if (MS_RENDERER_PLUGIN(img->format)) {
+#ifdef USE_GDAL
+        if( MS_DRIVER_GDAL(img->format) )
+        {
+           if (map != NULL && filename != NULL )
+             nReturnVal = msSaveImageGDAL(map, img,
+                                          msBuildPath(szPath, map->mappath, 
+                                                      filename));
+           else
+             nReturnVal = msSaveImageGDAL(map, img, filename);
+        } else
+#endif
+       if (MS_RENDERER_PLUGIN(img->format)) {
             rendererVTableObj *renderer = img->format->vtable;
             FILE *stream;
+            int ret;
             if(filename) 
                 stream = fopen(msBuildPath(szPath, map->mappath, filename),"wb");
             else {
@@ -678,28 +690,19 @@
                 return MS_FAILURE;
             if(renderer->supports_pixel_buffer) {
                 rasterBufferObj data;
-                renderer->getRasterBufferHandle(img,&data);
+                if(renderer->getRasterBufferHandle(img,&data) != MS_SUCCESS)
+                   return MS_FAILURE;
 
-                msSaveRasterBuffer(&data,stream,img->format );
+                ret = msSaveRasterBuffer(&data,stream,img->format );
             } else {
-                renderer->saveImage(img, stream, img->format);
+                ret = renderer->saveImage(img, stream, img->format);
             }
             fclose(stream);
-            return MS_SUCCESS;
+            return ret;
         }
         else if( MS_DRIVER_IMAGEMAP(img->format) )
             nReturnVal = msSaveImageIM(img, filename, img->format);
-#ifdef USE_GDAL
-        else if( MS_DRIVER_GDAL(img->format) )
-        {
-           if (map != NULL && filename != NULL )
-             nReturnVal = msSaveImageGDAL(map, img,
-                                          msBuildPath(szPath, map->mappath, 
-                                                      filename));
-           else
-             nReturnVal = msSaveImageGDAL(map, img, filename);
-        }
-#endif
+
 #ifdef USE_MING_FLASH
         else if(MS_DRIVER_SWF(img->format) )
         {
@@ -1698,6 +1701,7 @@
 #ifdef USE_GEOS
   msGEOSCleanup();
 #endif
+  
   msIO_Cleanup();
 
   msResetErrorList();
@@ -1726,7 +1730,6 @@
                     unsigned char *red_dst, unsigned char *green_dst,
                     unsigned char *blue_dst, unsigned char *alpha_dst )
 {
-    int src_weight, dst_weight, tot_weight;
     double alpha , onealpha, dstalpha;
 /* -------------------------------------------------------------------- */
 /*      Simple cases we want to handle fast.                            */



More information about the mapserver-commits mailing list