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-text.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index bae625f58..8f28ee255 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -249,7 +249,7 @@ sp_text_update (SPObject *object, SPCtx *ctx, guint flags) text->rebuildLayout(); NRRect paintbox; - sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE); + text->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView* v = text->display; v != NULL; v = v->next) { text->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); @@ -275,7 +275,7 @@ sp_text_modified (SPObject *object, guint flags) if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) { SPText *text = SP_TEXT (object); NRRect paintbox; - sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE); + text->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView* v = text->display; v != NULL; v = v->next) { text->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); @@ -387,7 +387,7 @@ sp_text_show(SPItem *item, NRArena *arena, unsigned /* key*/, unsigned /*flags*/ // pass the bbox of the text object as paintbox (used for paintserver fills) NRRect paintbox; - sp_item_invoke_bbox(item, &paintbox, Geom::identity(), TRUE); + item->invoke_bbox( &paintbox, Geom::identity(), TRUE); group->layout.show(flowed, &paintbox); return flowed; @@ -442,7 +442,7 @@ static void sp_text_snappoints(SPItem const *item, std::vectoroutputExists()) { boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * sp_item_i2d_affine(item), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); + p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); } } } @@ -483,13 +483,13 @@ sp_text_set_transform (SPItem *item, Geom::Matrix const &xform) text->_adjustFontsizeRecursive (item, ex); // Adjust stroke width - sp_item_adjust_stroke_width_recursive (item, ex); + item->adjust_stroke_width_recursive (ex); // Adjust pattern fill - sp_item_adjust_pattern(item, xform * ret.inverse()); + item->adjust_pattern(xform * ret.inverse()); // Adjust gradient fill - sp_item_adjust_gradient(item, xform * ret.inverse()); + item->adjust_gradient(xform * ret.inverse()); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); @@ -502,13 +502,13 @@ sp_text_print (SPItem *item, SPPrintContext *ctx) NRRect pbox, dbox, bbox; SPText *group = SP_TEXT (item); - sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE); - sp_item_bbox_desktop (item, &bbox); + item->invoke_bbox( &pbox, Geom::identity(), TRUE); + item->getBboxDesktop (&bbox); dbox.x0 = 0.0; dbox.y0 = 0.0; dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item)); dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item)); - Geom::Matrix const ctm (sp_item_i2d_affine(item)); + Geom::Matrix const ctm (item->i2d_affine()); group->layout.print(ctx,&pbox,&dbox,&bbox,ctm); } -- cgit v1.2.3 From 121815791be2d24cb745663520b111ee914fbc09 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Thu, 1 Jul 2010 15:36:56 +0530 Subject: C++fied SPDocument added (bzr r9546.1.2) --- src/sp-text.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 8f28ee255..46e17a75a 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -506,8 +506,8 @@ sp_text_print (SPItem *item, SPPrintContext *ctx) item->getBboxDesktop (&bbox); dbox.x0 = 0.0; dbox.y0 = 0.0; - dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item)); - dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item)); + dbox.x1 = SP_OBJECT_DOCUMENT (item)->getWidth (); + dbox.y1 = SP_OBJECT_DOCUMENT (item)->getHeight (); Geom::Matrix const ctm (item->i2d_affine()); group->layout.print(ctx,&pbox,&dbox,&bbox,ctm); -- cgit v1.2.3 From 1aad26aea24f62b63c992118f36b12483f9a5414 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Sat, 3 Jul 2010 22:50:36 +0530 Subject: another c++ification for sp-object.h/cpp and still in progress... (bzr r9546.1.4) --- src/sp-text.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 46e17a75a..7bdd84989 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -225,7 +225,7 @@ sp_text_update (SPObject *object, SPCtx *ctx, guint flags) /* Create temporary list of children */ GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { sp_object_ref (SP_OBJECT (child), object); l = g_slist_prepend (l, child); } @@ -286,7 +286,7 @@ sp_text_modified (SPObject *object, guint flags) /* Create temporary list of children */ GSList *l = NULL; SPObject *child; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { sp_object_ref (SP_OBJECT (child), object); l = g_slist_prepend (l, child); } @@ -310,7 +310,7 @@ sp_text_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML if (!repr) repr = xml_doc->createElement("svg:text"); GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; Inkscape::XML::Node *crepr = NULL; if (SP_IS_STRING(child)) { @@ -326,7 +326,7 @@ sp_text_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; if (SP_IS_STRING(child)) { SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str()); @@ -565,7 +565,7 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio child_attrs_offset--; } - for (SPObject *child = sp_object_first_child(root) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = root->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_STRING(child)) { Glib::ustring const &string = SP_STRING(child)->string; layout.appendText(string, root->style, child, &optional_attrs, child_attrs_offset + length); -- 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-text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 7bdd84989..e3e919796 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -570,7 +570,7 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio Glib::ustring const &string = SP_STRING(child)->string; layout.appendText(string, root->style, child, &optional_attrs, child_attrs_offset + length); length += string.length(); - } else if (!sp_repr_is_meta_element(child->repr)) { + } /*XML Tree being directly used here while it shouldn't be.*/ else if (!sp_repr_is_meta_element(child->getRepr())) { length += _buildLayoutInput(child, optional_attrs, child_attrs_offset + length, in_textpath); } } -- 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-text.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/sp-text.cpp') diff --git a/src/sp-text.cpp b/src/sp-text.cpp index e3e919796..dcf9160ff 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -149,16 +149,16 @@ sp_text_release (SPObject *object) static void sp_text_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "dx"); + object->readAttr( "dy"); + object->readAttr( "rotate"); if (((SPObjectClass *) text_parent_class)->build) ((SPObjectClass *) text_parent_class)->build(object, doc, repr); - sp_object_read_attr(object, "sodipodi:linespacing"); // has to happen after the styles are read + object->readAttr( "sodipodi:linespacing"); // has to happen after the styles are read } static void -- cgit v1.2.3