diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index 6bbaa5c06f2c6e938f80d8381fae3139b1832b84..d1462e52e5e43ae663bd381a351c1aa84650a4e2 100644 (file)
}
bool
-CairoRenderContext::setSurfaceTarget(cairo_surface_t *surface, bool is_vector)
+CairoRenderContext::setSurfaceTarget(cairo_surface_t *surface, bool is_vector, cairo_matrix_t *ctm)
{
if (_is_valid || !surface)
return false;
_vector_based_target = is_vector;
- bool ret = _finishSurfaceSetup (surface);
+ bool ret = _finishSurfaceSetup (surface, ctm);
if (ret)
cairo_surface_reference (surface);
return ret;
}
bool
-CairoRenderContext::_finishSurfaceSetup(cairo_surface_t *surface)
+CairoRenderContext::_finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t *ctm)
{
if(surface == NULL) {
return FALSE;
}
_cr = cairo_create(surface);
+ if (ctm)
+ cairo_set_matrix(_cr, ctm);
_surface = surface;
if (_vector_based_target) {
@@ -1189,7 +1191,8 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
void
CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox)
{
- g_return_if_fail( style->fill.isColor()
+ g_return_if_fail( !style->fill.set
+ || style->fill.isColor()
|| style->fill.isPaintserver() );
float alpha = SP_SCALE24_TO_FLOAT(style->fill_opacity.value);
@@ -1203,6 +1206,10 @@ CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox
sp_color_get_rgb_floatv(&style->fill.value.color, rgb);
cairo_set_source_rgba(_cr, rgb[0], rgb[1], rgb[2], alpha);
+
+ } else if (!style->fill.set) { // unset fill is black
+ cairo_set_source_rgba(_cr, 0, 0, 0, alpha);
+
} else {
g_assert( style->fill.isPaintserver()
|| SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style))
@@ -1305,7 +1312,11 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
return true;
}
- if (style->fill.isNone() && style->stroke.isNone())
+ bool no_fill = style->fill.isNone() || style->fill_opacity.value == 0;
+ bool no_stroke = style->stroke.isNone() || style->stroke_width.computed < 1e-9 ||
+ style->stroke_opacity.value == 0;
+
+ if (no_fill && no_stroke)
return true;
bool need_layer = ( !_state->merge_opacity && !_state->need_layer &&
@@ -1316,7 +1327,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
else
pushLayer();
- if (!style->fill.isNone()) {
+ if (!no_fill) {
_setFillStyle(style, pbox);
setPathVector(pathv);
@@ -1326,15 +1337,15 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
}
- if (style->stroke.isNone())
+ if (no_stroke)
cairo_fill(_cr);
else
cairo_fill_preserve(_cr);
}
- if (!style->stroke.isNone()) {
+ if (!no_stroke) {
_setStrokeStyle(style, pbox);
- if (style->fill.isNone())
+ if (no_fill)
setPathVector(pathv);
cairo_stroke(_cr);
@@ -1453,10 +1464,16 @@ CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoG
i++;
}
- if (is_stroke || _is_texttopath)
+ if (is_stroke) {
cairo_glyph_path(cr, glyphs, num_glyphs - num_invalid_glyphs);
- else
- cairo_show_glyphs(cr, glyphs, num_glyphs - num_invalid_glyphs);
+ } else {
+ if (_is_texttopath) {
+ cairo_glyph_path(cr, glyphs, num_glyphs - num_invalid_glyphs);
+ cairo_fill_preserve(cr);
+ } else {
+ cairo_show_glyphs(cr, glyphs, num_glyphs - num_invalid_glyphs);
+ }
+ }
if (num_glyphs > GLYPH_ARRAY_SIZE)
g_free(glyphs);