summaryrefslogtreecommitdiffstats
path: root/src/display/inkscape-cairo.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-08-02 22:17:01 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-08-02 22:17:01 +0000
commitcbf419d53ee3cb8989069ef0768e65bbe84d0870 (patch)
tree5df2feeb955fb409f21101068ad4653ac5525b42 /src/display/inkscape-cairo.cpp
parentconvert path to only linear and cubic segments when nodeediting. prevents cra... (diff)
downloadinkscape-cbf419d53ee3cb8989069ef0768e65bbe84d0870.tar.gz
inkscape-cbf419d53ee3cb8989069ef0768e65bbe84d0870.zip
remove old nartbpath to cairo method
(bzr r6532)
Diffstat (limited to 'src/display/inkscape-cairo.cpp')
-rw-r--r--src/display/inkscape-cairo.cpp98
1 files changed, 3 insertions, 95 deletions
diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp
index d077abbd2..c52404b23 100644
--- a/src/display/inkscape-cairo.cpp
+++ b/src/display/inkscape-cairo.cpp
@@ -13,9 +13,7 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include <libnr/n-art-bpath.h>
-#include <libnr/nr-matrix-ops.h>
-#include <libnr/nr-matrix-fns.h>
+
#include <libnr/nr-pixblock.h>
#include <libnr/nr-convert2geom.h>
#include "../style.h"
@@ -69,95 +67,6 @@ nr_create_cairo_context (NRRectL *area, NRPixBlock *pb)
return nr_create_cairo_context_for_data (area, &(pb->area), NR_PIXBLOCK_PX (pb), pb->rs);
}
-/** Feeds path-creating calls to the cairo context translating them from the SPCurve, with the given transform and shift */
-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)
-{
- NR::Point next(0,0), last(0,0);
- if (!area || area->isEmpty())
- return;
- NR::Point shift = area->min();
- NR::Rect view = *area;
- view.growBy (stroke_width);
- NR::Rect swept;
- bool closed = false;
- NR::Point startpath(0,0);
- for (int i = 0; bpath[i].code != NR_END; i++) {
- switch (bpath[i].code) {
- case NR_MOVETO_OPEN:
- case NR_MOVETO:
- if (closed) {
- // we cannot use close_path because some of the curves/lines may have been optimized out
- cairo_line_to(ct, startpath[NR::X], startpath[NR::Y]);
- }
- next[NR::X] = bpath[i].x3;
- next[NR::Y] = bpath[i].y3;
- next *= trans;
- last = next;
- next -= shift;
- if (bpath[i].code == NR_MOVETO) {
- // remember the start point of the subpath, for closing it later
- closed = true;
- startpath = next;
- } else {
- closed = false;
- }
- cairo_move_to(ct, next[NR::X], next[NR::Y]);
- break;
-
- case NR_LINETO:
- next[NR::X] = bpath[i].x3;
- next[NR::Y] = bpath[i].y3;
- next *= trans;
- if (optimize_stroke) {
- swept = NR::Rect(last, next);
- //std::cout << "swept: " << swept;
- //std::cout << "view: " << view;
- //std::cout << "intersects? " << (swept.intersects(view)? "YES" : "NO") << "\n";
- }
- last = next;
- next -= shift;
- if (!optimize_stroke || swept.intersects(view))
- cairo_line_to(ct, next[NR::X], next[NR::Y]);
- else
- cairo_move_to(ct, next[NR::X], next[NR::Y]);
- break;
-
- case NR_CURVETO: {
- NR::Point tm1, tm2, tm3;
- tm1[0]=bpath[i].x1;
- tm1[1]=bpath[i].y1;
- tm2[0]=bpath[i].x2;
- tm2[1]=bpath[i].y2;
- tm3[0]=bpath[i].x3;
- tm3[1]=bpath[i].y3;
- tm1 *= trans;
- tm2 *= trans;
- tm3 *= trans;
- if (optimize_stroke) {
- swept = NR::Rect(last, last);
- swept.expandTo(tm1);
- swept.expandTo(tm2);
- swept.expandTo(tm3);
- }
- last = tm3;
- tm1 -= shift;
- tm2 -= shift;
- tm3 -= shift;
- if (!optimize_stroke || swept.intersects(view))
- cairo_curve_to (ct, tm1[NR::X], tm1[NR::Y], tm2[NR::X], tm2[NR::Y], tm3[NR::X], tm3[NR::Y]);
- else
- cairo_move_to(ct, tm3[NR::X], tm3[NR::Y]);
- break;
- }
-
- default:
- break;
- }
- }
-}
-
-
/*
* Can be called recursively.
* If optimize_stroke == false, the view Rect is not used.
@@ -286,9 +195,8 @@ feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, NR:
if (path.closed()) {
cairo_line_to(ct, initial[0], initial[1]);
-// cairo_close_path(ct);
- /* I think we should use cairo_close_path(ct) here but it doesn't work. (the closing line is not rendered completely)
- According to cairo documentation:
+ /* It seems we cannot use cairo_close_path(ct) here; maybe because some parts of the path have been clipped and not drawn (maybe the before last segment was outside view area)
+ However, according to cairo documentation:
The behavior of cairo_close_path() is distinct from simply calling cairo_line_to() with the equivalent coordinate
in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead,
there is a line join connecting the final and initial segments of the sub-path.