From: johanengelen Date: Fri, 9 May 2008 17:06:59 +0000 (+0000) Subject: complete adding const to have only NArtBpath const * get_bpath() const; for accessing... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e5183c603c61d36c2c145e99693cbc62463122f3;p=inkscape.git complete adding const to have only NArtBpath const * get_bpath() const; for accessing the protected member of SPCurve. Nowhere in Inkscape source is the path data changed of SPCurve, except within SPCurve's own methods ! So removed the non-const NArtBpath* get_bpath. --- diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 2fff9f7b5..4bd10e854 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -121,12 +121,12 @@ box3d_side_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) sp_shape_set_shape ((SPShape *) object); /* Duplicate the path */ - SPCurve *curve = ((SPShape *) object)->curve; + SPCurve const *curve = ((SPShape *) object)->curve; //Nulls might be possible if this called iteratively if ( !curve ) { return NULL; } - NArtBpath *bpath = SP_CURVE_BPATH(curve); + NArtBpath const *bpath = SP_CURVE_BPATH(curve); if ( !bpath ) { return NULL; } diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 5b2ac024b..489553dac 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -150,11 +150,13 @@ SPCurve::get_bpath() const { return _bpath; }; +/* NArtBpath * SPCurve::get_bpath() { return _bpath; }; +*/ /** * Increase _refcount of curve. @@ -273,7 +275,7 @@ SPCurve::split() const { g_return_val_if_fail(this != NULL, NULL); - gint p = 0; + guint p = 0; GSList *l = NULL; while (p < _end) { @@ -304,7 +306,7 @@ tmpl_curve_transform(SPCurve *const curve, M const &m) { g_return_if_fail(curve != NULL); - for (gint i = 0; i < curve->_end; i++) { + for (guint i = 0; i < curve->_end; i++) { NArtBpath *p = curve->_bpath + i; switch (p->code) { case NR_MOVETO: diff --git a/src/display/curve.h b/src/display/curve.h index 28fce3132..5cd8bb12c 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -36,7 +36,6 @@ public: void set_bpath(NArtBpath * new_bpath); NArtBpath const * get_bpath() const; - NArtBpath * get_bpath(); /// Index in bpath[] of NR_END element. guint _end; diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp index d2e2b7d8b..15660e587 100644 --- a/src/display/inkscape-cairo.cpp +++ b/src/display/inkscape-cairo.cpp @@ -46,7 +46,7 @@ nr_create_cairo_context (NRRectL *area, NRPixBlock *pb) /** 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 *bpath, NR::Matrix trans, NR::Maybe area, bool optimize_stroke, double stroke_width) +feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR::Maybe area, bool optimize_stroke, double stroke_width) { NR::Point next(0,0), last(0,0); if (!area || area->isEmpty()) diff --git a/src/display/inkscape-cairo.h b/src/display/inkscape-cairo.h index fa579fb20..55fa08263 100644 --- a/src/display/inkscape-cairo.h +++ b/src/display/inkscape-cairo.h @@ -11,7 +11,7 @@ */ cairo_t *nr_create_cairo_context (NRRectL *area, NRPixBlock *pb); -void feed_curve_to_cairo (cairo_t *ct, NArtBpath *bpath, NR::Matrix trans, NR::Maybe area, bool optimize_stroke, double stroke_width); +void feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR::Maybe area, bool optimize_stroke, double stroke_width); #endif /* diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index aba06068e..0ff7132e1 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -249,7 +249,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g shape->ctm = gc->transform; if (state & NR_ARENA_ITEM_STATE_BBOX) { if (shape->curve) { - NRBPath bp; + const_NRBPath bp; /* fixme: */ bbox.x0 = bbox.y0 = NR_HUGE; bbox.x1 = bbox.y1 = -NR_HUGE; @@ -277,7 +277,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); if (shape->curve) { - NRBPath bp; + const_NRBPath bp; /* fixme: */ bbox.x0 = bbox.y0 = NR_HUGE; bbox.x1 = bbox.y1 = -NR_HUGE; @@ -1102,7 +1102,7 @@ nr_arena_shape_pick(NRArenaItem *item, NR::Point p, double delta, unsigned int / width = 0; } - NRBPath bp; + const_NRBPath bp; bp.path = SP_CURVE_BPATH(shape->curve); double dist = NR_HUGE; int wind = 0; diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 6614604ff..83b865cdb 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -166,14 +166,14 @@ Implementation::comment(Inkscape::Extension::Print */*module*/, char const */*co } unsigned int -Implementation::fill(Inkscape::Extension::Print */*module*/, NRBPath const */*bpath*/, NR::Matrix const */*ctm*/, SPStyle const */*style*/, +Implementation::fill(Inkscape::Extension::Print */*module*/, const_NRBPath const */*bpath*/, NR::Matrix const */*ctm*/, SPStyle const */*style*/, NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) { return 0; } unsigned int -Implementation::stroke(Inkscape::Extension::Print */*module*/, NRBPath const */*bpath*/, NR::Matrix const */*transform*/, SPStyle const */*style*/, +Implementation::stroke(Inkscape::Extension::Print */*module*/, const_NRBPath const */*bpath*/, NR::Matrix const */*transform*/, SPStyle const */*style*/, NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) { return 0; diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index caa4a89bd..29366ddf5 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -104,14 +104,14 @@ public: virtual unsigned release(Inkscape::Extension::Print *module); virtual unsigned comment(Inkscape::Extension::Print *module, const char * comment); virtual unsigned fill(Inkscape::Extension::Print *module, - NRBPath const *bpath, + const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); virtual unsigned stroke(Inkscape::Extension::Print *module, - NRBPath const *bpath, + const_NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 0722edff5..887ffe602 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1240,7 +1240,7 @@ CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox) } bool -CairoRenderContext::renderPath(NRBPath const *bpath, SPStyle const *style, NRRect const *pbox) +CairoRenderContext::renderPath(const_NRBPath const *bpath, SPStyle const *style, NRRect const *pbox) { g_assert( _is_valid ); diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index 948efc438..642c6d90e 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -136,7 +136,7 @@ public: void addClippingRect(double x, double y, double width, double height); /* Rendering methods */ - bool renderPath(NRBPath const *bpath, SPStyle const *style, NRRect const *pbox); + bool renderPath(const_NRBPath const *bpath, SPStyle const *style, NRRect const *pbox); bool renderImage(unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, NR::Matrix const *image_transform, SPStyle const *style); bool renderGlyphtext(PangoFont *font, NR::Matrix const *font_matrix, diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index f13e26abb..7ac9b9a2a 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -178,12 +178,12 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) SPStyle* style = SP_OBJECT_STYLE (item); CairoRenderer *renderer = ctx->getRenderer(); - NRBPath bp; + const_NRBPath bp; bp.path = SP_CURVE_BPATH(shape->curve); ctx->renderPath(&bp, style, &pbox); - for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { + for (NArtBpath const* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { for (int m = SP_MARKER_LOC_START; m < SP_MARKER_LOC_QTY; m++) { if (sp_shape_marker_required (shape, m, bp)) { diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index bb82183fd..1616d5d86 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -485,7 +485,7 @@ PrintEmfWin32::release(Inkscape::Extension::Print *mod) unsigned int PrintEmfWin32::fill(Inkscape::Extension::Print *mod, - NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, + const_NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!hdc) return 0; @@ -512,7 +512,7 @@ PrintEmfWin32::fill(Inkscape::Extension::Print *mod, unsigned int PrintEmfWin32::stroke (Inkscape::Extension::Print *mod, - const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, + const const_NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { if (!hdc) return 0; diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h index fdf0cd490..c0eb58481 100644 --- a/src/extension/internal/emf-win32-print.h +++ b/src/extension/internal/emf-win32-print.h @@ -64,10 +64,10 @@ public: virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); virtual unsigned int fill (Inkscape::Extension::Print * module, - const NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, + const const_NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int stroke (Inkscape::Extension::Print * module, - const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, + const const_NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); virtual unsigned int text(Inkscape::Extension::Print *module, char const *text, diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 0795ddbdb..1496b75f6 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -201,7 +201,7 @@ unsigned int PrintLatex::comment (Inkscape::Extension::Print * module, unsigned int PrintLatex::fill(Inkscape::Extension::Print *mod, - NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, + const_NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -228,7 +228,7 @@ PrintLatex::fill(Inkscape::Extension::Print *mod, } unsigned int -PrintLatex::stroke (Inkscape::Extension::Print *mod, const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, +PrintLatex::stroke (Inkscape::Extension::Print *mod, const const_NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. diff --git a/src/extension/internal/latex-pstricks.h b/src/extension/internal/latex-pstricks.h index c418eaf5b..56600023a 100644 --- a/src/extension/internal/latex-pstricks.h +++ b/src/extension/internal/latex-pstricks.h @@ -46,12 +46,12 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); - virtual unsigned int release(Inkscape::Extension::Print *module); + virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); + virtual unsigned int release(Inkscape::Extension::Print *module); - virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, + virtual unsigned int fill (Inkscape::Extension::Print * module, const const_NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); - virtual unsigned int stroke (Inkscape::Extension::Print * module, const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, + virtual unsigned int stroke (Inkscape::Extension::Print * module, const const_NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); bool textToPath (Inkscape::Extension::Print * ext); diff --git a/src/extension/internal/pdf-cairo.cpp b/src/extension/internal/pdf-cairo.cpp index 6669c619a..92b8d92c4 100644 --- a/src/extension/internal/pdf-cairo.cpp +++ b/src/extension/internal/pdf-cairo.cpp @@ -579,7 +579,7 @@ PrintCairoPDF::print_fill_style(cairo_t *cr, SPStyle const *const style, NRRect } unsigned int -PrintCairoPDF::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *const style, +PrintCairoPDF::fill(Inkscape::Extension::Print *mod, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *const style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -679,7 +679,7 @@ PrintCairoPDF::print_stroke_style(cairo_t *cr, SPStyle const *style, NRRect cons } unsigned int -PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, +PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. diff --git a/src/extension/internal/pdf-cairo.h b/src/extension/internal/pdf-cairo.h index 185f86727..b37cfe22d 100644 --- a/src/extension/internal/pdf-cairo.h +++ b/src/extension/internal/pdf-cairo.h @@ -78,9 +78,9 @@ public: virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment); - virtual unsigned int fill(Inkscape::Extension::Print *module, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, + virtual unsigned int fill(Inkscape::Extension::Print *module, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); - virtual unsigned int stroke(Inkscape::Extension::Print *module, NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, + virtual unsigned int stroke(Inkscape::Extension::Print *module, const_NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, NR::Matrix const *transform, SPStyle const *style); diff --git a/src/extension/internal/ps.cpp b/src/extension/internal/ps.cpp index ab52ac280..13024344d 100644 --- a/src/extension/internal/ps.cpp +++ b/src/extension/internal/ps.cpp @@ -813,7 +813,7 @@ PrintPS::print_stroke_style(SVGOStringStream &os, SPStyle const *style) unsigned int -PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *const style, +PrintPS::fill(Inkscape::Extension::Print *mod, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *const style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -879,7 +879,7 @@ PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NR::Matrix unsigned int -PrintPS::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, +PrintPS::stroke(Inkscape::Extension::Print *mod, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. diff --git a/src/extension/internal/ps.h b/src/extension/internal/ps.h index 1397063da..edeaaeac6 100644 --- a/src/extension/internal/ps.h +++ b/src/extension/internal/ps.h @@ -91,9 +91,9 @@ public: virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment); - virtual unsigned int fill(Inkscape::Extension::Print *module, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, + virtual unsigned int fill(Inkscape::Extension::Print *module, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); - virtual unsigned int stroke(Inkscape::Extension::Print *module, NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, + virtual unsigned int stroke(Inkscape::Extension::Print *module, const_NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, NR::Matrix const *transform, SPStyle const *style); diff --git a/src/extension/internal/win32.h b/src/extension/internal/win32.h index 6eb634f47..8fd16edf2 100644 --- a/src/extension/internal/win32.h +++ b/src/extension/internal/win32.h @@ -74,9 +74,9 @@ public: virtual unsigned int bind (Inkscape::Extension::Print * module, const NR::Matrix *transform, float opacity); virtual unsigned int release (Inkscape::Extension::Print * module); virtual unsigned int comment (Inkscape::Extension::Print * module, const char * comment); - virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, + virtual unsigned int fill (Inkscape::Extension::Print * module, const const_NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); - virtual unsigned int stroke (Inkscape::Extension::Print * module, const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, + virtual unsigned int stroke (Inkscape::Extension::Print * module, const const_NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int image (Inkscape::Extension::Print * module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, const NR::Matrix *transform, const SPStyle *style); diff --git a/src/extension/print.cpp b/src/extension/print.cpp index 6f8c1afd2..eded694a5 100644 --- a/src/extension/print.cpp +++ b/src/extension/print.cpp @@ -79,14 +79,14 @@ Print::comment (const char * comment) } unsigned int -Print::fill (const NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, +Print::fill (const const_NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { return imp->fill (this, bpath, ctm, style, pbox, dbox, bbox); } unsigned int -Print::stroke (const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, +Print::stroke (const const_NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { return imp->stroke (this, bpath, transform, style, pbox, dbox, bbox); diff --git a/src/extension/print.h b/src/extension/print.h index 070f928e3..e9796bb2d 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -45,13 +45,13 @@ public: float opacity); unsigned int release (void); unsigned int comment (const char * comment); - unsigned int fill (NRBPath const *bpath, + unsigned int fill (const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); - unsigned int stroke (NRBPath const *bpath, + unsigned int stroke (const_NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, diff --git a/src/libnr/nr-forward.h b/src/libnr/nr-forward.h index b12d141df..112313b24 100644 --- a/src/libnr/nr-forward.h +++ b/src/libnr/nr-forward.h @@ -21,6 +21,7 @@ class translate; class NArtBpath; struct NRBPath; +struct const_NRBPath; struct NRPixBlock; struct NRRect; struct NRRectL; diff --git a/src/libnr/nr-path.cpp b/src/libnr/nr-path.cpp index 713cfe43d..734f3426d 100644 --- a/src/libnr/nr-path.cpp +++ b/src/libnr/nr-path.cpp @@ -20,7 +20,7 @@ static void nr_curve_bbox(NR::Point const p000, NR::Point const p001, NR::Point const p011, NR::Point const p111, NRRect *bbox); -NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NR::Matrix const *transform) +NRBPath *nr_path_duplicate_transform(NRBPath *d, const_NRBPath *s, NR::Matrix const *transform) { int i; @@ -49,16 +49,17 @@ NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NR::Matrix const *t return d; } -NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NR::Matrix const transform) { +NRBPath *nr_path_duplicate_transform(NRBPath *d, const_NRBPath *s, NR::Matrix const transform) { NR::Matrix tr = transform; return nr_path_duplicate_transform(d, s, &tr); } -NArtBpath* nr_artpath_affine(NArtBpath *s, NR::Matrix const &aff) { - NRBPath bp, abp; - bp.path = s; - nr_path_duplicate_transform(&abp, &bp, aff); - return abp.path; +NArtBpath* nr_artpath_affine(NArtBpath const *s, NR::Matrix const &aff) { + const_NRBPath bp; + bp.path = s; + NRBPath abp; + nr_path_duplicate_transform(&abp, &bp, aff); + return abp.path; } static void @@ -212,7 +213,7 @@ nr_curve_bbox_wind_distance (NR::Coord x000, NR::Coord y000, } void -nr_path_matrix_point_bbox_wind_distance (NRBPath *bpath, NR::Matrix const &m, NR::Point &pt, +nr_path_matrix_point_bbox_wind_distance (const_NRBPath const *bpath, NR::Matrix const &m, NR::Point &pt, NRRect *bbox, int *wind, NR::Coord *dist, NR::Coord tolerance, NR::Rect *viewbox) { @@ -449,7 +450,7 @@ nr_curve_bbox (NR::Coord x000, NR::Coord y000, NR::Coord x001, NR::Coord y001, N } void -nr_path_matrix_bbox_union(NRBPath const *bpath, NR::Matrix const &m, +nr_path_matrix_bbox_union(const_NRBPath *bpath, NR::Matrix const &m, NRRect *bbox) { using NR::X; diff --git a/src/libnr/nr-path.h b/src/libnr/nr-path.h index bf7369be4..5e8b0e48e 100644 --- a/src/libnr/nr-path.h +++ b/src/libnr/nr-path.h @@ -30,21 +30,26 @@ #include #include -NArtBpath* nr_artpath_affine(NArtBpath *s, NR::Matrix const &transform); +NArtBpath* nr_artpath_affine(NArtBpath const *s, NR::Matrix const &transform); +struct const_NRBPath { + NArtBpath const *path; +}; struct NRBPath { - NArtBpath *path; + NArtBpath *path; + operator const_NRBPath() { const_NRBPath bp = { path }; return bp; }; }; -NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NR::Matrix const *transform); -NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NR::Matrix const transform); +NRBPath *nr_path_duplicate_transform(NRBPath *d, const_NRBPath *s, NR::Matrix const *transform); + +NRBPath *nr_path_duplicate_transform(NRBPath *d, const_NRBPath *s, NR::Matrix const transform); -void nr_path_matrix_point_bbox_wind_distance (NRBPath *bpath, NR::Matrix const &m, NR::Point &pt, +void nr_path_matrix_point_bbox_wind_distance (const_NRBPath const *bpath, NR::Matrix const &m, NR::Point &pt, NRRect *bbox, int *wind, NR::Coord *dist, NR::Coord tolerance, NR::Rect *viewbox); -void nr_path_matrix_bbox_union(NRBPath const *bpath, NR::Matrix const &m, NRRect *bbox); +void nr_path_matrix_bbox_union(const_NRBPath *bpath, NR::Matrix const &m, NRRect *bbox); NArtBpath *nr_path_from_rect(NRRect const &r); diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index f3fac4218..499a8f7a5 100755 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -156,14 +156,15 @@ void Layout::print(SPPrintContext *ctx, NRBPath bpath; bpath.path = (NArtBpath*)span.font->ArtBPath(_glyphs[glyph_index].glyph); if (bpath.path) { - NRBPath abp; + const_NRBPath abp; _getGlyphTransformMatrix(glyph_index, &glyph_matrix); - abp.path = nr_artpath_affine(bpath.path, glyph_matrix); + NArtBpath *temp_bpath = nr_artpath_affine(bpath.path, glyph_matrix); + abp.path = temp_bpath; if (!text_source->style->fill.isNone()) sp_print_fill(ctx, &abp, &ctm, text_source->style, pbox, dbox, bbox); if (!text_source->style->stroke.isNone()) sp_print_stroke(ctx, &abp, &ctm, text_source->style, pbox, dbox, bbox); - g_free(abp.path); + g_free(temp_bpath); } glyph_index++; } else { @@ -234,7 +235,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const NArtBpath *bpath = (NArtBpath*)span.font->ArtBPath(_glyphs[glyph_index].glyph); if (bpath) { NArtBpath *abp = nr_artpath_affine(bpath, glyph_matrix); - NRBPath bpath; + const_NRBPath bpath; bpath.path = abp; SPStyle const *style = text_source->style; ctx->renderPath(&bpath, style, NULL); diff --git a/src/livarot/Path.h b/src/livarot/Path.h index 454fb4ca4..2568f9ccc 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -176,7 +176,7 @@ public: void DashPolylineFromStyle(SPStyle *style, float scale, float min_len); //utilitaire pour inkscape - void LoadArtBPath(void *iP,NR::Matrix const &tr,bool doTransformation); + void LoadArtBPath(void const *iP,NR::Matrix const &tr,bool doTransformation); void* MakeArtBPath(); void Transform(const NR::Matrix &trans); diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index ea8a86f3e..dddb7bdf4 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -405,10 +405,10 @@ void* Path::MakeArtBPath(void) return bpath; } -void Path::LoadArtBPath(void *iV,NR::Matrix const &trans,bool doTransformation) +void Path::LoadArtBPath(void const *iV,NR::Matrix const &trans,bool doTransformation) { if ( iV == NULL ) return; - NArtBpath *bpath = (NArtBpath*)iV; + NArtBpath const *bpath = (NArtBpath const*)iV; SetBackData (false); Reset(); diff --git a/src/live_effects/lpe-spiro.cpp b/src/live_effects/lpe-spiro.cpp index 6994b684b..e4a0af741 100644 --- a/src/live_effects/lpe-spiro.cpp +++ b/src/live_effects/lpe-spiro.cpp @@ -99,12 +99,12 @@ LPESpiro::doEffect(SPCurve * curve) bezctx *bc = new_bezctx_ink(curve); int len = SP_CURVE_LENGTH(csrc); spiro_cp *path = g_new (spiro_cp, len + 1); - NArtBpath *bpath = csrc->get_bpath(); + NArtBpath const *bpath = csrc->get_bpath(); int ib = 0; int ip = 0; bool closed = false; NR::Point pt(0, 0); - NArtBpath *first_in_subpath = NULL; + NArtBpath const *first_in_subpath = NULL; while(ib <= len) { path [ip].x = bpath[ib].x3; path [ip].y = bpath[ib].y3; @@ -138,7 +138,7 @@ LPESpiro::doEffect(SPCurve * curve) } } else { // this point is not last, so makes sense to find a proper type for it - NArtBpath *next = NULL; + NArtBpath const *next = NULL; if (ib < len && (bpath[ib+1].code == NR_END || bpath[ib+1].code == NR_MOVETO_OPEN || bpath[ib+1].code == NR_MOVETO)) { // end of subpath if (closed) next = first_in_subpath; diff --git a/src/nodepath.cpp b/src/nodepath.cpp index d82b82f0d..c3d0f09b4 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -330,7 +330,7 @@ void sp_nodepath_ensure_livarot_path(Inkscape::NodePath::Path *np) { if (np && np->livarot_path == NULL) { SPCurve *curve = create_curve(np); - NArtBpath *bpath = SP_CURVE_BPATH(curve); + NArtBpath const *bpath = SP_CURVE_BPATH(curve); np->livarot_path = bpath_to_Path(bpath); if (np->livarot_path) diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index ffb776dfe..2584d5b49 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -321,9 +321,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const & SPCurve *curve = curve_for_item(root_item); if (curve) { NArtBpath *bpath = bpath_for_curve(root_item, curve, true, true); - _bpaths_to_snap_to->push_back(bpath); - // Because we set doTransformation to true in bpath_for_curve, we - // will get a dupe of the path, which must be freed at some point + _bpaths_to_snap_to->push_back(bpath); // we will get a dupe of the path, which must be freed at some point curve->unref(); } } @@ -376,9 +374,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc, SPCurve *curve = curve_for_item(SP_ITEM(selected_path)); if (curve) { NArtBpath *bpath = bpath_for_curve(SP_ITEM(selected_path), curve, true, true); - _bpaths_to_snap_to->push_back(bpath); - // Because we set doTransformation to true in bpath_for_curve, we - // will get a dupe of the path, which must be freed at some point + _bpaths_to_snap_to->push_back(bpath); // we will get a dupe of the path, which must be freed at some point curve->unref(); } } diff --git a/src/print.cpp b/src/print.cpp index b557298ef..b1fc6b3b2 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -52,14 +52,14 @@ sp_print_comment(SPPrintContext *ctx, char const *comment) } unsigned int -sp_print_fill(SPPrintContext *ctx, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, +sp_print_fill(SPPrintContext *ctx, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { return ctx->module->fill(bpath, ctm, style, pbox, dbox, bbox); } unsigned int -sp_print_stroke(SPPrintContext *ctx, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, +sp_print_stroke(SPPrintContext *ctx, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { return ctx->module->stroke(bpath, ctm, style, pbox, dbox, bbox); diff --git a/src/print.h b/src/print.h index dd5c1fa73..ce30b8418 100644 --- a/src/print.h +++ b/src/print.h @@ -24,9 +24,9 @@ unsigned int sp_print_bind(SPPrintContext *ctx, NR::Matrix const &transform, flo unsigned int sp_print_bind(SPPrintContext *ctx, NR::Matrix const *transform, float opacity); unsigned int sp_print_release(SPPrintContext *ctx); unsigned int sp_print_comment(SPPrintContext *ctx, char const *comment); -unsigned int sp_print_fill(SPPrintContext *ctx, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, +unsigned int sp_print_fill(SPPrintContext *ctx, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); -unsigned int sp_print_stroke(SPPrintContext *ctx, NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, +unsigned int sp_print_stroke(SPPrintContext *ctx, const_NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index d866df068..5ff01814f 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -86,7 +86,7 @@ static gchar *sp_offset_description (SPItem * item); static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p); static void sp_offset_set_shape (SPShape * shape); -Path *bpath_to_liv_path (NArtBpath * bpath); +Path *bpath_to_liv_path (NArtBpath const * bpath); static void refresh_offset_source(SPOffset* offset); @@ -444,7 +444,7 @@ sp_offset_description(SPItem *item) * livarot Path. Duplicate of splivarot. */ Path * -bpath_to_liv_path(NArtBpath *bpath) +bpath_to_liv_path(NArtBpath const *bpath) { if (bpath == NULL) return NULL; diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 86bc83e2b..14f04218f 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -157,7 +157,7 @@ sp_path_convert_to_guides(SPItem *item) SPCurve *curve = SP_SHAPE(path)->curve; if (!curve) return; - NArtBpath *bpath = SP_CURVE_BPATH(curve); + NArtBpath const *bpath = SP_CURVE_BPATH(curve); NR::Point last_pt; NR::Point pt; diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index fff9de7d3..991381bda 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -322,7 +322,7 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags) * \return 1 if a marker is required here, otherwise 0. */ bool -sp_shape_marker_required(SPShape const *shape, int const m, NArtBpath *bp) +sp_shape_marker_required(SPShape const *shape, int const m, NArtBpath const *bp) { if (shape->marker[m] == NULL) { return false; @@ -595,7 +595,7 @@ sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai) int n = 0; - for (NArtBpath *bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { + for (NArtBpath const *bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { if (sp_shape_marker_required (shape, i, bp)) { NR::Matrix const m(sp_shape_marker_get_transform(shape, bp)); sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, @@ -637,7 +637,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr if (shape->curve) { NRRect cbbox; - NRBPath bp; + const_NRBPath bp; bp.path = SP_CURVE_BPATH (shape->curve); @@ -664,7 +664,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr // Union with bboxes of the markers, if any if (sp_shape_has_markers (shape)) { - for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { + for (NArtBpath const* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { for (int m = SP_MARKER_LOC_START; m < SP_MARKER_LOC_QTY; m++) { if (sp_shape_marker_required (shape, m, bp)) { @@ -730,19 +730,19 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) SPStyle* style = SP_OBJECT_STYLE (item); - if (!style->fill.isNone()) { - NRBPath bp; - bp.path = SP_CURVE_BPATH(shape->curve); - sp_print_fill (ctx, &bp, &i2d, style, &pbox, &dbox, &bbox); - } + if (!style->fill.isNone()) { + const_NRBPath bp; + bp.path = SP_CURVE_BPATH(shape->curve); + sp_print_fill (ctx, &bp, &i2d, style, &pbox, &dbox, &bbox); + } - if (!style->stroke.isNone()) { - NRBPath bp; - bp.path = SP_CURVE_BPATH(shape->curve); - sp_print_stroke (ctx, &bp, &i2d, style, &pbox, &dbox, &bbox); - } + if (!style->stroke.isNone()) { + const_NRBPath bp; + bp.path = SP_CURVE_BPATH(shape->curve); + sp_print_stroke (ctx, &bp, &i2d, style, &pbox, &dbox, &bbox); + } - for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { + for (NArtBpath const* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { for (int m = SP_MARKER_LOC_START; m < SP_MARKER_LOC_QTY; m++) { if (sp_shape_marker_required (shape, m, bp)) { @@ -871,7 +871,7 @@ int sp_shape_number_of_markers (SPShape *shape, int type) { int n = 0; - for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { + for (NArtBpath const* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { if (sp_shape_marker_required (shape, type, bp)) { n++; } diff --git a/src/sp-shape.h b/src/sp-shape.h index cc25d2e88..d0bfc376a 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -63,6 +63,6 @@ void sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value int sp_shape_has_markers (SPShape const *shape); int sp_shape_number_of_markers (SPShape* Shape, int type); NR::Matrix sp_shape_marker_get_transform(SPShape const *shape, NArtBpath const *bp); -bool sp_shape_marker_required(SPShape const *shape, int const m, NArtBpath *bp); +bool sp_shape_marker_required(SPShape const *shape, int const m, NArtBpath const *bp); #endif diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index d543aa00f..60f2bbc92 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -174,7 +174,7 @@ sp_spiral_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) //g_warning("sp_spiral_write(): No path to copy\n"); return NULL; } - NArtBpath *bpath = SP_CURVE_BPATH(curve); + NArtBpath const *bpath = SP_CURVE_BPATH(curve); if ( !bpath ) { //g_warning("sp_spiral_write(): No path to copy\n"); return NULL; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index aec2b8f6e..382f857cf 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -826,7 +826,7 @@ sp_selected_path_outline() SPShape *shape = SP_SHAPE(item); - for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { + for (NArtBpath const* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { for (int m = SP_MARKER_LOC_START; m < SP_MARKER_LOC_QTY; m++) { if (sp_shape_marker_required (shape, m, bp)) { @@ -1729,18 +1729,15 @@ Path_for_item(SPItem *item, bool doTransformation, bool transformFull) Path *dest = bpath_to_Path(bpath); - if (doTransformation) { - g_free(bpath); // see comment in bpath_for_curve - } - + g_free(bpath); + curve->unref(); return dest; } /* - * This function is buggy: it can either return a new NArtBpath, or an existing one. - * It is therefore unclear whether the caller must g_free the path or not! + * This function always returns a new NArtBpath, the caller must g_free the returned path! */ NArtBpath * bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull) @@ -1748,22 +1745,23 @@ bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transf if (curve == NULL) return NULL; - NArtBpath *bpath = SP_CURVE_BPATH(curve); + NArtBpath const *bpath = SP_CURVE_BPATH(curve); if (bpath == NULL) { return NULL; } - + + NArtBpath *new_bpath; // we will get a duplicate which has to be freed at some point! if (doTransformation) { - NArtBpath *new_bpath; // we will get a duplicate which has to be freed at some point! if (transformFull) { new_bpath = nr_artpath_affine(bpath, sp_item_i2doc_affine(item)); } else { new_bpath = nr_artpath_affine(bpath, item->transform); } - bpath = new_bpath; + } else { + new_bpath = nr_artpath_affine(bpath, NR::identity()); } - return bpath; + return new_bpath; } SPCurve* curve_for_item(SPItem *item)