From 8867de5daf309e4cdd3fce177b408618490be4f3 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Tue, 29 Jun 2010 23:35:42 +0530 Subject: This is the first c++ification commit from me. It handles sp-line, sp-polyline, sp-item and marks the onset of document c++ification as well. Users can check performace increase with [/usr/bin/time -v inkscape_binary_with_commandline_options]. (bzr r9546.1.1) --- src/sp-offset.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-offset.cpp') diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 556778676..30626695e 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -510,7 +510,7 @@ sp_offset_set_shape(SPShape *shape) theRes->ConvertToForme (orig, 1, originaux); SPItem *item = shape; - Geom::OptRect bbox = sp_item_bbox_desktop (item); + Geom::OptRect bbox = item->getBboxDesktop (); if ( bbox ) { gdouble size = L2(bbox->dimensions()); gdouble const exp = item->transform.descrim(); @@ -1049,7 +1049,7 @@ sp_offset_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPOffset item->transform *= compensate; // commit the compensation - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform, &advertized_move); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform, &advertized_move); SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -- cgit v1.2.3 From 1aaf9a0ee3da28012bf43cfa61e2e5fa933edd2e Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Tue, 6 Jul 2010 12:52:32 +0530 Subject: C++ification of SPObject continued along with the onset of XML Privatisation. Users may checkout [grep -Ir XML Tree *] in the source code and all the places where the XML node/Tree is being used shall be reflected. (bzr r9546.1.5) --- src/sp-offset.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'src/sp-offset.cpp') diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 30626695e..ff915c92f 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -217,37 +217,42 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); - if (object->repr->attribute("inkscape:radius")) { + //XML Tree being used directly here while it shouldn't be. + if (object->getRepr()->attribute("inkscape:radius")) { sp_object_read_attr (object, "inkscape:radius"); } else { - gchar const *oldA = object->repr->attribute("sodipodi:radius"); - object->repr->setAttribute("inkscape:radius",oldA); - object->repr->setAttribute("sodipodi:radius",NULL); + + + //XML Tree being used directly here (as object->getRepr) + //in all the below lines in the block while it shouldn't be. + gchar const *oldA = object->getRepr()->attribute("sodipodi:radius"); + object->getRepr()->setAttribute("inkscape:radius",oldA); + object->getRepr()->setAttribute("sodipodi:radius",NULL); sp_object_read_attr (object, "inkscape:radius"); } - if (object->repr->attribute("inkscape:original")) { + if (object->getRepr()->attribute("inkscape:original")) { sp_object_read_attr (object, "inkscape:original"); } else { - gchar const *oldA = object->repr->attribute("sodipodi:original"); - object->repr->setAttribute("inkscape:original",oldA); - object->repr->setAttribute("sodipodi:original",NULL); + gchar const *oldA = object->getRepr()->attribute("sodipodi:original"); + object->getRepr()->setAttribute("inkscape:original",oldA); + object->getRepr()->setAttribute("sodipodi:original",NULL); sp_object_read_attr (object, "inkscape:original"); } - if (object->repr->attribute("xlink:href")) { + if (object->getRepr()->attribute("xlink:href")) { sp_object_read_attr(object, "xlink:href"); } else { - gchar const *oldA = object->repr->attribute("inkscape:href"); + gchar const *oldA = object->getRepr()->attribute("inkscape:href"); if (oldA) { size_t lA = strlen(oldA); char *nA=(char*)malloc((1+lA+1)*sizeof(char)); memcpy(nA+1,oldA,lA*sizeof(char)); nA[0]='#'; nA[lA+1]=0; - object->repr->setAttribute("xlink:href",nA); + object->getRepr()->setAttribute("xlink:href",nA); free(nA); - object->repr->setAttribute("inkscape:href",NULL); + object->getRepr()->setAttribute("inkscape:href",NULL); } sp_object_read_attr (object, "xlink:href"); } @@ -454,7 +459,8 @@ sp_offset_set_shape(SPShape *shape) // just put the source shape as the offseted one, no one will notice // it's also useless to compute the offset with a 0 radius - const char *res_d = SP_OBJECT(shape)->repr->attribute("inkscape:original"); + //XML Tree being used directly here while it shouldn't be. + const char *res_d = SP_OBJECT(shape)->getRepr()->attribute("inkscape:original"); if ( res_d ) { Geom::PathVector pv = sp_svg_read_pathv(res_d); SPCurve *c = new SPCurve(pv); @@ -1145,7 +1151,8 @@ refresh_offset_source(SPOffset* offset) delete res; delete orig; - SP_OBJECT (offset)->repr->setAttribute("inkscape:original", res_d); + //XML Tree being used diectly here while it shouldn't be. + SP_OBJECT (offset)->getRepr()->setAttribute("inkscape:original", res_d); free (res_d); } -- cgit v1.2.3 From 6cc35b45eab6422a6b6f67d621aa259a0a73786f Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Mon, 12 Jul 2010 22:06:46 +0530 Subject: SPObject c++ification finalized along with the beginning of XML Privatisation tweaks (bzr r9546.1.6) --- src/sp-offset.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/sp-offset.cpp') diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index ff915c92f..fdff5d7b6 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -219,7 +219,7 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep //XML Tree being used directly here while it shouldn't be. if (object->getRepr()->attribute("inkscape:radius")) { - sp_object_read_attr (object, "inkscape:radius"); + object->readAttr( "inkscape:radius"); } else { @@ -229,19 +229,19 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep object->getRepr()->setAttribute("inkscape:radius",oldA); object->getRepr()->setAttribute("sodipodi:radius",NULL); - sp_object_read_attr (object, "inkscape:radius"); + object->readAttr( "inkscape:radius"); } if (object->getRepr()->attribute("inkscape:original")) { - sp_object_read_attr (object, "inkscape:original"); + object->readAttr( "inkscape:original"); } else { gchar const *oldA = object->getRepr()->attribute("sodipodi:original"); object->getRepr()->setAttribute("inkscape:original",oldA); object->getRepr()->setAttribute("sodipodi:original",NULL); - sp_object_read_attr (object, "inkscape:original"); + object->readAttr( "inkscape:original"); } if (object->getRepr()->attribute("xlink:href")) { - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "xlink:href"); } else { gchar const *oldA = object->getRepr()->attribute("inkscape:href"); if (oldA) { @@ -254,7 +254,7 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep free(nA); object->getRepr()->setAttribute("inkscape:href",NULL); } - sp_object_read_attr (object, "xlink:href"); + object->readAttr( "xlink:href"); } } -- cgit v1.2.3 From cde0571b44ec5b108907bda85971c49f3ceb1de8 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Wed, 14 Jul 2010 23:40:35 +0530 Subject: SPShape c++ified to the extent it was possible and more changes done for XML privatisation. Major changes yet to come. (bzr r9546.1.7) --- src/sp-offset.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/sp-offset.cpp') diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index fdff5d7b6..449d7d44d 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -283,7 +283,7 @@ sp_offset_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM // Make sure the object has curve - SPCurve *curve = sp_shape_get_curve (SP_SHAPE (offset)); + SPCurve *curve = SP_SHAPE (offset)->getCurve(); if (curve == NULL) { sp_offset_set_shape (SP_SHAPE (offset)); } @@ -410,7 +410,7 @@ sp_offset_update(SPObject *object, SPCtx *ctx, guint flags) if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - sp_shape_set_shape ((SPShape *) object); + ((SPShape *) object)->setShape (); } offset->isUpdating=false; @@ -465,7 +465,7 @@ sp_offset_set_shape(SPShape *shape) Geom::PathVector pv = sp_svg_read_pathv(res_d); SPCurve *c = new SPCurve(pv); g_assert(c != NULL); - sp_shape_set_curve_insync ((SPShape *) offset, c, TRUE); + ((SPShape *) offset)->setCurveInsync (c, TRUE); c->unref(); } return; @@ -714,7 +714,7 @@ sp_offset_set_shape(SPShape *shape) Geom::PathVector pv = sp_svg_read_pathv(res_d); SPCurve *c = new SPCurve(pv); g_assert(c != NULL); - sp_shape_set_curve_insync ((SPShape *) offset, c, TRUE); + ((SPShape *) offset)->setCurveInsync (c, TRUE); c->unref(); free (res_d); @@ -954,11 +954,11 @@ sp_offset_top_point (SPOffset * offset, Geom::Point *px) return; } - SPCurve *curve = sp_shape_get_curve (SP_SHAPE (offset)); + SPCurve *curve = SP_SHAPE (offset)->getCurve(); if (curve == NULL) { sp_offset_set_shape (SP_SHAPE (offset)); - curve = sp_shape_get_curve (SP_SHAPE (offset)); + curve = SP_SHAPE (offset)->getCurve(); if (curve == NULL) return; } @@ -1082,7 +1082,7 @@ sp_offset_source_modified (SPObject */*iSource*/, guint /*flags*/, SPItem *item) SPOffset *offset = SP_OFFSET(item); offset->sourceDirty=true; refresh_offset_source(offset); - sp_shape_set_shape ((SPShape *) offset); + ((SPShape *) offset)->setShape (); } static void @@ -1100,7 +1100,7 @@ refresh_offset_source(SPOffset* offset) SPCurve *curve=NULL; if (!SP_IS_SHAPE (item) && !SP_IS_TEXT (item)) return; if (SP_IS_SHAPE (item)) { - curve = sp_shape_get_curve (SP_SHAPE (item)); + curve = SP_SHAPE (item)->getCurve (); if (curve == NULL) return; } -- cgit v1.2.3