diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-06-23 21:06:21 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-06-23 21:06:21 +0000 |
| commit | 12fc4174d3f7e277984e04a3e9221713bb5f8cff (patch) | |
| tree | 94c3c25eccb4d009c363e9e022824171c1cf2d88 /src | |
| parent | add #include <string.h> for portability (diff) | |
| download | inkscape-12fc4174d3f7e277984e04a3e9221713bb5f8cff.tar.gz inkscape-12fc4174d3f7e277984e04a3e9221713bb5f8cff.zip | |
convert optimizing check into 2geom terms. hopefully correct, please review if you have time
(bzr r6030)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/nr-arena-shape.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index b87c93a0c..40e55255f 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -26,6 +26,7 @@ #include <libnr/nr-blit.h> #include <libnr/nr-convert2geom.h> #include <2geom/pathvector.h> +#include <2geom/curves.h> #include <livarot/Path.h> #include <livarot/float-line.h> #include <livarot/int-line.h> @@ -36,7 +37,7 @@ #include "sp-filter.h" #include "sp-filter-reference.h" #include "display/nr-filter.h" - +#include <typeinfo> #include <cairo.h> //int showRuns=0; @@ -417,12 +418,35 @@ static bool is_inner_area(NRRectL const &outer, NRRectL const &inner) { return (outer.x0 <= inner.x0 && outer.y0 <= inner.y0 && outer.x1 >= inner.x1 && outer.y1 >= inner.y1); } +/* returns true if the pathvector has a region that needs fill. + * is for optimizing purposes, so should be fast and can falsely return true. + * CANNOT falsely return false. +static bool has_inner_area(Geom::PathVector const & pv) { + // return false for the cases where there is surely no region to be filled + if (pv.empty()) + return false; + + if ( (pv.size() == 1) && (pv.front().size() <= 1) ) { + // vector has only one path with only one segment, see if that's a non-curve segment: that would mean no internal region + Geom::Curve const & c = pv.front().front(); + if ( typeid(c) == typeid(Geom::LineSegment) ) + return false; + if ( typeid(c) == typeid(Geom::HLineSegment) ) + return false; + if ( typeid(c) == typeid(Geom::VLineSegment) ) + return false; + } + + return true; //too costly to see if it has region to be filled, so return true. +} + /** force_shape is used for clipping paths, when we need the shape for clipping even if it's not filled */ void nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool force_shape) { if ((shape->_fill.paint.type() != NRArenaShape::Paint::NONE || force_shape) && - ((shape->curve->get_length() > 2) || (SP_CURVE_BPATH(shape->curve)[1].code == NR_CURVETO)) ) { +// ((shape->curve->get_length() > 2) || (SP_CURVE_BPATH(shape->curve)[1].code == NR_CURVETO)) ) { // <-- this used to be the old code, i think it has to determine that the path has a sort of 'internal region' where fill would occur + has_inner_area(shape->curve->get_pathvector()) ) { if (TRUE || !shape->fill_shp) { NR::Matrix cached_to_new = NR::identity(); int isometry = 0; |
