[mapserver-commits] r10272 - sandbox/mapserver6

svn at osgeo.org svn at osgeo.org
Thu Jul 1 07:08:57 EDT 2010


Author: tbonfort
Date: 2010-07-01 11:08:56 +0000 (Thu, 01 Jul 2010)
New Revision: 10272

Modified:
   sandbox/mapserver6/mapagg.cpp
   sandbox/mapserver6/mapcairo.c
   sandbox/mapserver6/mapdummyrenderer.c
   sandbox/mapserver6/mapgd.c
   sandbox/mapserver6/maprendering.c
   sandbox/mapserver6/mapserver.h
Log:
cairo mem allocs


Modified: sandbox/mapserver6/mapagg.cpp
===================================================================
--- sandbox/mapserver6/mapagg.cpp	2010-07-01 10:20:50 UTC (rev 10271)
+++ sandbox/mapserver6/mapagg.cpp	2010-07-01 11:08:56 UTC (rev 10272)
@@ -765,10 +765,6 @@
    return MS_SUCCESS;
 }
 
-int agg2FreeTile(imageObj * tile) {
-	return MS_SUCCESS;
-}
-
 int agg2FreeSymbol(symbolObj * symbol) {
 	switch(symbol->type) {
 	case MS_SYMBOL_PIXMAP:
@@ -842,7 +838,6 @@
 
    renderer->transformShape = &msTransformShapeToPixel;
    renderer->freeImage = &agg2FreeImage;
-   renderer->freeTile = &agg2FreeTile;
    renderer->freeSymbol = &agg2FreeSymbol;
    renderer->cleanup = agg2Cleanup;
    

Modified: sandbox/mapserver6/mapcairo.c
===================================================================
--- sandbox/mapserver6/mapcairo.c	2010-07-01 10:20:50 UTC (rev 10271)
+++ sandbox/mapserver6/mapcairo.c	2010-07-01 11:08:56 UTC (rev 10272)
@@ -135,7 +135,7 @@
             msBufferFree(r->outputStream);
             free(r->outputStream);
         }
-        msFree(r);
+        free(r);
     }
     return MS_SUCCESS;
 }
@@ -167,9 +167,7 @@
     return newface;
 }
 
-inline void msCairoSetSourceColor(cairo_t *cr, colorObj *c) {
-	cairo_set_source_rgba(cr,c->red/255.0,c->green/255.0,c->blue/255.0,c->alpha/255.0);
-}
+#define msCairoSetSourceColor(cr, c) cairo_set_source_rgba((cr),(c)->red/255.0,(c)->green/255.0,(c)->blue/255.0,(c)->alpha/255.0);
 
 int renderLineCairo(imageObj *img, shapeObj *p, strokeStyleObj *stroke) {
 	cairo_renderer *r = CAIRO_RENDERER(img);
@@ -224,11 +222,6 @@
 	return MS_SUCCESS;
 }
 
-int freeTileCairo(imageObj *tile) {
-    freeImageCairo(tile);
-    return MS_SUCCESS;
-}
-
 int renderPolygonTiledCairo(imageObj *img, shapeObj *p,  imageObj *tile) {
     int i,j;
     cairo_renderer *r = CAIRO_RENDERER(img);
@@ -246,6 +239,7 @@
       //cairo_close_path(r->cr);
     }
     cairo_fill(r->cr);
+    cairo_pattern_destroy(pattern);
     return MS_SUCCESS;
 }
 
@@ -263,12 +257,13 @@
         symbolStyleObj *style) {
 	cairo_renderer *r = CAIRO_RENDERER(img);
 	cairo_surface_t *im;
-    rasterBufferObj *b = symbol->pixmap_buffer;
-    if(!b) {
-    	//should be caught at a higher level
-    	return MS_FAILURE;
-    }
-	im=createSurfaceFromBuffer(b);
+   rasterBufferObj *b = symbol->pixmap_buffer;
+   assert(b);
+   if(!symbol->renderer_cache) {
+      symbol->renderer_cache = (void*)createSurfaceFromBuffer(b);
+   }
+   assert(symbol->renderer_cache);
+	im=(cairo_surface_t*)symbol->renderer_cache;
 	cairo_save(r->cr);
 	if(style->rotation != 0 || style-> scale != 1) {
       cairo_translate (r->cr, x,y);
@@ -374,7 +369,7 @@
     return MS_SUCCESS;
 }
 
-void renderTileCairo(imageObj *img, imageObj *tile, double x, double y) {
+int renderTileCairo(imageObj *img, imageObj *tile, double x, double y) {
 	cairo_renderer *r = CAIRO_RENDERER(img);
     cairo_surface_t *im = CAIRO_RENDERER(tile)->surface;
 	int w = cairo_image_surface_get_width (im);
@@ -385,6 +380,7 @@
 	cairo_pattern_set_filter (cairo_get_source (r->cr), CAIRO_FILTER_NEAREST);
 	cairo_paint(r->cr);
 	cairo_restore(r->cr);
+	return MS_SUCCESS;
 }
 
 #define CAIROLINESPACE 1.33
@@ -628,24 +624,24 @@
 			r->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
 		}
 		r->cr = cairo_create(r->surface);
-        if(format->transparent || !bg || !MS_VALID_COLOR(*bg)) {
-           r->use_alpha = 1;
-			cairo_set_source_rgba (r->cr, 0,0,0,0);
+		if(format->transparent || !bg || !MS_VALID_COLOR(*bg)) {
+		   r->use_alpha = 1;
+		   cairo_set_source_rgba (r->cr, 0,0,0,0);
 		} else {
 		   r->use_alpha = 0;
-			msCairoSetSourceColor(r->cr,bg);
+		   msCairoSetSourceColor(r->cr,bg);
 		}
-        cairo_save (r->cr);
-        cairo_set_operator (r->cr, CAIRO_OPERATOR_SOURCE);
-        cairo_paint (r->cr);
-        cairo_restore (r->cr);
-        
+		cairo_save (r->cr);
+		cairo_set_operator (r->cr, CAIRO_OPERATOR_SOURCE);
+		cairo_paint (r->cr);
+		cairo_restore (r->cr);
+
 		cairo_set_line_cap (r->cr,CAIRO_LINE_CAP_ROUND);
 		cairo_set_line_join(r->cr,CAIRO_LINE_JOIN_ROUND);
 		image->img.plugin = (void*)r;
 	} else {
-		msSetError(MS_RENDERERERR, "Cannot create cairo image of size %dx%d.",
-			"msImageCreateCairo()", width, height);
+	   msSetError(MS_RENDERERERR, "Cannot create cairo image of size %dx%d.",
+	         "msImageCreateCairo()", width, height);
 	}
 	return image;
 }
