summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fdc44da)
raw | patch | inline | side by side (parent: fdc44da)
author | mental <mental@users.sourceforge.net> | |
Tue, 9 May 2006 04:12:54 +0000 (04:12 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Tue, 9 May 2006 04:12:54 +0000 (04:12 +0000) |
ChangeLog | patch | blob | history | |
src/display/curve.cpp | patch | blob | history | |
src/display/curve.h | patch | blob | history | |
src/dropper-context.cpp | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index fc04c8467101f20329433d741bdaf874fc659aa9..a23a46842541f7bc8000fd037815fc028fe50007 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-05-08 MenTaLguY <mental@rydia.net>
+
+ * src/display/curve.h, src/display/curve.cpp, src/dropper-context.cpp:
+
+ get rid of sp_curve_new_from_static_bpath() in a bid to simplify curve
+ memory management
+
2006-05-08 MenTaLguY <mental@rydia.net>
* src/display/canvas-bpath.cpp, src/display/curve.cpp, src/display/curve.h,
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 3ea4e60dfd7756fa51b65a2256805a21d906d952..aa899b902b64d161ee3585bfafcafa3f66345086 100644 (file)
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
curve->end = 0;
curve->length = length;
curve->substart = 0;
- curve->sbpath = false;
curve->hascpt = false;
curve->posSet = false;
curve->moving = false;
(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;
curve->refcount -= 1;
if (curve->refcount < 1) {
- if ((!curve->sbpath) && (curve->_bpath)) {
+ if (curve->_bpath) {
nr_free(curve->_bpath);
}
g_free(curve);
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;
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;
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;
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) {
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) {
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);
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);
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 07d951b6330022ddccfd3ee732fdfbe3d7db4fbe..5be8f5a4e48497157556b898acfc9489cca97e34 100644 (file)
--- a/src/display/curve.h
+++ b/src/display/curve.h
/// (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.
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);
index 148cceda47b0bef2a0b4a93b0a4aa87d07d1ef3c..0e621c32551f8ace68d14091411903c09148dc9e 100644 (file)
--- a/src/dropper-context.cpp
+++ b/src/dropper-context.cpp
((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);