[Mapserver-dev] mapdraw.c

Frank Warmerdam warmerdam at pobox.com
Fri Sep 17 14:17:07 EDT 2004


Titus von der Malsburg wrote:
> My problem with this is that during the rendering process these ifs and
> the MS_RENDERER_GD macro must be called thousands of times.  But since
> the outputformat wont change, it seems to me that this is redundant and
> expensive (execution of the macro; the CPUs pipeline becomes often
> invalid and has to be thrown away).
> 
> Wouldn't it be better to have something like this before the rendering
> actually starts:
> 
> imageObj (*_msImageCreate)    (int, int, ....);
> void     (*_msDrawLineSymbol) (symbolSetObj*, ...);
> ...
> 
>     ...
>     else if( MS_RENDERER_GD(map->outputformat) )
>     {
>         _msImageCreate = msImageCreateGD;
>         _msDrawLineSymbol = msDrawLineSymbolGD;
>         ...
>     }

...
> I guess this would make the code a bit faster, smaller, more readable
> and maintainable.  For example it would be easier to add new
> outputdrivers (that's what I'm doing).
> 
> What do you think?  I found some minor problems like the differences in
> the argument structures of the functions, for example:

Titus,

I think it might be desirable to have a table of "virtual functions"
within the outputformat object itself for a variety of these functions.
I would prefer this to using globals as with globals it might be very hard
to later have a multithreaded mapserver core that could be doing multiple
renders at the same time, potentially to different output formats.

However, I don't think this sort of virtualization is going to give much of
a performance boost.  The MS_RENDER_GD() macro is cheap to evaluate and I
am not aware of too many examples of places where it is used in a frequently
repeated loop.  If so, those would be the places to look most closely.

As you suggest, it is likely the greatest benefit would be the ability
to modularize new renderers and outputformat handlers.  It might even
become practical to demand-load output handlers from shared libraries without
the core really knowning anything about it.  That certainly isn't the case
now.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the mapserver-dev mailing list