summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-07-12 15:44:30 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-07-12 15:44:30 +0000
commit9377f816024bd56159ee1f1760c08098f25ef25f (patch)
treebe86e5fd686a64317670ae49546cee26382ef61d /src
parentadd simplified feed_path_to_cairo functions (diff)
downloadinkscape-9377f816024bd56159ee1f1760c08098f25ef25f.tar.gz
inkscape-9377f816024bd56159ee1f1760c08098f25ef25f.zip
* remove code duplication from pdf-cairo extension
* try to fix line closing bug when using cairo. didn't succeed (bzr r6276)
Diffstat (limited to 'src')
-rw-r--r--src/display/inkscape-cairo.cpp10
-rw-r--r--src/display/inkscape-cairo.h2
-rw-r--r--src/extension/internal/pdf-cairo.cpp49
-rw-r--r--src/extension/internal/pdf-cairo.h1
4 files changed, 13 insertions, 49 deletions
diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp
index 9210af1f4..e41d93952 100644
--- a/src/display/inkscape-cairo.cpp
+++ b/src/display/inkscape-cairo.cpp
@@ -233,8 +233,8 @@ feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix const & tran
}
-/** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */
-void
+/** Feeds path-creating calls to the cairo context translating them from the Path */
+static void
feed_path_to_cairo (cairo_t *ct, Geom::Path const &path)
{
if (path.empty())
@@ -259,7 +259,7 @@ feed_path_to_cairo (cairo_t *ct, Geom::Path const &path)
}
/** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */
-void
+static void
feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width)
{
if (!area || area->isEmpty())
@@ -303,6 +303,8 @@ feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matr
if (pathv.empty())
return;
+ cairo_new_path(ct);
+
for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) {
feed_path_to_cairo(ct, *it, trans, area, optimize_stroke, stroke_width);
}
@@ -315,6 +317,8 @@ feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv)
if (pathv.empty())
return;
+ cairo_new_path(ct);
+
for(Geom::PathVector::const_iterator it = pathv.begin(); it != pathv.end(); ++it) {
feed_path_to_cairo(ct, *it);
}
diff --git a/src/display/inkscape-cairo.h b/src/display/inkscape-cairo.h
index 02a145a33..43cafa4bc 100644
--- a/src/display/inkscape-cairo.h
+++ b/src/display/inkscape-cairo.h
@@ -23,8 +23,6 @@ class SPCanvasBuf;
cairo_t *nr_create_cairo_context_canvasbuf (NRRectL *area, SPCanvasBuf *b);
cairo_t *nr_create_cairo_context (NRRectL *area, NRPixBlock *pb);
void feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width);
-void feed_path_to_cairo (cairo_t *ct, Geom::Path const &path);
-void feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width);
void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width);
void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv);
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 <glibmm/i18n.h>
#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);