[mapserver-commits] r12756 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Mon Nov 7 06:14:16 EST 2011
Author: tbonfort
Date: 2011-11-07 03:14:16 -0800 (Mon, 07 Nov 2011)
New Revision: 12756
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapagg.cpp
trunk/mapserver/mapdummyrenderer.c
trunk/mapserver/maprendering.c
trunk/mapserver/mapserver.h
Log:
Use a renderer native follow text implementation if available.
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-11-07 11:03:05 UTC (rev 12755)
+++ trunk/mapserver/HISTORY.TXT 2011-11-07 11:14:16 UTC (rev 12756)
@@ -15,6 +15,8 @@
Current Version (SVN trunk, 6.1-dev, future 6.2):
-------------------------------------------------
+- Use a renderer native follow text implementation if available.
+
- Fixed layer with inline feature to support multiple classes (#4070)
- Add support for rfc45 anchorpoint on marker symbols (#4066)
Modified: trunk/mapserver/mapagg.cpp
===================================================================
--- trunk/mapserver/mapagg.cpp 2011-11-07 11:03:05 UTC (rev 12755)
+++ trunk/mapserver/mapagg.cpp 2011-11-07 11:14:16 UTC (rev 12756)
@@ -404,8 +404,57 @@
}
int agg2RenderGlyphsLine(imageObj *img, labelPathObj *labelpath, labelStyleObj *style, char *text) {
- msSetError(MS_AGGERR,"renderGlyphsLine not implemented","agg2RenderGlyphsLineLine()");
- return MS_FAILURE;
+ AGG2Renderer *r = AGG_RENDERER(img);
+ aggRendererCache *cache = (aggRendererCache*)MS_RENDERER_CACHE(MS_IMAGE_RENDERER(img));
+ if (!cache->m_feng.load_font(style->font, 0, mapserver::glyph_ren_outline)) {
+ msSetError(MS_TTFERR, "AGG error loading font (%s)", "agg2RenderGlyphs()", style->font);
+ return MS_FAILURE;
+ }
+ r->m_rasterizer_aa.filling_rule(mapserver::fill_non_zero);
+
+ const mapserver::glyph_cache* glyph;
+ int unicode;
+ //cache->m_feng.hinting(true);
+ cache->m_feng.height(style->size);
+ cache->m_feng.resolution(96);
+ cache->m_feng.flip_y(true);
+ font_curve_type m_curves(cache->m_fman.path_adaptor());
+
+ mapserver::path_storage glyphs;
+
+ for (int i = 0; i < labelpath->path.numpoints; i++) {
+ assert(text);
+ mapserver::trans_affine mtx;
+ mtx *= mapserver::trans_affine_translation(-labelpath->path.point[i].x,-labelpath->path.point[i].y);
+ mtx *= mapserver::trans_affine_rotation(-labelpath->angles[i]);
+ mtx *= mapserver::trans_affine_translation(labelpath->path.point[i].x,labelpath->path.point[i].y);
+ text += msUTF8ToUniChar(text, &unicode);
+ glyph = cache->m_fman.glyph(unicode);
+ if (glyph) {
+ cache->m_fman.init_embedded_adaptors(glyph, labelpath->path.point[i].x,labelpath->path.point[i].y);
+ mapserver::conv_transform<font_curve_type, mapserver::trans_affine> trans_c(m_curves, mtx);
+ glyphs.concat_path(trans_c);
+ }
+ }
+
+ if (style->outlinewidth) {
+ r->m_rasterizer_aa.reset();
+ r->m_rasterizer_aa.filling_rule(mapserver::fill_non_zero);
+ mapserver::conv_contour<mapserver::path_storage> cc(glyphs);
+ cc.width(style->outlinewidth + 1);
+ r->m_rasterizer_aa.add_path(cc);
+ r->m_renderer_scanline.color(aggColor(style->outlinecolor));
+ mapserver::render_scanlines(r->m_rasterizer_aa, r->sl_line, r->m_renderer_scanline);
+ }
+ if (style->color) {
+ r->m_rasterizer_aa.reset();
+ r->m_rasterizer_aa.filling_rule(mapserver::fill_non_zero);
+ r->m_rasterizer_aa.add_path(glyphs);
+ r->m_renderer_scanline.color(aggColor(style->color));
+ mapserver::render_scanlines(r->m_rasterizer_aa, r->sl_line, r->m_renderer_scanline);
+ }
+
+ return MS_SUCCESS;
}
static mapserver::path_storage imageVectorSymbolAGG(symbolObj *symbol) {
@@ -1091,6 +1140,7 @@
renderer->renderLineTiled = &agg2RenderLineTiled;
renderer->renderGlyphs = &agg2RenderGlyphs;
+ renderer->renderGlyphsLine = &agg2RenderGlyphsLine;
renderer->renderBitmapGlyphs = &agg2RenderBitmapGlyphs;
renderer->renderVectorSymbol = &agg2RenderVectorSymbol;
Modified: trunk/mapserver/mapdummyrenderer.c
===================================================================
--- trunk/mapserver/mapdummyrenderer.c 2011-11-07 11:03:05 UTC (rev 12755)
+++ trunk/mapserver/mapdummyrenderer.c 2011-11-07 11:14:16 UTC (rev 12756)
@@ -239,6 +239,7 @@
renderer->initializeRasterBuffer=initializeRasterBufferDummy;
renderer->renderPolygon=&renderPolygonDummy;
renderer->renderGlyphs=&renderGlyphsDummy;
+ renderer->renderGlyphsLine = NULL;
renderer->renderBitmapGlyphs = &renderGlyphsDummy;
renderer->freeImage=&freeImageDummy;
renderer->renderEllipseSymbol = &renderEllipseSymbolDummy;
Modified: trunk/mapserver/maprendering.c
===================================================================
--- trunk/mapserver/maprendering.c 2011-11-07 11:03:05 UTC (rev 12755)
+++ trunk/mapserver/maprendering.c 2011-11-07 11:14:16 UTC (rev 12756)
@@ -919,46 +919,73 @@
int msDrawTextLine(imageObj *image, char *string, labelObj *label, labelPathObj *labelpath, fontSetObj *fontset, double scalefactor)
{
- int nReturnVal = -1;
+ int nReturnVal = MS_SUCCESS;
if(image) {
if (MS_RENDERER_PLUGIN(image->format)) {
rendererVTableObj *renderer = image->format->vtable;
labelStyleObj s;
if (!string || !strlen(string))
- return (0); /* not errors, just don't want to do anything */
+ return (MS_SUCCESS); /* not errors, just don't want to do anything */
if(computeLabelStyle(&s, label, fontset, scalefactor) != MS_SUCCESS) return MS_FAILURE;
if (label->type == MS_TRUETYPE) {
- const char* string_ptr = string;
- int i;
- double x, y;
- char glyph[11];
- if(MS_VALID_COLOR(label->outlinecolor)) {
- s.outlinecolor = &(label->outlinecolor);
- s.outlinewidth = s.size/label->size * label->outlinewidth;
+ if(renderer->renderGlyphsLine) {
+ if(MS_VALID_COLOR(label->outlinecolor)) {
+ s.outlinecolor = &(label->outlinecolor);
+ s.outlinewidth = s.size/label->size * label->outlinewidth;
+ } else {
+ s.outlinewidth = 0;
+ s.outlinecolor = NULL;
+ }
+ s.color = &(label->color);
+ nReturnVal = renderer->renderGlyphsLine(image,labelpath,&s,string);
+ } else {
+ /*
+ * if the renderer doesn't support direct labelPath usage,
+ * decompose the string and send it down character by character
+ */
+ const char* string_ptr = string;
+ int i;
+ double x, y;
+ char glyph[11];
+
+ /*
+ * we first render all the outlines if present, so that the
+ * joining of characters stays correct
+ */
+ if(MS_VALID_COLOR(label->outlinecolor)) {
+ s.outlinecolor = &(label->outlinecolor);
+ s.outlinewidth = s.size/label->size * label->outlinewidth;
+ for (i = 0; i < labelpath->path.numpoints; i++) {
+ if (msGetNextGlyph(&string_ptr, glyph) == -1)
+ break; /* Premature end of string??? */
+ s.rotation = labelpath->angles[i];
+ x = labelpath->path.point[i].x;
+ y = labelpath->path.point[i].y;
+ nReturnVal = renderer->renderGlyphs(image, x, y, &s, glyph);
+ if(nReturnVal != MS_SUCCESS) {
+ return nReturnVal;
+ }
+ }
+ string_ptr = string; /* reset to beginning of string */
+ }
+ s.outlinecolor = NULL;
+ s.outlinewidth = 0;
+ s.color = &(label->color);
for (i = 0; i < labelpath->path.numpoints; i++) {
if (msGetNextGlyph(&string_ptr, glyph) == -1)
break; /* Premature end of string??? */
+
s.rotation = labelpath->angles[i];
x = labelpath->path.point[i].x;
y = labelpath->path.point[i].y;
- renderer->renderGlyphs(image, x, y, &s, glyph);
+
+ nReturnVal = renderer->renderGlyphs(image, x, y, &s, glyph);
+ if(nReturnVal != MS_SUCCESS) {
+ return nReturnVal;
+ }
}
- string_ptr = string;
}
- s.outlinecolor = NULL;
- s.outlinewidth = 0;
- s.color = &(label->color);
- for (i = 0; i < labelpath->path.numpoints; i++) {
- if (msGetNextGlyph(&string_ptr, glyph) == -1)
- break; /* Premature end of string??? */
-
- s.rotation = labelpath->angles[i];
- x = labelpath->path.point[i].x;
- y = labelpath->path.point[i].y;
-
- renderer->renderGlyphs(image, x, y, &s, glyph);
- }
}
}
}
Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2011-11-07 11:03:05 UTC (rev 12755)
+++ trunk/mapserver/mapserver.h 2011-11-07 11:14:16 UTC (rev 12756)
@@ -2685,6 +2685,9 @@
int (*renderGlyphs)(imageObj *img, double x, double y,
labelStyleObj *style, char *text);
+ int (*renderGlyphsLine)(imageObj *img, labelPathObj *labelpath,
+ labelStyleObj *style, char *text);
+
int (*renderVectorSymbol)(imageObj *img, double x, double y,
symbolObj *symbol, symbolStyleObj *style);
More information about the mapserver-commits
mailing list