From 9377f816024bd56159ee1f1760c08098f25ef25f Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 12 Jul 2008 15:44:30 +0000 Subject: * remove code duplication from pdf-cairo extension * try to fix line closing bug when using cairo. didn't succeed (bzr r6276) --- src/extension/internal/pdf-cairo.cpp | 49 +++++------------------------------- src/extension/internal/pdf-cairo.h | 1 - 2 files changed, 6 insertions(+), 44 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/pdf-cairo.cpp b/src/extension/internal/pdf-cairo.cpp index 6dfed9e82..813724e71 100644 --- a/src/extension/internal/pdf-cairo.cpp +++ b/src/extension/internal/pdf-cairo.cpp @@ -48,6 +48,7 @@ #include #include "display/nr-arena-item.h" #include "display/canvas-bpath.h" +#include "display/inkscape-cairo.h" #include "sp-item.h" #include "style.h" #include "sp-linear-gradient.h" @@ -600,9 +601,9 @@ PrintCairoPDF::fill(Inkscape::Extension::Print *mod, Geom::PathVector const &pat cairo_save(cr); print_fill_style(cr, style, pbox); - NArtBpath * bpath = BPath_from_2GeomPath(pathv); - print_bpath(cr, bpath); - g_free(bpath); + + feed_pathvector_to_cairo(cr, pathv); + if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) { cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); } else { @@ -700,9 +701,8 @@ PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, Geom::PathVector const &p cairo_save(cr); print_stroke_style(cr, style, pbox); - NArtBpath * bpath = BPath_from_2GeomPath(pathv); - print_bpath(cr, bpath); - g_free(bpath); + + feed_pathvector_to_cairo(cr, pathv); cairo_stroke(cr); cairo_restore(cr); @@ -988,43 +988,6 @@ PrintCairoPDF::text(Inkscape::Extension::Print *mod, char const *text, NR::Point /* Helper functions */ -void -PrintCairoPDF::print_bpath(cairo_t *cr, NArtBpath const *bp) -{ - cairo_new_path(cr); - bool closed = false; - while (bp->code != NR_END) { - switch (bp->code) { - case NR_MOVETO: - if (closed) { - cairo_close_path(cr); - } - closed = true; - cairo_move_to(cr, bp->x3, bp->y3); - break; - case NR_MOVETO_OPEN: - if (closed) { - cairo_close_path(cr); - } - closed = false; - cairo_move_to(cr, bp->x3, bp->y3); - break; - case NR_LINETO: - cairo_line_to(cr, bp->x3, bp->y3); - break; - case NR_CURVETO: - cairo_curve_to(cr, bp->x1, bp->y1, bp->x2, bp->y2, bp->x3, bp->y3); - break; - default: - break; - } - bp += 1; - } - if (closed) { - cairo_close_path(cr); - } -} - static void _concat_transform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0) { diff --git a/src/extension/internal/pdf-cairo.h b/src/extension/internal/pdf-cairo.h index 8e2764fa4..f45d7a4cd 100644 --- a/src/extension/internal/pdf-cairo.h +++ b/src/extension/internal/pdf-cairo.h @@ -50,7 +50,6 @@ class PrintCairoPDF : public Inkscape::Extension::Implementation::Implementation unsigned short _dpi; bool _bitmap; - void print_bpath(cairo_t *cr, NArtBpath const *bp); cairo_pattern_t *create_pattern_for_paint(SPPaintServer const *const paintserver, NRRect const *pbox, float alpha); void print_fill_style(cairo_t *cr, SPStyle const *const style, NRRect const *pbox); -- cgit v1.2.3