Changeset 9114


Ignore:
Timestamp:
Jun 21, 2009 11:20:48 AM (7 years ago)
Author:
tbonfort
Message:

refactor renderer plugins to follow the layer vtable approach a bit more closely

Location:
trunk/mapserver
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/mapserver/mapcairo.c

    r9094 r9114  
    2727 * DEALINGS IN THE SOFTWARE.
    2828 *****************************************************************************/
     29#include "mapserver.h"
    2930
    3031#ifdef USE_CAIRO
    3132
    32 #include "mapserver.h"
    3333#include <cairo.h>
    3434#if defined(_WIN32) && !defined(__CYGWIN__)
     
    5050#include FT_FREETYPE_H
    5151*/
     52
     53
    5254
    5355
     
    750752}
    751753
     754#endif /*USE_CAIRO*/
     755
     756
     757int msPopulateRendererVTableCairoRaster( rendererVTableObj *renderer ) {
     758#ifdef USE_CAIRO
     759    renderer->supports_imagecache=0;
     760    renderer->supports_pixel_buffer=1;
     761    renderer->supports_transparent_layers = 1;
     762    renderer->startNewLayer = startNewLayerCairo;
     763    renderer->closeNewLayer = closeNewLayerCairo;
     764    renderer->renderLine=&renderLineCairo;
     765    renderer->createImage=&createImageCairo;
     766    renderer->saveImage=&saveImageCairo;
     767    renderer->getRasterBuffer=&getRasterBufferCairo;
     768    renderer->transformShape=&msTransformShapeAGG;
     769    renderer->renderPolygon=&renderPolygonCairo;
     770    renderer->renderGlyphsLine=&renderGlyphsLineCairo;
     771    renderer->renderGlyphs=&renderGlyphsCairo;
     772    renderer->freeImage=&freeImageCairo;
     773    renderer->renderEllipseSymbol = &renderEllipseSymbolCairo;
     774    renderer->renderVectorSymbol = &renderVectorSymbolCairo;
     775    renderer->renderTruetypeSymbol = &renderTruetypeSymbolCairo;
     776    renderer->renderPixmapSymbol = &renderPixmapSymbolCairo;
     777    renderer->mergeRasterBuffer = &mergeRasterBufferCairo;
     778    renderer->getTruetypeTextBBox = &getTruetypeTextBBoxCairo;
     779    renderer->renderTile = &renderTileCairo;
     780    renderer->renderPolygonTiled = &renderPolygonTiledCairo;
     781    renderer->freeTile = &freeTileCairo;
     782    renderer->freeSymbol = &freeSymbolCairo;
     783    return MS_SUCCESS;
     784#else
     785    msSetError(MS_MISCERR, "Cairo Driver requested but is not built in",
     786            "msPopulateRendererVTableCairoRaster()");
     787    return MS_FAILURE;
    752788#endif
     789}
     790
     791inline int populateRendererVTableCairoVector( rendererVTableObj *renderer ) {
     792#ifdef USE_CAIRO
     793    renderer->supports_imagecache=0;
     794    renderer->supports_pixel_buffer=0;
     795    renderer->supports_transparent_layers = 1;
     796    renderer->startNewLayer = startNewLayerCairo;
     797    renderer->closeNewLayer = closeNewLayerCairo;
     798    renderer->renderLine=&renderLineCairo;
     799    renderer->createImage=&createImageCairo;
     800    renderer->saveImage=&saveImageCairo;
     801    renderer->getRasterBuffer=&getRasterBufferCairo;
     802    renderer->transformShape=&msTransformShapeAGG;
     803    renderer->renderPolygon=&renderPolygonCairo;
     804    renderer->renderGlyphsLine=&renderGlyphsLineCairo;
     805    renderer->renderGlyphs=&renderGlyphsCairo;
     806    renderer->freeImage=&freeImageCairo;
     807    renderer->renderEllipseSymbol = &renderEllipseSymbolCairo;
     808    renderer->renderVectorSymbol = &renderVectorSymbolCairo;
     809    renderer->renderTruetypeSymbol = &renderTruetypeSymbolCairo;
     810    renderer->renderPixmapSymbol = &renderPixmapSymbolCairo;
     811    renderer->mergeRasterBuffer = &mergeRasterBufferCairo;
     812    renderer->getTruetypeTextBBox = &getTruetypeTextBBoxCairo;
     813    renderer->renderTile = &renderTileCairo;
     814    renderer->renderPolygonTiled = &renderPolygonTiledCairo;
     815    renderer->freeTile = &freeTileCairo;
     816    renderer->freeSymbol = &freeSymbolCairo;
     817    return MS_SUCCESS;
     818#else
     819    msSetError(MS_MISCERR, "Cairo Driver requested but is not built in",
     820            "msPopulateRendererVTableCairoRaster()");
     821    return MS_FAILURE;
     822#endif
     823}
     824
     825int msPopulateRendererVTableCairoSVG( rendererVTableObj *renderer ) {
     826    return populateRendererVTableCairoVector(renderer);
     827}
     828int msPopulateRendererVTableCairoPDF( rendererVTableObj *renderer ) {
     829    return populateRendererVTableCairoVector(renderer);
     830}
     831
  • trunk/mapserver/mapdraw.c

    r9109 r9114  
    149149    }
    150150    else if (MS_RENDERER_PLUGIN(map->outputformat)) {
    151                 renderObj *r = map->outputformat->r;
    152                 image = r->createImage(map->width, map->height, map->outputformat,&map->imagecolor);
     151                rendererVTableObj *renderer = map->outputformat->vtable;
     152                image = renderer->createImage(map->width, map->height, map->outputformat,&map->imagecolor);
    153153        if (image == NULL)
    154154            return(NULL);
     
    746746  else if (MS_RENDERER_PLUGIN(image_draw->format)) {
    747747                if (layer->opacity > 0 && layer->opacity < 100) {
    748                         if (!image_draw->format->r->supports_transparent_layers) {
     748                        if (!image_draw->format->vtable->supports_transparent_layers) {
    749749                                msApplyOutputFormat(&transFormat, image->format, MS_TRUE,
    750750                                                MS_NOOVERRIDE,MS_NOOVERRIDE);
     
    757757                                }
    758758                        } else {
    759                                 image_draw->format->r->startNewLayer(image_draw,layer->opacity);
     759                                image_draw->format->vtable->startNewLayer(image_draw,layer->opacity);
    760760                        }
    761761                }
     
    827827  }
    828828  else if( MS_RENDERER_PLUGIN(image_draw->format) && layer->opacity > 0 && layer->opacity < 100 ) {
    829           if (!image_draw->format->r->supports_transparent_layers) {
     829          rendererVTableObj *renderer = image_draw->format->vtable;
     830      if (!renderer->supports_transparent_layers) {
    830831          rasterBufferObj rb;
    831           image_draw->format->r->getRasterBuffer(image_draw,&rb);
    832                   image_draw->format->r->mergeRasterBuffer(image,&rb,layer->opacity*0.01,0,0); 
    833                   image_draw->format->r->freeImage( image_draw );
     832          renderer->getRasterBuffer(image_draw,&rb);
     833                  renderer->mergeRasterBuffer(image,&rb,layer->opacity*0.01,0,0); 
     834                  renderer->freeImage( image_draw );
    834835       
    835836                  /* deref and possibly free temporary transparent output format.  */
    836837                  msApplyOutputFormat( &transFormat, NULL, MS_NOOVERRIDE, MS_NOOVERRIDE, MS_NOOVERRIDE );
    837838          } else {
    838                   image_draw->format->r->closeNewLayer(image_draw,layer->opacity*0.01);
     839                  renderer->closeNewLayer(image_draw,layer->opacity*0.01);
    839840          }
    840841  }
  • trunk/mapserver/maplabel.c

    r9093 r9114  
    667667#ifdef USE_GD_FT
    668668        if(img!=NULL && MS_RENDERER_PLUGIN(img->format)) {
    669                 img->format->r->getTruetypeTextBBox(img,font,size,string,rect,advances);
     669                img->format->vtable->getTruetypeTextBBox(img,font,size,string,rect,advances);
    670670                //printf("%s: %f %f %f %f\n",string,rect->minx,rect->miny,rect->maxx,rect->maxy);
    671671                return MS_SUCCESS;
  • trunk/mapserver/mapogl.cpp

    r9094 r9114  
    66 */
    77
     8#include "mapserver.h"
     9
    810#ifdef USE_OGL
    911#include <assert.h>
    10 #include "mapserver.h"
    11 
    1212#include "mapoglrenderer.h"
    1313#include "mapoglcontext.h"
     
    216216       
    217217}
    218 
    219218#endif /* USE_OGL */
     219
     220int msPopulateRendererVTableOGL(rendererVTableObj *renderer) {
     221#ifdef USE_OGL
     222        renderer->supports_transparent_layers = 1;
     223        renderer->startNewLayer = msStartNewLayerOgl;
     224        renderer->closeNewLayer = msCloseNewLayerOgl;
     225        renderer->renderLine=&msDrawLineOgl;
     226        renderer->createImage=&msImageCreateOgl;
     227        renderer->saveImage=&msSaveImageOgl;
     228        renderer->transformShape=&msTransformShapeAGG;
     229        renderer->renderPolygon=&msDrawPolygonOgl;
     230        renderer->renderGlyphs=&msRenderGlyphsOgl;
     231        renderer->renderEllipseSymbol = &msRenderEllipseOgl;
     232        renderer->renderVectorSymbol = &msRenderVectorSymbolOgl;
     233        renderer->renderPixmapSymbol = &msRenderPixmapOgl;
     234        renderer->mergeRasterBuffer = &msMergeImagesOgl;
     235        renderer->getTruetypeTextBBox = &msGetTruetypeTextBBoxOgl;
     236        renderer->createPixmapSymbolTile = &msCreateTilePixmapOgl;
     237        renderer->createVectorSymbolTile = &msCreateTileVectorOgl;
     238        renderer->createEllipseSymbolTile = &msCreateTileEllipseOgl;
     239        renderer->createTruetypeSymbolTile = &msCreateTileTruetypeOgl;
     240        renderer->renderTile = &msRenderTileOgl;
     241        renderer->renderPolygonTiled = &msDrawPolygonTiledOgl;
     242        renderer->renderLineTiled = &msDrawLineTiledOgl;
     243        renderer->freeTile = &msFreeTileOgl;
     244        renderer->freeSymbol = &msFreeSymbolOgl;
     245        renderer->freeImage=&msFreeImageOgl;
     246        return MS_SUCCESS;
     247    #else
     248        msSetError(MS_MISCERR,"OGL driver requested but it is not compiled in this release",
     249                "msPopulateRendererVTableOGL()");
     250        return MS_FAILURE;
     251#endif
     252
     253}
     254
  • trunk/mapserver/mapoutput.c

    r9093 r9114  
    229229        format->extension = strdup("png");
    230230        format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
    231         format->r = msCreateRenderer(MS_RENDER_WITH_CAIRO_RASTER);
    232231    }
    233232    if( strcasecmp(driver,"CAIRO/JPEG") == 0 )
     
    238237        format->extension = strdup("jpg");
    239238        format->renderer = MS_RENDER_WITH_CAIRO_RASTER;
    240         format->r = msCreateRenderer(MS_RENDER_WITH_CAIRO_RASTER);
    241239    }
    242240    if( strcasecmp(driver,"CAIRO/PDF") == 0 )
     
    246244                format->imagemode = MS_IMAGEMODE_RGB;
    247245                format->extension = strdup("pdf");
    248                 format->renderer = MS_RENDER_WITH_CAIRO_VECTOR;
    249                 format->r = msCreateRenderer(MS_RENDER_WITH_CAIRO_VECTOR);
     246                format->renderer = MS_RENDER_WITH_CAIRO_PDF;
    250247        }
    251248    if( strcasecmp(driver,"CAIRO/SVG") == 0 )
     
    255252                format->imagemode = MS_IMAGEMODE_RGB;
    256253                format->extension = strdup("svg");
    257                 format->renderer = MS_RENDER_WITH_CAIRO_VECTOR;
    258                 format->r = msCreateRenderer(MS_RENDER_WITH_CAIRO_VECTOR);
     254                format->renderer = MS_RENDER_WITH_CAIRO_SVG;
    259255        }
    260256   
     
    270266        format->extension = strdup("png");
    271267        format->renderer = MS_RENDER_WITH_OGL;
    272         format->r = msCreateRenderer(MS_RENDER_WITH_OGL);
    273268    }
    274269#endif
     
    340335    if( format != NULL )
    341336      format->inmapfile = MS_FALSE;
    342 
     337   
     338    if( format!= NULL && MS_RENDERER_PLUGIN(format) ) {
     339        msInitializeRendererVTable(format);
     340    }
    343341    return format;
    344342}
     
    438436    msFree( format->extension );
    439437    msFreeCharArray( format->formatoptions, format->numformatoptions );
    440     msFree( format->r);
     438    /* msFreeRendererVTable( format->vtable ); */
     439    msFree( format->vtable );
    441440    msFree( format );
    442441}
     
    469468    format->driver = strdup(driver);
    470469    format->refcount = 0;
    471     format->r = NULL;
     470    format->vtable = NULL;
    472471    format->imagemode = MS_IMAGEMODE_PC256;
    473472
     
    753752    dst->imagemode = src->imagemode;
    754753    dst->renderer = src->renderer;
    755     dst->r = src->r;
    756754   
    757755    dst->transparent = src->transparent;
     
    767765    dst->inmapfile = src->inmapfile;
    768766
     767    msInitializeRendererVTable(dst);
     768   
    769769    return dst;
    770770}
     
    10031003}
    10041004
    1005 renderObj* msCreateRenderer(int type) {
    1006     renderObj *r = malloc(sizeof(renderObj));
    1007     switch(type) {
    1008 #ifdef USE_CAIRO
    1009     case MS_RENDER_WITH_CAIRO_RASTER:
    1010         r->supports_imagecache=0;
    1011         r->supports_pixel_buffer=1;
    1012         r->supports_transparent_layers = 1;
    1013         r->startNewLayer = startNewLayerCairo;
    1014         r->closeNewLayer = closeNewLayerCairo;
    1015         r->renderLine=&renderLineCairo;
    1016         r->createImage=&createImageCairo;
    1017         r->saveImage=&saveImageCairo;
    1018         r->getRasterBuffer=&getRasterBufferCairo;
    1019         r->transformShape=&msTransformShapeAGG;
    1020         r->renderPolygon=&renderPolygonCairo;
    1021         r->renderGlyphsLine=&renderGlyphsLineCairo;
    1022         r->renderGlyphs=&renderGlyphsCairo;
    1023         r->freeImage=&freeImageCairo;
    1024         r->renderEllipseSymbol = &renderEllipseSymbolCairo;
    1025         r->renderVectorSymbol = &renderVectorSymbolCairo;
    1026         r->renderTruetypeSymbol = &renderTruetypeSymbolCairo;
    1027         r->renderPixmapSymbol = &renderPixmapSymbolCairo;
    1028         r->mergeRasterBuffer = &mergeRasterBufferCairo;
    1029         r->getTruetypeTextBBox = &getTruetypeTextBBoxCairo;
    1030         r->renderTile = &renderTileCairo;
    1031         r->renderPolygonTiled = &renderPolygonTiledCairo;
    1032         r->freeTile = &freeTileCairo;
    1033         r->freeSymbol = &freeSymbolCairo;
    1034         return r;
    1035     case MS_RENDER_WITH_CAIRO_VECTOR:
    1036         r->supports_imagecache=0;
    1037         r->supports_pixel_buffer=0;
    1038         r->supports_transparent_layers = 1;
    1039         r->startNewLayer = startNewLayerCairo;
    1040         r->closeNewLayer = closeNewLayerCairo;
    1041         r->renderLine=&renderLineCairo;
    1042         r->createImage=&createImageCairo;
    1043         r->saveImage=&saveImageCairo;
    1044         r->getRasterBuffer=&getRasterBufferCairo;
    1045         r->transformShape=&msTransformShapeAGG;
    1046         r->renderPolygon=&renderPolygonCairo;
    1047         r->renderGlyphsLine=&renderGlyphsLineCairo;
    1048         r->renderGlyphs=&renderGlyphsCairo;
    1049         r->freeImage=&freeImageCairo;
    1050         r->renderEllipseSymbol = &renderEllipseSymbolCairo;
    1051         r->renderVectorSymbol = &renderVectorSymbolCairo;
    1052         r->renderTruetypeSymbol = &renderTruetypeSymbolCairo;
    1053         r->renderPixmapSymbol = &renderPixmapSymbolCairo;
    1054         r->mergeRasterBuffer = &mergeRasterBufferCairo;
    1055         r->getTruetypeTextBBox = &getTruetypeTextBBoxCairo;
    1056         r->renderTile = &renderTileCairo;
    1057         r->renderPolygonTiled = &renderPolygonTiledCairo;
    1058         r->freeTile = &freeTileCairo;
    1059         r->freeSymbol = &freeSymbolCairo;
    1060         return r;
    1061 #endif
    1062 #ifdef USE_OGL
    1063     case MS_RENDER_WITH_OGL:
    1064         r->supports_transparent_layers = 1;
    1065         r->startNewLayer = msStartNewLayerOgl;
    1066         r->closeNewLayer = msCloseNewLayerOgl;
    1067         r->renderLine=&msDrawLineOgl;
    1068         r->createImage=&msImageCreateOgl;
    1069         r->saveImage=&msSaveImageOgl;
    1070         r->transformShape=&msTransformShapeAGG;
    1071         r->renderPolygon=&msDrawPolygonOgl;
    1072         r->renderGlyphs=&msRenderGlyphsOgl;
    1073         r->renderEllipseSymbol = &msRenderEllipseOgl;
    1074         r->renderVectorSymbol = &msRenderVectorSymbolOgl;
    1075         r->renderPixmapSymbol = &msRenderPixmapOgl;
    1076         r->mergeRasterBuffer = &msMergeImagesOgl;
    1077         r->getTruetypeTextBBox = &msGetTruetypeTextBBoxOgl;
    1078         r->createPixmapSymbolTile = &msCreateTilePixmapOgl;
    1079         r->createVectorSymbolTile = &msCreateTileVectorOgl;
    1080         r->createEllipseSymbolTile = &msCreateTileEllipseOgl;
    1081         r->createTruetypeSymbolTile = &msCreateTileTruetypeOgl;
    1082         r->renderTile = &msRenderTileOgl;
    1083         r->renderPolygonTiled = &msDrawPolygonTiledOgl;
    1084         r->renderLineTiled = &msDrawLineTiledOgl;
    1085         r->freeTile = &msFreeTileOgl;
    1086         r->freeSymbol = &msFreeSymbolOgl;
    1087         r->freeImage=&msFreeImageOgl;
    1088         return r;
    1089 #endif
    1090 
    1091     default:
    1092         return NULL;
    1093     }
    1094 }
     1005int msInitializeRendererVTable(outputFormatObj *format) {
     1006    assert(format);
     1007    if(format->vtable) {
     1008        /* TODO?: clean up caches before switch
     1009        msFreeRendererVTable(format->vtable); */
     1010        msFree(format->vtable);
     1011    }
     1012    format->vtable = (rendererVTableObj*)malloc(sizeof(rendererVTableObj));
     1013   
     1014    switch(format->renderer) {
     1015        case MS_RENDER_WITH_CAIRO_RASTER:
     1016            return msPopulateRendererVTableCairoRaster(format->vtable);
     1017        case MS_RENDER_WITH_CAIRO_PDF:
     1018            return msPopulateRendererVTableCairoPDF(format->vtable);
     1019        case MS_RENDER_WITH_CAIRO_SVG:
     1020            return msPopulateRendererVTableCairoSVG(format->vtable);
     1021        case MS_RENDER_WITH_OGL:
     1022            return msPopulateRendererVTableOGL(format->vtable);
     1023        default:
     1024            msSetError(MS_MISCERR, "unsupported RendererVtable renderer %d",
     1025                    "msInitializeRendererVTable()",format->renderer);
     1026            return MS_FAILURE;           
     1027    }
     1028    /* this code should never be executed */
     1029    return MS_FAILURE;
     1030}
     1031
  • trunk/mapserver/maprendering.c

    r9094 r9114  
    170170
    171171        /*free the last tile's data*/
    172         img->format->r->freeTile(cachep->next->data);
     172        img->format->vtable->freeTile(cachep->next->data);
    173173
    174174        /*reuse the last tile object*/
     
    202202tileCacheObj *getTile(imageObj *img, symbolObj *symbol,  symbolStyleObj *s, int width, int height) {
    203203        tileCacheObj *tile;
    204         renderObj *r = img->format->r;
     204        rendererVTableObj *renderer = img->format->vtable;
    205205    if(width==-1 || height == -1) {
    206206        width=height=MS_MAX(symbol->sizex,symbol->sizey);
     
    215215        format.driver = img->format->driver;
    216216        format.imagemode = MS_IMAGEMODE_RGBA;
    217         tileimg = r->createImage(width,height,&format,NULL);
     217        tileimg = renderer->createImage(width,height,&format,NULL);
    218218        switch(symbol->type) {
    219219            case (MS_SYMBOL_TRUETYPE):
    220                 r->renderTruetypeSymbol(tileimg, p_x, p_y, symbol, s);
     220                renderer->renderTruetypeSymbol(tileimg, p_x, p_y, symbol, s);
    221221                break;
    222222            case (MS_SYMBOL_PIXMAP):
    223                 r->renderPixmapSymbol(tileimg, p_x, p_y, symbol, s);
     223                renderer->renderPixmapSymbol(tileimg, p_x, p_y, symbol, s);
    224224                break;
    225225            case (MS_SYMBOL_ELLIPSE):
    226                 r->renderEllipseSymbol(tileimg, p_x, p_y,symbol, s);
     226                renderer->renderEllipseSymbol(tileimg, p_x, p_y,symbol, s);
    227227                break;
    228228            case (MS_SYMBOL_VECTOR):
    229                 r->renderVectorSymbol(tileimg, p_x, p_y, symbol, s);
     229                renderer->renderVectorSymbol(tileimg, p_x, p_y, symbol, s);
    230230                break;
    231231            default:
     
    239239void msImagePolylineMarkers(imageObj *image, shapeObj *p, symbolObj *symbol,
    240240        symbolStyleObj *style, double spacing, int auto_angle) {
    241     renderObj *r = image->format->r;
     241    rendererVTableObj *renderer = image->format->vtable;
    242242    int i,j;
    243243    pointObj point;
     
    248248    else {
    249249        rectObj rect;
    250         r->getTruetypeTextBBox(image,symbol->full_font_path,style->scale,
     250        renderer->getTruetypeTextBBox(image,symbol->full_font_path,style->scale,
    251251                symbol->character,&rect,NULL);
    252252        symbol_width=rect.maxx-rect.minx;
     
    281281                switch (symbol->type) {
    282282                    case MS_SYMBOL_PIXMAP:
    283                         r->renderPixmapSymbol(image, point.x, point.y, symbol, style);
     283                        renderer->renderPixmapSymbol(image, point.x, point.y, symbol, style);
    284284                        break;
    285285                    case MS_SYMBOL_ELLIPSE:
    286                         r->renderEllipseSymbol(image, point.x, point.y, symbol, style);
     286                        renderer->renderEllipseSymbol(image, point.x, point.y, symbol, style);
    287287                        break;
    288288                    case MS_SYMBOL_VECTOR:
    289                         r->renderVectorSymbol(image, point.x, point.y, symbol, style);
     289                        renderer->renderVectorSymbol(image, point.x, point.y, symbol, style);
    290290                        break;
    291291                    case MS_SYMBOL_TRUETYPE:
    292                         r->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
     292                        renderer->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
    293293                        break;
    294294                }
     
    342342                    switch (symbol->type) {
    343343                        case MS_SYMBOL_PIXMAP:
    344                             r->renderPixmapSymbol(image, point.x, point.y, symbol, style);
     344                            renderer->renderPixmapSymbol(image, point.x, point.y, symbol, style);
    345345                            break;
    346346                        case MS_SYMBOL_ELLIPSE:
    347                             r->renderEllipseSymbol(image, point.x, point.y, symbol, style);
     347                            renderer->renderEllipseSymbol(image, point.x, point.y, symbol, style);
    348348                            break;
    349349                        case MS_SYMBOL_VECTOR:
    350                             r->renderVectorSymbol(image, point.x, point.y, symbol, style);
     350                            renderer->renderVectorSymbol(image, point.x, point.y, symbol, style);
    351351                            break;
    352352                        case MS_SYMBOL_TRUETYPE:
    353                             r->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
     353                            renderer->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
    354354                            break;
    355355                    }
     
    402402    {
    403403                if (MS_RENDERER_PLUGIN(image->format)) {
    404                         renderObj *r = image->format->r;
     404                        rendererVTableObj *renderer = image->format->vtable;
    405405                        symbolObj *symbol;
    406406                        shapeObj *offsetLine = p;
     
    416416                        symbol = symbolset->symbol[style->symbol];
    417417            /* store a reference to the renderer to be used for freeing */
    418             symbol->renderer = r;
     418            symbol->renderer = renderer;
    419419
    420420                        width = style->width * scalefactor;
     
    448448                s.color.alpha = MS_NINT(style->opacity * 2.55);
    449449
    450                 r->renderLine(image,offsetLine,&s);
     450                renderer->renderLine(image,offsetLine,&s);
    451451            }
    452452                        else {
     
    537537    {
    538538        if (MS_RENDERER_PLUGIN(image->format)) {
    539                 renderObj *r = image->format->r;
     539                rendererVTableObj *renderer = image->format->vtable;
    540540                shapeObj *offsetPolygon = NULL;
    541541                symbolObj *symbol = symbolset->symbol[style->symbol];
    542542            /* store a reference to the renderer to be used for freeing */
    543             symbol->renderer = r;
     543            symbol->renderer = renderer;
    544544           
    545545            if (style->offsetx != 0 || style->offsety != 0) {
     
    555555            if(style->symbol == 0 || symbol->type == MS_SYMBOL_SIMPLE) {
    556556                style->color.alpha = MS_NINT(style->opacity*2.55);
    557                 r->renderPolygon(image,offsetPolygon,&style->color);
     557                renderer->renderPolygon(image,offsetPolygon,&style->color);
    558558                if(MS_VALID_COLOR(style->outlinecolor)) {
    559559                    strokeStyleObj s;
     
    563563
    564564                    s.color.alpha = style->color.alpha;
    565                     r->renderLine(image,offsetPolygon,&s);
     565                    renderer->renderLine(image,offsetPolygon,&s);
    566566                }
    567567                goto cleanup; /*finished plain polygon*/
     
    572572                MS_INIT_COLOR(red,255,0,0);
    573573                red.alpha=255;
    574                 r->renderPolygon(image,offsetPolygon,&red);
     574                renderer->renderPolygon(image,offsetPolygon,&red);
    575575                goto cleanup; /*finished plain polygon*/
    576576            }
     
    671671   {
    672672       if(MS_RENDERER_PLUGIN(image->format)) {
    673             renderObj *r = image->format->r;
     673            rendererVTableObj *renderer = image->format->vtable;
    674674            symbolStyleObj s;
    675675            double p_x,p_y;
    676676            symbolObj *symbol = symbolset->symbol[style->symbol];
    677677            /* store a reference to the renderer to be used for freeing */
    678             symbol->renderer = r;
     678            symbol->renderer = renderer;
    679679           
    680680            computeSymbolStyle(&s,style,symbol,scalefactor);
     
    698698            p_y = p->y + style->offsety * scalefactor;
    699699
    700                         if(r->supports_imagecache) {
     700                        if(renderer->supports_imagecache) {
    701701                                tileCacheObj *tile = getTile(image, symbol, &s, -1, -1);
    702702                                if(tile!=NULL)
    703                                     r->renderTile(image, (imageObj*)tile->data, p_x, p_y);
     703                                    renderer->renderTile(image, (imageObj*)tile->data, p_x, p_y);
    704704                                return;
    705705                        }
     
    711711                if(!symbol->full_font_path)
    712712                                        return;
    713                 r->renderTruetypeSymbol(image, p_x, p_y, symbol, &s);
     713                renderer->renderTruetypeSymbol(image, p_x, p_y, symbol, &s);
    714714
    715715                        }
    716716                                break;
    717717                        case (MS_SYMBOL_PIXMAP): {
    718                                 r->renderPixmapSymbol(image,p_x,p_y,symbol,&s);
     718                                renderer->renderPixmapSymbol(image,p_x,p_y,symbol,&s);
    719719                        }
    720720                                break;
    721721                        case (MS_SYMBOL_ELLIPSE): {
    722                                 r->renderEllipseSymbol(image, p_x, p_y,symbol, &s);
     722                                renderer->renderEllipseSymbol(image, p_x, p_y,symbol, &s);
    723723                        }
    724724                                break;
    725725                        case (MS_SYMBOL_VECTOR): {
    726                                 r->renderVectorSymbol(image, p_x, p_y, symbol, &s);
     726                                renderer->renderVectorSymbol(image, p_x, p_y, symbol, &s);
    727727                        }
    728728                                break;
     
    807807        if (image) {
    808808                if (MS_RENDERER_PLUGIN(image->format)) {
    809                         renderObj *r = image->format->r;
     809                        rendererVTableObj *renderer = image->format->vtable;
    810810            double x, y;
    811811                        if (!string || !strlen(string))
     
    817817                        y = labelPnt.y;
    818818                        if (label->type == MS_TRUETYPE) {
    819                                 r->renderGlyphs(image,x,y,&s,string);                   }
     819                                renderer->renderGlyphs(image,x,y,&s,string);                    }
    820820                }
    821821        else if( MS_RENDERER_GD(image->format) )
     
    847847    if(image) {
    848848        if (MS_RENDERER_PLUGIN(image->format)) {
    849             renderObj *r = image->format->r;
     849            rendererVTableObj *renderer = image->format->vtable;
    850850            labelStyleObj s;
    851851            if (!string || !strlen(string))
     
    855855            computeLabelStyle(&s,label,fontset,scalefactor);
    856856            if (label->type == MS_TRUETYPE) {
    857                 r->renderGlyphsLine(image,labelpath,&s,string);                 
     857                renderer->renderGlyphsLine(image,labelpath,&s,string);                 
    858858            }
    859859        }
  • trunk/mapserver/mapserver.h

    r9093 r9114  
    9090
    9191/*forward declaration of rendering object*/
    92 struct renderer;
     92struct rendererVTable;
    9393struct tilecache;
    94 typedef struct renderer renderObj;
     94typedef struct rendererVTable rendererVTableObj;
    9595typedef struct tilecache tileCacheObj;
    9696
     
    305305#define MS_DRIVER_IMAGEMAP(format)  (strncasecmp((format)->driver,"imagemap",8)==0)
    306306#define MS_DRIVER_SVG(format) (strncasecmp((format)->driver,"svg",3)==0)
    307 #define MS_DRIVER_AGG(format) (strncasecmp((format)->driver,"agg/",3)==0)
     307#define MS_DRIVER_AGG(format) (strncasecmp((format)->driver,"agg/",4)==0)
    308308#define MS_DRIVER_CAIRO(format) (strncasecmp((format)->driver,"cairo/",6)==0)
    309309#define MS_DRIVER_OGL(format) (strncasecmp((format)->driver,"ogl/",4)==0)
     
    319319#define MS_RENDER_WITH_TEMPLATE 8 /* query results only */
    320320#define MS_RENDER_WITH_CAIRO_RASTER   9
    321 #define MS_RENDER_WITH_CAIRO_VECTOR 10
    322 #define MS_RENDER_WITH_OGL      11
     321#define MS_RENDER_WITH_CAIRO_PDF 10
     322#define MS_RENDER_WITH_CAIRO_SVG 11
     323#define MS_RENDER_WITH_OGL      12
    323324
    324325#define MS_RENDERER_GD(format)  ((format)->renderer == MS_RENDER_WITH_GD)
     
    558559    int  refcount;
    559560    int inmapfile; /* boolean value for writing */
    560     renderObj *r;
     561    rendererVTableObj *vtable;
    561562} outputFormatObj;
    562563
     
    24722473#endif /* SWIG */
    24732474
    2474 /* ==================================================================== */
    2475 /*      Prototypes for functions in mapogl.cpp                          */
    2476 /* ==================================================================== */
    2477 
    2478 #ifdef USE_OGL
    2479 #ifndef SWIG
    2480 void msDrawLineOgl(imageObj *img, shapeObj *p, colorObj *c, double width, int patternlength, double* pattern);
    2481 imageObj* msImageCreateOgl(int width, int height, outputFormatObj *format, colorObj* bg);
    2482 int msSaveImageOgl(imageObj *img, char *filename, outputFormatObj *format);
    2483 void msDrawPolygonOgl(imageObj *img, shapeObj *p,colorObj *c, colorObj *oc, double outlineWidth);
    2484 void msDrawPolygonTiledOgl(imageObj *img, shapeObj *p, colorObj *oc, double outlineWidth, void *tile);
    2485 void msDrawLineTiledOgl(imageObj *img, shapeObj *p, void* tile);
    2486 void msRenderGlyphsOgl(imageObj *img,double x, double y, colorObj *color, colorObj *outlinecolor,
    2487             double size, char *font, char *thechars, double angle,
    2488             colorObj *shadowcolor, double shdx, double shdy,
    2489             int outlinewidth);
    2490 void msRenderEllipseOgl(imageObj *image, double x, double y,
    2491                 double width, double height, double angle,
    2492                 colorObj *color, colorObj *outlinecolor,
    2493                 double outlinewidth);
    2494 void msRenderVectorSymbolOgl(imageObj *img, double x, double y, symbolObj *symbol,
    2495                 double scale, double angle, colorObj *c, colorObj *oc, double ow);
    2496 void msRenderPixmapOgl(imageObj *img, double x, double y,
    2497                         symbolObj *symbol,
    2498                         double scale, double angle);
    2499 void msMergeImagesOgl(imageObj *dest, imageObj *overlay, int opacity,
    2500                 int dstX, int dstY);
    2501 void* msCreateTileVectorOgl(symbolObj *symbol, double scale, double angle,
    2502                 colorObj *color,
    2503                 colorObj *backgroundcolor,
    2504                 colorObj *outlinecolor, double outlinewidth);
    2505 void* msCreateTileEllipseOgl(double width, double height, double angle,
    2506                         colorObj *color,
    2507                         colorObj *backgroundcolor,
    2508                         colorObj *outlinecolor,
    2509         double outlinewidth);
    2510 
    2511 void* msCreateTilePixmapOgl(symbolObj *symbol, double scale, double angle, colorObj *bc);
    2512 
    2513 void* msCreateTileTruetypeOgl(imageObj *img, char *text, char *font,
    2514         double size, double angle, colorObj *c, colorObj *bc, colorObj *oc,
    2515         double ow);
    2516 void msRenderTileOgl(imageObj *img, void *tile, double x, double y, double angle);
    2517 int msGetTruetypeTextBBoxOgl(imageObj *img,char *font, double size, char *string,
    2518                 rectObj *rect, double **advances);
    2519 void msFreeImageOgl(imageObj *image);
    2520 void msFreeTileOgl(void *tile);
    2521 void msStartNewLayerOgl(imageObj *img, double opacity);
    2522 void msCloseNewLayerOgl(imageObj *img, double opacity);
    2523 void msFreeSymbolOgl(symbolObj *s);
    2524 
    2525 #endif /* SWIG */
    2526 #endif  /* USE_OGL  */
    2527 
    2528 
    2529 /* ==================================================================== */
    2530 /*      prototypes for functions in mapcairo.c                        */
    2531 /* ==================================================================== */
    2532 #ifdef USE_CAIRO
    2533 #ifndef SWIG
    2534         void renderLineCairo(imageObj *img, shapeObj *p, strokeStyleObj *s);
    2535     imageObj* createImageCairo(int width, int height, outputFormatObj *format, colorObj* bg);
    2536     void getRasterBufferCairo(imageObj *img,rasterBufferObj *rb);
    2537     int saveImageCairo(imageObj *img, FILE *fp, outputFormatObj *format);
    2538     void renderPolygonCairo(imageObj *img, shapeObj *p,colorObj *c);
    2539     void renderPolygonTiledCairo(imageObj *img, shapeObj *p, imageObj *tile);
    2540     void renderGlyphsCairo(imageObj *img,double x, double y, labelStyleObj *s, char *text);
    2541     void renderGlyphsLineCairo(imageObj *img,labelPathObj *labelpath,labelStyleObj *style, char *text);
    2542 
    2543 
    2544    
    2545     void renderEllipseSymbolCairo(imageObj *image, double x, double y, symbolObj *symbol, symbolStyleObj *s);
    2546     void renderVectorSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *s);
    2547     void renderPixmapSymbolCairo(imageObj *img, double x, double y,symbolObj *symbol, symbolStyleObj *s);
    2548     void renderTruetypeSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *style);
    2549 
    2550     void mergeRasterBufferCairo(imageObj *img, rasterBufferObj *rb, double opacity, int dstX, int dstY);
    2551    
    2552     void renderTileCairo(imageObj *img, imageObj *tile, double x, double y);
    2553     int getTruetypeTextBBoxCairo(imageObj *img,char *font, double size, char *string,
    2554                         rectObj *rect, double **advances);
    2555     void freeImageCairo(imageObj *image);
    2556     void freeTileCairo(imageObj *tile);
    2557     void startNewLayerCairo(imageObj *img, double opacity);
    2558     void closeNewLayerCairo(imageObj *img, double opacity);
    2559     void freeSymbolCairo(symbolObj *s);
    2560 #endif /* SWIG */
    2561 #endif
    2562 /* ==================================================================== */
    2563 /*      end of prototypes for functions in mapcairo.c                 */
    2564 /* ==================================================================== */   
    2565 
    2566 #ifndef SWIG
    2567 renderObj* msCreateRenderer(int type);
     2475#ifndef SWIG
     2476MS_DLL_EXPORT int msInitializeRendererVTable(outputFormatObj *outputformat);
     2477MS_DLL_EXPORT int msPopulateRendererVTableCairoRaster( rendererVTableObj *renderer );
     2478MS_DLL_EXPORT int msPopulateRendererVTableCairoSVG( rendererVTableObj *renderer );
     2479MS_DLL_EXPORT int msPopulateRendererVTableCairoPDF( rendererVTableObj *renderer );
     2480MS_DLL_EXPORT int msPopulateRendererVTableOGL( rendererVTableObj *renderer );
    25682481
    25692482//allocate 50k for starters
     
    25882501MS_DLL_EXPORT  inline void msBufferAppend(bufferObj *buffer, void *data, size_t length);
    25892502
    2590 struct renderer{
    2591         //void *renderer_data;
     2503struct rendererVTable {
    25922504        int supports_transparent_layers;
    25932505    int supports_pixel_buffer;
  • trunk/mapserver/mapsymbol.h

    r9093 r9114  
    113113  gdImagePtr img;
    114114  void *renderer_cache; /* Renderer storage */
    115   renderObj *renderer;
     115  rendererVTableObj *renderer;
    116116  rasterBufferObj *pixmap_buffer;
    117117  char *full_font_path;
  • trunk/mapserver/maputil.c

    r9093 r9114  
    654654    {
    655655        if (MS_RENDERER_PLUGIN(img->format)) {
    656             renderObj *r = img->format->r;
     656            rendererVTableObj *renderer = img->format->vtable;
    657657            FILE *stream;
    658658            if(filename)
     
    665665            if(!stream)
    666666                return MS_FAILURE;
    667             if(r->supports_pixel_buffer) {
     667            if(renderer->supports_pixel_buffer) {
    668668                rasterBufferObj data;
    669                 r->getRasterBuffer(img,&data);
     669                renderer->getRasterBuffer(img,&data);
    670670
    671671                msSaveRasterBuffer(&data,stream,img->format );
    672672            } else {
    673                 r->saveImage(img, stream, img->format);
     673                renderer->saveImage(img, stream, img->format);
    674674            }
    675675            fclose(stream);
     
    774774    if( MS_RENDERER_PLUGIN(image->format)){
    775775        rasterBufferObj data;
    776         renderObj *r = image->format->r;
    777         if(r->supports_pixel_buffer) {
     776        rendererVTableObj *renderer = image->format->vtable;
     777        if(renderer->supports_pixel_buffer) {
    778778            bufferObj buffer;
    779779            msBufferInit(&buffer);
    780             r->getRasterBuffer(image,&data);
     780            renderer->getRasterBuffer(image,&data);
    781781            msSaveRasterBufferToBuffer(&data,&buffer,format);
    782782            return buffer.data;
     
    810810    {
    811811        if(MS_RENDERER_PLUGIN(image->format)) {
    812             renderObj *r = image->format->r;
    813             if(r->supports_imagecache) {
     812            rendererVTableObj *renderer = image->format->vtable;
     813            if(renderer->supports_imagecache) {
    814814                tileCacheObj *next,*cur = image->tilecache;
    815815                while(cur) {
    816                     r->freeTile(cur->data);
     816                    renderer->freeTile(cur->data);
    817817                    next = cur->next;
    818818                    free(cur);
     
    821821                image->ntiles = 0;
    822822            }
    823                 image->format->r->freeImage(image);
     823                renderer->freeImage(image);
    824824        }
    825825        else if( MS_RENDERER_GD(image->format) ) {
     
    13771377    }
    13781378    else if(MS_RENDERER_PLUGIN(format)) {
    1379         image = format->r->createImage(width,height,format,&map->imagecolor);
     1379        image = format->vtable->createImage(width,height,format,&map->imagecolor);
    13801380        image->format = format;
    13811381                format->refcount++;
     
    14951495{
    14961496        if (image != NULL && MS_RENDERER_PLUGIN(image->format)) {
    1497                 image->format->r->transformShape(shape, extent, cellsize);
     1497                image->format->vtable->transformShape(shape, extent, cellsize);
    14981498
    14991499                return;
Note: See TracChangeset for help on using the changeset viewer.