Version 3 (modified by 16 years ago) ( diff ) | ,
---|
Unifying The Rendering Interfaces
page to keep track of ideas and notes concerning "pluggable" renderers, and their interface with the main mapserver program
Desired Functionality
Line Layers
- simple: straightforward case, need to pass vertexes, width, color, and optionally caps and joins
- dashed
- outlined: the renderer can provide a method to draw a solid line with a one pixel outline in a single step. Not very usefull for lines as in that case the ouline is drawn first, and the inside is cached for later processing so as to provide nice intersections.
void renderSimpleLine(imageObj *image, shapeObj *thePoints, int/double width, colorObj *color, int* dashstyle, int dashstylelength, some_struct *capsandjoins)
- brushed: used essentially with a pixmap symbol as in
- pixmap
- vector,truetype : investigate if this should be supported. very probably have to be transformed to a pixmap before being used internally by the renderer.
- markers : mapserver passes a list of points and orientations to the renderer, and all the markers are rendered in one pass. pixmap, vector, truetype, and ellipse? specific versions could be presented by the renderer:
- vector markers: the vector has been scaled to the desired size, need to pass on line width and the vector symbol points to the renderer
- truetype markers: the font file location/lookup has been done, need to pass on font absolute path, symbol character, size
- pixmap markers: need to pass on the pixmap symbol, and a scaling factor for the final pixmap size
- ellipse markers: ...
void renderXXXMarkers(imageObj *image, int nmarkers, pointObj **labelpoints, double *angles, colorObj *color, colorObj *outlinecolor XXXX marker type specific data);
Point Layers
should be pretty straightforward. must probably expose a way for the renderer to cache an internal representation of the symbol if needed.
- vector: the vector points have been scaled and rotated beforehand.
void renderVectorSymbol(imageObj*image, pointObj *location, pointObj **vectorpoints, int nvectorpoints, int/double width, colorObj *color, colorObj *outlinecolor, colorObj* backgroundcolor?)
- pixmap: need to pass on the pixmap scaling factor, angle
void renderPixmapSymbol(imageObj *image, pointObj *location, TBD:image representation, double scalingfactor, double angle)
- truetype: need to pass on font file, character, size, angle
void renderTruetypeSymbol(imageObj *image, pointObj *location, char *fontfile, char character, int size, double angle, colorObj *color, colorObj *outlinecolor, colorObj* backgroundcolor?)
- ellipse: ellipse has been scaled beforehand, pass on angle?
void renderEllipseSymbol(imageObj *image, pointObj *location, int w, int h, double angle, colorObj *color, colorObj *outlinecolor, colorObj* backgroundcolor?)
Polygon and Circle Layers
I've grouped these together as they are conceptually rather equivalent. all the following will need to be split up in circle/polygon at implementation.
- simple: straightforward, provide vertexes and color
void renderSimplePolygon(imageObj *image, shapeObj *polypoints, colorObj *color, colorObj *outlinecolor, int/double outlinewidth) /*optional outlined polygon in one step*/
- hatched: renders only the hatch with an optional background. polygon outline would be done with another STYLE block.
void renderHatchedPolygon(imageObj *image, shapeObj *polypoints, int/double linewidth, int/double linespacing, colorObj *color, colorObj *backgroundcolor)
- tiled: the specified symbol is used as a tile to fill the polygon. it could be nice to provide a way to specify symbol size and spacing between symbols. Same as for marker symbols, all possible preprocessing on the actual symbol must be done before passing it on to the renderer.
- vector: vector symbol adjusted for size and angle beforehand.
void renderVectorTiledPolygon(imageObj *image, shapeObj *polypoints, pointObj **vectorpoints, int nvectorpoints, int/double linewidth, int tileheight, int tilewidth, /*here the vector symbol would be centered on this specified tile size*/ colorObj *color, colorObj *outlineColor, colorObj *backgroundcolor);
- ellipse: ellipse symbol adjusted for size
void renderEllipseTiledPolygon(imageObj *image, shapeObj *polypoints, int/double ellipsewidth, int/double ellipseheight, double ellipseangle, int tileheight, int tilewidth, /*here the ellipse symbol would be centered on this specified tile size*/ colorObj *color, colorObj *outlineColor, colorObj *backgroundcolor);
- pixmap: pass on pixmap scaling factor and angle
void renderPixmapTiledPolygon(imageObj *image, shapeObj *polypoints, TBD: image data, double pixmapscalingfactor, double pixmapangle, int tileheight, int tilewidth, /*here the pixmap symbol would be centered on this specified tile size*/ colorObj *backgroundcolor);
- truetype: idem, pass on font file and character
void renderTruetypeTiledPolygon(imageObj *image, shapeObj *polypoints, char* fontfile, int charsize, double angle, int tileheight, int tilewidth, /*here the truetype symbol would be centered on this specified tile size*/ colorObj *color, colorObj *outlineColor, colorObj *backgroundcolor);
- vector: vector symbol adjusted for size and angle beforehand.
Labelling
- font caching: gd has a global font cache, accessed through a mutex. AGG currently attaches the font cache to its imageObj.
- encoding: gd tries to automatically detect encoding. options can either be to pass on the encoding to the renderer, or always convert to utf8 for example.
- simple: straighforward once caching has been solved/decided
- follow: font rendering function is called once per character. could be optimized by passing the whole string and a list of positions/angles.
- bounding box : used by the labelcache to determine which labels can/will be drawn. With gd this is easy as the font cache is global. For other renderers, the font cache could be tied to the fontset object.
Raster Layers
A possible solution to avoid function call overhead while allowing the raster functions to set single pixel values could be for the renderers to expose an inlined setPixel (and getPixel?) function, probably without any bounds checking for performance. for example
inline void setPixelAGG(imageObj *im, int x, int y, int r, int g, int b, int a) { im->buffer[x][y]=AGGPixelMacro(r,g,b,a); }
and then use a vtable approach to connect that to a generic setPixel function.
update: this won't work out as an inline function is of no use if we're using function pointers (i.e. the vtable)
I/O and Pixel Formats
All I/O is currently done with gd (or not: geotiff,etc)
pixmap input
- have gd load pixmaps, and let the renderer convert and cache on first access
or
- let the renderer provide a pixmap loading function
image output
- the renderer converts its internal image representation to a gdimage and let gd do the saving
or
- have the renderer provide saving functions directly (i.e. call directly libpng/libjpeg/...)