Changes between Version 5 and Version 6 of UnifyingTheRenderingInterfaces


Ignore:
Timestamp:
Nov 21, 2007, 3:52:20 AM (17 years ago)
Author:
tbonfort
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UnifyingTheRenderingInterfaces

    v5 v6  
    5151}}}
    5252
     53----------------------------------------------------------------------------------------------------------
     54
     55== Proposed VTable Approach ==
     56I propose we attach a structure containing pointers to rendering function to the outputFormatObj
     57{{{
     58#!c
     59struct renderObj{
     60    void (*renderSimpleLine)(imageObj *img, shapeObj *p, colorObj *c, double width, int patternlength, int* pattern);
     61    void (*renderVectorSymbol)(imageObj*image, pointObj *location, pointObj **vectorpoints, int nvectorpoints, int/double width,
     62                         colorObj *color, colorObj *outlinecolor, colorObj* backgroundcolor);
     63    /*
     64    ... all the other low level rendering functions
     65    */
     66
     67    /* image i/o */
     68    imageObj* (*createImage)(int width, int height, char *imagepath, char* imageurl /*+ format specific args, eg, rgb/rgba, TODO */);
     69    int (*saveImage)(imageObj *img /*etc*/);
     70    /*...*/
     71
     72    /* helper functions */
     73    void (*getLabelSize)(char* font, int size, char *text /*...*/);
     74    /*...*/
     75};
     76}}}
     77
     78
     79which would be populated when creating the outputFormatObj by
     80{{{
     81#!c
     82
     83/*forward declaration of render functions defined in maprenderer.h*/
     84#ifdef __cplusplus
     85extern "C" {
     86#endif
     87MS_DLL_EXPORT void msDrawSimpleLineGD(imageObj *img, shapeObj *p, colorObj *c, double width, int patternlength, int* pattern);
     88MS_DLL_EXPORT void msDrawSimpleLineAGG(imageObj *img, shapeObj *p, colorObj *c, double width, int patternlength, int* pattern);
     89/*....*/
     90#ifdef __cplusplus
     91}
     92#endif
     93
     94
     95renderObj* msCreateRenderer(int type) {
     96    renderObj *r = malloc(sizeof(renderObj));
     97    switch(type) {
     98    case MS_RENDER_WITH_AGG:
     99        r->renderSimpleLine=&msDrawSimpleLineAGG;
     100        /*....*/
     101        return r;
     102    case MS_RENDER_WITH_GD:
     103        r->renderSimpleLine=&msDrawSimpleLineGD;
     104        /*.....*/
     105        return r;
     106    case MS_RENDER_WITH_PDF:
     107    /*...*/
     108    default:
     109        return NULL;
     110    }
     111}
     112}}}
     113
     114
     115
     116the higher level functions in mapdraw.c then become:
     117{{{
     118#!c
     119void msDrawLineSymbol(symbolSetObj *symbolset, imageObj *image, shapeObj *p, styleObj *style, double scalefactor)
     120{
     121    if (image)
     122    {
     123        if( image->format->rendererPtr!=NULL) {
     124            renderObj *r=image->format->rendererPtr;
     125           
     126            /* do some common processing of colors, widths, scalefactors, etc
     127            ...
     128            */
     129           
     130            if(style->symbol == 0 || symbol->type==MS_SYMBOL_CIRCLE || symbol->type==MS_SYMBOL_SIMPLE) { /*simple line case*/
     131                  r->renderSimpleLine(image,p,color,nwidth,symbol->patternlength, symbol->pattern); 
     132                  return;
     133            }
     134            /*continue on with the other line styling possibilities
     135            ...
     136            */
     137       }
     138       /* continue using the old style rendering functions for the renderers
     139          that haven't been migrated yet to the plugin format, or for those
     140          where such an approach isn't feasible
     141       */
     142       else if( MS_RENDERER_IMAGEMAP(image->format) )
     143            msDrawLineSymbolIM(symbolset, image, p, style, scalefactor);
     144
     145#ifdef USE_MING_FLASH
     146        else if( MS_RENDERER_SWF(image->format) )
     147            msDrawLineSymbolSWF(symbolset, image, p,  style, scalefactor);
     148#endif
     149#ifdef USE_PDF
     150        else if( MS_RENDERER_PDF(image->format) )
     151            msDrawLineSymbolPDF(symbolset, image, p,  style, scalefactor);
     152#endif
     153        else if( MS_RENDERER_SVG(image->format) )
     154            msDrawLineSymbolSVG(symbolset, image, p,  style, scalefactor);
     155
     156}}}
     157
     158
     159
     160----------------------------------------------------------------------------------------------------------
     161
     162
    53163== Desired Functionality ==
    54164=== Line Layers ===
     
    164274
    165275'''update''': this won't work out as an inline function is of no use if we're using function pointers (i.e. the vtable)
     276
     277
     278
     279
     280----------------------------------------------------------------------------------------------------------
     281
     282
     283
    166284
    167285== I/O and Pixel Formats ==