diff options
| author | MenTaLguY <mental@rydia.net> | 2006-05-09 04:12:54 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2006-05-09 04:12:54 +0000 |
| commit | 7177726d1c73b908351360b301f5d84cabb0c271 (patch) | |
| tree | 9faa736c1bca09dd0db63b615b8ad4696006e162 /src | |
| parent | eliminate direct accesses to SPCurve::bpath (diff) | |
| download | inkscape-7177726d1c73b908351360b301f5d84cabb0c271.tar.gz inkscape-7177726d1c73b908351360b301f5d84cabb0c271.zip | |
get rid of sp_curve_new_from_static_bpath() in a bid to simplify curve memory management
(bzr r788)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/curve.cpp | 54 | ||||
| -rw-r--r-- | src/display/curve.h | 6 | ||||
| -rw-r--r-- | src/dropper-context.cpp | 2 |
3 files changed, 2 insertions, 60 deletions
diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 3ea4e60df..aa899b902 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -61,7 +61,6 @@ sp_curve_new_sized(gint length) curve->end = 0; curve->length = length; curve->substart = 0; - curve->sbpath = false; curve->hascpt = false; curve->posSet = false; curve->moving = false; @@ -101,49 +100,6 @@ sp_curve_new_from_bpath(NArtBpath *bpath) (curve->_bpath[i].code == NR_MOVETO_OPEN)) break; curve->substart = i; - curve->sbpath = false; - curve->hascpt = false; - curve->posSet = false; - curve->moving = false; - curve->closed = sp_bpath_closed(bpath); - - return curve; -} - -/** - * Construct an SPCurve from read-only, static storage. - * - * We could treat read-onliness and staticness (i.e. can't call free on bpath) as orthogonal - * attributes, but at the time of writing we have only one caller. - */ -SPCurve * -sp_curve_new_from_static_bpath(NArtBpath const *bpath) -{ - g_return_val_if_fail(bpath != NULL, NULL); - - bool sbpath; - if (!sp_bpath_good(bpath)) { - NArtBpath *new_bpath = sp_bpath_clean(bpath); - g_return_val_if_fail(new_bpath != NULL, NULL); - sbpath = false; - bpath = new_bpath; - } else { - sbpath = true; - } - - SPCurve *curve = g_new(SPCurve, 1); - - curve->refcount = 1; - curve->_bpath = const_cast<NArtBpath *>(bpath); - curve->length = sp_bpath_length(bpath); - curve->end = curve->length - 1; - gint i = curve->end; - for (; i > 0; i--) - if ((curve->_bpath[i].code == NR_MOVETO) || - (curve->_bpath[i].code == NR_MOVETO_OPEN)) - break; - curve->substart = i; - curve->sbpath = sbpath; curve->hascpt = false; curve->posSet = false; curve->moving = false; @@ -207,7 +163,7 @@ sp_curve_unref(SPCurve *curve) curve->refcount -= 1; if (curve->refcount < 1) { - if ((!curve->sbpath) && (curve->_bpath)) { + if (curve->_bpath) { nr_free(curve->_bpath); } g_free(curve); @@ -330,7 +286,6 @@ static void tmpl_curve_transform(SPCurve *const curve, M const &m) { g_return_if_fail(curve != NULL); - g_return_if_fail(!curve->sbpath); for (gint i = 0; i < curve->end; i++) { NArtBpath *p = curve->_bpath + i; @@ -381,7 +336,6 @@ void sp_curve_reset(SPCurve *curve) { g_return_if_fail(curve != NULL); - g_return_if_fail(!curve->sbpath); curve->_bpath->code = NR_END; curve->end = 0; @@ -410,7 +364,6 @@ void sp_curve_moveto(SPCurve *curve, NR::Point const &p) { g_return_if_fail(curve != NULL); - g_return_if_fail(!curve->sbpath); g_return_if_fail(!curve->moving); curve->substart = curve->end; @@ -435,7 +388,6 @@ void sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y) { g_return_if_fail(curve != NULL); - g_return_if_fail(!curve->sbpath); g_return_if_fail(curve->hascpt); if (curve->moving) { @@ -486,7 +438,6 @@ void sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y) { g_return_if_fail(curve != NULL); - g_return_if_fail(!curve->sbpath); g_return_if_fail(curve->hascpt); if (curve->moving) { @@ -554,7 +505,6 @@ void sp_curve_curveto(SPCurve *curve, gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2) { g_return_if_fail(curve != NULL); - g_return_if_fail(!curve->sbpath); g_return_if_fail(curve->hascpt); g_return_if_fail(!curve->moving); @@ -604,7 +554,6 @@ void sp_curve_closepath(SPCurve *curve) { g_return_if_fail(curve != NULL); - g_return_if_fail(!curve->sbpath); g_return_if_fail(curve->hascpt); g_return_if_fail(!curve->posSet); g_return_if_fail(!curve->moving); @@ -648,7 +597,6 @@ void sp_curve_closepath_current(SPCurve *curve) { g_return_if_fail(curve != NULL); - g_return_if_fail(!curve->sbpath); g_return_if_fail(curve->hascpt); g_return_if_fail(!curve->posSet); g_return_if_fail(!curve->closed); diff --git a/src/display/curve.h b/src/display/curve.h index 07d951b63..5be8f5a4e 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -45,11 +45,6 @@ struct SPCurve { /// (first subitem of the item about zero-length path segments) NR::Point movePos; - /// True iff bpath points to read-only, static storage (see callers of - /// sp_curve_new_from_static_bpath), in which case we shouldn't free - /// bpath and shouldn't write through it. - bool sbpath : 1; - /// True iff current point is defined. Initially false for a new curve; /// becomes true after moveto; becomes false on closepath. Curveto, /// lineto etc. require hascpt; hascpt remains true after lineto/curveto. @@ -74,7 +69,6 @@ struct SPCurve { SPCurve *sp_curve_new(); SPCurve *sp_curve_new_sized(gint length); SPCurve *sp_curve_new_from_bpath(NArtBpath *bpath); -SPCurve *sp_curve_new_from_static_bpath(NArtBpath const *bpath); SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[]); SPCurve *sp_curve_ref(SPCurve *curve); diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 148cceda4..0e621c325 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -111,7 +111,7 @@ static void sp_dropper_context_setup(SPEventContext *ec) ((SPEventContextClass *) parent_class)->setup(ec); } - SPCurve *c = sp_curve_new_from_static_bpath(spdc_circle); + SPCurve *c = sp_curve_new_from_foreign_bpath(spdc_circle); dc->area = sp_canvas_bpath_new(sp_desktop_controls(ec->desktop), c); sp_curve_unref(c); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(dc->area), 0x00000000,(SPWindRule)0); |
