diff options
| author | Alvin Penner <penner@vaxxine.com> | 2012-02-23 23:20:44 +0000 |
|---|---|---|
| committer | apenner <penner@vaxxine.com> | 2012-02-23 23:20:44 +0000 |
| commit | b7e5111e685e4bf9b75c5823708fdf79fc0c307b (patch) | |
| tree | 88d51acf92f0c85d0b87ae9569b2b833707defb6 | |
| parent | cppcheck: null pointer dereference fix (diff) | |
| download | inkscape-b7e5111e685e4bf9b75c5823708fdf79fc0c307b.tar.gz inkscape-b7e5111e685e4bf9b75c5823708fdf79fc0c307b.zip | |
avoid some Shape calculations that are not relevant to visual bbox (Bug 906952)
Fixed bugs:
- https://launchpad.net/bugs/906952
(bzr r11010)
| -rw-r--r-- | src/sp-shape.cpp | 2 | ||||
| -rw-r--r-- | src/splivarot.cpp | 48 | ||||
| -rw-r--r-- | src/splivarot.h | 2 |
3 files changed, 24 insertions, 28 deletions
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index ad2bea77d..f27b3c9db 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -515,7 +515,7 @@ Geom::OptRect SPShape::sp_shape_bbox(SPItem const *item, Geom::Affine const &tra // convert the stroke to a path and calculate that path's geometric bbox SPStyle* style = item->style; if (!style->stroke.isNone()) { - Geom::PathVector *pathv = item_outline(item, false); // disable Path::Coalesce + Geom::PathVector *pathv = item_outline(item, true); // calculate bbox_only if (pathv) { bbox |= bounds_exact_transformed(*pathv, transform); delete pathv; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 8b06e8ae4..4c1421684 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -678,7 +678,7 @@ void item_outline_add_marker( SPObject const *marker_object, Geom::Affine marker * Returns a pathvector that is the outline of the stroked item, with markers. * item must be SPShape or SPText. */ -Geom::PathVector* item_outline(SPItem const *item, bool coalesce) +Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) { Geom::PathVector *ret_pathv = NULL; @@ -768,40 +768,36 @@ Geom::PathVector* item_outline(SPItem const *item, bool coalesce) 0.5 * o_miter); orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); - Shape *theRes = new Shape; - - theRes->ConvertToShape(theShape, fill_positive); - - Path *originaux[1]; - originaux[0] = res; - theRes->ConvertToForme(orig, 1, originaux); + if (!bbox_only) { + Shape *theRes = new Shape; + theRes->ConvertToShape(theShape, fill_positive); - if (coalesce) { + Path *originaux[1]; + originaux[0] = res; + theRes->ConvertToForme(orig, 1, originaux); res->Coalesce(5.0); + delete theRes; } - delete theShape; - delete theRes; } else { orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); - if (coalesce) { + if (!bbox_only) { orig->Coalesce(0.5 * o_width); - } - - Shape *theShape = new Shape; - Shape *theRes = new Shape; + Shape *theShape = new Shape; + Shape *theRes = new Shape; - res->ConvertWithBackData(1.0); - res->Fill(theShape, 0); - theRes->ConvertToShape(theShape, fill_positive); + res->ConvertWithBackData(1.0); + res->Fill(theShape, 0); + theRes->ConvertToShape(theShape, fill_positive); - Path *originaux[1]; - originaux[0] = res; - theRes->ConvertToForme(orig, 1, originaux); + Path *originaux[1]; + originaux[0] = res; + theRes->ConvertToForme(orig, 1, originaux); - delete theShape; - delete theRes; + delete theShape; + delete theRes; + } } if (orig->descr_cmd.size() <= 1) { @@ -814,9 +810,9 @@ Geom::PathVector* item_outline(SPItem const *item, bool coalesce) if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether - ret_pathv = orig->MakePathVector(); + ret_pathv = bbox_only ? res->MakePathVector() : orig->MakePathVector(); - if (SP_IS_SHAPE(item) && SP_SHAPE(item)->hasMarkers ()) { + if (SP_IS_SHAPE(item) && SP_SHAPE(item)->hasMarkers() && !bbox_only) { SPShape *shape = SP_SHAPE(item); Geom::PathVector const & pathv = curve->get_pathvector(); diff --git a/src/splivarot.h b/src/splivarot.h index 079139775..3d2a1ee58 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -43,7 +43,7 @@ void sp_selected_path_create_updating_offset_object_zero (SPDesktop *desktop); // outline of a curve // uses the stroke-width void sp_selected_path_outline (SPDesktop *desktop); -Geom::PathVector* item_outline(SPItem const *item, bool coalesce = true); +Geom::PathVector* item_outline(SPItem const *item, bool bbox_only = false); // simplifies a path (removes small segments and the like) void sp_selected_path_simplify (SPDesktop *desktop); |
