[mapserver-commits] r9114 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Sun Jun 21 14:20:48 EDT 2009
Author: tbonfort
Date: 2009-06-21 14:20:48 -0400 (Sun, 21 Jun 2009)
New Revision: 9114
Modified:
trunk/mapserver/mapcairo.c
trunk/mapserver/mapdraw.c
trunk/mapserver/maplabel.c
trunk/mapserver/mapogl.cpp
trunk/mapserver/mapoutput.c
trunk/mapserver/maprendering.c
trunk/mapserver/mapserver.h
trunk/mapserver/mapsymbol.h
trunk/mapserver/maputil.c
Log:
refactor renderer plugins to follow the layer vtable approach a bit more closely
Modified: trunk/mapserver/mapcairo.c
===================================================================
--- trunk/mapserver/mapcairo.c 2009-06-19 14:00:59 UTC (rev 9113)
+++ trunk/mapserver/mapcairo.c 2009-06-21 18:20:48 UTC (rev 9114)
@@ -26,10 +26,10 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
+#include "mapserver.h"
#ifdef USE_CAIRO
-#include "mapserver.h"
#include <cairo.h>
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <cairo-pdf.h>
@@ -51,6 +51,8 @@
*/
+
+
/* trivial cache container */
struct facecache;
typedef struct facecache faceCacheObj;
@@ -749,4 +751,81 @@
s->renderer_cache=NULL;
}
+#endif /*USE_CAIRO*/
+
+
+int msPopulateRendererVTableCairoRaster( rendererVTableObj *renderer ) {
+#ifdef USE_CAIRO
+ renderer->supports_imagecache=0;
+ renderer->supports_pixel_buffer=1;
+ renderer->supports_transparent_layers = 1;
+ renderer->startNewLayer = startNewLayerCairo;
+ renderer->closeNewLayer = closeNewLayerCairo;
+ renderer->renderLine=&renderLineCairo;
+ renderer->createImage=&createImageCairo;
+ renderer->saveImage=&saveImageCairo;
+ renderer->getRasterBuffer=&getRasterBufferCairo;
+ renderer->transformShape=&msTransformShapeAGG;
+ renderer->renderPolygon=&renderPolygonCairo;
+ renderer->renderGlyphsLine=&renderGlyphsLineCairo;
+ renderer->renderGlyphs=&renderGlyphsCairo;
+ renderer->freeImage=&freeImageCairo;
+ renderer->renderEllipseSymbol = &renderEllipseSymbolCairo;
+ renderer->renderVectorSymbol = &renderVectorSymbolCairo;
+ renderer->renderTruetypeSymbol = &renderTruetypeSymbolCairo;
+ renderer->renderPixmapSymbol = &renderPixmapSymbolCairo;
+ renderer->mergeRasterBuffer = &mergeRasterBufferCairo;
+ renderer->getTruetypeTextBBox = &getTruetypeTextBBoxCairo;
+ renderer->renderTile = &renderTileCairo;
+ renderer->renderPolygonTiled = &renderPolygonTiledCairo;
+ renderer->freeTile = &freeTileCairo;
+ renderer->freeSymbol = &freeSymbolCairo;
+ return MS_SUCCESS;
+#else
+ msSetError(MS_MISCERR, "Cairo Driver requested but is not built in",
+ "msPopulateRendererVTableCairoRaster()");
+ return MS_FAILURE;
#endif
+}
+
+inline int populateRendererVTableCairoVector( rendererVTableObj *renderer ) {
+#ifdef USE_CAIRO
+ renderer->supports_imagecache=0;
+ renderer->supports_pixel_buffer=0;
+ renderer->supports_transparent_layers = 1;
+ renderer->startNewLayer = startNewLayerCairo;
+ renderer->closeNewLayer = closeNewLayerCairo;
+ renderer->renderLine=&renderLineCairo;
+ renderer->createImage=&createImageCairo;
+ renderer->saveImage=&saveImageCairo;
+ renderer->getRasterBuffer=&getRasterBufferCairo;
+ renderer->transformShape=&msTransformShapeAGG;
+ renderer->renderPolygon=&renderPolygonCairo;
+ renderer->renderGlyphsLine=&renderGlyphsLineCairo;
+ renderer->renderGlyphs=&renderGlyphsCairo;
+ renderer->freeImage=&freeImageCairo;
+ renderer->renderEllipseSymbol = &renderEllipseSymbolCairo;
+ renderer->renderVectorSymbol = &renderVectorSymbolCairo;
+ renderer->renderTruetypeSymbol = &renderTruetypeSymbolCairo;
+ renderer->renderPixmapSymbol = &renderPixmapSymbolCairo;
+ renderer->mergeRasterBuffer = &mergeRasterBufferCairo;
+ renderer->getTruetypeTextBBox = &getTruetypeTextBBoxCairo;
+ renderer->renderTile = &renderTileCairo;
+ renderer->renderPolygonTiled = &renderPolygonTiledCairo;
+ renderer->freeTile = &freeTileCairo;
+ renderer->freeSymbol = &freeSymbolCairo;
+ return MS_SUCCESS;
+#else
+ msSetError(MS_MISCERR, "Cairo Driver requested but is not built in",
+ "msPopulateRendererVTableCairoRaster()");
+ return MS_FAILURE;
+#endif
+}
+
+int msPopulateRendererVTableCairoSVG( rendererVTableObj *renderer ) {
+ return populateRendererVTableCairoVector(renderer);
+}
+int msPopulateRendererVTableCairoPDF( rendererVTableObj *renderer ) {
+ return populateRendererVTableCairoVector(renderer);
+}
+
Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c 2009-06-19 14:00:59 UTC (rev 9113)
+++ trunk/mapserver/mapdraw.c 2009-06-21 18:20:48 UTC (rev 9114)
@@ -148,8 +148,8 @@
return(NULL);
}
else if (MS_RENDERER_PLUGIN(map->outputformat)) {
- renderObj *r = map->outputformat->r;
- image = r->createImage(map->width, map->height, map->outputformat,&map->imagecolor);
+ rendererVTableObj *renderer = map->outputformat->vtable;
+ image = renderer->createImage(map->width, map->height, map->outputformat,&map->imagecolor);
if (image == NULL)
return(NULL);
image->format = map->outputformat;
@@ -745,7 +745,7 @@
}
else if (MS_RENDERER_PLUGIN(image_draw->format)) {
if (layer->opacity > 0 && layer->opacity < 100) {
- if (!image_draw->format->r->supports_transparent_layers) {
+ if (!image_draw->format->vtable->supports_transparent_layers) {
msApplyOutputFormat(&transFormat, image->format, MS_TRUE,
MS_NOOVERRIDE,MS_NOOVERRIDE);
image_draw = msImageCreate(image->width, image->height,
@@ -756,7 +756,7 @@
return (MS_FAILURE);
}
} else {
- image_draw->format->r->startNewLayer(image_draw,layer->opacity);
+ image_draw->format->vtable->startNewLayer(image_draw,layer->opacity);
}
}
}
@@ -826,16 +826,17 @@
msApplyOutputFormat( &transFormat, NULL, MS_NOOVERRIDE, MS_NOOVERRIDE, MS_NOOVERRIDE );
}
else if( MS_RENDERER_PLUGIN(image_draw->format) && layer->opacity > 0 && layer->opacity < 100 ) {
- if (!image_draw->format->r->supports_transparent_layers) {
+ rendererVTableObj *renderer = image_draw->format->vtable;
+ if (!renderer->supports_transparent_layers) {
rasterBufferObj rb;
- image_draw->format->r->getRasterBuffer(image_draw,&rb);
- image_draw->format->r->mergeRasterBuffer(image,&rb,layer->opacity*0.01,0,0);
- image_draw->format->r->freeImage( image_draw );
+ renderer->getRasterBuffer(image_draw,&rb);
+ renderer->mergeRasterBuffer(image,&rb,layer->opacity*0.01,0,0);
+ renderer->freeImage( image_draw );
/* deref and possibly free temporary transparent output format. */
msApplyOutputFormat( &transFormat, NULL, MS_NOOVERRIDE, MS_NOOVERRIDE, MS_NOOVERRIDE );
} else {
- image_draw->format->r->closeNewLayer(image_draw,layer->opacity*0.01);
+ renderer->closeNewLayer(image_draw,layer->opacity*0.01);
}
}
#ifdef USE_AGG
Modified: trunk/mapserver/maplabel.c
===================================================================
--- trunk/mapserver/maplabel.c 2009-06-19 14:00:59 UTC (rev 9113)
+++ trunk/mapserver/maplabel.c 2009-06-21 18:20:48 UTC (rev 9114)
@@ -666,7 +666,7 @@
int msGetTruetypeTextBBox(imageObj *img, char *font, double size, char *string, rectObj *rect, double **advances) {
#ifdef USE_GD_FT
if(img!=NULL && MS_RENDERER_PLUGIN(img->format)) {
- img->format->r->getTruetypeTextBBox(img,font,size,string,rect,advances);
+ img->format->vtable->getTruetypeTextBBox(img,font,size,string,rect,advances);
//printf("%s: %f %f %f %f\n",string,rect->minx,rect->miny,rect->maxx,rect->maxy);
return MS_SUCCESS;
} else
Modified: trunk/mapserver/mapogl.cpp
===================================================================
--- trunk/mapserver/mapogl.cpp 2009-06-19 14:00:59 UTC (rev 9113)
+++ trunk/mapserver/mapogl.cpp 2009-06-21 18:20:48 UTC (rev 9114)
@@ -5,10 +5,10 @@
* Author: toby
*/
+#include "mapserver.h"
+
#ifdef USE_OGL
#include <assert.h>
-#include "mapserver.h"
-
#include "mapoglrenderer.h"
#include "mapoglcontext.h"
@@ -215,5 +215,40 @@
{
}
+#endif /* USE_OGL */
-#endif /* USE_OGL */
+int msPopulateRendererVTableOGL(rendererVTableObj *renderer) {
+#ifdef USE_OGL
+ renderer->supports_transparent_layers = 1;
+ renderer->startNewLayer = msStartNewLayerOgl;
+ renderer->closeNewLayer = msCloseNewLayerOgl;
+ renderer->renderLine=&msDrawLineOgl;
+ renderer->createImage=&msImageCreateOgl;
+ renderer->saveImage=&msSaveImageOgl;
+ renderer->transformShape=&msTransformShapeAGG;
+ renderer->renderPolygon=&msDrawPolygonOgl;
+ renderer->renderGlyphs=&msRenderGlyphsOgl;
+ renderer->renderEllipseSymbol = &msRenderEllipseOgl;
+ renderer->renderVectorSymbol = &msRenderVectorSymbolOgl;
+ renderer->renderPixmapSymbol = &msRenderPixmapOgl;
+ renderer->mergeRasterBuffer = &msMergeImagesOgl;
+ renderer->getTruetypeTextBBox = &msGetTruetypeTextBBoxOgl;
+ renderer->createPixmapSymbolTile = &msCreateTilePixmapOgl;
+ renderer->createVectorSymbolTile = &msCreateTileVectorOgl;
+ renderer->createEllipseSymbolTile = &msCreateTileEllipseOgl;
+ renderer->createTruetypeSymbolTile = &msCreateTileTruetypeOgl;
+ renderer->renderTile = &msRenderTileOgl;
+ renderer->renderPolygonTiled = &msDrawPolygonTiledOgl;
+ renderer->renderLineTiled = &msDrawLineTiledOgl;
+ renderer->freeTile = &msFreeTileOgl;
+ renderer->freeSymbol = &msFreeSymbolOgl;
+ renderer->freeImage=&msFreeImageOgl;
+ return MS_SUCCESS;
+ #else
+ msSetError(MS_MISCERR,"OGL driver requested but it is not compiled in this release",
+ "msPopulateRendererVTableOGL()");
+ return MS_FAILURE;
+#endif
+
+}
+
Modified: trunk/mapserver/mapoutput.c
===================================================================
--- trunk/mapserver/mapoutput.c 2009-06-19 14:00:59 UTC (rev 9113)
+++ trunk/mapserver/mapoutput.c 2009-06-21 18:20:48 UTC (rev 9114)
@@ -228,7 +228,6 @@
format->imagemode = MS_IMAGEMODE_RGB;
format->extension = strdup("png");
format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
- format->r = msCreateRenderer(MS_RENDER_WITH_CAIRO_RASTER);
}
if( strcasecmp(driver,"CAIRO/JPEG") == 0 )
{
@@ -237,7 +236,6 @@
format->imagemode = MS_IMAGEMODE_RGB;
format->extension = strdup("jpg");
format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
- format->r = msCreateRenderer(MS_RENDER_WITH_CAIRO_RASTER);
}
if( strcasecmp(driver,"CAIRO/PDF") == 0 )
{
@@ -245,8 +243,7 @@
format->mimetype = strdup("application/x-pdf");
format->imagemode = MS_IMAGEMODE_RGB;
format->extension = strdup("pdf");
- format->renderer = MS_RENDER_WITH_CAIRO_VECTOR;
- format->r = msCreateRenderer(MS_RENDER_WITH_CAIRO_VECTOR);
+ format->renderer = MS_RENDER_WITH_CAIRO_PDF;
}
if( strcasecmp(driver,"CAIRO/SVG") == 0 )
{
@@ -254,8 +251,7 @@
format->mimetype = strdup("image/svg+xml");
format->imagemode = MS_IMAGEMODE_RGB;
format->extension = strdup("svg");
- format->renderer = MS_RENDER_WITH_CAIRO_VECTOR;
- format->r = msCreateRenderer(MS_RENDER_WITH_CAIRO_VECTOR);
+ format->renderer = MS_RENDER_WITH_CAIRO_SVG;
}
@@ -269,7 +265,6 @@
format->imagemode = MS_IMAGEMODE_RGB;
format->extension = strdup("png");
format->renderer = MS_RENDER_WITH_OGL;
- format->r = msCreateRenderer(MS_RENDER_WITH_OGL);
}
#endif
@@ -339,7 +334,10 @@
if( format != NULL )
format->inmapfile = MS_FALSE;
-
+
+ if( format!= NULL && MS_RENDERER_PLUGIN(format) ) {
+ msInitializeRendererVTable(format);
+ }
return format;
}
@@ -437,7 +435,8 @@
msFree( format->driver );
msFree( format->extension );
msFreeCharArray( format->formatoptions, format->numformatoptions );
- msFree( format->r);
+ /* msFreeRendererVTable( format->vtable ); */
+ msFree( format->vtable );
msFree( format );
}
@@ -468,7 +467,7 @@
format->name = strdup(name);
format->driver = strdup(driver);
format->refcount = 0;
- format->r = NULL;
+ format->vtable = NULL;
format->imagemode = MS_IMAGEMODE_PC256;
/* -------------------------------------------------------------------- */
@@ -752,7 +751,6 @@
dst->imagemode = src->imagemode;
dst->renderer = src->renderer;
- dst->r = src->r;
dst->transparent = src->transparent;
dst->bands = src->bands;
@@ -766,6 +764,8 @@
dst->inmapfile = src->inmapfile;
+ msInitializeRendererVTable(dst);
+
return dst;
}
@@ -1002,93 +1002,30 @@
return result;
}
-renderObj* msCreateRenderer(int type) {
- renderObj *r = malloc(sizeof(renderObj));
- switch(type) {
-#ifdef USE_CAIRO
- case MS_RENDER_WITH_CAIRO_RASTER:
- r->supports_imagecache=0;
- r->supports_pixel_buffer=1;
- r->supports_transparent_layers = 1;
- r->startNewLayer = startNewLayerCairo;
- r->closeNewLayer = closeNewLayerCairo;
- r->renderLine=&renderLineCairo;
- r->createImage=&createImageCairo;
- r->saveImage=&saveImageCairo;
- r->getRasterBuffer=&getRasterBufferCairo;
- r->transformShape=&msTransformShapeAGG;
- r->renderPolygon=&renderPolygonCairo;
- r->renderGlyphsLine=&renderGlyphsLineCairo;
- r->renderGlyphs=&renderGlyphsCairo;
- r->freeImage=&freeImageCairo;
- r->renderEllipseSymbol = &renderEllipseSymbolCairo;
- r->renderVectorSymbol = &renderVectorSymbolCairo;
- r->renderTruetypeSymbol = &renderTruetypeSymbolCairo;
- r->renderPixmapSymbol = &renderPixmapSymbolCairo;
- r->mergeRasterBuffer = &mergeRasterBufferCairo;
- r->getTruetypeTextBBox = &getTruetypeTextBBoxCairo;
- r->renderTile = &renderTileCairo;
- r->renderPolygonTiled = &renderPolygonTiledCairo;
- r->freeTile = &freeTileCairo;
- r->freeSymbol = &freeSymbolCairo;
- return r;
- case MS_RENDER_WITH_CAIRO_VECTOR:
- r->supports_imagecache=0;
- r->supports_pixel_buffer=0;
- r->supports_transparent_layers = 1;
- r->startNewLayer = startNewLayerCairo;
- r->closeNewLayer = closeNewLayerCairo;
- r->renderLine=&renderLineCairo;
- r->createImage=&createImageCairo;
- r->saveImage=&saveImageCairo;
- r->getRasterBuffer=&getRasterBufferCairo;
- r->transformShape=&msTransformShapeAGG;
- r->renderPolygon=&renderPolygonCairo;
- r->renderGlyphsLine=&renderGlyphsLineCairo;
- r->renderGlyphs=&renderGlyphsCairo;
- r->freeImage=&freeImageCairo;
- r->renderEllipseSymbol = &renderEllipseSymbolCairo;
- r->renderVectorSymbol = &renderVectorSymbolCairo;
- r->renderTruetypeSymbol = &renderTruetypeSymbolCairo;
- r->renderPixmapSymbol = &renderPixmapSymbolCairo;
- r->mergeRasterBuffer = &mergeRasterBufferCairo;
- r->getTruetypeTextBBox = &getTruetypeTextBBoxCairo;
- r->renderTile = &renderTileCairo;
- r->renderPolygonTiled = &renderPolygonTiledCairo;
- r->freeTile = &freeTileCairo;
- r->freeSymbol = &freeSymbolCairo;
- return r;
-#endif
-#ifdef USE_OGL
- case MS_RENDER_WITH_OGL:
- r->supports_transparent_layers = 1;
- r->startNewLayer = msStartNewLayerOgl;
- r->closeNewLayer = msCloseNewLayerOgl;
- r->renderLine=&msDrawLineOgl;
- r->createImage=&msImageCreateOgl;
- r->saveImage=&msSaveImageOgl;
- r->transformShape=&msTransformShapeAGG;
- r->renderPolygon=&msDrawPolygonOgl;
- r->renderGlyphs=&msRenderGlyphsOgl;
- r->renderEllipseSymbol = &msRenderEllipseOgl;
- r->renderVectorSymbol = &msRenderVectorSymbolOgl;
- r->renderPixmapSymbol = &msRenderPixmapOgl;
- r->mergeRasterBuffer = &msMergeImagesOgl;
- r->getTruetypeTextBBox = &msGetTruetypeTextBBoxOgl;
- r->createPixmapSymbolTile = &msCreateTilePixmapOgl;
- r->createVectorSymbolTile = &msCreateTileVectorOgl;
- r->createEllipseSymbolTile = &msCreateTileEllipseOgl;
- r->createTruetypeSymbolTile = &msCreateTileTruetypeOgl;
- r->renderTile = &msRenderTileOgl;
- r->renderPolygonTiled = &msDrawPolygonTiledOgl;
- r->renderLineTiled = &msDrawLineTiledOgl;
- r->freeTile = &msFreeTileOgl;
- r->freeSymbol = &msFreeSymbolOgl;
- r->freeImage=&msFreeImageOgl;
- return r;
-#endif
-
- default:
- return NULL;
+int msInitializeRendererVTable(outputFormatObj *format) {
+ assert(format);
+ if(format->vtable) {
+ /* TODO?: clean up caches before switch
+ msFreeRendererVTable(format->vtable); */
+ msFree(format->vtable);
}
+ format->vtable = (rendererVTableObj*)malloc(sizeof(rendererVTableObj));
+
+ switch(format->renderer) {
+ case MS_RENDER_WITH_CAIRO_RASTER:
+ return msPopulateRendererVTableCairoRaster(format->vtable);
+ case MS_RENDER_WITH_CAIRO_PDF:
+ return msPopulateRendererVTableCairoPDF(format->vtable);
+ case MS_RENDER_WITH_CAIRO_SVG:
+ return msPopulateRendererVTableCairoSVG(format->vtable);
+ case MS_RENDER_WITH_OGL:
+ return msPopulateRendererVTableOGL(format->vtable);
+ default:
+ msSetError(MS_MISCERR, "unsupported RendererVtable renderer %d",
+ "msInitializeRendererVTable()",format->renderer);
+ return MS_FAILURE;
+ }
+ /* this code should never be executed */
+ return MS_FAILURE;
}
+
Modified: trunk/mapserver/maprendering.c
===================================================================
--- trunk/mapserver/maprendering.c 2009-06-19 14:00:59 UTC (rev 9113)
+++ trunk/mapserver/maprendering.c 2009-06-21 18:20:48 UTC (rev 9114)
@@ -169,7 +169,7 @@
while(cachep->next && cachep->next->next) cachep = cachep->next;
/*free the last tile's data*/
- img->format->r->freeTile(cachep->next->data);
+ img->format->vtable->freeTile(cachep->next->data);
/*reuse the last tile object*/
/* make the cache point to the start of the list*/
@@ -201,7 +201,7 @@
tileCacheObj *getTile(imageObj *img, symbolObj *symbol, symbolStyleObj *s, int width, int height) {
tileCacheObj *tile;
- renderObj *r = img->format->r;
+ rendererVTableObj *renderer = img->format->vtable;
if(width==-1 || height == -1) {
width=height=MS_MAX(symbol->sizex,symbol->sizey);
}
@@ -214,19 +214,19 @@
p_y = height/2.0;
format.driver = img->format->driver;
format.imagemode = MS_IMAGEMODE_RGBA;
- tileimg = r->createImage(width,height,&format,NULL);
+ tileimg = renderer->createImage(width,height,&format,NULL);
switch(symbol->type) {
case (MS_SYMBOL_TRUETYPE):
- r->renderTruetypeSymbol(tileimg, p_x, p_y, symbol, s);
+ renderer->renderTruetypeSymbol(tileimg, p_x, p_y, symbol, s);
break;
case (MS_SYMBOL_PIXMAP):
- r->renderPixmapSymbol(tileimg, p_x, p_y, symbol, s);
+ renderer->renderPixmapSymbol(tileimg, p_x, p_y, symbol, s);
break;
case (MS_SYMBOL_ELLIPSE):
- r->renderEllipseSymbol(tileimg, p_x, p_y,symbol, s);
+ renderer->renderEllipseSymbol(tileimg, p_x, p_y,symbol, s);
break;
case (MS_SYMBOL_VECTOR):
- r->renderVectorSymbol(tileimg, p_x, p_y, symbol, s);
+ renderer->renderVectorSymbol(tileimg, p_x, p_y, symbol, s);
break;
default:
break;
@@ -238,7 +238,7 @@
void msImagePolylineMarkers(imageObj *image, shapeObj *p, symbolObj *symbol,
symbolStyleObj *style, double spacing, int auto_angle) {
- renderObj *r = image->format->r;
+ rendererVTableObj *renderer = image->format->vtable;
int i,j;
pointObj point;
double original_rotation = style->rotation;
@@ -247,7 +247,7 @@
symbol_width = MS_MAX(1,symbol->sizex*style->scale);
else {
rectObj rect;
- r->getTruetypeTextBBox(image,symbol->full_font_path,style->scale,
+ renderer->getTruetypeTextBBox(image,symbol->full_font_path,style->scale,
symbol->character,&rect,NULL);
symbol_width=rect.maxx-rect.minx;
}
@@ -280,16 +280,16 @@
point.y = p->line[i].point[j - 1].y + current_length * ry;
switch (symbol->type) {
case MS_SYMBOL_PIXMAP:
- r->renderPixmapSymbol(image, point.x, point.y, symbol, style);
+ renderer->renderPixmapSymbol(image, point.x, point.y, symbol, style);
break;
case MS_SYMBOL_ELLIPSE:
- r->renderEllipseSymbol(image, point.x, point.y, symbol, style);
+ renderer->renderEllipseSymbol(image, point.x, point.y, symbol, style);
break;
case MS_SYMBOL_VECTOR:
- r->renderVectorSymbol(image, point.x, point.y, symbol, style);
+ renderer->renderVectorSymbol(image, point.x, point.y, symbol, style);
break;
case MS_SYMBOL_TRUETYPE:
- r->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
+ renderer->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
break;
}
current_length += symbol_width + spacing;
@@ -341,16 +341,16 @@
point.y = p->line[i].point[j - 1].y + offset * ry;
switch (symbol->type) {
case MS_SYMBOL_PIXMAP:
- r->renderPixmapSymbol(image, point.x, point.y, symbol, style);
+ renderer->renderPixmapSymbol(image, point.x, point.y, symbol, style);
break;
case MS_SYMBOL_ELLIPSE:
- r->renderEllipseSymbol(image, point.x, point.y, symbol, style);
+ renderer->renderEllipseSymbol(image, point.x, point.y, symbol, style);
break;
case MS_SYMBOL_VECTOR:
- r->renderVectorSymbol(image, point.x, point.y, symbol, style);
+ renderer->renderVectorSymbol(image, point.x, point.y, symbol, style);
break;
case MS_SYMBOL_TRUETYPE:
- r->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
+ renderer->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
break;
}
break;
@@ -401,7 +401,7 @@
if (image)
{
if (MS_RENDERER_PLUGIN(image->format)) {
- renderObj *r = image->format->r;
+ rendererVTableObj *renderer = image->format->vtable;
symbolObj *symbol;
shapeObj *offsetLine = p;
int i;
@@ -415,7 +415,7 @@
symbol = symbolset->symbol[style->symbol];
/* store a reference to the renderer to be used for freeing */
- symbol->renderer = r;
+ symbol->renderer = renderer;
width = style->width * scalefactor;
width = MS_MIN(width,style->maxwidth);
@@ -447,7 +447,7 @@
}
s.color.alpha = MS_NINT(style->opacity * 2.55);
- r->renderLine(image,offsetLine,&s);
+ renderer->renderLine(image,offsetLine,&s);
}
else {
symbolStyleObj s;
@@ -536,11 +536,11 @@
if (image)
{
if (MS_RENDERER_PLUGIN(image->format)) {
- renderObj *r = image->format->r;
+ rendererVTableObj *renderer = image->format->vtable;
shapeObj *offsetPolygon = NULL;
symbolObj *symbol = symbolset->symbol[style->symbol];
/* store a reference to the renderer to be used for freeing */
- symbol->renderer = r;
+ symbol->renderer = renderer;
if (style->offsetx != 0 || style->offsety != 0) {
if(style->offsety==-99)
@@ -554,7 +554,7 @@
* also draws an optional outline */
if(style->symbol == 0 || symbol->type == MS_SYMBOL_SIMPLE) {
style->color.alpha = MS_NINT(style->opacity*2.55);
- r->renderPolygon(image,offsetPolygon,&style->color);
+ renderer->renderPolygon(image,offsetPolygon,&style->color);
if(MS_VALID_COLOR(style->outlinecolor)) {
strokeStyleObj s;
MS_COPYCOLOR(&s.color,&style->outlinecolor);
@@ -562,7 +562,7 @@
s.width = (style->width == 0)?scalefactor:style->width*scalefactor;
s.color.alpha = style->color.alpha;
- r->renderLine(image,offsetPolygon,&s);
+ renderer->renderLine(image,offsetPolygon,&s);
}
goto cleanup; /*finished plain polygon*/
}
@@ -571,7 +571,7 @@
colorObj red;
MS_INIT_COLOR(red,255,0,0);
red.alpha=255;
- r->renderPolygon(image,offsetPolygon,&red);
+ renderer->renderPolygon(image,offsetPolygon,&red);
goto cleanup; /*finished plain polygon*/
}
#if 0
@@ -670,12 +670,12 @@
if (image)
{
if(MS_RENDERER_PLUGIN(image->format)) {
- renderObj *r = image->format->r;
+ rendererVTableObj *renderer = image->format->vtable;
symbolStyleObj s;
double p_x,p_y;
symbolObj *symbol = symbolset->symbol[style->symbol];
/* store a reference to the renderer to be used for freeing */
- symbol->renderer = r;
+ symbol->renderer = renderer;
computeSymbolStyle(&s,style,symbol,scalefactor);
if (!MS_VALID_COLOR(s.color) && !MS_VALID_COLOR(s.outlinecolor) && symbol->type != MS_SYMBOL_PIXMAP)
@@ -697,10 +697,10 @@
p_x = p->x + style->offsetx * scalefactor;
p_y = p->y + style->offsety * scalefactor;
- if(r->supports_imagecache) {
+ if(renderer->supports_imagecache) {
tileCacheObj *tile = getTile(image, symbol, &s, -1, -1);
if(tile!=NULL)
- r->renderTile(image, (imageObj*)tile->data, p_x, p_y);
+ renderer->renderTile(image, (imageObj*)tile->data, p_x, p_y);
return;
}
switch (symbol->type) {
@@ -710,20 +710,20 @@
symbol->font));
if(!symbol->full_font_path)
return;
- r->renderTruetypeSymbol(image, p_x, p_y, symbol, &s);
+ renderer->renderTruetypeSymbol(image, p_x, p_y, symbol, &s);
}
break;
case (MS_SYMBOL_PIXMAP): {
- r->renderPixmapSymbol(image,p_x,p_y,symbol,&s);
+ renderer->renderPixmapSymbol(image,p_x,p_y,symbol,&s);
}
break;
case (MS_SYMBOL_ELLIPSE): {
- r->renderEllipseSymbol(image, p_x, p_y,symbol, &s);
+ renderer->renderEllipseSymbol(image, p_x, p_y,symbol, &s);
}
break;
case (MS_SYMBOL_VECTOR): {
- r->renderVectorSymbol(image, p_x, p_y, symbol, &s);
+ renderer->renderVectorSymbol(image, p_x, p_y, symbol, &s);
}
break;
default:
@@ -806,7 +806,7 @@
labelStyleObj s;
if (image) {
if (MS_RENDERER_PLUGIN(image->format)) {
- renderObj *r = image->format->r;
+ rendererVTableObj *renderer = image->format->vtable;
double x, y;
if (!string || !strlen(string))
return (0); // not errors, just don't want to do anything
@@ -816,7 +816,7 @@
x = labelPnt.x;
y = labelPnt.y;
if (label->type == MS_TRUETYPE) {
- r->renderGlyphs(image,x,y,&s,string); }
+ renderer->renderGlyphs(image,x,y,&s,string); }
}
else if( MS_RENDERER_GD(image->format) )
nReturnVal = msDrawTextGD(image->img.gd, labelPnt, string, label, fontset, scalefactor);
@@ -846,7 +846,7 @@
int nReturnVal = -1;
if(image) {
if (MS_RENDERER_PLUGIN(image->format)) {
- renderObj *r = image->format->r;
+ rendererVTableObj *renderer = image->format->vtable;
labelStyleObj s;
if (!string || !strlen(string))
return (0); // not errors, just don't want to do anything
@@ -854,7 +854,7 @@
computeLabelStyle(&s,label,fontset,scalefactor);
if (label->type == MS_TRUETYPE) {
- r->renderGlyphsLine(image,labelpath,&s,string);
+ renderer->renderGlyphsLine(image,labelpath,&s,string);
}
}
else if( MS_RENDERER_GD(image->format) )
Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2009-06-19 14:00:59 UTC (rev 9113)
+++ trunk/mapserver/mapserver.h 2009-06-21 18:20:48 UTC (rev 9114)
@@ -89,9 +89,9 @@
#endif
/*forward declaration of rendering object*/
-struct renderer;
+struct rendererVTable;
struct tilecache;
-typedef struct renderer renderObj;
+typedef struct rendererVTable rendererVTableObj;
typedef struct tilecache tileCacheObj;
@@ -304,7 +304,7 @@
#define MS_DRIVER_PDF(format) (strncasecmp((format)->driver,"pdf",3)==0)
#define MS_DRIVER_IMAGEMAP(format) (strncasecmp((format)->driver,"imagemap",8)==0)
#define MS_DRIVER_SVG(format) (strncasecmp((format)->driver,"svg",3)==0)
-#define MS_DRIVER_AGG(format) (strncasecmp((format)->driver,"agg/",3)==0)
+#define MS_DRIVER_AGG(format) (strncasecmp((format)->driver,"agg/",4)==0)
#define MS_DRIVER_CAIRO(format) (strncasecmp((format)->driver,"cairo/",6)==0)
#define MS_DRIVER_OGL(format) (strncasecmp((format)->driver,"ogl/",4)==0)
#define MS_DRIVER_TEMPLATE(format) (strncasecmp((format)->driver,"template",8)==0)
@@ -318,8 +318,9 @@
#define MS_RENDER_WITH_AGG 7
#define MS_RENDER_WITH_TEMPLATE 8 /* query results only */
#define MS_RENDER_WITH_CAIRO_RASTER 9
-#define MS_RENDER_WITH_CAIRO_VECTOR 10
-#define MS_RENDER_WITH_OGL 11
+#define MS_RENDER_WITH_CAIRO_PDF 10
+#define MS_RENDER_WITH_CAIRO_SVG 11
+#define MS_RENDER_WITH_OGL 12
#define MS_RENDERER_GD(format) ((format)->renderer == MS_RENDER_WITH_GD)
#define MS_RENDERER_SWF(format) ((format)->renderer == MS_RENDER_WITH_SWF)
@@ -557,7 +558,7 @@
char **formatoptions;
int refcount;
int inmapfile; /* boolean value for writing */
- renderObj *r;
+ rendererVTableObj *vtable;
} outputFormatObj;
/* The following is used for "don't care" values in transparent, interlace and
@@ -2471,101 +2472,13 @@
void msFreeRasterBuffer(rasterBufferObj *b);
#endif /* SWIG */
-/* ==================================================================== */
-/* Prototypes for functions in mapogl.cpp */
-/* ==================================================================== */
-
-#ifdef USE_OGL
#ifndef SWIG
-void msDrawLineOgl(imageObj *img, shapeObj *p, colorObj *c, double width, int patternlength, double* pattern);
-imageObj* msImageCreateOgl(int width, int height, outputFormatObj *format, colorObj* bg);
-int msSaveImageOgl(imageObj *img, char *filename, outputFormatObj *format);
-void msDrawPolygonOgl(imageObj *img, shapeObj *p,colorObj *c, colorObj *oc, double outlineWidth);
-void msDrawPolygonTiledOgl(imageObj *img, shapeObj *p, colorObj *oc, double outlineWidth, void *tile);
-void msDrawLineTiledOgl(imageObj *img, shapeObj *p, void* tile);
-void msRenderGlyphsOgl(imageObj *img,double x, double y, colorObj *color, colorObj *outlinecolor,
- double size, char *font, char *thechars, double angle,
- colorObj *shadowcolor, double shdx, double shdy,
- int outlinewidth);
-void msRenderEllipseOgl(imageObj *image, double x, double y,
- double width, double height, double angle,
- colorObj *color, colorObj *outlinecolor,
- double outlinewidth);
-void msRenderVectorSymbolOgl(imageObj *img, double x, double y, symbolObj *symbol,
- double scale, double angle, colorObj *c, colorObj *oc, double ow);
-void msRenderPixmapOgl(imageObj *img, double x, double y,
- symbolObj *symbol,
- double scale, double angle);
-void msMergeImagesOgl(imageObj *dest, imageObj *overlay, int opacity,
- int dstX, int dstY);
-void* msCreateTileVectorOgl(symbolObj *symbol, double scale, double angle,
- colorObj *color,
- colorObj *backgroundcolor,
- colorObj *outlinecolor, double outlinewidth);
-void* msCreateTileEllipseOgl(double width, double height, double angle,
- colorObj *color,
- colorObj *backgroundcolor,
- colorObj *outlinecolor,
- double outlinewidth);
+MS_DLL_EXPORT int msInitializeRendererVTable(outputFormatObj *outputformat);
+MS_DLL_EXPORT int msPopulateRendererVTableCairoRaster( rendererVTableObj *renderer );
+MS_DLL_EXPORT int msPopulateRendererVTableCairoSVG( rendererVTableObj *renderer );
+MS_DLL_EXPORT int msPopulateRendererVTableCairoPDF( rendererVTableObj *renderer );
+MS_DLL_EXPORT int msPopulateRendererVTableOGL( rendererVTableObj *renderer );
-void* msCreateTilePixmapOgl(symbolObj *symbol, double scale, double angle, colorObj *bc);
-
-void* msCreateTileTruetypeOgl(imageObj *img, char *text, char *font,
- double size, double angle, colorObj *c, colorObj *bc, colorObj *oc,
- double ow);
-void msRenderTileOgl(imageObj *img, void *tile, double x, double y, double angle);
-int msGetTruetypeTextBBoxOgl(imageObj *img,char *font, double size, char *string,
- rectObj *rect, double **advances);
-void msFreeImageOgl(imageObj *image);
-void msFreeTileOgl(void *tile);
-void msStartNewLayerOgl(imageObj *img, double opacity);
-void msCloseNewLayerOgl(imageObj *img, double opacity);
-void msFreeSymbolOgl(symbolObj *s);
-
-#endif /* SWIG */
-#endif /* USE_OGL */
-
-
-/* ==================================================================== */
-/* prototypes for functions in mapcairo.c */
-/* ==================================================================== */
-#ifdef USE_CAIRO
-#ifndef SWIG
- void renderLineCairo(imageObj *img, shapeObj *p, strokeStyleObj *s);
- imageObj* createImageCairo(int width, int height, outputFormatObj *format, colorObj* bg);
- void getRasterBufferCairo(imageObj *img,rasterBufferObj *rb);
- int saveImageCairo(imageObj *img, FILE *fp, outputFormatObj *format);
- void renderPolygonCairo(imageObj *img, shapeObj *p,colorObj *c);
- void renderPolygonTiledCairo(imageObj *img, shapeObj *p, imageObj *tile);
- void renderGlyphsCairo(imageObj *img,double x, double y, labelStyleObj *s, char *text);
- void renderGlyphsLineCairo(imageObj *img,labelPathObj *labelpath,labelStyleObj *style, char *text);
-
-
-
- void renderEllipseSymbolCairo(imageObj *image, double x, double y, symbolObj *symbol, symbolStyleObj *s);
- void renderVectorSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *s);
- void renderPixmapSymbolCairo(imageObj *img, double x, double y,symbolObj *symbol, symbolStyleObj *s);
- void renderTruetypeSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *style);
-
- void mergeRasterBufferCairo(imageObj *img, rasterBufferObj *rb, double opacity, int dstX, int dstY);
-
- void renderTileCairo(imageObj *img, imageObj *tile, double x, double y);
- int getTruetypeTextBBoxCairo(imageObj *img,char *font, double size, char *string,
- rectObj *rect, double **advances);
- void freeImageCairo(imageObj *image);
- void freeTileCairo(imageObj *tile);
- void startNewLayerCairo(imageObj *img, double opacity);
- void closeNewLayerCairo(imageObj *img, double opacity);
- void freeSymbolCairo(symbolObj *s);
-#endif /* SWIG */
-#endif
-/* ==================================================================== */
-/* end of prototypes for functions in mapcairo.c */
-/* ==================================================================== */
-
-#ifndef SWIG
-renderObj* msCreateRenderer(int type);
-
//allocate 50k for starters
#define MS_DEFAULT_BUFFER_ALLOC 50000
@@ -2587,8 +2500,7 @@
MS_DLL_EXPORT inline void msBufferFree(bufferObj *buffer);
MS_DLL_EXPORT inline void msBufferAppend(bufferObj *buffer, void *data, size_t length);
-struct renderer{
- //void *renderer_data;
+struct rendererVTable {
int supports_transparent_layers;
int supports_pixel_buffer;
int supports_imagecache;
Modified: trunk/mapserver/mapsymbol.h
===================================================================
--- trunk/mapserver/mapsymbol.h 2009-06-19 14:00:59 UTC (rev 9113)
+++ trunk/mapserver/mapsymbol.h 2009-06-21 18:20:48 UTC (rev 9114)
@@ -112,7 +112,7 @@
#ifndef SWIG
gdImagePtr img;
void *renderer_cache; /* Renderer storage */
- renderObj *renderer;
+ rendererVTableObj *renderer;
rasterBufferObj *pixmap_buffer;
char *full_font_path;
#endif /* SWIG */
Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c 2009-06-19 14:00:59 UTC (rev 9113)
+++ trunk/mapserver/maputil.c 2009-06-21 18:20:48 UTC (rev 9114)
@@ -653,7 +653,7 @@
if (img)
{
if (MS_RENDERER_PLUGIN(img->format)) {
- renderObj *r = img->format->r;
+ rendererVTableObj *renderer = img->format->vtable;
FILE *stream;
if(filename)
stream = fopen(msBuildPath(szPath, map->mappath, filename),"wb");
@@ -664,13 +664,13 @@
}
if(!stream)
return MS_FAILURE;
- if(r->supports_pixel_buffer) {
+ if(renderer->supports_pixel_buffer) {
rasterBufferObj data;
- r->getRasterBuffer(img,&data);
+ renderer->getRasterBuffer(img,&data);
msSaveRasterBuffer(&data,stream,img->format );
} else {
- r->saveImage(img, stream, img->format);
+ renderer->saveImage(img, stream, img->format);
}
fclose(stream);
return MS_SUCCESS;
@@ -773,11 +773,11 @@
*size_ptr = 0;
if( MS_RENDERER_PLUGIN(image->format)){
rasterBufferObj data;
- renderObj *r = image->format->r;
- if(r->supports_pixel_buffer) {
+ rendererVTableObj *renderer = image->format->vtable;
+ if(renderer->supports_pixel_buffer) {
bufferObj buffer;
msBufferInit(&buffer);
- r->getRasterBuffer(image,&data);
+ renderer->getRasterBuffer(image,&data);
msSaveRasterBufferToBuffer(&data,&buffer,format);
return buffer.data;
//don't free the bufferObj as we don't own the bytes anymore
@@ -809,18 +809,18 @@
if (image)
{
if(MS_RENDERER_PLUGIN(image->format)) {
- renderObj *r = image->format->r;
- if(r->supports_imagecache) {
+ rendererVTableObj *renderer = image->format->vtable;
+ if(renderer->supports_imagecache) {
tileCacheObj *next,*cur = image->tilecache;
while(cur) {
- r->freeTile(cur->data);
+ renderer->freeTile(cur->data);
next = cur->next;
free(cur);
cur = next;
}
image->ntiles = 0;
}
- image->format->r->freeImage(image);
+ renderer->freeImage(image);
}
else if( MS_RENDERER_GD(image->format) ) {
if( image->img.gd != NULL )
@@ -1376,7 +1376,7 @@
if( image != NULL && map) msImageInitGD( image, &map->imagecolor );
}
else if(MS_RENDERER_PLUGIN(format)) {
- image = format->r->createImage(width,height,format,&map->imagecolor);
+ image = format->vtable->createImage(width,height,format,&map->imagecolor);
image->format = format;
format->refcount++;
@@ -1494,7 +1494,7 @@
imageObj *image)
{
if (image != NULL && MS_RENDERER_PLUGIN(image->format)) {
- image->format->r->transformShape(shape, extent, cellsize);
+ image->format->vtable->transformShape(shape, extent, cellsize);
return;
}
More information about the mapserver-commits
mailing list