+ use separate stroke-opacity and fill-opacity

This commit is contained in:
artemp 2012-07-12 15:38:25 +01:00
parent d3bc55761b
commit 461f5cfe08
5 changed files with 26 additions and 20 deletions

View file

@ -193,7 +193,7 @@ public:
}
// Attribute setting functions.
void fill(const agg::rgba8& f)
void fill(agg::rgba8 const& f)
{
path_attributes& attr = cur_attr();
double a = attr.fill_color.opacity();
@ -202,19 +202,19 @@ public:
attr.fill_flag = true;
}
void add_fill_gradient(mapnik::gradient& grad)
void add_fill_gradient(mapnik::gradient const& grad)
{
path_attributes& attr = cur_attr();
attr.fill_gradient = grad;
}
void add_stroke_gradient(mapnik::gradient& grad)
void add_stroke_gradient(mapnik::gradient const& grad)
{
path_attributes& attr = cur_attr();
attr.stroke_gradient = grad;
}
void stroke(const agg::rgba8& s)
void stroke(agg::rgba8 const& s)
{
path_attributes& attr = cur_attr();
double a = attr.stroke_color.opacity();
@ -264,16 +264,17 @@ public:
void fill_opacity(double op)
{
cur_attr().fill_color.opacity(op);
cur_attr().fill_opacity = op;
}
void stroke_opacity(double op)
{
cur_attr().stroke_color.opacity(op);
cur_attr().stroke_opacity = op;
}
void opacity(double op)
{
cur_attr().opacity = op;
cur_attr().stroke_opacity = op;
cur_attr().fill_opacity = op;
}
void line_join(agg::line_join_e join)

View file

@ -39,8 +39,9 @@ struct path_attributes
{
unsigned index;
agg::rgba8 fill_color;
double fill_opacity;
agg::rgba8 stroke_color;
double opacity;
double stroke_opacity;
bool fill_flag;
bool stroke_flag;
bool even_odd_flag;
@ -58,8 +59,9 @@ struct path_attributes
path_attributes() :
index(0),
fill_color(agg::rgba(0,0,0)),
fill_opacity(1.0),
stroke_color(agg::rgba(0,0,0)),
opacity(1.0),
stroke_opacity(1.0),
fill_flag(true),
stroke_flag(false),
even_odd_flag(false),
@ -79,8 +81,9 @@ struct path_attributes
path_attributes(const path_attributes& attr)
: index(attr.index),
fill_color(attr.fill_color),
fill_opacity(attr.fill_opacity),
stroke_color(attr.stroke_color),
opacity(attr.opacity),
stroke_opacity(attr.stroke_opacity),
fill_flag(attr.fill_flag),
stroke_flag(attr.stroke_flag),
even_odd_flag(attr.even_odd_flag),
@ -99,8 +102,9 @@ struct path_attributes
path_attributes(path_attributes const& attr, unsigned idx)
: index(idx),
fill_color(attr.fill_color),
fill_opacity(attr.fill_opacity),
stroke_color(attr.stroke_color),
opacity(attr.opacity),
stroke_opacity(attr.stroke_opacity),
fill_flag(attr.fill_flag),
stroke_flag(attr.stroke_flag),
even_odd_flag(attr.even_odd_flag),

View file

@ -292,13 +292,13 @@ public:
if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
{
render_gradient(ras, sl, ren, attr.fill_gradient, transform, attr.opacity * opacity, symbol_bbox, path_bbox);
render_gradient(ras, sl, ren, attr.fill_gradient, transform, attr.fill_opacity * opacity, symbol_bbox, path_bbox);
}
else
{
ras.filling_rule(attr.even_odd_flag ? fill_even_odd : fill_non_zero);
color = attr.fill_color;
color.opacity(color.opacity() * attr.opacity * opacity);
color.opacity(color.opacity() * attr.fill_opacity * opacity);
ScanlineRenderer ren_s(ren);
color.premultiply();
ren_s.color(color);
@ -328,13 +328,13 @@ public:
if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
{
render_gradient(ras, sl, ren, attr.stroke_gradient, transform, attr.opacity * opacity, symbol_bbox, path_bbox);
render_gradient(ras, sl, ren, attr.stroke_gradient, transform, attr.stroke_opacity * opacity, symbol_bbox, path_bbox);
}
else
{
ras.filling_rule(fill_non_zero);
color = attr.stroke_color;
color.opacity(color.opacity() * attr.opacity * opacity);
color.opacity(color.opacity() * attr.stroke_opacity * opacity);
ScanlineRenderer ren_s(ren);
color.premultiply();
ren_s.color(color);

View file

@ -1085,14 +1085,14 @@ void cairo_renderer_base::render_marker(pixel_position const& pos, marker const&
}
if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
{
cairo_gradient g(attr.fill_gradient,attr.opacity*opacity);
cairo_gradient g(attr.fill_gradient,attr.fill_opacity*opacity);
context.set_gradient(g,bbox);
context.fill();
}
else if(attr.fill_flag)
{
double fill_opacity = attr.opacity * opacity * attr.fill_color.opacity();
double fill_opacity = attr.fill_opacity * opacity * attr.fill_color.opacity();
context.set_color(attr.fill_color.r,attr.fill_color.g,attr.fill_color.b, fill_opacity);
context.fill();
}
@ -1107,13 +1107,13 @@ void cairo_renderer_base::render_marker(pixel_position const& pos, marker const&
context.set_line_cap(line_cap_enum(attr.line_cap));
context.set_line_join(line_join_enum(attr.line_join));
context.set_miter_limit(attr.miter_limit);
cairo_gradient g(attr.stroke_gradient,attr.opacity*opacity);
cairo_gradient g(attr.stroke_gradient,attr.fill_opacity*opacity);
context.set_gradient(g,bbox);
context.stroke();
}
else if (attr.stroke_flag)
{
double stroke_opacity = attr.opacity * opacity * attr.stroke_color.opacity();
double stroke_opacity = attr.stroke_opacity * opacity * attr.stroke_color.opacity();
context.set_color(attr.stroke_color.r,attr.stroke_color.g,attr.stroke_color.b, stroke_opacity);
context.set_line_width(attr.stroke_width);
context.set_line_cap(line_cap_enum(attr.line_cap));

View file

@ -407,7 +407,8 @@ void svg_parser::parse_attr(const xmlChar * name, const xmlChar * value )
else if(xmlStrEqual(name, BAD_CAST "opacity"))
{
double opacity = parse_double((const char*)value);
path_.opacity(opacity);
path_.stroke_opacity(opacity);
path_.fill_opacity(opacity);
}
else if (xmlStrEqual(name, BAD_CAST "visibility"))
{