void SVGStylable::computeGeometry(svgl::Context * svglContext, svgl::GLInfo* glinfo) { SVGElement * meAsElement = dynamic_cast<SVGElement*>(this); if(!meAsElement) return; bool damaged = meAsElement->getDamaged(); if(!(damaged)) return; shape_type * gshape = new shape_type; agg::path_storage * ppath = new agg::path_storage; asBezier(svglContext, glinfo, ppath); shape_type::contour_type * pcontour = new shape_type::contour_type(*ppath); gshape->_path = ppath; gshape->_contour = pcontour; fillGlPoly = new glPoly; fillGlPoly->setTessCallbacks(glinfo->gluTriangulator); agg2glPoly(*pcontour, *fillGlPoly, glinfo->gluTriangulator); const css::CSSStyleDeclaration& style = GET_SIMPLE_VAL(Style); svg::SVGLength strokeWidth = style.getStrokeWidth(); double sw = svglContext->computeWidthLength(strokeWidth); if (sw > 0) { const css::CSSStyle::StringType& linecap = style.getStrokeLinecap(); const css::CSSStyle::StringType& linejoin = style.getStrokeLinejoin(); const css::CSSStyle::FloatType& strokeMiterLimit = style.getStrokeMiterlimit(); const css::CSSStyle::StrokeDasharrayType& strokeDasharray = style.getStrokeDasharray(); css::CSSStyle::LengthType strokeDashoffset = style.getStrokeDashoffset(); float dashOffset = svglContext->computeWidthLength(strokeDashoffset); //std::cerr << DBGVAR(strokeDasharray.size()) << __FL__; if(!strokeDasharray.empty()) { shape_type::dash_type * pdash = new shape_type::dash_type(*pcontour); shape_type::dash_type& dash = *pdash; for(css::CSSStyle::StrokeDasharrayType::const_iterator it = strokeDasharray.begin(); it != strokeDasharray.end(); ++it) { double a,b; a = *it++; if (it==strokeDasharray.end()) { b = a; dash.add_dash(a,b); break; } else b = *it; dash.add_dash(a,b); } dash.dash_start(dashOffset); gshape->_dash= new shape_type::dashstroke_type(*pdash); } else gshape->_plain = new shape_type::plainstroke_type(*pcontour); shape_type& shape = *gshape; static unicode::String // *butt_cap_string = unicode::String::internString("butt"), *square_cap_string = unicode::String::internString("square"), *round_cap_string = unicode::String::internString("round"), // *miter_join_string = unicode::String::internString("miter"), *round_join_string = unicode::String::internString("round"), *bevel_join_string = unicode::String::internString("bevel"); //std::cerr << DBGVAR(linecap) << __FL__; //std::cerr << DBGVAR(linejoin) << __FL__; agg::gen_stroke::line_cap_e cap = agg::gen_stroke::butt_cap; if(*linecap == *square_cap_string) { cap = agg::gen_stroke::square_cap; } else if(*linecap == *round_cap_string) { cap = agg::gen_stroke::round_cap; } agg::gen_stroke::line_join_e join = agg::gen_stroke::miter_join; if(*linejoin == *round_join_string) { join = agg::gen_stroke::round_join; } else if(*linejoin == *bevel_join_string) { join = agg::gen_stroke::bevel_join; } shape.line_join(join); shape.line_cap(cap); shape.miter_limit(strokeMiterLimit); shape.width(sw); strokeGlPoly = new glPoly; strokeGlPoly->setTessCallbacks(glinfo->gluTriangulator); gluTessProperty(glinfo->gluTriangulator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO); agg2glPoly(*gshape, *strokeGlPoly, glinfo->gluTriangulator); gluTessProperty(glinfo->gluTriangulator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); } }