@@ -842,7 +838,6 @@
 
 int msPopulateRendererVTableCairoRaster( rendererVTableObj *renderer ) {
 #ifdef USE_CAIRO
-    renderer->supports_imagecache=0;
     renderer->supports_pixel_buffer=1;
     renderer->supports_transparent_layers = 0;
     initializeCache(&MS_RENDERER_CACHE(renderer));
@@ -868,7 +863,6 @@
     renderer->renderTile = &renderTileCairo;
     renderer->loadImageFromFile = &msLoadMSRasterBufferFromFile;
     renderer->renderPolygonTiled = &renderPolygonTiledCairo;
-    renderer->freeTile = &freeTileCairo;
     renderer->freeSymbol = &freeSymbolCairo;
     renderer->cleanup = &cleanupCairo;
     return MS_SUCCESS;
@@ -906,7 +900,6 @@
     renderer->getTruetypeTextBBox = &getTruetypeTextBBoxCairo;
     renderer->renderTile = &renderTileCairo;
     renderer->renderPolygonTiled = &renderPolygonTiledCairo;
-    renderer->freeTile = &freeTileCairo;
     renderer->freeSymbol = &freeSymbolCairo;
     renderer->cleanup = &cleanupCairo;
     return MS_SUCCESS;

Modified: sandbox/mapserver6/mapdummyrenderer.c
===================================================================
--- sandbox/mapserver6/mapdummyrenderer.c	2010-07-01 10:20:50 UTC (rev 10271)
+++ sandbox/mapserver6/mapdummyrenderer.c	2010-07-01 11:08:56 UTC (rev 10272)
@@ -254,7 +254,6 @@
 	renderer->getTruetypeTextBBox = &getTruetypeTextBBoxDummy;
 	renderer->renderTile = &renderTileDummy;
 	renderer->renderPolygonTiled = &renderPolygonTiledDummy;
-	renderer->freeTile = &freeTileDummy;
 	renderer->freeSymbol = &freeSymbolDummy;
 	renderer->cleanup = &cleanupDummy;
 	renderer->startShape = NULL;

Modified: sandbox/mapserver6/mapgd.c
===================================================================
--- sandbox/mapserver6/mapgd.c	2010-07-01 10:20:50 UTC (rev 10271)
+++ sandbox/mapserver6/mapgd.c	2010-07-01 11:08:56 UTC (rev 10272)
@@ -910,10 +910,6 @@
 /*
 ** Misc. cleanup functions for GD driver.
 */
-int freeTileGD(imageObj *tile) {
-  freeImageGD(tile);
-  return MS_SUCCESS;
-}
 
 int freeSymbolGD(symbolObj *s) {
   return MS_SUCCESS;
@@ -958,7 +954,6 @@
   renderer->getTruetypeTextBBox = &getTruetypeTextBBoxGD;
   renderer->renderTile = &renderTileGD;
   renderer->renderPolygonTiled = &renderPolygonTiledGD;
-  renderer->freeTile = &freeTileGD;
   renderer->freeSymbol = &freeSymbolGD;
   return MS_SUCCESS;
 }

Modified: sandbox/mapserver6/maprendering.c
===================================================================
--- sandbox/mapserver6/maprendering.c	2010-07-01 10:20:50 UTC (rev 10271)
+++ sandbox/mapserver6/maprendering.c	2010-07-01 11:08:56 UTC (rev 10272)
@@ -168,7 +168,7 @@
         while(cachep->next && cachep->next->next) cachep = cachep->next;
 
         /*free the last tile's data*/
-        img->format->vtable->freeTile(cachep->next->image);
+        msFreeImage(cachep->next->image);
 
         /*reuse the last tile object*/
             /* make the cache point to the start of the list*/

Modified: sandbox/mapserver6/mapserver.h
===================================================================
--- sandbox/mapserver6/mapserver.h	2010-07-01 10:20:50 UTC (rev 10271)
+++ sandbox/mapserver6/mapserver.h	2010-07-01 11:08:56 UTC (rev 10272)
@@ -2599,7 +2599,6 @@
 
 	int (*transformShape)(shapeObj *shape, rectObj extend, double cellsize, enum MS_SIMPLIFY_MODE simplify);
 	int (*freeImage)(imageObj *image);
-	int (*freeTile)(imageObj *tile);
 	int (*freeSymbol)(symbolObj *symbol);
 	int (*cleanup)(void *renderer_data);
 } ;



More information about the mapserver-commits mailing list