diff options
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/canvas-bpath.cpp | 2 | ||||
| -rw-r--r-- | src/display/curve.cpp | 36 | ||||
| -rw-r--r-- | src/display/curve.h | 2 | ||||
| -rw-r--r-- | src/display/inkscape-cairo.cpp | 12 | ||||
| -rw-r--r-- | src/display/inkscape-cairo.h | 2 | ||||
| -rw-r--r-- | src/display/nr-arena-glyphs.cpp | 24 | ||||
| -rw-r--r-- | src/display/nr-arena-group.cpp | 17 | ||||
| -rw-r--r-- | src/display/nr-arena-group.h | 6 | ||||
| -rw-r--r-- | src/display/nr-arena-image.cpp | 63 | ||||
| -rw-r--r-- | src/display/nr-arena-image.h | 4 | ||||
| -rw-r--r-- | src/display/nr-arena-item.cpp | 29 | ||||
| -rw-r--r-- | src/display/nr-arena-item.h | 19 | ||||
| -rw-r--r-- | src/display/nr-arena-shape.cpp | 52 | ||||
| -rw-r--r-- | src/display/nr-arena-shape.h | 8 | ||||
| -rw-r--r-- | src/display/nr-filter-image.cpp | 6 | ||||
| -rw-r--r-- | src/display/nr-filter-turbulence.cpp | 2 | ||||
| -rw-r--r-- | src/display/nr-filter.cpp | 24 | ||||
| -rw-r--r-- | src/display/nr-filter.h | 2 | ||||
| -rw-r--r-- | src/display/nr-svgfonts.cpp | 59 | ||||
| -rw-r--r-- | src/display/nr-svgfonts.h | 2 | ||||
| -rw-r--r-- | src/display/sp-canvas.cpp | 15 |
21 files changed, 193 insertions, 193 deletions
diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 8342ff7ff..1900ed961 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -160,7 +160,7 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) sp_canvas_prepare_buffer(buf); - NR::Rect area (NR::Point(buf->rect.x0, buf->rect.y0), NR::Point(buf->rect.x1, buf->rect.y1)); + Geom::Rect area (Geom::Point(buf->rect.x0, buf->rect.y0), Geom::Point(buf->rect.x1, buf->rect.y1)); if ( !cbp->curve || ((cbp->stroke_rgba & 0xff) == 0 && (cbp->fill_rgba & 0xff) == 0 ) || diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 52ffe4f5b..5a1e2abeb 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -200,6 +200,7 @@ SPCurve::moveto(gdouble x, gdouble y) } /** * Perform a moveto to a point, thus starting a new subpath. + * Point p must be finite. */ void SPCurve::moveto(Geom::Point const &p) @@ -209,16 +210,17 @@ SPCurve::moveto(Geom::Point const &p) } /** - * Calls SPCurve::lineto() with a point's coordinates. + * Adds a line to the current subpath. + * Point p must be finite. */ void SPCurve::lineto(Geom::Point const &p) { - if (_pathv.empty()) g_message("SPCurve::lineto path is empty!"); + if (_pathv.empty()) g_message("SPCurve::lineto - path is empty!"); else _pathv.back().appendNew<Geom::LineSegment>( p ); } /** - * Adds a line to the current subpath. + * Calls SPCurve::lineto( Geom::Point(x,y) ) */ void SPCurve::lineto(gdouble x, gdouble y) @@ -227,16 +229,38 @@ SPCurve::lineto(gdouble x, gdouble y) } /** - * Calls SPCurve::curveto() with coordinates of three points. + * Adds a quadratic bezier segment to the current subpath. + * All points must be finite. + */ +void +SPCurve::quadto(Geom::Point const &p1, Geom::Point const &p2) +{ + if (_pathv.empty()) g_message("SPCurve::quadto - path is empty!"); + else _pathv.back().appendNew<Geom::QuadraticBezier>( p1, p2); +} +/** + * Calls SPCurve::quadto( Geom::Point(x1,y1), Geom::Point(x2,y2) ) + * All coordinates must be finite. + */ +void +SPCurve::quadto(gdouble x1, gdouble y1, gdouble x2, gdouble y2) +{ + quadto( Geom::Point(x1,y1), Geom::Point(x2,y2) ); +} + +/** + * Adds a bezier segment to the current subpath. + * All points must be finite. */ void SPCurve::curveto(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2) { - if (_pathv.empty()) g_message("SPCurve::lineto path is empty!"); + if (_pathv.empty()) g_message("SPCurve::curveto - path is empty!"); else _pathv.back().appendNew<Geom::CubicBezier>( p0, p1, p2 ); } /** - * Adds a bezier segment to the current subpath. + * Calls SPCurve::curveto( Geom::Point(x0,y0), Geom::Point(x1,y1), Geom::Point(x2,y2) ) + * All coordinates must be finite. */ void SPCurve::curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2) diff --git a/src/display/curve.h b/src/display/curve.h index 1b09c8c6e..79a385b09 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -59,6 +59,8 @@ public: void moveto(gdouble x, gdouble y); void lineto(Geom::Point const &p); void lineto(gdouble x, gdouble y); + void quadto(Geom::Point const &p1, Geom::Point const &p2); + void quadto(gdouble x1, gdouble y1, gdouble x2, gdouble y2); void curveto(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2); void curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2); void closepath(); diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp index 2ef726aab..54f979f37 100644 --- a/src/display/inkscape-cairo.cpp +++ b/src/display/inkscape-cairo.cpp @@ -170,7 +170,7 @@ 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<NR::Rect> area, bool optimize_stroke, double stroke_width) +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) { if (!area || area->isEmpty()) return; @@ -179,9 +179,9 @@ feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, boo // Transform all coordinates to coords within "area" Geom::Point shift = area->min(); - NR::Rect view = *area; - view.growBy (stroke_width); - view = view * (NR::Matrix)Geom::Translate(-shift); + Geom::Rect view = *area; + view.expandBy (stroke_width); + view = view * (Geom::Matrix)Geom::Translate(-shift); // Pass transformation to feed_curve, so that we don't need to create a whole new path. Geom::Matrix transshift(trans * Geom::Translate(-shift)); @@ -189,7 +189,7 @@ feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, boo cairo_move_to(ct, initial[0], initial[1] ); for(Geom::Path::const_iterator cit = path.begin(); cit != path.end_open(); ++cit) { - feed_curve_to_cairo(ct, *cit, transshift, to_2geom(view), optimize_stroke); + feed_curve_to_cairo(ct, *cit, transshift, view, optimize_stroke); } if (path.closed()) { @@ -214,7 +214,7 @@ 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<NR::Rect> area, bool optimize_stroke, double stroke_width) +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) { if (!area || area->isEmpty()) return; diff --git a/src/display/inkscape-cairo.h b/src/display/inkscape-cairo.h index f3be94464..4a9c15ae3 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<NR::Rect> area, bool optimize_stroke, double stroke_width); +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); #endif diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 6bb64f8d0..5f20d077a 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -47,7 +47,7 @@ static void nr_arena_glyphs_finalize(NRObject *object); static guint nr_arena_glyphs_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset); static guint nr_arena_glyphs_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb); -static NRArenaItem *nr_arena_glyphs_pick(NRArenaItem *item, NR::Point p, double delta, unsigned int sticky); +static NRArenaItem *nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); static NRArenaItemClass *glyphs_parent_class; @@ -145,8 +145,8 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s float const scale = NR::expansion(gc->transform); if (!glyphs->style->fill.isNone()) { - NR::Matrix t; - t = glyphs->g_transform * gc->transform; + Geom::Matrix t; + t = to_2geom(glyphs->g_transform) * gc->transform; glyphs->x = t[4]; glyphs->y = t[5]; t[4]=0; @@ -167,8 +167,8 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s if (!glyphs->style->stroke.isNone()) { /* Build state data */ - NR::Matrix t; - t = glyphs->g_transform * gc->transform; + Geom::Matrix t; + t = to_2geom(glyphs->g_transform) * gc->transform; glyphs->x = t[4]; glyphs->y = t[5]; t[4]=0; @@ -237,7 +237,7 @@ nr_arena_glyphs_clip(NRArenaItem *item, NRRectL */*area*/, NRPixBlock */*pb*/) } static NRArenaItem * -nr_arena_glyphs_pick(NRArenaItem *item, NR::Point p, gdouble /*delta*/, unsigned int /*sticky*/) +nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point p, gdouble /*delta*/, unsigned int /*sticky*/) { NRArenaGlyphs *glyphs; @@ -246,8 +246,8 @@ nr_arena_glyphs_pick(NRArenaItem *item, NR::Point p, gdouble /*delta*/, unsigned if (!glyphs->font ) return NULL; if (!glyphs->style) return NULL; - double const x = p[NR::X]; - double const y = p[NR::Y]; + double const x = p[Geom::X]; + double const y = p[Geom::Y]; /* With text we take a simple approach: pick if the point is in a characher bbox */ if ((x >= item->bbox.x0) && (y >= item->bbox.y0) && (x <= item->bbox.x1) && (y <= item->bbox.y1)) return item; @@ -323,7 +323,7 @@ static void nr_arena_glyphs_group_finalize(NRObject *object); static guint nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset); static unsigned int nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); static unsigned int nr_arena_glyphs_group_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb); -static NRArenaItem *nr_arena_glyphs_group_pick(NRArenaItem *item, NR::Point p, gdouble delta, unsigned int sticky); +static NRArenaItem *nr_arena_glyphs_group_pick(NRArenaItem *item, Geom::Point p, gdouble delta, unsigned int sticky); static NRArenaGroupClass *group_parent_class; @@ -465,8 +465,8 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi Geom::PathVector const * pathv = g->font->PathVector(g->glyph); cairo_new_path(ct); - Geom::Matrix transform = g->g_transform * group->ctm; - feed_pathvector_to_cairo (ct, *pathv, transform, (pb->area).upgrade(), false, 0); + Geom::Matrix transform = to_2geom(g->g_transform) * group->ctm; + feed_pathvector_to_cairo (ct, *pathv, transform, to_2geom((pb->area).upgrade()), false, 0); cairo_fill(ct); pb->empty = FALSE; } @@ -582,7 +582,7 @@ nr_arena_glyphs_group_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb) } static NRArenaItem * -nr_arena_glyphs_group_pick(NRArenaItem *item, NR::Point p, gdouble delta, unsigned int sticky) +nr_arena_glyphs_group_pick(NRArenaItem *item, Geom::Point p, gdouble delta, unsigned int sticky) { NRArenaItem *picked = NULL; diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 716a9f9fd..8b388aa40 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -24,6 +24,7 @@ #include "display/nr-filter-blend.h" #include "libnr/nr-matrix-fns.h" #include "libnr/nr-matrix-ops.h" +#include "helper/geom.h" static void nr_arena_group_class_init (NRArenaGroupClass *klass); static void nr_arena_group_init (NRArenaGroup *group); @@ -37,7 +38,7 @@ static void nr_arena_group_set_child_position (NRArenaItem *item, NRArenaItem *c static unsigned int nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); static unsigned int nr_arena_group_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); static unsigned int nr_arena_group_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb); -static NRArenaItem *nr_arena_group_pick (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky); +static NRArenaItem *nr_arena_group_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); static NRArenaItemClass *parent_class; @@ -87,7 +88,7 @@ nr_arena_group_init (NRArenaGroup *group) group->children = NULL; group->last = NULL; group->style = NULL; - group->child_transform.set_identity(); + group->child_transform.setIdentity(); } static NRArenaItem * @@ -250,7 +251,7 @@ nr_arena_group_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb) } static NRArenaItem * -nr_arena_group_pick (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky) +nr_arena_group_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky) { NRArenaGroup *group = NR_ARENA_GROUP (item); @@ -272,17 +273,17 @@ nr_arena_group_set_transparent (NRArenaGroup *group, unsigned int transparent) group->transparent = transparent; } -void nr_arena_group_set_child_transform(NRArenaGroup *group, NR::Matrix const &t) +void nr_arena_group_set_child_transform(NRArenaGroup *group, Geom::Matrix const &t) { - NR::Matrix nt(t); + Geom::Matrix nt(t); nr_arena_group_set_child_transform(group, &nt); } -void nr_arena_group_set_child_transform(NRArenaGroup *group, NR::Matrix const *t) +void nr_arena_group_set_child_transform(NRArenaGroup *group, Geom::Matrix const *t) { - if (!t) t = &NR_MATRIX_IDENTITY; + if (!t) t = &GEOM_MATRIX_IDENTITY; - if (!NR::matrix_equalp(*t, group->child_transform, NR_EPSILON)) { + if (!Geom::matrix_equalp(*t, group->child_transform, NR_EPSILON)) { nr_arena_item_request_render (NR_ARENA_ITEM (group)); group->child_transform = *t; nr_arena_item_request_update (NR_ARENA_ITEM (group), NR_ARENA_ITEM_STATE_ALL, TRUE); diff --git a/src/display/nr-arena-group.h b/src/display/nr-arena-group.h index ff3ec02dd..ae1763e99 100644 --- a/src/display/nr-arena-group.h +++ b/src/display/nr-arena-group.h @@ -26,7 +26,7 @@ struct NRArenaGroup : public NRArenaItem{ unsigned int transparent : 1; NRArenaItem *children; NRArenaItem *last; - NR::Matrix child_transform; + Geom::Matrix child_transform; SPStyle *style; static NRArenaGroup *create(NRArena *arena) { @@ -42,8 +42,8 @@ struct NRArenaGroupClass { void nr_arena_group_set_transparent(NRArenaGroup *group, unsigned int transparent); -void nr_arena_group_set_child_transform(NRArenaGroup *group, NR::Matrix const &t); -void nr_arena_group_set_child_transform(NRArenaGroup *group, NR::Matrix const *t); +void nr_arena_group_set_child_transform(NRArenaGroup *group, Geom::Matrix const &t); +void nr_arena_group_set_child_transform(NRArenaGroup *group, Geom::Matrix const *t); void nr_arena_group_set_style(NRArenaGroup *group, SPStyle *style); #endif diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 480322873..c8a988483 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -13,6 +13,7 @@ */ #include <libnr/nr-compose-transform.h> +#include <2geom/transforms.h> #include <libnr/nr-blit.h> #include "../prefs-utils.h" #include "nr-arena-image.h" @@ -40,7 +41,7 @@ static void nr_arena_image_finalize (NRObject *object); static unsigned int nr_arena_image_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); static unsigned int nr_arena_image_render (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); -static NRArenaItem *nr_arena_image_pick (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky); +static NRArenaItem *nr_arena_image_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); static NRArenaItemClass *parent_class; @@ -88,7 +89,7 @@ nr_arena_image_init (NRArenaImage *image) image->width = 256.0; image->height = 256.0; - image->grid2px.set_identity(); + image->grid2px.setIdentity(); image->style = 0; } @@ -106,7 +107,7 @@ nr_arena_image_finalize (NRObject *object) static unsigned int nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned int /*state*/, unsigned int /*reset*/ ) { - NR::Matrix grid2px; + Geom::Matrix grid2px; NRArenaImage *image = NR_ARENA_IMAGE (item); @@ -115,7 +116,7 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned /* Copy affine */ grid2px = gc->transform.inverse(); - double hscale, vscale; // todo: replace with NR::scale + double hscale, vscale; // todo: replace with Geom::Scale if (image->px) { hscale = image->pxw / image->width; vscale = image->pxh / image->height; @@ -143,12 +144,12 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned bbox.x1 = image->x + image->width; bbox.y1 = image->y + image->height; - image->c00 = (NR::Point(bbox.x0, bbox.y0) * gc->transform); - image->c01 = (NR::Point(bbox.x0, bbox.y1) * gc->transform); - image->c10 = (NR::Point(bbox.x1, bbox.y0) * gc->transform); - image->c11 = (NR::Point(bbox.x1, bbox.y1) * gc->transform); + image->c00 = (Geom::Point(bbox.x0, bbox.y0) * gc->transform); + image->c01 = (Geom::Point(bbox.x0, bbox.y1) * gc->transform); + image->c10 = (Geom::Point(bbox.x1, bbox.y0) * gc->transform); + image->c11 = (Geom::Point(bbox.x1, bbox.y1) * gc->transform); - nr_rect_d_matrix_transform (&bbox, &bbox, &gc->transform); + nr_rect_d_matrix_transform (&bbox, &bbox, from_2geom(gc->transform)); item->bbox.x0 = (int) floor (bbox.x0); item->bbox.y0 = (int) floor (bbox.y0); @@ -179,7 +180,7 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL */*area*/, NRPixB NRArenaImage *image = NR_ARENA_IMAGE (item); - NR::Matrix d2s; + Geom::Matrix d2s; d2s[0] = b2i[0]; d2s[1] = b2i[1]; @@ -235,23 +236,23 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL */*area*/, NRPixB cairo_set_line_width(ct, 0.5); cairo_new_path(ct); - NR::Point shift(pb->area.x0, pb->area.y0); - NR::Point c00 = image->c00 - shift; - NR::Point c01 = image->c01 - shift; - NR::Point c11 = image->c11 - shift; - NR::Point c10 = image->c10 - shift; + Geom::Point shift(pb->area.x0, pb->area.y0); + Geom::Point c00 = image->c00 - shift; + Geom::Point c01 = image->c01 - shift; + Geom::Point c11 = image->c11 - shift; + Geom::Point c10 = image->c10 - shift; - cairo_move_to (ct, c00[NR::X], c00[NR::Y]); + cairo_move_to (ct, c00[Geom::X], c00[Geom::Y]); // the box - cairo_line_to (ct, c10[NR::X], c10[NR::Y]); - cairo_line_to (ct, c11[NR::X], c11[NR::Y]); - cairo_line_to (ct, c01[NR::X], c01[NR::Y]); - cairo_line_to (ct, c00[NR::X], c00[NR::Y]); + cairo_line_to (ct, c10[Geom::X], c10[Geom::Y]); + cairo_line_to (ct, c11[Geom::X], c11[Geom::Y]); + cairo_line_to (ct, c01[Geom::X], c01[Geom::Y]); + cairo_line_to (ct, c00[Geom::X], c00[Geom::Y]); // the diagonals - cairo_line_to (ct, c11[NR::X], c11[NR::Y]); - cairo_move_to (ct, c10[NR::X], c10[NR::Y]); - cairo_line_to (ct, c01[NR::X], c01[NR::Y]); + cairo_line_to (ct, c11[Geom::X], c11[Geom::Y]); + cairo_move_to (ct, c10[Geom::X], c10[Geom::Y]); + cairo_line_to (ct, c01[Geom::X], c01[Geom::Y]); cairo_stroke(ct); @@ -263,14 +264,14 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL */*area*/, NRPixB /** Calculates the closest distance from p to the segment a1-a2*/ double -distance_to_segment (NR::Point p, NR::Point a1, NR::Point a2) +distance_to_segment (Geom::Point p, Geom::Point a1, Geom::Point a2) { // calculate sides of the triangle and their squares - double d1 = NR::L2(p - a1); + double d1 = Geom::L2(p - a1); double d1_2 = d1 * d1; - double d2 = NR::L2(p - a2); + double d2 = Geom::L2(p - a2); double d2_2 = d2 * d2; - double a = NR::L2(a1 - a2); + double a = Geom::L2(a1 - a2); double a_2 = a * a; // if one of the angles at the base is > 90, return the corresponding side @@ -283,7 +284,7 @@ distance_to_segment (NR::Point p, NR::Point a1, NR::Point a2) } static NRArenaItem * -nr_arena_image_pick( NRArenaItem *item, NR::Point p, double delta, unsigned int /*sticky*/ ) +nr_arena_image_pick( NRArenaItem *item, Geom::Point p, double delta, unsigned int /*sticky*/ ) { NRArenaImage *image = NR_ARENA_IMAGE (item); @@ -311,9 +312,9 @@ nr_arena_image_pick( NRArenaItem *item, NR::Point p, double delta, unsigned int int const width = image->pxw; int const height = image->pxh; int const rowstride = image->pxrs; - NR::Point tp = p * image->grid2px; - int const ix = (int)(tp[NR::X]); - int const iy = (int)(tp[NR::Y]); + Geom::Point tp = p * image->grid2px; + int const ix = (int)(tp[Geom::X]); + int const iy = (int)(tp[Geom::Y]); if ((ix < 0) || (iy < 0) || (ix >= width) || (iy >= height)) return NULL; diff --git a/src/display/nr-arena-image.h b/src/display/nr-arena-image.h index 2d7328263..d4653a692 100644 --- a/src/display/nr-arena-image.h +++ b/src/display/nr-arena-image.h @@ -32,10 +32,10 @@ struct NRArenaImage : public NRArenaItem { double x, y; double width, height; - NR::Point c00, c01, c11, c10; // all 4 corners of the image, for outline mode rect + Geom::Point c00, c01, c11, c10; // all 4 corners of the image, for outline mode rect /* From GRID to PIXELS */ - NR::Matrix grid2px; + Geom::Matrix grid2px; SPStyle *style; diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index a236b866b..b9a0cc371 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -25,6 +25,7 @@ #include "nr-arena.h" #include "nr-arena-item.h" #include "gc-core.h" +#include "helper/geom.h" #include "nr-filter.h" #include "libnr/nr-rect.h" @@ -619,7 +620,7 @@ nr_arena_item_invoke_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb) } NRArenaItem * -nr_arena_item_invoke_pick (NRArenaItem *item, NR::Point p, double delta, +nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky) { nr_return_val_if_fail (item != NULL, NULL); @@ -633,9 +634,9 @@ nr_arena_item_invoke_pick (NRArenaItem *item, NR::Point p, double delta, if (!sticky && !(item->visible && item->sensitive)) return NULL; - // TODO: rewrite using NR::Rect - const double x = p[NR::X]; - const double y = p[NR::Y]; + // TODO: rewrite using Geom::Rect + const double x = p[Geom::X]; + const double y = p[Geom::Y]; if (((x + delta) >= item->bbox.x0) && ((x - delta) < item->bbox.x1) && @@ -711,14 +712,14 @@ nr_arena_item_append_child (NRArenaItem *parent, NRArenaItem *child) } void -nr_arena_item_set_transform (NRArenaItem *item, NR::Matrix const &transform) +nr_arena_item_set_transform (NRArenaItem *item, Geom::Matrix const &transform) { - NR::Matrix const t (transform); + Geom::Matrix const t (transform); nr_arena_item_set_transform (item, &t); } void -nr_arena_item_set_transform (NRArenaItem *item, NR::Matrix const *transform) +nr_arena_item_set_transform (NRArenaItem *item, Geom::Matrix const *transform) { nr_return_if_fail (item != NULL); nr_return_if_fail (NR_IS_ARENA_ITEM (item)); @@ -726,17 +727,17 @@ nr_arena_item_set_transform (NRArenaItem *item, NR::Matrix const *transform) if (!transform && !item->transform) return; - const NR::Matrix *md = (item->transform) ? item->transform : &NR_MATRIX_IDENTITY; - const NR::Matrix *ms = (transform) ? transform : &NR_MATRIX_IDENTITY; + const Geom::Matrix *md = (item->transform) ? item->transform : &GEOM_MATRIX_IDENTITY; + const Geom::Matrix *ms = (transform) ? transform : &GEOM_MATRIX_IDENTITY; - if (!NR::matrix_equalp(*md, *ms, NR_EPSILON)) { + if (!Geom::matrix_equalp(*md, *ms, NR_EPSILON)) { nr_arena_item_request_render (item); - if (!transform || transform->test_identity()) { + if (!transform || transform->isIdentity()) { /* Set to identity affine */ item->transform = NULL; } else { if (!item->transform) - item->transform = new (GC::ATOMIC) NR::Matrix (); + item->transform = new (GC::ATOMIC) Geom::Matrix (); *item->transform = *transform; } nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, TRUE); @@ -836,12 +837,12 @@ nr_arena_item_set_order (NRArenaItem *item, int order) } void -nr_arena_item_set_item_bbox (NRArenaItem *item, boost::optional<NR::Rect> &bbox) +nr_arena_item_set_item_bbox (NRArenaItem *item, boost::optional<Geom::Rect> &bbox) { nr_return_if_fail(item != NULL); nr_return_if_fail(NR_IS_ARENA_ITEM(item)); - item->item_bbox = bbox; + if(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 b95fc5e72..9db8d7a40 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -60,11 +60,12 @@ #include "nr-arena-forward.h" #include "display/nr-filter.h" #include <cairo.h> +#include <libnr/nr-convert2geom.h> struct NRGC { NRGC(NRGC const *p) : parent(p) {} NRGC const *parent; - NR::Matrix transform; + Geom::Matrix transform; }; struct NRArenaItem : public NRObject { @@ -91,9 +92,9 @@ 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<NR::Rect> item_bbox; + boost::optional<Geom::Rect> item_bbox; /* Our affine */ - NR::Matrix *transform; + Geom::Matrix *transform; /* Clip item */ NRArenaItem *clip; /* Mask item */ @@ -107,7 +108,7 @@ struct NRArenaItem : public NRObject { void *data; /* Current Transformation Matrix */ - NR::Matrix ctm; + Geom::Matrix ctm; /* These hold background buffer state for filter rendering */ NRPixBlock *background_pb; @@ -128,7 +129,7 @@ struct NRArenaItemClass : public NRObjectClass { unsigned int (* update) (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset); unsigned int (* render) (cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); unsigned int (* clip) (NRArenaItem *item, NRRectL *area, NRPixBlock *pb); - NRArenaItem * (* pick) (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky); + NRArenaItem * (* pick) (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); }; #define NR_ARENA_ITEM_ARENA(ai) (((NRArenaItem *) (ai))->arena) @@ -158,7 +159,7 @@ unsigned int nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC unsigned int nr_arena_item_invoke_render(cairo_t *ct, NRArenaItem *item, NRRectL const *area, NRPixBlock *pb, unsigned int flags); unsigned int nr_arena_item_invoke_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb); -NRArenaItem *nr_arena_item_invoke_pick (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky); +NRArenaItem *nr_arena_item_invoke_pick (NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); void nr_arena_item_request_update (NRArenaItem *item, unsigned int reset, unsigned int propagate); void nr_arena_item_request_render (NRArenaItem *item); @@ -169,15 +170,15 @@ NRArenaItem *nr_arena_item_unparent (NRArenaItem *item); void nr_arena_item_append_child (NRArenaItem *parent, NRArenaItem *child); -void nr_arena_item_set_transform(NRArenaItem *item, NR::Matrix const &transform); -void nr_arena_item_set_transform(NRArenaItem *item, NR::Matrix const *transform); +void nr_arena_item_set_transform(NRArenaItem *item, Geom::Matrix const &transform); +void nr_arena_item_set_transform(NRArenaItem *item, Geom::Matrix const *transform); void nr_arena_item_set_opacity (NRArenaItem *item, double opacity); void nr_arena_item_set_sensitive (NRArenaItem *item, unsigned int sensitive); 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<NR::Rect> &bbox); +void nr_arena_item_set_item_bbox (NRArenaItem *item, boost::optional<Geom::Rect> &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 751801c7e..6a252e5f5 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -58,7 +58,7 @@ static void nr_arena_shape_set_child_position(NRArenaItem *item, NRArenaItem *ch static guint nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset); static unsigned int nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags); static guint nr_arena_shape_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb); -static NRArenaItem *nr_arena_shape_pick(NRArenaItem *item, NR::Point p, double delta, unsigned int sticky); +static NRArenaItem *nr_arena_shape_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int sticky); static NRArenaItemClass *shape_parent_class; @@ -113,7 +113,7 @@ nr_arena_shape_init(NRArenaShape *shape) shape->paintbox.x0 = shape->paintbox.y0 = 0.0F; shape->paintbox.x1 = shape->paintbox.y1 = 256.0F; - shape->ctm.set_identity(); + shape->ctm.setIdentity(); shape->fill_painter = NULL; shape->stroke_painter = NULL; shape->cached_fill = NULL; @@ -127,8 +127,8 @@ nr_arena_shape_init(NRArenaShape *shape) shape->approx_bbox.x0 = shape->approx_bbox.y0 = 0; shape->approx_bbox.x1 = shape->approx_bbox.y1 = 0; - shape->cached_fctm.set_identity(); - shape->cached_sctm.set_identity(); + shape->cached_fctm.setIdentity(); + shape->cached_sctm.setIdentity(); shape->markers = NULL; @@ -282,7 +282,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE || outline) { float width, scale; - scale = NR::expansion(gc->transform); + 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); @@ -303,7 +303,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if ( area && nr_rect_l_test_intersect_ptr(area, &shape->approx_bbox) ) shape->delayed_shp=false; /* Release state data */ - if (TRUE || !NR::transform_equalp(gc->transform, shape->ctm, NR_EPSILON)) { + if (TRUE || !Geom::transform_equalp(gc->transform, shape->ctm, NR_EPSILON)) { /* Concept test */ if (shape->fill_shp) { delete shape->fill_shp; @@ -393,8 +393,8 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g return NR_ARENA_ITEM_STATE_ALL; } -int matrix_is_isometry(NR::Matrix p) { - NR::Matrix tp; +int matrix_is_isometry(Geom::Matrix p) { + Geom::Matrix tp; // transposition tp[0]=p[0]; tp[1]=p[2]; @@ -402,9 +402,9 @@ int matrix_is_isometry(NR::Matrix p) { tp[3]=p[3]; for (int i = 4; i < 6; i++) // shut valgrind up :) tp[i] = p[i] = 0; - NR::Matrix isom = tp*p; // A^T * A = adjunct? + Geom::Matrix isom = tp*p; // A^T * A = adjunct? // Is the adjunct nearly an identity function? - if (isom.is_translation(0.01)) { + if (isom.isTranslation(0.01)) { // the transformation is an isometry -> no need to recompute // the uncrossed polygon if ( p.det() < 0 ) @@ -446,7 +446,7 @@ nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool fo // ((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(); + Geom::Matrix cached_to_new = Geom::identity(); int isometry = 0; if ( shape->cached_fill ) { if (shape->cached_fctm == gc->transform) { @@ -508,7 +508,7 @@ nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool fo shape->fill_shp->Reset(shape->cached_fill->numberOfPoints(), shape->cached_fill->numberOfEdges()); for (int i = 0; i < shape->cached_fill->numberOfPoints(); i++) - shape->fill_shp->AddPoint(shape->cached_fill->getPoint(i).x * cached_to_new); + shape->fill_shp->AddPoint(to_2geom(shape->cached_fill->getPoint(i).x) * cached_to_new); if ( isometry == 1 ) { for (int i = 0; i < shape->cached_fill->numberOfEdges(); i++) shape->fill_shp->AddEdge(shape->cached_fill->getEdge(i).st, @@ -532,7 +532,7 @@ nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc, NRRectL *area) { SPStyle* style = shape->style; - float const scale = NR::expansion(gc->transform); + float const scale = gc->transform.descrim(); bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); @@ -556,7 +556,7 @@ nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc, NRRectL *area) width = style_width; } - NR::Matrix cached_to_new = NR::identity(); + Geom::Matrix cached_to_new = Geom::identity(); int isometry = 0; if ( shape->cached_stroke ) { @@ -664,7 +664,7 @@ nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc, NRRectL *area) shape->stroke_shp=new Shape; shape->stroke_shp->Reset(shape->cached_stroke->numberOfPoints(), shape->cached_stroke->numberOfEdges()); for (int i = 0; i < shape->cached_stroke->numberOfPoints(); i++) - shape->stroke_shp->AddPoint(shape->cached_stroke->getPoint(i).x * cached_to_new); + shape->stroke_shp->AddPoint(to_2geom(shape->cached_stroke->getPoint(i).x) * cached_to_new); if ( isometry == 1 ) { for (int i = 0; i < shape->cached_stroke->numberOfEdges(); i++) shape->stroke_shp->AddEdge(shape->cached_stroke->getEdge(i).st, @@ -716,7 +716,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<NR::Rect> area) +cairo_arena_shape_render_outline(cairo_t *ct, NRArenaItem *item, boost::optional<Geom::Rect> area) { NRArenaShape *shape = NR_ARENA_SHAPE(item); @@ -748,7 +748,7 @@ cairo_arena_shape_render_stroke(NRArenaItem *item, NRRectL *area, NRPixBlock *pb NRArenaShape *shape = NR_ARENA_SHAPE(item); SPStyle const *style = shape->style; - float const scale = NR::expansion(shape->ctm); + float const scale = shape->ctm.descrim(); if (fabs(shape->_stroke.width * scale) < 0.01) return; @@ -813,7 +813,7 @@ cairo_arena_shape_render_stroke(NRArenaItem *item, NRRectL *area, NRPixBlock *pb cairo_set_tolerance(ct, 0.1); cairo_new_path(ct); - feed_pathvector_to_cairo (ct, shape->curve->get_pathvector(), shape->ctm, area->upgrade(), true, style_width); + feed_pathvector_to_cairo (ct, shape->curve->get_pathvector(), shape->ctm, to_2geom(area->upgrade()), true, style_width); cairo_stroke(ct); @@ -842,7 +842,7 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock if (outline) { // cairo outline rendering pb->empty = FALSE; - unsigned int ret = cairo_arena_shape_render_outline (ct, item, (&pb->area)->upgrade()); + unsigned int ret = cairo_arena_shape_render_outline (ct, item, to_2geom((&pb->area)->upgrade())); if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret; } else { @@ -1056,7 +1056,7 @@ nr_arena_shape_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb) } static NRArenaItem * -nr_arena_shape_pick(NRArenaItem *item, NR::Point p, double delta, unsigned int /*sticky*/) +nr_arena_shape_pick(NRArenaItem *item, Geom::Point p, double delta, unsigned int /*sticky*/) { NRArenaShape *shape = NR_ARENA_SHAPE(item); @@ -1082,7 +1082,7 @@ nr_arena_shape_pick(NRArenaItem *item, NR::Point p, double delta, unsigned int / if (outline) { width = 0.5; } else if (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE && shape->_stroke.opacity > 1e-3) { - float const scale = NR::expansion(shape->ctm); + float const scale = shape->ctm.descrim(); width = MAX(0.125, shape->_stroke.width * scale) / 2; } else { width = 0; @@ -1359,12 +1359,12 @@ nr_arena_shape_set_paintbox(NRArenaShape *shape, NRRect const *pbox) nr_arena_item_request_update(shape, NR_ARENA_ITEM_STATE_ALL, FALSE); } -void NRArenaShape::setPaintBox(NR::Rect const &pbox) +void NRArenaShape::setPaintBox(Geom::Rect const &pbox) { - paintbox.x0 = pbox.min()[NR::X]; - paintbox.y0 = pbox.min()[NR::Y]; - paintbox.x1 = pbox.max()[NR::X]; - paintbox.y1 = pbox.max()[NR::Y]; + paintbox.x0 = pbox.min()[Geom::X]; + paintbox.y0 = pbox.min()[Geom::Y]; + paintbox.x1 = pbox.max()[Geom::X]; + paintbox.y1 = pbox.max()[Geom::Y]; nr_arena_item_request_update(this, NR_ARENA_ITEM_STATE_ALL, FALSE); } diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h index 2b56fbf75..8ff8c476a 100644 --- a/src/display/nr-arena-shape.h +++ b/src/display/nr-arena-shape.h @@ -113,7 +113,7 @@ struct NRArenaShape : public NRArenaItem { SPStyle *style; NRRect paintbox; /* State data */ - NR::Matrix ctm; + Geom::Matrix ctm; SPPainter *fill_painter; SPPainter *stroke_painter; @@ -136,8 +136,8 @@ struct NRArenaShape : public NRArenaItem { // polygon to get the *_shp polygon. Otherwise, recompute so this // works fine for translation and rotation, but not scaling and // skewing - NR::Matrix cached_fctm; - NR::Matrix cached_sctm; + Geom::Matrix cached_fctm; + Geom::Matrix cached_sctm; NRRectL cached_farea; NRRectL cached_sarea; bool cached_fpartialy; @@ -170,7 +170,7 @@ struct NRArenaShape : public NRArenaItem { void setLineJoin(JoinType join); void setMitreLimit(double limit); - void setPaintBox(NR::Rect const &pbox); + void setPaintBox(Geom::Rect const &pbox); void _invalidateCachedFill() { if (cached_fill) { diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 65958f0d2..7837770ed 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<NR::Rect> area = SVGElem->getBounds(identity); + boost::optional<Geom::Rect> area = SVGElem->getBounds(identity); NRRectL rect; rect.x0=area->min()[NR::X]; @@ -80,9 +80,9 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { NRGC gc(NULL); /* Update to renderable state */ double sf = 1.0; - NR::Matrix t(NR::scale(sf, sf)); + Geom::Matrix t(Geom::Scale(sf, sf)); nr_arena_item_set_transform(ai, &t); - gc.transform.set_identity(); + gc.transform.setIdentity(); nr_arena_item_invoke_update( ai, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index 3fd577309..1a3a8d1f1 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -14,7 +14,7 @@ * http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 * * Copyright (C) 2007 authors - * Released under GNU GPL, read the file 'COPYING' for more information + * Released under GNU GPL version 2 (or later), read the file 'COPYING' for more information */ #include "display/nr-arena-item.h" diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 0e608e901..8930a74df 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -114,13 +114,13 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) Matrix trans = item->ctm; FilterSlot slot(_slot_count, item); - Rect item_bbox; + Geom::Rect item_bbox; if (item->item_bbox) { item_bbox = *(item->item_bbox); } else { // Bounding box might not exist, so create a dummy one. - Point zero(0, 0); - item_bbox = Rect(zero, zero); + Geom::Point zero(0, 0); + item_bbox = Geom::Rect(zero, zero); } if (item_bbox.min()[X] > item_bbox.max()[X] || item_bbox.min()[Y] > item_bbox.max()[Y]) @@ -129,7 +129,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) return 1; } - Rect filter_area = filter_effect_area(item_bbox); + Geom::Rect filter_area = filter_effect_area(item_bbox); if (item_bbox.isEmpty()) { // It's no use to try and filter an empty object. return 1; @@ -137,8 +137,8 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) FilterUnits units(_filter_units, _primitive_units); units.set_ctm(trans); - units.set_item_bbox(item_bbox); - units.set_filter_area(filter_area); + units.set_item_bbox(from_2geom(item_bbox)); + units.set_filter_area(from_2geom(filter_area)); // TODO: with filterRes of 0x0 should return an empty image if (_x_pixels > 0) { @@ -224,11 +224,11 @@ void Filter::bbox_enlarge(NRRectL &bbox) { /* TODO: this is wrong. Should use bounding box in user coordinates * and find its extents in display coordinates. */ - Point min(bbox.x0, bbox.y0); - Point max(bbox.x1, bbox.y1); - Rect tmp_bbox(min, max); + Geom::Point min(bbox.x0, bbox.y0); + Geom::Point max(bbox.x1, bbox.y1); + Geom::Rect tmp_bbox(min, max); - Rect enlarged = filter_effect_area(tmp_bbox); + Geom::Rect enlarged = filter_effect_area(tmp_bbox); bbox.x0 = (ICoord)enlarged.min()[X]; bbox.y0 = (ICoord)enlarged.min()[Y]; @@ -236,7 +236,7 @@ void Filter::bbox_enlarge(NRRectL &bbox) { bbox.y1 = (ICoord)enlarged.max()[Y]; } -Rect Filter::filter_effect_area(Rect const &bbox) +Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) { Point minp, maxp; double len_x = bbox.max()[X] - bbox.min()[X]; @@ -277,7 +277,7 @@ Rect Filter::filter_effect_area(Rect const &bbox) } else { g_warning("Error in NR::Filter::bbox_enlarge: unrecognized value of _filter_units"); } - Rect area(minp, maxp); + Geom::Rect area(minp, maxp); return area; } diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 267f242d1..1dbdfd1ef 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -155,7 +155,7 @@ public: * The given bounding box should be a bounding box as specified in * SVG standard and in user coordinate system. */ - Rect filter_effect_area(Rect const &bbox); + Geom::Rect filter_effect_area(Geom::Rect const &bbox); /** Creates a new filter with space for one filter element */ Filter(); diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 0dd5d996a..28d29b59c 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -30,17 +30,6 @@ static cairo_user_data_key_t key; - -/** - * Felipe, - * Cairo is changing its userfont api a little bit for 1.7+, 1.8, - * etc. This switch makes your code compile both on 1.6 and 1.7. Is - * this ok? - * - * Bob - */ -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 7, 0)) - static cairo_status_t font_init_cb (cairo_scaled_font_t *scaled_font, cairo_t */*cairo*/, cairo_font_extents_t *metrics){ cairo_font_face_t* face; @@ -52,42 +41,18 @@ static cairo_status_t font_init_cb (cairo_scaled_font_t *scaled_font, static cairo_status_t font_text_to_glyphs_cb ( cairo_scaled_font_t *scaled_font, const char *utf8, - int /*utf8_len*/, + int utf8_len, cairo_glyph_t **glyphs, int *num_glyphs, - cairo_text_cluster_t **/*clusters*/, - int */*num_clusters*/, - cairo_bool_t */*backward*/){ - cairo_font_face_t* face; - face = cairo_scaled_font_get_font_face(scaled_font); - SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key); - return instance->scaled_font_text_to_glyphs(scaled_font, utf8, glyphs, num_glyphs); -} - - -#else - -static cairo_status_t font_init_cb (cairo_scaled_font_t *scaled_font, - cairo_font_extents_t *metrics){ + cairo_text_cluster_t **clusters, + int *num_clusters, + cairo_text_cluster_flags_t *flags){ cairo_font_face_t* face; face = cairo_scaled_font_get_font_face(scaled_font); SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key); - return instance->scaled_font_init(scaled_font, metrics); -} - -static cairo_status_t font_text_to_glyphs_cb (cairo_scaled_font_t *scaled_font, - const char *utf8, - cairo_glyph_t **glyphs, - int *num_glyphs){ - cairo_font_face_t* face; - face = cairo_scaled_font_get_font_face(scaled_font); - SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key); - return instance->scaled_font_text_to_glyphs(scaled_font, utf8, glyphs, num_glyphs); + return instance->scaled_font_text_to_glyphs(scaled_font, utf8, utf8_len, glyphs, num_glyphs, clusters, num_clusters, flags); } -#endif - - static cairo_status_t font_render_glyph_cb (cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, @@ -136,12 +101,16 @@ unsigned int compare_them(char* s1, char* s2){ cairo_status_t SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, const char *utf8, + int utf8_len, cairo_glyph_t **glyphs, - int *num_glyphs) + int *num_glyphs, + cairo_text_cluster_t **clusters, + int *num_clusters, + cairo_text_cluster_flags_t *flags) { //This function receives a text string to be rendered. It then defines what is the sequence of glyphs that - // is used to properly render this string. It alse defines the respective coordinates of each glyph. Thus, it - // has to read the attributes od the SVGFont hkern and vkern nodes in order to adjust the glyph kerning. + // is used to properly render this string. It also defines the respective coordinates of each glyph. Thus, it + // has to read the attributes of the SVGFont hkern and vkern nodes in order to adjust the glyph kerning. //It also determines the usage of the missing-glyph in portions of the string that does not match any of the declared glyphs. unsigned long i; @@ -258,8 +227,8 @@ 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); - NRRect area(0,0,1,1); //I need help here! - feed_pathvector_to_cairo (cr, pathv, s, area.upgrade(), false, 0); + 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>() ) + feed_pathvector_to_cairo (cr, pathv, s, area, false, 0); cairo_fill(cr); } diff --git a/src/display/nr-svgfonts.h b/src/display/nr-svgfonts.h index e3bac7d7a..a41627f86 100644 --- a/src/display/nr-svgfonts.h +++ b/src/display/nr-svgfonts.h @@ -34,7 +34,7 @@ public: SvgFont(SPFont* spfont); cairo_font_face_t* get_font_face(); cairo_status_t scaled_font_init (cairo_scaled_font_t *scaled_font, cairo_font_extents_t *metrics); -cairo_status_t scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, const char *utf8, cairo_glyph_t **glyphs, int *num_glyphs); +cairo_status_t scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, const char *utf8, int utf8_len, cairo_glyph_t **glyphs, int *num_glyphs, cairo_text_cluster_t **clusters, int *num_clusters, cairo_text_cluster_flags_t *flags); cairo_status_t scaled_font_render_glyph (cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics); private: diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index fd124aa1e..d82e39238 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -29,6 +29,7 @@ #include <gtkmm.h> #include <helper/sp-marshal.h> +#include <helper/recthull.h> #include <display/sp-canvas.h> #include "display-forward.h" #include <libnr/nr-matrix-fns.h> @@ -773,7 +774,7 @@ static void sp_canvas_group_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SPCanvasGroup const *group = SP_CANVAS_GROUP (item); - NR::ConvexHull corners(Geom::Point(0, 0)); + Geom::RectHull corners(Geom::Point(0, 0)); bool empty=true; for (GList *list = group->items; list; list = list->next) { @@ -783,7 +784,7 @@ sp_canvas_group_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned if ( i->x2 > i->x1 && i->y2 > i->y1 ) { if (empty) { - corners = NR::ConvexHull(Geom::Point(i->x1, i->y1)); + corners = Geom::RectHull(Geom::Point(i->x1, i->y1)); empty = false; } else { corners.add(Geom::Point(i->x1, i->y1)); @@ -792,12 +793,12 @@ sp_canvas_group_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned } } - boost::optional<NR::Rect> const bounds = corners.bounds(); + boost::optional<Geom::Rect> const bounds = corners.bounds(); if (bounds) { - item->x1 = bounds->min()[NR::X]; - item->y1 = bounds->min()[NR::Y]; - item->x2 = bounds->max()[NR::X]; - item->y2 = bounds->max()[NR::Y]; + item->x1 = bounds->min()[Geom::X]; + item->y1 = bounds->min()[Geom::Y]; + item->x2 = bounds->max()[Geom::X]; + item->y2 = bounds->max()[Geom::Y]; } else { // FIXME ? item->x1 = item->x2 = item->y1 = item->y2 = 0; |
