[mapserver-commits] r8711 - sandbox/graphics
svn at osgeo.org
svn at osgeo.org
Mon Mar 9 14:02:08 EDT 2009
Author: tbonfort
Date: 2009-03-09 14:02:08 -0400 (Mon, 09 Mar 2009)
New Revision: 8711
Modified:
sandbox/graphics/mapagg.cpp
sandbox/graphics/mapgd.c
sandbox/graphics/mapimagecache.c
sandbox/graphics/mapobject.c
sandbox/graphics/maprendering.c
sandbox/graphics/mapserver.h
sandbox/graphics/mapsymbol.c
sandbox/graphics/mapsymbol.h
Log:
revert cache clearing functions. the reference to the renderobj is now stored inside the structure instead of being passed to the freeing functions
Modified: sandbox/graphics/mapagg.cpp
===================================================================
--- sandbox/graphics/mapagg.cpp 2009-03-09 17:43:44 UTC (rev 8710)
+++ sandbox/graphics/mapagg.cpp 2009-03-09 18:02:08 UTC (rev 8711)
@@ -1187,7 +1187,7 @@
}
if(bRotated) { // free the rotated symbol
- msFreeSymbol(symbol,NULL);
+ msFreeSymbol(symbol);
msFree(symbol);
}
}
@@ -1318,7 +1318,7 @@
break;
}
if(bRotated) {
- msFreeSymbol(symbol,NULL); // clean up
+ msFreeSymbol(symbol); // clean up
msFree(symbol);
}
}
@@ -1459,7 +1459,7 @@
if(symbol->type==MS_SYMBOL_VECTOR && bRotated) {
- msFreeSymbol(symbol,NULL); // clean up
+ msFreeSymbol(symbol); // clean up
msFree(symbol);
}
}
@@ -1723,7 +1723,7 @@
ren->renderPolylineVectorSymbol(*lines,stroke,pw,ph,*color,agg_bcolor);
}
if(bRotated) { /* free the rotated symbol */
- msFreeSymbol(symbol,NULL);
+ msFreeSymbol(symbol);
msFree(symbol);
}
}
@@ -1891,7 +1891,7 @@
ren->renderPathSolid(*polygons,AGG_NO_COLOR,agg_ocolor,1);
if(bRotated) { // free the rotated symbol
- msFreeSymbol(symbol,NULL);
+ msFreeSymbol(symbol);
msFree(symbol);
}
}
Modified: sandbox/graphics/mapgd.c
===================================================================
--- sandbox/graphics/mapgd.c 2009-03-09 17:43:44 UTC (rev 8710)
+++ sandbox/graphics/mapgd.c 2009-03-09 18:02:08 UTC (rev 8711)
@@ -1113,7 +1113,7 @@
if(gdImageTrueColor(img) && width > 1 && style->antialias == MS_TRUE) { /* use a fuzzy brush */
if((brush = searchImageCache(symbolset->imagecache, &tmpStyle)) == NULL) {
brush = createFuzzyBrush(width, gdImageRed(img, fc), gdImageGreen(img, fc), gdImageBlue(img, fc));
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
gdImageSetBrush(img, brush);
gdImageArc(img, (int)p->x + ox, (int)p->y + oy, (int)2*r, (int)2*r, 0, 360, gdBrushed);
@@ -1136,7 +1136,7 @@
if(gdImageTrueColor(img) && width > 1 && style->antialias == MS_TRUE) { /* use a fuzzy brush */
if((brush = searchImageCache(symbolset->imagecache, &tmpStyle)) == NULL) {
brush = createFuzzyBrush(width, gdImageRed(img, fc), gdImageGreen(img, fc), gdImageBlue(img, fc));
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
gdImageSetBrush(img, brush);
fc = 1; bc = 0;
@@ -1166,7 +1166,7 @@
/* create the brush image if not already in the cache */
if((brush = searchImageCache(symbolset->imagecache, &tmpStyle)) == NULL) {
brush = createFuzzyBrush(x, gdImageRed(img, fc), gdImageGreen(img, fc), gdImageBlue(img, fc));
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
} else {
@@ -1183,7 +1183,7 @@
else
gdImageArc(brush, x, y, MS_NINT(d*symbol->points[0].x), MS_NINT(d*symbol->points[0].y), 0, 360, brush_fc);
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
}
@@ -1214,7 +1214,7 @@
}
gdImageFilledPolygon(brush, points, symbol->numpoints, brush_fc);
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
gdImageSetBrush(img, brush);
@@ -1476,7 +1476,7 @@
if(tile) gdImageDestroy(tile);
if(bRotated) { /* free the rotated symbol */
- msFreeSymbol(symbol,NULL);
+ msFreeSymbol(symbol);
msFree(symbol);
}
@@ -1598,7 +1598,7 @@
}
if(bRotated) {
- msFreeSymbol(symbol,NULL); /* clean up */
+ msFreeSymbol(symbol); /* clean up */
msFree(symbol);
}
@@ -1714,7 +1714,7 @@
} /* end if-then-else */
if(bRotated) {
- msFreeSymbol(symbol,NULL); /* clean up */
+ msFreeSymbol(symbol); /* clean up */
msFree(symbol);
}
@@ -1795,7 +1795,7 @@
if(gdImageTrueColor(img) && width > 1 && style->antialias == MS_TRUE) { /* use a fuzzy brush */
if((brush = searchImageCache(symbolset->imagecache, &tmpStyle)) == NULL) {
brush = createFuzzyBrush(width, gdImageRed(img, fc), gdImageGreen(img, fc), gdImageBlue(img, fc));
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
gdImageSetBrush(img, brush);
gdImageAlphaBlending(img, 1);
@@ -1821,7 +1821,7 @@
if(gdImageTrueColor(img) && width > 1 && style->antialias == MS_TRUE) { /* use a fuzzy brush */
if((brush = searchImageCache(symbolset->imagecache, &tmpStyle)) == NULL) {
brush = createFuzzyBrush(width, gdImageRed(img, fc), gdImageGreen(img, fc), gdImageBlue(img, fc));
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
gdImageAlphaBlending(img, 1);
gdImageSetBrush(img, brush);
@@ -1855,7 +1855,7 @@
/* create the brush image if not already in the cache */
if((brush = searchImageCache(symbolset->imagecache, &tmpStyle)) == NULL) {
brush = createFuzzyBrush(x, gdImageRed(img, fc), gdImageGreen(img, fc), gdImageBlue(img, fc));
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
gdImageAlphaBlending(img, 1);
} else {
@@ -1873,7 +1873,7 @@
else
gdImageArc(brush, x, y, MS_NINT(d*symbol->points[0].x), MS_NINT(d*symbol->points[0].y), 0, 360, brush_fc);
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
}
@@ -1948,7 +1948,7 @@
}
}
- symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush, NULL);
+ symbolset->imagecache = addImageCache(symbolset->imagecache, &symbolset->imagecachesize, &tmpStyle, brush);
}
gdImageSetBrush(img, brush);
@@ -2001,7 +2001,7 @@
gdImageAlphaBlending(img, oldAlphaBlending);
gdImageSetThickness(img, 1);
if(oldsymbol) {
- msFreeSymbol(symbol,NULL); /* delete rotated version */
+ msFreeSymbol(symbol); /* delete rotated version */
symbol = oldsymbol;
}
@@ -2173,7 +2173,7 @@
if(oc>-1) imagePolyline(img, p, oc, ox, oy);
if(bRotated) { /* free the rotated symbol */
- msFreeSymbol(symbol,NULL);
+ msFreeSymbol(symbol);
msFree(symbol);
}
@@ -2314,7 +2314,7 @@
gdImageDestroy(tile);
if(bRotated) { /* free the rotated symbol */
- msFreeSymbol(symbol,NULL);
+ msFreeSymbol(symbol);
msFree(symbol);
}
Modified: sandbox/graphics/mapimagecache.c
===================================================================
--- sandbox/graphics/mapimagecache.c 2009-03-09 17:43:44 UTC (rev 8710)
+++ sandbox/graphics/mapimagecache.c 2009-03-09 18:02:08 UTC (rev 8711)
@@ -28,14 +28,14 @@
}
struct imageCacheObj *addImageCache(struct imageCacheObj *ic, int *icsize, styleObj *style,
- void *img, renderObj *r)
+ void *img)
{
struct imageCacheObj *icp;
if(*icsize > MS_IMAGECACHESIZE) { /* remove last element, size stays the same */
icp = ic;
while(icp->next && icp->next->next) icp = icp->next;
- freeImageCache(icp->next,r);
+ freeImageCache(icp->next);
icp->next = NULL;
} else
@@ -57,4 +57,4 @@
icp->next = ic; /* insert at the beginning */
return(icp);
-}
\ No newline at end of file
+}
Modified: sandbox/graphics/mapobject.c
===================================================================
--- sandbox/graphics/mapobject.c 2009-03-09 17:43:44 UTC (rev 8710)
+++ sandbox/graphics/mapobject.c 2009-03-09 18:02:08 UTC (rev 8711)
@@ -99,7 +99,7 @@
msFreeFontSet(&(map->fontset));
- msFreeSymbolSet(&map->symbolset, map->outputformat->r); /* free symbols */
+ msFreeSymbolSet(&map->symbolset); /* free symbols */
msFree(map->symbolset.filename);
freeWeb(&(map->web));
Modified: sandbox/graphics/maprendering.c
===================================================================
--- sandbox/graphics/maprendering.c 2009-03-09 17:43:44 UTC (rev 8710)
+++ sandbox/graphics/maprendering.c 2009-03-09 18:02:08 UTC (rev 8711)
@@ -83,7 +83,8 @@
break;
}
symbolset->imagecache = addImageCache(symbolset->imagecache,
- &symbolset->imagecachesize, style, tile, r);
+ &symbolset->imagecachesize, style, tile);
+ symbolset->imagecache->renderer = r;
}
return tile;
}
@@ -303,6 +304,8 @@
if (style->symbol >= symbolset->numsymbols || style->symbol < 0)
return; /* no such symbol, 0 is OK */
symbol = symbolset->symbol[style->symbol];
+ /* store a reference to the renderer to be used for freeing */
+ symbol->renderer = r;
if (p->numlines == 0)
return;
@@ -360,7 +363,11 @@
double ox, oy, size, angle_radians, width,scaling;
shapeObj *offsetPolygon = NULL;
symbolObj *symbol = symbolset->symbol[style->symbol];
- colorObj c = style->color;
+
+ /* store a reference to the renderer to be used for freeing */
+ symbol->renderer = r;
+
+ colorObj c = style->color;
colorObj oc = style->outlinecolor;
colorObj bc = style->backgroundcolor;
double ow = style->outlinewidth == 0 ? 1.0 : style->outlinewidth;
@@ -480,7 +487,10 @@
if (style->symbol >= symbolset->numsymbols || style->symbol < 0)
return; /* no such symbol, 0 is OK */
symbol = symbolset->symbol[style->symbol];
- computeStyle(style,&s,symbol,scalefactor);
+ /* store a reference to the renderer to be used for freeing */
+ symbol->renderer = r;
+
+ computeStyle(style,&s,symbol,scalefactor);
if(symbol->type!= MS_SYMBOL_PIXMAP) {
if (!symbol->filled) {
c=NULL;
@@ -626,7 +636,7 @@
if (image) {
if (MS_RENDERER_PLUGIN(image->format)) {
renderObj *r = image->format->r;
- double x, y;
+ double x, y;
if (!string || !strlen(string))
return (0); // not errors, just don't want to do anything
Modified: sandbox/graphics/mapserver.h
===================================================================
--- sandbox/graphics/mapserver.h 2009-03-09 17:43:44 UTC (rev 8710)
+++ sandbox/graphics/mapserver.h 2009-03-09 18:02:08 UTC (rev 8711)
@@ -89,6 +89,12 @@
typedef uint32_t ms_uint32;
#endif
+/*forward declaration of rendering object*/
+struct renderer;
+typedef struct renderer renderObj;
+
+
+
#include "maperror.h"
#include "mapprimitive.h"
#include "mapshape.h"
@@ -530,10 +536,6 @@
/* see mapoutput.c for most related code. */
/************************************************************************/
-/*forward declaration of rendering object*/
-struct renderer;
-typedef struct renderer renderObj;
-
typedef struct {
char *name;
char *mimetype;
@@ -1724,8 +1726,8 @@
MS_DLL_EXPORT void msInitSymbolSet(symbolSetObj *symbolset);
MS_DLL_EXPORT symbolObj *msGrowSymbolSet( symbolSetObj *symbolset );
MS_DLL_EXPORT int msAddImageSymbol(symbolSetObj *symbolset, char *filename);
-MS_DLL_EXPORT int msFreeSymbolSet(symbolSetObj *symbolset, renderObj *renderer);
-MS_DLL_EXPORT int msFreeSymbol(symbolObj *symbol, renderObj *renderer);
+MS_DLL_EXPORT int msFreeSymbolSet(symbolSetObj *symbolset);
+MS_DLL_EXPORT int msFreeSymbol(symbolObj *symbol);
MS_DLL_EXPORT int msAddNewSymbol(mapObj *map, char *name);
MS_DLL_EXPORT int msAppendSymbol(symbolSetObj *symbolset, symbolObj *symbol);
MS_DLL_EXPORT symbolObj *msRemoveSymbol(symbolSetObj *symbolset, int index);
@@ -1739,7 +1741,7 @@
MS_DLL_EXPORT int msGetMarkerSize(symbolSetObj *symbolset, styleObj *style, int *width, int *height, double scalefactor);
MS_DLL_EXPORT int msGetCharacterSize(char *character, int size, char *font, rectObj *rect);
MS_DLL_EXPORT double msSymbolGetDefaultSize(symbolObj *s);
-MS_DLL_EXPORT void freeImageCache(struct imageCacheObj *ic, renderObj *r);
+MS_DLL_EXPORT void freeImageCache(struct imageCacheObj *ic);
MS_DLL_EXPORT imageObj *msDrawLegend(mapObj *map, int scale_independent); /* in maplegend.c */
MS_DLL_EXPORT int msLegendCalcSize(mapObj *map, int scale_independent, int *size_x, int *size_y, layerObj *lp);
@@ -2467,7 +2469,7 @@
void *searchImageCache(struct imageCacheObj *ic, styleObj *style);
struct imageCacheObj *addImageCache(struct imageCacheObj *ic, int *icsize, styleObj *style,
- void *img, renderObj *r);
+ void *img);
renderObj* msCreateRenderer(int type);
struct renderer{
void *renderer_data;
Modified: sandbox/graphics/mapsymbol.c
===================================================================
--- sandbox/graphics/mapsymbol.c 2009-03-09 17:43:44 UTC (rev 8710)
+++ sandbox/graphics/mapsymbol.c 2009-03-09 18:02:08 UTC (rev 8711)
@@ -54,14 +54,14 @@
extern char *msPositionsText[]; /* Defined in mapfile.c */
static char *msCapsJoinsCorners[7]={"NONE", "BEVEL", "BUTT", "MITER", "ROUND", "SQUARE", "TRIANGLE"};
-void freeImageCache(struct imageCacheObj *ic, renderObj *r)
+void freeImageCache(struct imageCacheObj *ic)
{
if(ic) {
- freeImageCache(ic->next,r); /* free any children */
- if(r==NULL)
+ freeImageCache(ic->next); /* free any children */
+ if(ic->renderer==NULL)
gdImageDestroy(ic->img);
else
- r->freeTile(ic->img);
+ ic->renderer->freeTile(ic->img);
free(ic);
}
return;
@@ -137,6 +137,7 @@
s->numpoints=0;
s->img = NULL;
s->renderer_cache=NULL;
+ s->renderer=NULL;
s->imagepath = NULL;
s->name = NULL;
s->gap = 0;
@@ -151,7 +152,7 @@
s->linejoinmaxsize = 3;
}
-int msFreeSymbol(symbolObj *s, renderObj *r) {
+int msFreeSymbol(symbolObj *s) {
if(!s) return MS_FAILURE;
if( MS_REFCNT_DECR_IS_NOT_ZERO(s) ) {
return MS_FAILURE;
@@ -159,8 +160,8 @@
if(s->name) free(s->name);
if(s->img) gdImageDestroy(s->img);
- if(r!=NULL) {
- r->freeSymbol(s);
+ if(s->renderer!=NULL) {
+ s->renderer->freeSymbol(s);
}
#ifdef USE_AGG
else
@@ -515,14 +516,14 @@
return(i);
}
-int msFreeSymbolSet(symbolSetObj *symbolset, renderObj *renderer)
+int msFreeSymbolSet(symbolSetObj *symbolset)
{
int i;
- freeImageCache(symbolset->imagecache, renderer);
+ freeImageCache(symbolset->imagecache);
for(i=0; i<symbolset->numsymbols; i++) {
if (symbolset->symbol[i]!=NULL) {
- if ( msFreeSymbol((symbolset->symbol[i]), renderer) == MS_SUCCESS ) {
+ if ( msFreeSymbol((symbolset->symbol[i])) == MS_SUCCESS ) {
msFree(symbolset->symbol[i]);
symbolset->symbol[i]=NULL;
}
Modified: sandbox/graphics/mapsymbol.h
===================================================================
--- sandbox/graphics/mapsymbol.h 2009-03-09 17:43:44 UTC (rev 8710)
+++ sandbox/graphics/mapsymbol.h 2009-03-09 18:02:08 UTC (rev 8711)
@@ -59,6 +59,7 @@
colorObj outlinecolor;
colorObj backgroundcolor;
void* img;
+ renderObj *renderer;
struct imageCacheObj *next;
};
#endif /* SWIG */
@@ -105,6 +106,7 @@
#ifndef SWIG
gdImagePtr img;
void *renderer_cache; /* Renderer storage */
+ renderObj *renderer;
#endif /* SWIG */
#ifdef SWIG
More information about the mapserver-commits
mailing list