diff options
| author | Ted Gould <ted@gould.cx> | 2008-11-21 05:24:08 +0000 |
|---|---|---|
| committer | Ted Gould <ted@canonical.com> | 2008-11-21 05:24:08 +0000 |
| commit | 44a3a78fb6a3863c0c7f3c1193837337e68a67e4 (patch) | |
| tree | 1722ee5ec6f88c881cd4124923354b3c1311501b /src/display | |
| parent | Merge from trunk (diff) | |
| download | inkscape-44a3a78fb6a3863c0c7f3c1193837337e68a67e4.tar.gz inkscape-44a3a78fb6a3863c0c7f3c1193837337e68a67e4.zip | |
Merge from fe-moved
(bzr r6891)
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/canvas-bpath.cpp | 20 | ||||
| -rw-r--r-- | src/display/inkscape-cairo.cpp | 8 | ||||
| -rw-r--r-- | src/display/inkscape-cairo.h | 2 | ||||
| -rw-r--r-- | src/display/nr-arena-group.cpp | 2 | ||||
| -rw-r--r-- | src/display/nr-arena-image.cpp | 2 | ||||
| -rw-r--r-- | src/display/nr-arena-item.cpp | 8 | ||||
| -rw-r--r-- | src/display/nr-arena-item.h | 4 | ||||
| -rw-r--r-- | src/display/nr-arena-shape.cpp | 82 | ||||
| -rw-r--r-- | src/display/nr-filter-composite.cpp | 2 | ||||
| -rw-r--r-- | src/display/nr-filter-composite.h | 2 | ||||
| -rw-r--r-- | src/display/nr-filter-diffuselighting.h | 6 | ||||
| -rw-r--r-- | src/display/nr-filter-displacement-map.h | 2 | ||||
| -rw-r--r-- | src/display/nr-filter-image.cpp | 2 | ||||
| -rw-r--r-- | src/display/nr-filter-merge.cpp | 2 | ||||
| -rw-r--r-- | src/display/nr-filter-merge.h | 2 | ||||
| -rw-r--r-- | src/display/nr-filter-specularlighting.h | 6 | ||||
| -rw-r--r-- | src/display/nr-filter-units.h | 1 | ||||
| -rw-r--r-- | src/display/nr-filter.cpp | 2 | ||||
| -rw-r--r-- | src/display/nr-light.cpp | 6 | ||||
| -rw-r--r-- | src/display/nr-svgfonts.cpp | 2 | ||||
| -rw-r--r-- | src/display/snap-indicator.cpp | 9 | ||||
| -rw-r--r-- | src/display/sodipodi-ctrl.cpp | 16 | ||||
| -rw-r--r-- | src/display/sp-canvas.cpp | 91 |
23 files changed, 157 insertions, 122 deletions
diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 1900ed961..357d67359 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -143,13 +143,19 @@ sp_canvas_bpath_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned cbp->affine = affine; - Geom::Rect bbox = bounds_exact_transformed(cbp->curve->get_pathvector(), affine); - - item->x1 = (int)bbox.min()[Geom::X] - 1; - item->y1 = (int)bbox.min()[Geom::Y] - 1; - item->x2 = (int)bbox.max()[Geom::X] + 1; - item->y2 = (int)bbox.max()[Geom::Y] + 1; - + Geom::OptRect bbox = bounds_exact_transformed(cbp->curve->get_pathvector(), affine); + + if (bbox) { + item->x1 = (int)bbox->min()[Geom::X] - 1; + item->y1 = (int)bbox->min()[Geom::Y] - 1; + item->x2 = (int)bbox->max()[Geom::X] + 1; + item->y2 = (int)bbox->max()[Geom::Y] + 1; + } else { + item->x1 = 0; + item->y1 = 0; + item->x2 = 0; + item->y2 = 0; + } sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); } diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp index 54f979f37..a31a9387f 100644 --- a/src/display/inkscape-cairo.cpp +++ b/src/display/inkscape-cairo.cpp @@ -170,9 +170,9 @@ feed_path_to_cairo (cairo_t *ct, Geom::Path const &path) /** Feeds path-creating calls to the cairo context translating them from the Path, with the given transform and shift */ static void -feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, boost::optional<Geom::Rect> area, bool optimize_stroke, double stroke_width) +feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width) { - if (!area || area->isEmpty()) + if (!area) return; if (path.empty()) return; @@ -214,9 +214,9 @@ feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, boo /** Feeds path-creating calls to the cairo context translating them from the PathVector, with the given transform and shift * One must have done cairo_new_path(ct); before calling this function. */ void -feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, boost::optional<Geom::Rect> area, bool optimize_stroke, double stroke_width) +feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width) { - if (!area || area->isEmpty()) + if (!area) return; if (pathv.empty()) return; diff --git a/src/display/inkscape-cairo.h b/src/display/inkscape-cairo.h index 4a9c15ae3..cb4d474a6 100644 --- a/src/display/inkscape-cairo.h +++ b/src/display/inkscape-cairo.h @@ -21,7 +21,7 @@ class SPCanvasBuf; cairo_t *nr_create_cairo_context_canvasbuf (NRRectL *area, SPCanvasBuf *b); cairo_t *nr_create_cairo_context (NRRectL *area, NRPixBlock *pb); -void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, boost::optional<Geom::Rect> area, bool optimize_stroke, double stroke_width); +void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv, Geom::Matrix trans, Geom::OptRect area, bool optimize_stroke, double stroke_width); void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv); #endif diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 8b388aa40..d63d9b704 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -20,7 +20,7 @@ #include "sp-filter.h" #include "sp-filter-reference.h" #include "sp-gaussian-blur.h" -#include "sp-feblend.h" +#include "filters/blend.h" #include "display/nr-filter-blend.h" #include "libnr/nr-matrix-fns.h" #include "libnr/nr-matrix-ops.h" diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 17c9ab07c..3778dc642 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -24,7 +24,7 @@ #include "sp-filter.h" #include "sp-filter-reference.h" #include "sp-gaussian-blur.h" -#include "sp-feblend.h" +#include "filters/blend.h" #include "display/nr-filter-blend.h" int nr_arena_image_x_sample = 1; diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index d944b4228..b4fada749 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -255,9 +255,7 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, item->ctm = childgc.transform; /* Invoke the real method */ - item->state = - NR_ARENA_ITEM_VIRTUAL (item, update) (item, area, &childgc, state, - reset); + item->state = NR_ARENA_ITEM_VIRTUAL (item, update) (item, area, &childgc, state, reset); if (item->state & NR_ARENA_ITEM_STATE_INVALID) return item->state; /* Enlarge the bounding box to contain filter effects */ @@ -838,12 +836,12 @@ nr_arena_item_set_order (NRArenaItem *item, int order) } void -nr_arena_item_set_item_bbox (NRArenaItem *item, boost::optional<Geom::Rect> &bbox) +nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect &bbox) { nr_return_if_fail(item != NULL); nr_return_if_fail(NR_IS_ARENA_ITEM(item)); - if(bbox) item->item_bbox = *bbox; + item->item_bbox = bbox; } /** Returns a background image for use with filter effects. */ diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 9db8d7a40..23dd92a43 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -92,7 +92,7 @@ struct NRArenaItem : public NRObject { NRRectL bbox; /* BBox in item coordinates - this should be a bounding box as * specified in SVG standard. Required by filters. */ - boost::optional<Geom::Rect> item_bbox; + Geom::OptRect item_bbox; /* Our affine */ Geom::Matrix *transform; /* Clip item */ @@ -178,7 +178,7 @@ void nr_arena_item_set_visible (NRArenaItem *item, unsigned int visible); void nr_arena_item_set_clip (NRArenaItem *item, NRArenaItem *clip); void nr_arena_item_set_mask (NRArenaItem *item, NRArenaItem *mask); void nr_arena_item_set_order (NRArenaItem *item, int order); -void nr_arena_item_set_item_bbox (NRArenaItem *item, boost::optional<Geom::Rect> &bbox); +void nr_arena_item_set_item_bbox (NRArenaItem *item, Geom::OptRect &bbox); NRPixBlock *nr_arena_item_get_background (NRArenaItem const *item, int depth = 0); diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 4c988be46..e47907826 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -229,7 +229,7 @@ nr_arena_shape_set_child_position(NRArenaItem *item, NRArenaItem *child, NRArena void nr_arena_shape_update_stroke(NRArenaShape *shape, NRGC* gc, NRRectL *area); void nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool force_shape = false); -void nr_arena_shape_add_bboxes(NRArenaShape* shape, Geom::Rect &bbox); +void nr_arena_shape_add_bboxes(NRArenaShape* shape, Geom::OptRect &bbox); /** * Updates the arena shape 'item' and all of its children, including the markers. @@ -237,7 +237,7 @@ void nr_arena_shape_add_bboxes(NRArenaShape* shape, Geom::Rect &bbox); static guint nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset) { - Geom::Rect boundingbox; + Geom::OptRect boundingbox; NRArenaShape *shape = NR_ARENA_SHAPE(item); @@ -255,10 +255,15 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if (state & NR_ARENA_ITEM_STATE_BBOX) { if (shape->curve) { boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); - item->bbox.x0 = (gint32)(boundingbox[0][0] - 1.0F); - item->bbox.y0 = (gint32)(boundingbox[1][0] - 1.0F); - item->bbox.x1 = (gint32)(boundingbox[0][1] + 1.9999F); - item->bbox.y1 = (gint32)(boundingbox[1][1] + 1.9999F); + /// \todo just write item->bbox = boundingbox + if (boundingbox) { + item->bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F); + item->bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F); + item->bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.9999F); + item->bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.9999F); + } else { + item->bbox = NR_RECT_L_EMPTY; + } } if (beststate & NR_ARENA_ITEM_STATE_BBOX) { for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) { @@ -271,43 +276,44 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g shape->delayed_shp=true; shape->ctm = gc->transform; - boundingbox[0][0] = boundingbox[1][0] = NR_HUGE; - boundingbox[0][1] = boundingbox[1][1] = -NR_HUGE; + boundingbox = Geom::OptRect(); bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); if (shape->curve) { boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform); - if (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE || outline) { + if (boundingbox && (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE || outline)) { float width, scale; scale = gc->transform.descrim(); width = MAX(0.125, shape->_stroke.width * scale); if ( fabs(shape->_stroke.width * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord - boundingbox.expandBy(width); + boundingbox->expandBy(width); } // those pesky miters, now float miterMax=width*shape->_stroke.mitre_limit; if ( miterMax > 0.01 ) { // grunt mode. we should compute the various miters instead (one for each point on the curve) - boundingbox.expandBy(miterMax); + boundingbox->expandBy(miterMax); } } + } + + /// \todo just write item->bbox = boundingbox + if (boundingbox) { + shape->approx_bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F); + shape->approx_bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F); + shape->approx_bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.9999F); + shape->approx_bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.9999F); } else { + shape->approx_bbox = NR_RECT_L_EMPTY; } - shape->approx_bbox.x0 = (gint32)(boundingbox[0][0] - 1.0F); - shape->approx_bbox.y0 = (gint32)(boundingbox[1][0] - 1.0F); - shape->approx_bbox.x1 = (gint32)(boundingbox[0][1] + 1.9999F); - shape->approx_bbox.y1 = (gint32)(boundingbox[1][1] + 1.9999F); if ( area && nr_rect_l_test_intersect_ptr(area, &shape->approx_bbox) ) shape->delayed_shp=false; /* Release state data */ - if (TRUE || !Geom::transform_equalp(gc->transform, shape->ctm, NR_EPSILON)) { - /* Concept test */ - if (shape->fill_shp) { - delete shape->fill_shp; - shape->fill_shp = NULL; - } + if (shape->fill_shp) { + delete shape->fill_shp; + shape->fill_shp = NULL; } if (shape->stroke_shp) { delete shape->stroke_shp; @@ -339,22 +345,28 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g nr_arena_shape_update_stroke(shape, gc, area); nr_arena_shape_update_fill(shape, gc, area); - boundingbox[0][0] = boundingbox[0][1] = boundingbox[1][0] = boundingbox[1][1] = 0.0; + boundingbox = Geom::OptRect(); nr_arena_shape_add_bboxes(shape, boundingbox); - shape->approx_bbox.x0 = (gint32)(boundingbox[0][0] - 1.0F); - shape->approx_bbox.y0 = (gint32)(boundingbox[1][0] - 1.0F); - shape->approx_bbox.x1 = (gint32)(boundingbox[0][1] + 1.9999F); - shape->approx_bbox.y1 = (gint32)(boundingbox[1][1] + 1.9999F); + /// \todo just write shape->approx_bbox = boundingbox + if (boundingbox) { + shape->approx_bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F); + shape->approx_bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F); + shape->approx_bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.9999F); + shape->approx_bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.9999F); + } else { + shape->approx_bbox = NR_RECT_L_EMPTY; + } } - if (boundingbox.isEmpty()) + if (!boundingbox) return NR_ARENA_ITEM_STATE_ALL; - item->bbox.x0 = (gint32)(boundingbox[0][0] - 1.0F); - item->bbox.y0 = (gint32)(boundingbox[1][0] - 1.0F); - item->bbox.x1 = (gint32)(boundingbox[0][1] + 1.0F); - item->bbox.y1 = (gint32)(boundingbox[1][1] + 1.0F); + /// \todo just write item->bbox = boundingbox + item->bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F); + item->bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F); + item->bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.0F); + item->bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.0F); nr_arena_request_render_rect(item->arena, &item->bbox); item->render_opacity = TRUE; @@ -442,9 +454,8 @@ 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)) ) { // <-- 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) { + Geom::Matrix cached_to_new = Geom::identity(); int isometry = 0; if ( shape->cached_fill ) { @@ -522,7 +533,6 @@ nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool fo shape->fill_shp->needEdgesSorting(); } shape->delayed_shp |= shape->cached_fpartialy; - } } } @@ -683,7 +693,7 @@ nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc, NRRectL *area) void -nr_arena_shape_add_bboxes(NRArenaShape* shape, Geom::Rect &bbox) +nr_arena_shape_add_bboxes(NRArenaShape* shape, Geom::OptRect &bbox) { /* TODO: are these two if's mutually exclusive? ( i.e. "shape->stroke_shp <=> !shape->fill_shp" ) * if so, then this can be written much more compact ! */ @@ -715,7 +725,7 @@ nr_arena_shape_add_bboxes(NRArenaShape* shape, Geom::Rect &bbox) // cairo outline rendering: static unsigned int -cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, boost::optional<Geom::Rect> area) +cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, Geom::OptRect area) { NRArenaShape *shape = NR_ARENA_SHAPE(item); diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index a1a488674..32fa3e2a5 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -12,7 +12,7 @@ #include <cmath> #include "2geom/isnan.h" -#include "sp-fecomposite.h" +#include "filters/composite.h" #include "display/nr-filter-composite.h" #include "display/nr-filter-pixops.h" #include "display/nr-filter-slot.h" diff --git a/src/display/nr-filter-composite.h b/src/display/nr-filter-composite.h index e41dd77db..72331f767 100644 --- a/src/display/nr-filter-composite.h +++ b/src/display/nr-filter-composite.h @@ -12,7 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-fecomposite.h" +#include "filters/composite.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 669d2c7e1..b3b574f0c 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -19,9 +19,9 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" -#include "sp-fedistantlight.h" -#include "sp-fepointlight.h" -#include "sp-fespotlight.h" +#include "filters/distantlight.h" +#include "filters/pointlight.h" +#include "filters/spotlight.h" #include "color.h" namespace NR { diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index 34ba3aad2..6730822d9 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -12,7 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "sp-fedisplacementmap.h" +#include "filters/displacementmap.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 7837770ed..517f2dac9 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -62,7 +62,7 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { Matrix identity(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); - boost::optional<Geom::Rect> area = SVGElem->getBounds(identity); + Geom::OptRect area = SVGElem->getBounds(identity); NRRectL rect; rect.x0=area->min()[NR::X]; diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index 1632a7a82..4581238b7 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -13,7 +13,7 @@ #include <vector> #include "2geom/isnan.h" -#include "sp-femerge.h" +#include "filters/merge.h" #include "display/nr-filter-merge.h" #include "display/nr-filter-pixops.h" #include "display/nr-filter-slot.h" diff --git a/src/display/nr-filter-merge.h b/src/display/nr-filter-merge.h index 5fe6b33e3..3fa62a9cc 100644 --- a/src/display/nr-filter-merge.h +++ b/src/display/nr-filter-merge.h @@ -14,7 +14,7 @@ #include <vector> -#include "sp-femerge.h" +#include "filters/merge.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 6de682972..4d0bea8ff 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -19,9 +19,9 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" -#include "sp-fedistantlight.h" -#include "sp-fepointlight.h" -#include "sp-fespotlight.h" +#include "filters/distantlight.h" +#include "filters/pointlight.h" +#include "filters/spotlight.h" #include "color.h" namespace NR { diff --git a/src/display/nr-filter-units.h b/src/display/nr-filter-units.h index 49fe30aa9..df38c2bb9 100644 --- a/src/display/nr-filter-units.h +++ b/src/display/nr-filter-units.h @@ -16,6 +16,7 @@ #include "libnr/nr-matrix.h" #include "libnr/nr-rect.h" #include "libnr/nr-rect-l.h" +#include <2geom/rect.h> namespace NR { diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 31aec0748..01a092177 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -136,7 +136,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) } Geom::Rect filter_area = filter_effect_area(item_bbox); - if (item_bbox.area() == 0.0) { + if (item_bbox.hasZeroArea()) { // It's no use to try and filter an empty object. return 1; } diff --git a/src/display/nr-light.cpp b/src/display/nr-light.cpp index c2e6f1f83..72ed684b0 100644 --- a/src/display/nr-light.cpp +++ b/src/display/nr-light.cpp @@ -16,9 +16,9 @@ #include "libnr/nr-pixops.h" #include "display/nr-light.h" #include "display/nr-3dutils.h" -#include "sp-fedistantlight.h" -#include "sp-fepointlight.h" -#include "sp-fespotlight.h" +#include "filters/distantlight.h" +#include "filters/pointlight.h" +#include "filters/spotlight.h" namespace NR { diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 02c9a9ea2..723929ea7 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -249,7 +249,7 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t *scaled_font, //This glyph has a path description on its d attribute, so we render it: cairo_new_path(cr); Geom::Scale s(1.0/((SPFont*) node->parent)->horiz_adv_x); - Geom::Rect area( Geom::Point(0,0), Geom::Point(1,1) ); //I need help here! (reaction: note that the 'area' parameter is an *optional* rect, so you can pass an empty boost::optional<Geom::Rect>() ) + Geom::Rect area( Geom::Point(0,0), Geom::Point(1,1) ); //I need help here! (reaction: note that the 'area' parameter is an *optional* rect, so you can pass an empty Geom::OptRect() ) feed_pathvector_to_cairo (cr, pathv, s, area, false, 0); cairo_fill(cr); } diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 59578123e..441b64c02 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -15,9 +15,9 @@ #include "desktop.h" #include "desktop-handles.h" -#include "sp-namedview.h" #include "display/sodipodi-ctrl.h" #include "knot.h" +#include "preferences.h" namespace Inkscape { namespace Display { @@ -47,9 +47,10 @@ SnapIndicator::set_new_snappoint(Inkscape::SnappedPoint const p) } */ - SPNamedView *nv = sp_desktop_namedview(_desktop); - - if (nv->snapindicator) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool value = prefs->getBool("/options/snapindicator/value", true); + + if (value) { // TODO add many different kinds of snap indicator :-) // For this we should use p->getTarget() to find out what has snapped // and adjust the shape of the snapindicator accordingly, e.g. a cross diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index 1bed9355d..c26402743 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -12,6 +12,7 @@ #include "sp-canvas-util.h" #include "display-forward.h" #include "sodipodi-ctrl.h" +#include "libnr/nr-pixops.h" enum { ARG_0, @@ -122,6 +123,11 @@ sp_ctrl_destroy (GtkObject *object) ctrl = SP_CTRL (object); + if (ctrl->cache) { + g_free(ctrl->cache); + ctrl->cache = NULL; + } + if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -314,11 +320,13 @@ sp_ctrl_build_cache (SPCtrl *ctrl) side = (ctrl->span * 2 +1); c = ctrl->span ; - g_free (ctrl->cache); size = (side) * (side) * 4; - ctrl->cache = (guchar*)g_malloc (size); if (side < 2) return; + if (ctrl->cache) + g_free (ctrl->cache); + ctrl->cache = (guchar*)g_malloc (size); + switch (ctrl->shape) { case SP_CTRL_SHAPE_SQUARE: p = ctrl->cache; @@ -482,9 +490,9 @@ sp_ctrl_build_cache (SPCtrl *ctrl) } // composite background, foreground, alpha for xor mode -#define COMPOSE_X(b,f,a) ( ( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) / 0xff ) +#define COMPOSE_X(b,f,a) ( FAST_DIVIDE<255>( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) ) // composite background, foreground, alpha for color mode -#define COMPOSE_N(b,f,a) ( ( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) f) * ((guchar) a) ) / 0xff ) +#define COMPOSE_N(b,f,a) ( FAST_DIVIDE<255>( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) f) * ((guchar) a) ) ) static void sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index e9bf1633e..651bd0414 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -795,7 +795,7 @@ sp_canvas_group_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned } } - boost::optional<Geom::Rect> const bounds = corners.bounds(); + Geom::OptRect const bounds = corners.bounds(); if (bounds) { item->x1 = bounds->min()[Geom::X]; item->y1 = bounds->min()[Geom::Y]; @@ -1612,45 +1612,54 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event) // Snap when speed drops below e.g. 0.02 px/msec, or when no motion events have occured for some period. // i.e. snap when we're at stand still. A speed threshold enforces snapping for tablets, which might never // be fully at stand still and might keep spitting out motion events. - - if (event->type == GDK_MOTION_NOTIFY) { - Geom::Point event_pos(event->x, event->y); - guint32 event_t = gdk_event_get_time ( (GdkEvent *) event ); - - if (dt) { // put snapping on hold - dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(true); - } - - if (prev_pos) { - Geom::Coord dist = Geom::L2(event_pos - *prev_pos); - guint32 delta_t = event_t - prev_time; - gdouble speed = delta_t > 0 ? dist/delta_t : 1000; - // std::cout << "speed = " << speed << " px/msec " << "| time passed = " << delta_t << " msec" << std::endl; - if (speed > 0.02) { // Jitter threshold, might be needed for tablets - // We're moving fast, so postpone any snapping until the next GDK_MOTION_NOTIFY event. We - // will keep on postponing the snapping as long as the speed is high. - // We must snap at some point in time though, so set a watchdog timer at some time from - // now, just in case there's no future motion event that drops under the speed limit (when - // stoppping abruptly) - sp_canvas_snap_watchdog_kill(canvas); - sp_canvas_snap_watchdog_set(canvas, event); // watchdog is reset, i.e. pushed forward in time - } else { // Speed is very low, so we're virtually at stand still - // But if we're really standing still, then we should snap now. We could use some low-pass filtering, - // otherwise snapping occurs for each jitter movement. For this filtering we'll leave the watchdog to expire, - // snap, and set a new watchdog again. - if (canvas->watchdog_id == 0) { // no watchdog has been set - // it might have already expired, so we'll set a new one; the snapping frequency will be limited by this - sp_canvas_snap_watchdog_set(canvas, event); - } // else: watchdog has been set before and we'll wait for it to expire - } - } else { - // This is the first GDK_MOTION_NOTIFY event, so postpone snapping and set the watchdog - sp_canvas_snap_watchdog_set(canvas, event); - } + if (dt) { + bool const c1 = event->type == GDK_MOTION_NOTIFY; + bool const c21 = event->state & GDK_BUTTON1_MASK; // Snapping only occurs when dragging with the left mouse button down + bool const c22 = event->state & GDK_BUTTON2_MASK; // We shouldn't hold back any events when other mouse buttons have been + bool const c23 = event->state & GDK_BUTTON3_MASK; // pressed, e.g. when scrolling with the middle mouse button; if we do then + // Inkscape will get stuck in an unresponsive state + bool const c3 = dt->namedview->snap_manager.snapprefs.getSnapEnabledGlobally(); + if (c1 && c21 && (!c22) && (!c23) && c3) { + Geom::Point event_pos(event->x, event->y); + guint32 event_t = gdk_event_get_time ( (GdkEvent *) event ); + + dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(true); // put snapping on hold - prev_pos = event_pos; - prev_time = event_t; - } + if (prev_pos) { + Geom::Coord dist = Geom::L2(event_pos - *prev_pos); + guint32 delta_t = event_t - prev_time; + gdouble speed = delta_t > 0 ? dist/delta_t : 1000; + // std::cout << "speed = " << speed << " px/msec " << "| time passed = " << delta_t << " msec" << std::endl; + if (speed > 0.02) { // Jitter threshold, might be needed for tablets + // We're moving fast, so postpone any snapping until the next GDK_MOTION_NOTIFY event. We + // will keep on postponing the snapping as long as the speed is high. + // We must snap at some point in time though, so set a watchdog timer at some time from + // now, just in case there's no future motion event that drops under the speed limit (when + // stoppping abruptly) + sp_canvas_snap_watchdog_kill(canvas); + sp_canvas_snap_watchdog_set(canvas, event); // watchdog is reset, i.e. pushed forward in time + // If the watchdog expires before a new motion event is received, we will snap (as explained + // above). This means however that when the timer is too short, we will always snap and that the + // speed threshold is ineffective. In the extreme case the delay is set to zero, and snapping will + // be immediate, as it used to be in the old days ;-). + } else { // Speed is very low, so we're virtually at stand still + // But if we're really standing still, then we should snap now. We could use some low-pass filtering, + // otherwise snapping occurs for each jitter movement. For this filtering we'll leave the watchdog to expire, + // snap, and set a new watchdog again. + if (canvas->watchdog_id == 0) { // no watchdog has been set + // it might have already expired, so we'll set a new one; the snapping frequency will be limited by this + sp_canvas_snap_watchdog_set(canvas, event); + } // else: watchdog has been set before and we'll wait for it to expire + } + } else { + // This is the first GDK_MOTION_NOTIFY event, so postpone snapping and set the watchdog + sp_canvas_snap_watchdog_set(canvas, event); + } + + prev_pos = event_pos; + prev_time = event_t; + } + } canvas->state = event->state; pick_current_item (canvas, (GdkEvent *) event); @@ -1687,8 +1696,10 @@ gboolean sp_canvas_snap_watchdog_callback(gpointer data) void sp_canvas_snap_watchdog_set(SPCanvas *canvas, GdkEventMotion *event) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double value = prefs->getDoubleLimited("/options/snapdelay/value", 0, 0, 1000); g_assert(canvas->watchdog_id == 0); - canvas->watchdog_id = g_timeout_add(400, &sp_canvas_snap_watchdog_callback, canvas); + canvas->watchdog_id = g_timeout_add(value, &sp_canvas_snap_watchdog_callback, canvas); g_assert(canvas->watchdog_event == NULL); canvas->watchdog_event = gdk_event_copy( (GdkEvent *) event); } |
