From: jaspervdg Date: Fri, 21 Mar 2008 19:53:10 +0000 (+0000) Subject: No more NRMatrix or NRPoint. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3955580a5a68a873b098921626f5b9d841b964ec;p=inkscape.git No more NRMatrix or NRPoint. --- diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 48dc59400..3504dcf40 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -405,7 +405,7 @@ stroke_average_width (GSList const *objects) notstroked = false; } - avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * i2d.expansion(); + avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * NR::expansion(i2d); } if (notstroked) @@ -661,7 +661,7 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) n_stroked ++; NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); - double sw = style->stroke_width.computed * i2d.expansion(); + double sw = style->stroke_width.computed * NR::expansion(i2d); if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3) same_sw = false; diff --git a/src/desktop.h b/src/desktop.h index 1435eea6f..52bb91c76 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -233,7 +233,7 @@ struct SPDesktop : public Inkscape::UI::View::View void zoom_drawing(); void zoom_selection(); void zoom_grab_focus(); - double current_zoom() const { return _d2w.expansion(); } + double current_zoom() const { return NR::expansion(_d2w); } void prev_zoom(); void next_zoom(); diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 899b7b5ca..64583b9f2 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -893,11 +893,10 @@ clonetiler_trace_pick (NR::Rect box) if (!trace_arena) return 0; - NRMatrix t; - nr_matrix_set_scale(&t, trace_zoom, trace_zoom); + NR::Matrix t(NR::scale(trace_zoom, trace_zoom)); nr_arena_item_set_transform(trace_root, &t); NRGC gc(NULL); - nr_matrix_set_identity(&gc.transform); + gc.transform.set_identity(); nr_arena_item_invoke_update( trace_root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); @@ -1481,7 +1480,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) if (blur > 0.0) { SPObject *clone_object = sp_desktop_document(desktop)->getObjectByRepr(clone); - double perimeter = perimeter_original * t.expansion(); + double perimeter = perimeter_original * NR::expansion(t); double radius = blur * perimeter; // this is necessary for all newly added clones to have correct bboxes, // otherwise filters won't work: @@ -1489,7 +1488,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) // it's hard to figure out exact width/height of the tile without having an object // that we can take bbox of; however here we only need a lower bound so that blur // margins are not too small, and the perimeter should work - SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, t.expansion(), t.expansionX(), t.expansionY(), perimeter, perimeter); + SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, NR::expansion(t), NR::expansionX(t), NR::expansionY(t), perimeter, perimeter); sp_style_set_property_url (clone_object, "filter", SP_OBJECT(constructed), false); } diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index ca4e781a9..9456e8a7e 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -85,7 +85,7 @@ static void nr_arena_glyphs_init(NRArenaGlyphs *glyphs) { glyphs->style = NULL; - nr_matrix_set_identity(&glyphs->g_transform); + glyphs->g_transform.set_identity(); glyphs->font = NULL; glyphs->glyph = 0; @@ -138,15 +138,15 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s bbox.x0 = bbox.y0 = NR_HUGE; bbox.x1 = bbox.y1 = -NR_HUGE; - float const scale = NR_MATRIX_DF_EXPANSION(&gc->transform); + float const scale = NR::expansion(gc->transform); if (!glyphs->style->fill.isNone()) { - NRMatrix t; - nr_matrix_multiply(&t, &glyphs->g_transform, &gc->transform); - glyphs->x = t.c[4]; - glyphs->y = t.c[5]; - t.c[4]=0; - t.c[5]=0; + NR::Matrix t; + t = glyphs->g_transform * gc->transform; + glyphs->x = t[4]; + glyphs->y = t[5]; + t[4]=0; + t[5]=0; rfont = glyphs->font->RasterFont(t, 0); if (glyphs->rfont) glyphs->rfont->Unref(); glyphs->rfont = rfont; @@ -163,12 +163,12 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s if (!glyphs->style->stroke.isNone()) { /* Build state data */ - NRMatrix t; - nr_matrix_multiply(&t, &glyphs->g_transform, &gc->transform); - glyphs->x = t.c[4]; - glyphs->y = t.c[5]; - t.c[4]=0; - t.c[5]=0; + NR::Matrix t; + t = glyphs->g_transform * gc->transform; + glyphs->x = t[4]; + glyphs->y = t[5]; + t[4]=0; + t[5]=0; if ( fabs(glyphs->style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord font_style nstyl; @@ -251,7 +251,7 @@ nr_arena_glyphs_pick(NRArenaItem *item, NR::Point p, gdouble /*delta*/, unsigned } void -nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve */*curve*/, unsigned int /*lieutenant*/, font_instance *font, gint glyph, NRMatrix const *transform) +nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve */*curve*/, unsigned int /*lieutenant*/, font_instance *font, gint glyph, NR::Matrix const *transform) { nr_return_if_fail(glyphs != NULL); nr_return_if_fail(NR_IS_ARENA_GLYPHS(glyphs)); @@ -261,7 +261,7 @@ nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve */*curve*/, unsigned int if (transform) { glyphs->g_transform = *transform; } else { - nr_matrix_set_identity(&glyphs->g_transform); + glyphs->g_transform.set_identity(); } if (font) font->Ref(); @@ -410,14 +410,14 @@ nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint s item->render_opacity = TRUE; if (group->style->fill.isPaintserver()) { group->fill_painter = sp_paint_server_painter_new(SP_STYLE_FILL_SERVER(group->style), - NR::Matrix(&gc->transform), NR::Matrix(&gc->parent->transform), + gc->transform, gc->parent->transform, &group->paintbox); item->render_opacity = FALSE; } if (group->style->stroke.isPaintserver()) { group->stroke_painter = sp_paint_server_painter_new(SP_STYLE_STROKE_SERVER(group->style), - NR::Matrix(&gc->transform), NR::Matrix(&gc->parent->transform), + gc->transform, gc->parent->transform, &group->paintbox); item->render_opacity = FALSE; } @@ -603,7 +603,7 @@ nr_arena_glyphs_group_clear(NRArenaGlyphsGroup *sg) } void -nr_arena_glyphs_group_add_component(NRArenaGlyphsGroup *sg, font_instance *font, int glyph, NRMatrix const *transform) +nr_arena_glyphs_group_add_component(NRArenaGlyphsGroup *sg, font_instance *font, int glyph, NR::Matrix const *transform) { NRArenaGroup *group; NRBPath bpath; diff --git a/src/display/nr-arena-glyphs.h b/src/display/nr-arena-glyphs.h index a2dda988b..0c0121160 100644 --- a/src/display/nr-arena-glyphs.h +++ b/src/display/nr-arena-glyphs.h @@ -33,7 +33,7 @@ NRType nr_arena_glyphs_get_type (void); struct NRArenaGlyphs : public NRArenaItem { /* Glyphs data */ SPStyle *style; - NRMatrix g_transform; + NR::Matrix g_transform; font_instance *font; gint glyph; @@ -41,7 +41,7 @@ struct NRArenaGlyphs : public NRArenaItem { raster_font *sfont; float x, y; -// NRMatrix cached_tr; +// NR::Matrix cached_tr; // Shape *cached_shp; // bool cached_shp_dirty; // bool cached_style_dirty; @@ -62,7 +62,7 @@ struct NRArenaGlyphsClass { void nr_arena_glyphs_set_path (NRArenaGlyphs *glyphs, SPCurve *curve, unsigned int lieutenant, font_instance *font, int glyph, - const NRMatrix *transform); + const NR::Matrix *transform); void nr_arena_glyphs_set_style (NRArenaGlyphs *glyphs, SPStyle *style); /* Integrated group of component glyphss */ @@ -100,7 +100,7 @@ struct NRArenaGlyphsGroupClass { void nr_arena_glyphs_group_clear (NRArenaGlyphsGroup *group); -void nr_arena_glyphs_group_add_component (NRArenaGlyphsGroup *group, font_instance *font, int glyph, const NRMatrix *transform); +void nr_arena_glyphs_group_add_component (NRArenaGlyphsGroup *group, font_instance *font, int glyph, const NR::Matrix *transform); void nr_arena_glyphs_group_set_style (NRArenaGlyphsGroup *group, SPStyle *style); diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index fcce681a8..51f1c6b2f 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -22,6 +22,8 @@ #include "sp-gaussian-blur.h" #include "sp-feblend.h" #include "display/nr-filter-blend.h" +#include "libnr/nr-matrix-fns.h" +#include "libnr/nr-matrix-ops.h" static void nr_arena_group_class_init (NRArenaGroupClass *klass); static void nr_arena_group_init (NRArenaGroup *group); @@ -85,7 +87,7 @@ nr_arena_group_init (NRArenaGroup *group) group->children = NULL; group->last = NULL; group->style = NULL; - nr_matrix_set_identity (&group->child_transform); + group->child_transform.set_identity(); } static NRArenaItem * @@ -171,7 +173,7 @@ nr_arena_group_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int for (NRArenaItem *child = group->children; child != NULL; child = child->next) { NRGC cgc(gc); - nr_matrix_multiply (&cgc.transform, &group->child_transform, &gc->transform); + cgc.transform = group->child_transform * gc->transform; newstate = nr_arena_item_invoke_update (child, area, &cgc, state, reset); beststate = beststate & newstate; } @@ -271,15 +273,15 @@ nr_arena_group_set_transparent (NRArenaGroup *group, unsigned int transparent) void nr_arena_group_set_child_transform(NRArenaGroup *group, NR::Matrix const &t) { - NRMatrix nt(t); + NR::Matrix nt(t); nr_arena_group_set_child_transform(group, &nt); } -void nr_arena_group_set_child_transform(NRArenaGroup *group, NRMatrix const *t) +void nr_arena_group_set_child_transform(NRArenaGroup *group, NR::Matrix const *t) { if (!t) t = &NR_MATRIX_IDENTITY; - if (!NR_MATRIX_DF_TEST_CLOSE (t, &group->child_transform, NR_EPSILON)) { + if (!NR::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 1b699fd04..ff3ec02dd 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; - NRMatrix child_transform; + NR::Matrix child_transform; SPStyle *style; static NRArenaGroup *create(NRArena *arena) { @@ -43,7 +43,7 @@ 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, NRMatrix const *t); +void nr_arena_group_set_child_transform(NRArenaGroup *group, NR::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 c0c53f0ee..a2050f75c 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -93,7 +93,7 @@ nr_arena_image_init (NRArenaImage *image) image->width = 256.0; image->height = 256.0; - nr_matrix_set_identity (&image->grid2px); + image->grid2px.set_identity(); image->style = 0; } @@ -111,7 +111,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*/ ) { - NRMatrix grid2px; + NR::Matrix grid2px; NRArenaImage *image = NR_ARENA_IMAGE (item); @@ -119,7 +119,7 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned nr_arena_item_request_render (item); /* Copy affine */ - nr_matrix_invert (&grid2px, &gc->transform); + grid2px = gc->transform.inverse(); double hscale, vscale; // todo: replace with NR::scale if (image->px) { hscale = image->pxw / image->width; @@ -129,12 +129,12 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned vscale = 1.0; } - image->grid2px[0] = grid2px.c[0] * hscale; - image->grid2px[2] = grid2px.c[2] * hscale; - image->grid2px[4] = grid2px.c[4] * hscale; - image->grid2px[1] = grid2px.c[1] * vscale; - image->grid2px[3] = grid2px.c[3] * vscale; - image->grid2px[5] = grid2px.c[5] * vscale; + image->grid2px[0] = grid2px[0] * hscale; + image->grid2px[2] = grid2px[2] * hscale; + image->grid2px[4] = grid2px[4] * hscale; + image->grid2px[1] = grid2px[1] * vscale; + image->grid2px[3] = grid2px[3] * vscale; + image->grid2px[5] = grid2px[5] * vscale; image->grid2px[4] -= image->x * hscale; image->grid2px[5] -= image->y * vscale; diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 95b0c0eae..f04146f20 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -20,6 +20,8 @@ #include #include +#include +#include #include "nr-arena.h" #include "nr-arena-item.h" #include "gc-core.h" @@ -245,8 +247,7 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, /* Set up local gc */ childgc = *gc; if (item->transform) { - nr_matrix_multiply (&childgc.transform, item->transform, - &childgc.transform); + childgc.transform = (*item->transform) * childgc.transform; } /* Remember the transformation matrix */ item->ctm = childgc.transform; @@ -710,12 +711,12 @@ nr_arena_item_append_child (NRArenaItem *parent, NRArenaItem *child) void nr_arena_item_set_transform (NRArenaItem *item, NR::Matrix const &transform) { - NRMatrix const t (transform); + NR::Matrix const t (transform); nr_arena_item_set_transform (item, &t); } void -nr_arena_item_set_transform (NRArenaItem *item, NRMatrix const *transform) +nr_arena_item_set_transform (NRArenaItem *item, NR::Matrix const *transform) { nr_return_if_fail (item != NULL); nr_return_if_fail (NR_IS_ARENA_ITEM (item)); @@ -723,17 +724,17 @@ nr_arena_item_set_transform (NRArenaItem *item, NRMatrix const *transform) if (!transform && !item->transform) return; - const NRMatrix *md = (item->transform) ? item->transform : &NR_MATRIX_IDENTITY; - const NRMatrix *ms = (transform) ? transform : &NR_MATRIX_IDENTITY; + const NR::Matrix *md = (item->transform) ? item->transform : &NR_MATRIX_IDENTITY; + const NR::Matrix *ms = (transform) ? transform : &NR_MATRIX_IDENTITY; - if (!NR_MATRIX_DF_TEST_CLOSE (md, ms, NR_EPSILON)) { + if (!NR::matrix_equalp(*md, *ms, NR_EPSILON)) { nr_arena_item_request_render (item); - if (!transform || nr_matrix_test_identity (transform, NR_EPSILON)) { + if (!transform || transform->test_identity()) { /* Set to identity affine */ item->transform = NULL; } else { if (!item->transform) - item->transform = new (GC::ATOMIC) NRMatrix (); + item->transform = new (GC::ATOMIC) NR::Matrix (); *item->transform = *transform; } nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, TRUE); diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 6ca1564a1..c62c9a6ca 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -64,7 +64,7 @@ struct NRGC { NRGC(NRGC const *p) : parent(p) {} NRGC const *parent; - NRMatrix transform; + NR::Matrix transform; }; struct NRArenaItem : public NRObject { @@ -93,7 +93,7 @@ struct NRArenaItem : public NRObject { * specified in SVG standard. Required by filters. */ NR::Maybe item_bbox; /* Our affine */ - NRMatrix *transform; + NR::Matrix *transform; /* Clip item */ NRArenaItem *clip; /* Mask item */ @@ -170,7 +170,7 @@ 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, NRMatrix const *transform); +void nr_arena_item_set_transform(NRArenaItem *item, NR::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); diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 9150b419f..8e53e7262 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -106,7 +106,7 @@ nr_arena_shape_init(NRArenaShape *shape) shape->paintbox.x0 = shape->paintbox.y0 = 0.0F; shape->paintbox.x1 = shape->paintbox.y1 = 256.0F; - nr_matrix_set_identity(&shape->ctm); + shape->ctm.set_identity(); shape->fill_painter = NULL; shape->stroke_painter = NULL; shape->cached_fill = NULL; @@ -120,8 +120,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; - nr_matrix_set_identity(&shape->cached_fctm); - nr_matrix_set_identity(&shape->cached_sctm); + shape->cached_fctm.set_identity(); + shape->cached_sctm.set_identity(); shape->markers = NULL; @@ -284,7 +284,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g nr_path_matrix_bbox_union(&bp, gc->transform, &bbox); if (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE || outline) { float width, scale; - scale = NR_MATRIX_DF_EXPANSION(&gc->transform); + scale = NR::expansion(gc->transform); 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 bbox.x0-=width; @@ -311,7 +311,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if ( area && nr_rect_l_test_intersect(area, &shape->approx_bbox) ) shape->delayed_shp=false; /* Release state data */ - if (TRUE || !nr_matrix_test_transform_equal(&gc->transform, &shape->ctm, NR_EPSILON)) { + if (TRUE || !NR::transform_equalp(gc->transform, shape->ctm, NR_EPSILON)) { /* Concept test */ if (shape->fill_shp) { delete shape->fill_shp; @@ -369,7 +369,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if ( shape->_fill.paint.type() == NRArenaShape::Paint::SERVER ) { if (gc && gc->parent) { shape->fill_painter = sp_paint_server_painter_new(shape->_fill.paint.server(), - NR::Matrix(&gc->transform), NR::Matrix(&gc->parent->transform), + gc->transform, gc->parent->transform, &shape->paintbox); } item->render_opacity = FALSE; @@ -377,7 +377,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g if ( shape->_stroke.paint.type() == NRArenaShape::Paint::SERVER ) { if (gc && gc->parent) { shape->stroke_painter = sp_paint_server_painter_new(shape->_stroke.paint.server(), - NR::Matrix(&gc->transform), NR::Matrix(&gc->parent->transform), + gc->transform, gc->parent->transform, &shape->paintbox); } item->render_opacity = FALSE; @@ -519,7 +519,7 @@ nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc, NRRectL *area) { SPStyle* style = shape->style; - float const scale = NR_MATRIX_DF_EXPANSION(&gc->transform); + float const scale = NR::expansion(gc->transform); bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE); @@ -763,7 +763,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_MATRIX_DF_EXPANSION(shape->ctm); + float const scale = NR::expansion(shape->ctm); if (fabs(shape->_stroke.width * scale) < 0.01) return; @@ -1095,7 +1095,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_MATRIX_DF_EXPANSION(&shape->ctm); + float const scale = NR::expansion(shape->ctm); width = MAX(0.125, shape->_stroke.width * scale) / 2; } else { width = 0; diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index ecf0e8def..886ee118e 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -13,6 +13,7 @@ #include "display/nr-filter-types.h" #include "display/nr-filter-units.h" #include "libnr/nr-blit.h" +#include "libnr/nr-matrix-fns.h" #include "libnr/nr-pixops.h" namespace NR { @@ -77,8 +78,8 @@ int FilterDisplacementMap::render(FilterSlot &slot, FilterUnits const &units) { double coordx, coordy; Matrix trans = units.get_matrix_primitiveunits2pb(); - double scalex = scale*trans.expansionX(); - double scaley = scale*trans.expansionY(); + double scalex = scale*NR::expansionX(trans); + double scaley = scale*NR::expansionY(trans); for (x=0; x < out_w; x++){ for (y=0; y < out_h; y++){ diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index b4d1fb00d..5ef430394 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -28,6 +28,7 @@ #include "display/nr-filter-units.h" #include "libnr/nr-pixblock.h" #include "libnr/nr-matrix.h" +#include "libnr/nr-matrix-fns.h" #include "util/fixed_point.h" #include "prefs-utils.h" @@ -539,8 +540,8 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units) // Some common constants int const width_org = in->area.x1-in->area.x0, height_org = in->area.y1-in->area.y0; - double const deviation_x_org = _deviation_x * trans.expansionX(); - double const deviation_y_org = _deviation_y * trans.expansionY(); + double const deviation_x_org = _deviation_x * NR::expansionX(trans); + double const deviation_y_org = _deviation_y * NR::expansionY(trans); int const PC = NR_PIXBLOCK_BPP(in); // Subsampling constants @@ -774,8 +775,8 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units) void FilterGaussian::area_enlarge(NRRectL &area, Matrix const &trans) { - int area_x = _effect_area_scr(_deviation_x * trans.expansionX()); - int area_y = _effect_area_scr(_deviation_y * trans.expansionY()); + int area_x = _effect_area_scr(_deviation_x * NR::expansionX(trans)); + int area_y = _effect_area_scr(_deviation_y * NR::expansionY(trans)); // maximum is used because rotations can mix up these directions // TODO: calculate a more tight-fitting rendering area int area_max = std::max(area_x, area_y); diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 42b78fa16..1eeb3e8c6 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -80,10 +80,9 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { NRGC gc(NULL); /* Update to renderable state */ double sf = 1.0; - NRMatrix t; - nr_matrix_set_scale(&t, sf, sf); + NR::Matrix t(NR::scale(sf, sf)); nr_arena_item_set_transform(ai, &t); - nr_matrix_set_identity(&gc.transform); + gc.transform.set_identity(); 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-units.cpp b/src/display/nr-filter-units.cpp index 5b7bcdd4e..6836e39af 100644 --- a/src/display/nr-filter-units.cpp +++ b/src/display/nr-filter-units.cpp @@ -13,6 +13,9 @@ #include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" +#include "libnr/nr-matrix-fns.h" +#include "libnr/nr-matrix-ops.h" +#include "libnr/nr-matrix-scale-ops.h" #include "libnr/nr-rect.h" #include "libnr/nr-rect-l.h" #include "libnr/nr-scale.h" @@ -139,7 +142,7 @@ Matrix FilterUnits::get_matrix_user2units(SPFilterUnits units) const { 0, scale_y, min[X] * scale_x, min[Y] * scale_y); } else if (units == SP_FILTER_UNITS_USERSPACEONUSE) { - return Matrix(NULL); + return identity(); } else { g_warning("Error in NR::FilterUnits::get_matrix_user2units: unrecognized unit type (%d)", units); return Matrix(); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 6027b5f27..7423bb7f3 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -111,7 +111,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) return 1; } - Matrix trans = *item->ctm; + Matrix trans = item->ctm; FilterSlot slot(_slot_count, item); Rect item_bbox; diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index e94805831..a3c7839c7 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -76,7 +76,7 @@ static void sp_ctrlline_init (SPCtrlLine *ctrlline) { ctrlline->rgba = 0x0000ff7f; - ctrlline->s.x = ctrlline->s.y = ctrlline->e.x = ctrlline->e.y = 0.0; + ctrlline->s[NR::X] = ctrlline->s[NR::Y] = ctrlline->e[NR::X] = ctrlline->e[NR::Y] = 0.0; ctrlline->shp=NULL; ctrlline->item=NULL; } @@ -180,8 +180,8 @@ sp_ctrlline_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int f cl->shp = NULL; } Path* thePath = new Path; - thePath->MoveTo(NR::Point(cl->s.x, cl->s.y) * affine); - thePath->LineTo(NR::Point(cl->e.x, cl->e.y) * affine); + thePath->MoveTo(NR::Point(cl->s[NR::X], cl->s[NR::Y]) * affine); + thePath->LineTo(NR::Point(cl->e[NR::X], cl->e[NR::Y]) * affine); NRRectL area; area.x0=(NR::ICoord)(double)item->x1; @@ -236,11 +236,11 @@ sp_ctrlline_set_coords (SPCtrlLine *cl, gdouble x0, gdouble y0, gdouble x1, gdou g_return_if_fail (cl != NULL); g_return_if_fail (SP_IS_CTRLLINE (cl)); - if (DIFFER (x0, cl->s.x) || DIFFER (y0, cl->s.y) || DIFFER (x1, cl->e.x) || DIFFER (y1, cl->e.y)) { - cl->s.x = x0; - cl->s.y = y0; - cl->e.x = x1; - cl->e.y = y1; + if (DIFFER (x0, cl->s[NR::X]) || DIFFER (y0, cl->s[NR::Y]) || DIFFER (x1, cl->e[NR::X]) || DIFFER (y1, cl->e[NR::Y])) { + cl->s[NR::X] = x0; + cl->s[NR::Y] = y0; + cl->e[NR::X] = x1; + cl->e[NR::Y] = y1; sp_canvas_item_request_update (SP_CANVAS_ITEM (cl)); } } diff --git a/src/display/sp-ctrlline.h b/src/display/sp-ctrlline.h index d7863bf19..3c83388d8 100644 --- a/src/display/sp-ctrlline.h +++ b/src/display/sp-ctrlline.h @@ -27,7 +27,7 @@ struct SPItem; struct SPCtrlLine : public SPCanvasItem{ SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users guint32 rgba; - NRPoint s, e; + NR::Point s, e; Shape* shp; }; struct SPCtrlLineClass : public SPCanvasItemClass{}; diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 5c11aa50c..66e8a40fb 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -257,7 +257,7 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv NR::Point const cd = desktop->w2d(dc->centre); NR::Matrix const w2dt = desktop->w2d(); - const double scale = rw * NR_MATRIX_DF_EXPANSION(&w2dt); + const double scale = rw * NR::expansion(w2dt); NR::Matrix const sm( NR::scale(scale, scale) * NR::translate(cd) ); sp_canvas_item_affine_absolute(dc->area, sm); sp_canvas_item_show(dc->area); diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 0c7cdb92e..5fdb47835 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -129,7 +129,7 @@ Implementation::finish(Inkscape::Extension::Print */*module*/) /* Rendering methods */ unsigned int -Implementation::bind(Inkscape::Extension::Print */*module*/, NRMatrix const */*transform*/, float /*opacity*/) +Implementation::bind(Inkscape::Extension::Print */*module*/, NR::Matrix const */*transform*/, float /*opacity*/) { return 0; } @@ -147,14 +147,14 @@ Implementation::comment(Inkscape::Extension::Print */*module*/, char const */*co } unsigned int -Implementation::fill(Inkscape::Extension::Print */*module*/, NRBPath const */*bpath*/, NRMatrix const */*ctm*/, SPStyle const */*style*/, +Implementation::fill(Inkscape::Extension::Print */*module*/, NRBPath const */*bpath*/, NR::Matrix const */*ctm*/, SPStyle const */*style*/, NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) { return 0; } unsigned int -Implementation::stroke(Inkscape::Extension::Print */*module*/, NRBPath const */*bpath*/, NRMatrix const */*transform*/, SPStyle const */*style*/, +Implementation::stroke(Inkscape::Extension::Print */*module*/, NRBPath const */*bpath*/, NR::Matrix const */*transform*/, SPStyle const */*style*/, NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/) { return 0; @@ -162,7 +162,7 @@ Implementation::stroke(Inkscape::Extension::Print */*module*/, NRBPath const */* unsigned int Implementation::image(Inkscape::Extension::Print */*module*/, unsigned char */*px*/, unsigned int /*w*/, unsigned int /*h*/, unsigned int /*rs*/, - NRMatrix const */*transform*/, SPStyle const */*style*/) + NR::Matrix const */*transform*/, SPStyle const */*style*/) { return 0; } diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index f2855a168..caa4a89bd 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -99,20 +99,20 @@ public: /* ----- Rendering methods ----- */ virtual unsigned bind(Inkscape::Extension::Print *module, - NRMatrix const *transform, + NR::Matrix const *transform, float opacity); virtual unsigned release(Inkscape::Extension::Print *module); virtual unsigned comment(Inkscape::Extension::Print *module, const char * comment); virtual unsigned fill(Inkscape::Extension::Print *module, NRBPath const *bpath, - NRMatrix const *ctm, + NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); virtual unsigned stroke(Inkscape::Extension::Print *module, NRBPath const *bpath, - NRMatrix const *transform, + NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, @@ -122,7 +122,7 @@ public: unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *transform, + NR::Matrix const *transform, SPStyle const *style); virtual unsigned text(Inkscape::Extension::Print *module, char const *text, diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index d7fbbc1aa..a040d5c09 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -801,7 +802,7 @@ CairoRenderContext::finish(void) } void -CairoRenderContext::transform(NRMatrix const *transform) +CairoRenderContext::transform(NR::Matrix const *transform) { g_assert( _is_valid ); @@ -814,7 +815,7 @@ CairoRenderContext::transform(NRMatrix const *transform) } void -CairoRenderContext::setTransform(NRMatrix const *transform) +CairoRenderContext::setTransform(NR::Matrix const *transform) { g_assert( _is_valid ); @@ -825,7 +826,7 @@ CairoRenderContext::setTransform(NRMatrix const *transform) } void -CairoRenderContext::getTransform(NRMatrix *copy) const +CairoRenderContext::getTransform(NR::Matrix *copy) const { g_assert( _is_valid ); @@ -840,12 +841,12 @@ CairoRenderContext::getTransform(NRMatrix *copy) const } void -CairoRenderContext::getParentTransform(NRMatrix *copy) const +CairoRenderContext::getParentTransform(NR::Matrix *copy) const { g_assert( _is_valid ); CairoRenderState *parent_state = getParentState(); - memcpy(copy, &parent_state->transform, sizeof(NRMatrix)); + memcpy(copy, &parent_state->transform, sizeof(NR::Matrix)); } void @@ -893,9 +894,9 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver SPPattern *pat = SP_PATTERN (paintserver); - NRMatrix ps2user, pcs2dev; - nr_matrix_set_identity(&ps2user); - nr_matrix_set_identity(&pcs2dev); + NR::Matrix ps2user, pcs2dev; + ps2user.set_identity(); + pcs2dev.set_identity(); double x = pattern_x(pat); double y = pattern_y(pat); @@ -920,8 +921,8 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver } // apply pattern transformation - NRMatrix pattern_transform(pattern_patternTransform(pat)); - nr_matrix_multiply(&ps2user, &ps2user, &pattern_transform); + NR::Matrix pattern_transform(pattern_patternTransform(pat)); + ps2user *= pattern_transform; // create pattern contents coordinate system if (pat->viewBox_set) { @@ -949,8 +950,8 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // calculate the size of the surface which has to be created // the scaling needs to be taken into account in the ctm after the pattern transformation - NRMatrix temp; - nr_matrix_multiply(&temp, &pattern_transform, &_state->transform); + NR::Matrix temp; + temp = pattern_transform * _state->transform; double width_scaler = sqrt(temp[0] * temp[0] + temp[2] * temp[2]); double height_scaler = sqrt(temp[1] * temp[1] + temp[3] * temp[3]); @@ -971,12 +972,8 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver double scale_height = surface_height / (bbox_height_scaler * height); if (scale_width != 1.0 || scale_height != 1.0 || _vector_based_target) { TRACE(("needed to scale with %f %f\n", scale_width, scale_height)); - NRMatrix scale; - nr_matrix_set_scale(&scale, 1.0 / scale_width, 1.0 / scale_height); - nr_matrix_multiply(&pcs2dev, &pcs2dev, &scale); - - nr_matrix_set_scale(&scale, scale_width, scale_height); - nr_matrix_multiply(&ps2user, &ps2user, &scale); + pcs2dev *= NR::scale(1.0 / scale_width, 1.0 / scale_height); + ps2user *= NR::scale(scale_width, scale_height); } pattern_ctx->setTransform(&pcs2dev); @@ -1301,7 +1298,7 @@ CairoRenderContext::renderPath(NRBPath const *bpath, SPStyle const *style, NRRec bool CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *image_transform, SPStyle const *style) + NR::Matrix const *image_transform, SPStyle const *style) { g_assert( _is_valid ); @@ -1416,7 +1413,7 @@ CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont *font, std::vector const &glyphtext, SPStyle const *style) { // create a cairo_font_face from PangoFont @@ -1538,7 +1535,7 @@ CairoRenderContext::_concatTransform(cairo_t *cr, double xx, double yx, double x } void -CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, NRMatrix const *transform) +CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, NR::Matrix const *transform) { matrix->xx = (*transform)[0]; matrix->yx = (*transform)[1]; @@ -1549,7 +1546,7 @@ CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, NRMatrix const *tra } void -CairoRenderContext::_concatTransform(cairo_t *cr, NRMatrix const *transform) +CairoRenderContext::_concatTransform(cairo_t *cr, NR::Matrix const *transform) { _concatTransform(cr, (*transform)[0], (*transform)[1], (*transform)[2], (*transform)[3], diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index 595043467..948efc438 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -58,7 +58,7 @@ struct CairoRenderState { SPClipPath *clip_path; SPMask* mask; - NRMatrix transform; // the CTM + NR::Matrix transform; // the CTM }; class CairoRenderContext { @@ -126,10 +126,10 @@ public: CairoRenderState *getParentState(void) const; void setStateForStyle(SPStyle const *style); - void transform(NRMatrix const *transform); - void setTransform(NRMatrix const *transform); - void getTransform(NRMatrix *copy) const; - void getParentTransform(NRMatrix *copy) const; + void transform(NR::Matrix const *transform); + void setTransform(NR::Matrix const *transform); + void getTransform(NR::Matrix *copy) const; + void getParentTransform(NR::Matrix *copy) const; /* Clipping methods */ void addClipPath(NArtBpath const *bp, SPIEnum const *fill_rule); @@ -138,8 +138,8 @@ public: /* Rendering methods */ bool renderPath(NRBPath const *bpath, SPStyle const *style, NRRect const *pbox); bool renderImage(unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *image_transform, SPStyle const *style); - bool renderGlyphtext(PangoFont *font, NRMatrix const *font_matrix, + NR::Matrix const *image_transform, SPStyle const *style); + bool renderGlyphtext(PangoFont *font, NR::Matrix const *font_matrix, std::vector const &glyphtext, SPStyle const *style); /* More general rendering methods will have to be added (like fill, stroke) */ @@ -189,9 +189,9 @@ protected: void _setFillStyle(SPStyle const *style, NRRect const *pbox); void _setStrokeStyle(SPStyle const *style, NRRect const *pbox); - void _initCairoMatrix(cairo_matrix_t *matrix, NRMatrix const *transform); + void _initCairoMatrix(cairo_matrix_t *matrix, NR::Matrix const *transform); void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0); - void _concatTransform(cairo_t *cr, NRMatrix const *transform); + void _concatTransform(cairo_t *cr, NR::Matrix const *transform); CairoRenderState *_createState(void); }; diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 1d103fed2..f13e26abb 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -133,7 +133,7 @@ CairoRenderer::createContext(void) // create initial render state CairoRenderState *state = new_context->_createState(); - nr_matrix_set_identity(&state->transform); + state->transform.set_identity(); new_context->_state_stack = g_slist_prepend(new_context->_state_stack, state); new_context->_state = state; @@ -226,12 +226,11 @@ static void sp_group_render(SPItem *item, CairoRenderContext *ctx) static void sp_use_render(SPItem *item, CairoRenderContext *ctx) { bool translated = false; - NRMatrix tp; SPUse *use = SP_USE(item); CairoRenderer *renderer = ctx->getRenderer(); if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { - nr_matrix_set_translate(&tp, use->x.computed, use->y.computed); + NR::Matrix tp(NR::translate(use->x.computed, use->y.computed)); ctx->pushState(); ctx->transform(&tp); translated = true; @@ -261,7 +260,6 @@ static void sp_flowtext_render(SPItem *item, CairoRenderContext *ctx) static void sp_image_render(SPItem *item, CairoRenderContext *ctx) { SPImage *image; - NRMatrix tp, s, t; guchar *px; int w, h, rs; @@ -289,9 +287,9 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx) ctx->addClippingRect(image->x.computed, image->y.computed, image->width.computed, image->height.computed); } - nr_matrix_set_translate (&tp, x, y); - nr_matrix_set_scale (&s, width / (double)w, height / (double)h); - nr_matrix_multiply (&t, &s, &tp); + NR::translate tp(x, y); + NR::scale s(width / (double)w, height / (double)h); + NR::Matrix t(s * tp); ctx->renderImage (px, w, h, rs, &t, SP_OBJECT_STYLE (item)); } @@ -308,7 +306,7 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) // apply viewbox if set if (0 /*symbol->viewBox_set*/) { - NRMatrix vb2user; + NR::Matrix vb2user; double x, y, width, height; double view_width, view_height; x = 0.0; @@ -323,7 +321,7 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) &x, &y,&width, &height); // [itemTransform *] translate(x, y) * scale(w/vw, h/vh) * translate(-vx, -vy); - nr_matrix_set_identity(&vb2user); + vb2user.set_identity(); vb2user[0] = width / view_width; vb2user[3] = height / view_height; vb2user[4] = x - symbol->viewBox.x0 * vb2user[0]; @@ -346,7 +344,7 @@ static void sp_root_render(SPItem *item, CairoRenderContext *ctx) ctx->pushState(); renderer->setStateForItem(ctx, item); - ctx->transform(root->c2p); + ctx->transform(&root->c2p); sp_group_render(item, ctx); ctx->popState(); } @@ -448,10 +446,10 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) unsigned int w = gdk_pixbuf_get_width(pb); unsigned int h = gdk_pixbuf_get_height(pb); unsigned int rs = gdk_pixbuf_get_rowstride(pb); - NRMatrix matrix; + NR::Matrix matrix; matrix = t; //matrix = ((NR::Matrix)ctx->getCurrentState()->transform).inverse(); - //nr_matrix_set_identity(&matrix); + //matrix.set_identity(); ctx->renderImage (px, w, h, rs, &matrix, SP_OBJECT_STYLE (item)); /* @@ -556,7 +554,7 @@ CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) state->merge_opacity = FALSE; ctx->pushLayer(); } - ctx->transform(item->transform); + ctx->transform(&item->transform); sp_item_invoke_render(item, ctx); if (state->need_layer) @@ -614,15 +612,14 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) CairoRenderContext::CairoRenderMode saved_mode = ctx->getRenderMode(); ctx->setRenderMode(CairoRenderContext::RENDER_MODE_CLIP); - NRMatrix saved_ctm; + NR::Matrix saved_ctm; if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - NRMatrix t; //SP_PRINT_DRECT("clipd", cp->display->bbox); NRRect clip_bbox(cp->display->bbox); - nr_matrix_set_scale(&t, clip_bbox.x1 - clip_bbox.x0, clip_bbox.y1 - clip_bbox.y0); - t.c[4] = clip_bbox.x0; - t.c[5] = clip_bbox.y0; - nr_matrix_multiply(&t, &t, &ctx->getCurrentState()->transform); + NR::Matrix t(NR::scale(clip_bbox.x1 - clip_bbox.x0, clip_bbox.y1 - clip_bbox.y0)); + t[4] = clip_bbox.x0; + t[5] = clip_bbox.y0; + t *= ctx->getCurrentState()->transform; ctx->getTransform(&saved_ctm); ctx->setTransform(&t); } @@ -660,11 +657,10 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) NRRect mask_bbox(mask->display->bbox); // TODO: should the bbox be transformed if maskUnits != userSpaceOnUse ? if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - NRMatrix t; - nr_matrix_set_scale(&t, mask_bbox.x1 - mask_bbox.x0, mask_bbox.y1 - mask_bbox.y0); - t.c[4] = mask_bbox.x0; - t.c[5] = mask_bbox.y0; - nr_matrix_multiply(&t, &t, &ctx->getCurrentState()->transform); + NR::Matrix t(NR::scale(mask_bbox.x1 - mask_bbox.x0, mask_bbox.y1 - mask_bbox.y0)); + t[4] = mask_bbox.x0; + t[5] = mask_bbox.y0; + t *= ctx->getCurrentState()->transform; ctx->setTransform(&t); } diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 6b2fd912c..d486a7803 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -279,7 +279,7 @@ PrintEmfWin32::destroy_brush() void -PrintEmfWin32::create_pen(SPStyle const *style, const NRMatrix *transform) +PrintEmfWin32::create_pen(SPStyle const *style, const NR::Matrix *transform) { if (style) { float rgb[3]; @@ -471,7 +471,7 @@ PrintEmfWin32::cmp_bpath(const NArtBpath *bp1, const NArtBpath *bp2) } unsigned int -PrintEmfWin32::bind(Inkscape::Extension::Print *mod, NRMatrix const *transform, float opacity) +PrintEmfWin32::bind(Inkscape::Extension::Print *mod, NR::Matrix const *transform, float opacity) { text_transform = *transform; return 0; @@ -485,7 +485,7 @@ PrintEmfWin32::release(Inkscape::Extension::Print *mod) unsigned int PrintEmfWin32::fill(Inkscape::Extension::Print *mod, - NRBPath const *bpath, NRMatrix const *transform, SPStyle const *style, + NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!hdc) return 0; @@ -512,7 +512,7 @@ PrintEmfWin32::fill(Inkscape::Extension::Print *mod, unsigned int PrintEmfWin32::stroke (Inkscape::Extension::Print *mod, - const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style, + const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { if (!hdc) return 0; @@ -548,7 +548,7 @@ PrintEmfWin32::stroke (Inkscape::Extension::Print *mod, unsigned int -PrintEmfWin32::print_bpath(const NArtBpath *bp, const NRMatrix *transform, NRRect const *pbox) +PrintEmfWin32::print_bpath(const NArtBpath *bp, const NR::Matrix *transform, NRRect const *pbox) { unsigned int closed; NR::Matrix tf = *transform; diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h index 26ffc1807..fdf0cd490 100644 --- a/src/extension/internal/emf-win32-print.h +++ b/src/extension/internal/emf-win32-print.h @@ -44,11 +44,11 @@ class PrintEmfWin32 : public Inkscape::Extension::Implementation::Implementation NArtBpath *fill_path; NArtBpath *fill_path_copy; - NRMatrix fill_transform; + NR::Matrix fill_transform; NRRect fill_pbox; - NRMatrix text_transform; + NR::Matrix text_transform; - unsigned int print_bpath (const NArtBpath *bp, const NRMatrix *transform, NRRect const *pbox); + unsigned int print_bpath (const NArtBpath *bp, const NR::Matrix *transform, NRRect const *pbox); public: PrintEmfWin32 (void); @@ -61,13 +61,13 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, NRMatrix const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); virtual unsigned int fill (Inkscape::Extension::Print * module, - const NRBPath *bpath, const NRMatrix *ctm, const SPStyle *style, + const NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int stroke (Inkscape::Extension::Print * module, - const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style, + const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); virtual unsigned int text(Inkscape::Extension::Print *module, char const *text, @@ -81,7 +81,7 @@ protected: void destroy_brush(); - void create_pen(SPStyle const *style, const NRMatrix *transform); + void create_pen(SPStyle const *style, const NR::Matrix *transform); void destroy_pen(); diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 116cccb3b..1baa06991 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -171,7 +171,7 @@ PrintLatex::finish (Inkscape::Extension::Print *mod) } unsigned int -PrintLatex::bind(Inkscape::Extension::Print *mod, NRMatrix const *transform, float opacity) +PrintLatex::bind(Inkscape::Extension::Print *mod, NR::Matrix const *transform, float opacity) { NR::Matrix tr = *transform; @@ -201,7 +201,7 @@ unsigned int PrintLatex::comment (Inkscape::Extension::Print * module, unsigned int PrintLatex::fill(Inkscape::Extension::Print *mod, - NRBPath const *bpath, NRMatrix const *transform, SPStyle const *style, + NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -228,7 +228,7 @@ PrintLatex::fill(Inkscape::Extension::Print *mod, } unsigned int -PrintLatex::stroke (Inkscape::Extension::Print *mod, const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style, +PrintLatex::stroke (Inkscape::Extension::Print *mod, const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -271,7 +271,7 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, const NRBPath *bpath, const } void -PrintLatex::print_bpath(SVGOStringStream &os, const NArtBpath *bp, const NRMatrix *transform) +PrintLatex::print_bpath(SVGOStringStream &os, const NArtBpath *bp, const NR::Matrix *transform) { unsigned int closed; NR::Matrix tf=*transform; diff --git a/src/extension/internal/latex-pstricks.h b/src/extension/internal/latex-pstricks.h index 0e1500630..c418eaf5b 100644 --- a/src/extension/internal/latex-pstricks.h +++ b/src/extension/internal/latex-pstricks.h @@ -33,7 +33,7 @@ class PrintLatex : public Inkscape::Extension::Implementation::Implementation { std::stack m_tr_stack; - void print_bpath (SVGOStringStream &os, const NArtBpath *bp, const NRMatrix *transform); + void print_bpath (SVGOStringStream &os, const NArtBpath *bp, const NR::Matrix *transform); public: PrintLatex (void); @@ -46,12 +46,12 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, NRMatrix const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); - virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *ctm, const SPStyle *style, + virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); - virtual unsigned int stroke (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style, + virtual unsigned int stroke (Inkscape::Extension::Print * module, const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); bool textToPath (Inkscape::Extension::Print * ext); diff --git a/src/extension/internal/pdf-cairo.cpp b/src/extension/internal/pdf-cairo.cpp index f189d6b6b..019a8f710 100644 --- a/src/extension/internal/pdf-cairo.cpp +++ b/src/extension/internal/pdf-cairo.cpp @@ -379,7 +379,7 @@ PrintCairoPDF::finish(Inkscape::Extension::Print *mod) } unsigned int -PrintCairoPDF::bind(Inkscape::Extension::Print *mod, NRMatrix const *transform, float opacity) +PrintCairoPDF::bind(Inkscape::Extension::Print *mod, NR::Matrix const *transform, float opacity) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. if (_bitmap) return 0; @@ -389,11 +389,11 @@ PrintCairoPDF::bind(Inkscape::Extension::Print *mod, NRMatrix const *transform, } else { cairo_save(cr); } - _concat_transform(cr, transform->c[0], transform->c[1], transform->c[2], transform->c[3], transform->c[4], transform->c[5]); + _concat_transform(cr, (*transform)[0], (*transform)[1], (*transform)[2], (*transform)[3], (*transform)[4], (*transform)[5]); // printf("bind: (%f) %f %f %f %f %f %f\n", opacity, transform->c[0], transform->c[1], transform->c[2], transform->c[3], transform->c[4], transform->c[5]); // remember these to be able to undo them when outputting text - _last_tx = transform->c[4]; - _last_ty = transform->c[5]; + _last_tx = (*transform)[4]; + _last_ty = (*transform)[5]; _alpha_stack.push_back(opacity); @@ -560,7 +560,7 @@ PrintCairoPDF::print_fill_style(cairo_t *cr, SPStyle const *const style, NRRect } unsigned int -PrintCairoPDF::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *const style, +PrintCairoPDF::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *const style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -660,7 +660,7 @@ PrintCairoPDF::print_stroke_style(cairo_t *cr, SPStyle const *style, NRRect cons } unsigned int -PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *style, +PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -684,7 +684,7 @@ PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRM unsigned int PrintCairoPDF::image(Inkscape::Extension::Print *mod, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *transform, SPStyle const *style) + NR::Matrix const *transform, SPStyle const *style) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. if (_bitmap) return 0; @@ -728,9 +728,9 @@ PrintCairoPDF::image(Inkscape::Extension::Print *mod, guchar *px, unsigned int w // we have to translate down by height also in order to eliminate the last translation done by sp_image_print cairo_matrix_t matrix; cairo_matrix_init(&matrix, - transform->c[0]/w, transform->c[1], - transform->c[2], -transform->c[3]/h, - transform->c[4], transform->c[5] + transform->c[3]); + (*transform)[0]/w, (*transform)[1], + (*transform)[2], -(*transform)[3]/h, + (*transform)[4], (*transform)[5] + (*transform)[3]); cairo_transform(cr, &matrix); cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image_surface); diff --git a/src/extension/internal/pdf-cairo.h b/src/extension/internal/pdf-cairo.h index f18a15d86..185f86727 100644 --- a/src/extension/internal/pdf-cairo.h +++ b/src/extension/internal/pdf-cairo.h @@ -75,15 +75,15 @@ public: virtual unsigned int finish(Inkscape::Extension::Print *module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, NRMatrix const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment); - virtual unsigned int fill(Inkscape::Extension::Print *module, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *style, + virtual unsigned int fill(Inkscape::Extension::Print *module, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); - virtual unsigned int stroke(Inkscape::Extension::Print *module, NRBPath const *bpath, NRMatrix const *transform, SPStyle const *style, + virtual unsigned int stroke(Inkscape::Extension::Print *module, NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *transform, SPStyle const *style); + NR::Matrix const *transform, SPStyle const *style); virtual unsigned int text(Inkscape::Extension::Print *module, char const *text, NR::Point p, SPStyle const *style); diff --git a/src/extension/internal/ps.cpp b/src/extension/internal/ps.cpp index 6cc27988d..e6086aa81 100644 --- a/src/extension/internal/ps.cpp +++ b/src/extension/internal/ps.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -548,13 +549,13 @@ PrintPS::finish(Inkscape::Extension::Print *mod) int const width = (int) (_width * dots_per_pt + 0.5); int const height = (int) (_height * dots_per_pt + 0.5); - NRMatrix affine; - affine.c[0] = width / ((x1 - x0) * PX_PER_PT); - affine.c[1] = 0.0; - affine.c[2] = 0.0; - affine.c[3] = height / ((y1 - y0) * PX_PER_PT); - affine.c[4] = -affine.c[0] * x0; - affine.c[5] = -affine.c[3] * y0; + NR::Matrix affine; + affine[0] = width / ((x1 - x0) * PX_PER_PT); + affine[1] = 0.0; + affine[2] = 0.0; + affine[3] = height / ((y1 - y0) * PX_PER_PT); + affine[4] = -affine[0] * x0; + affine[5] = -affine[3] * y0; nr_arena_item_set_transform(mod->root, &affine); @@ -570,7 +571,7 @@ PrintPS::finish(Inkscape::Extension::Print *mod) /* Update to renderable state. */ NRGC gc(NULL); - nr_matrix_set_identity(&gc.transform); + gc.transform.set_identity(); nr_arena_item_invoke_update(mod->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); /* Render */ /* This should take guchar* instead of unsigned char*) */ @@ -581,13 +582,13 @@ PrintPS::finish(Inkscape::Extension::Print *mod) memset(px, 0xff, 4 * width * 64); nr_arena_item_invoke_render(NULL, mod->root, &bbox, &pb, 0); /* Blitter goes here */ - NRMatrix imgt; - imgt.c[0] = (bbox.x1 - bbox.x0) / dots_per_pt; - imgt.c[1] = 0.0; - imgt.c[2] = 0.0; - imgt.c[3] = (bbox.y1 - bbox.y0) / dots_per_pt; - imgt.c[4] = 0.0; - imgt.c[5] = _height - y / dots_per_pt - (bbox.y1 - bbox.y0) / dots_per_pt; + NR::Matrix imgt; + imgt[0] = (bbox.x1 - bbox.x0) / dots_per_pt; + imgt[1] = 0.0; + imgt[2] = 0.0; + imgt[3] = (bbox.y1 - bbox.y0) / dots_per_pt; + imgt[4] = 0.0; + imgt[5] = _height - y / dots_per_pt - (bbox.y1 - bbox.y0) / dots_per_pt; print_image(_stream, px, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0, 4 * width, &imgt); } @@ -628,18 +629,18 @@ PrintPS::finish(Inkscape::Extension::Print *mod) } unsigned int -PrintPS::bind(Inkscape::Extension::Print */*mod*/, NRMatrix const *transform, float /*opacity*/) +PrintPS::bind(Inkscape::Extension::Print */*mod*/, NR::Matrix const *transform, float /*opacity*/) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. if (_bitmap) return 0; Inkscape::SVGOStringStream os; - os << "gsave [" << transform->c[0] << " " - << transform->c[1] << " " - << transform->c[2] << " " - << transform->c[3] << " " - << transform->c[4] << " " - << transform->c[5] << "] concat\n"; + os << "gsave [" << (*transform)[0] << " " + << (*transform)[1] << " " + << (*transform)[2] << " " + << (*transform)[3] << " " + << (*transform)[4] << " " + << (*transform)[5] << "] concat\n"; return fprintf(_stream, "%s", os.str().c_str()); } @@ -733,7 +734,7 @@ PrintPS::print_fill_style(SVGOStringStream &os, SPStyle const *const style, NRRe pbox->x0, pbox->y0); c *= bbox2user; f *= bbox2user; - r *= bbox2user.expansion(); + r *= NR::expansion(bbox2user); } os << "<<\n/ShadingType 3\n/ColorSpace /DeviceRGB\n"; @@ -812,7 +813,7 @@ PrintPS::print_stroke_style(SVGOStringStream &os, SPStyle const *style) unsigned int -PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *const style, +PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *const style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -878,7 +879,7 @@ PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix co unsigned int -PrintPS::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *style, +PrintPS::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -901,7 +902,7 @@ PrintPS::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix unsigned int PrintPS::image(Inkscape::Extension::Print *mod, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *transform, SPStyle const *style) + NR::Matrix const *transform, SPStyle const *style) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. if (_bitmap) return 0; @@ -1634,18 +1635,18 @@ PrintPS::ascii85_done(SVGOStringStream &os) unsigned int PrintPS::print_image(FILE *ofp, guchar *px, unsigned int width, unsigned int height, unsigned int rs, - NRMatrix const *transform) + NR::Matrix const *transform) { Inkscape::SVGOStringStream os; os << "gsave\n"; - os << "[" << transform->c[0] << " " - << transform->c[1] << " " - << transform->c[2] << " " - << transform->c[3] << " " - << transform->c[4] << " " - << transform->c[5] << "] concat\n"; + os << "[" << (*transform)[0] << " " + << (*transform)[1] << " " + << (*transform)[2] << " " + << (*transform)[3] << " " + << (*transform)[4] << " " + << (*transform)[5] << "] concat\n"; /* Write read image procedure */ os << "<<\n"; diff --git a/src/extension/internal/ps.h b/src/extension/internal/ps.h index 673cde82c..1397063da 100644 --- a/src/extension/internal/ps.h +++ b/src/extension/internal/ps.h @@ -59,7 +59,7 @@ class PrintPS : public Inkscape::Extension::Implementation::Implementation { void print_glyphlist(SVGOStringStream &os, font_instance* font, Glib::ustring unistring); unsigned int print_image(FILE *ofp, guchar *px, unsigned int width, unsigned int height, unsigned int rs, - NRMatrix const *transform); + NR::Matrix const *transform); void compress_packbits(int nin, guchar *src, int *nout, guchar *dst); /* ASCII 85 variables */ @@ -88,15 +88,15 @@ public: virtual unsigned int finish(Inkscape::Extension::Print *module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, NRMatrix const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment); - virtual unsigned int fill(Inkscape::Extension::Print *module, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *style, + virtual unsigned int fill(Inkscape::Extension::Print *module, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); - virtual unsigned int stroke(Inkscape::Extension::Print *module, NRBPath const *bpath, NRMatrix const *transform, SPStyle const *style, + virtual unsigned int stroke(Inkscape::Extension::Print *module, NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *transform, SPStyle const *style); + NR::Matrix const *transform, SPStyle const *style); virtual unsigned int text(Inkscape::Extension::Print *module, char const *text, NR::Point p, SPStyle const *style); diff --git a/src/extension/internal/win32.cpp b/src/extension/internal/win32.cpp index 74635b2a6..b66308c9f 100644 --- a/src/extension/internal/win32.cpp +++ b/src/extension/internal/win32.cpp @@ -251,7 +251,7 @@ PrintWin32::finish (Inkscape::Extension::Print *mod) float scalex, scaley; int x0, y0, x1, y1; int width, height; - NRMatrix affine; + NR::Matrix affine; unsigned char *px; int sheight, row; BITMAPINFO bmInfo = { @@ -293,12 +293,12 @@ PrintWin32::finish (Inkscape::Extension::Print *mod) scaley = dpiY / 72.0; // We simply map document 0,0 to physical page 0,0 - affine.c[0] = scalex / 1.25; - affine.c[1] = 0.0; - affine.c[2] = 0.0; - affine.c[3] = scaley / 1.25; - affine.c[4] = 0.0; - affine.c[5] = 0.0; + affine[0] = scalex / 1.25; + affine[1] = 0.0; + affine[2] = 0.0; + affine[3] = scaley / 1.25; + affine[4] = 0.0; + affine[5] = 0.0; nr_arena_item_set_transform (mod->root, &affine); @@ -333,7 +333,7 @@ PrintWin32::finish (Inkscape::Extension::Print *mod) bbox.x1 = bbox.x0 + width; bbox.y1 = bbox.y0 + num_rows; /* Update to renderable state */ - nr_matrix_set_identity (&gc.transform); + gc.transform.set_identity(); nr_arena_item_invoke_update (mod->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox.x0, bbox.y0, bbox.x1, bbox.y1, px, 4 * (bbox.x1 - bbox.x0), FALSE, FALSE); diff --git a/src/extension/internal/win32.h b/src/extension/internal/win32.h index d46b5b2fb..6eb634f47 100644 --- a/src/extension/internal/win32.h +++ b/src/extension/internal/win32.h @@ -71,15 +71,15 @@ public: /* Rendering methods */ /* - virtual unsigned int bind (Inkscape::Extension::Print * module, const NRMatrix *transform, float opacity); + virtual unsigned int bind (Inkscape::Extension::Print * module, const NR::Matrix *transform, float opacity); virtual unsigned int release (Inkscape::Extension::Print * module); virtual unsigned int comment (Inkscape::Extension::Print * module, const char * comment); - virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *ctm, const SPStyle *style, + virtual unsigned int fill (Inkscape::Extension::Print * module, const NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); - virtual unsigned int stroke (Inkscape::Extension::Print * module, const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style, + virtual unsigned int stroke (Inkscape::Extension::Print * module, const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); virtual unsigned int image (Inkscape::Extension::Print * module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - const NRMatrix *transform, const SPStyle *style); + const NR::Matrix *transform, const SPStyle *style); */ }; diff --git a/src/extension/print.cpp b/src/extension/print.cpp index 6aed4da25..6f8c1afd2 100644 --- a/src/extension/print.cpp +++ b/src/extension/print.cpp @@ -61,7 +61,7 @@ Print::finish (void) } unsigned int -Print::bind (const NRMatrix *transform, float opacity) +Print::bind (const NR::Matrix *transform, float opacity) { return imp->bind (this, transform, opacity); } @@ -79,14 +79,14 @@ Print::comment (const char * comment) } unsigned int -Print::fill (const NRBPath *bpath, const NRMatrix *ctm, const SPStyle *style, +Print::fill (const NRBPath *bpath, const NR::Matrix *ctm, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { return imp->fill (this, bpath, ctm, style, pbox, dbox, bbox); } unsigned int -Print::stroke (const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style, +Print::stroke (const NRBPath *bpath, const NR::Matrix *transform, const SPStyle *style, const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) { return imp->stroke (this, bpath, transform, style, pbox, dbox, bbox); @@ -94,7 +94,7 @@ Print::stroke (const NRBPath *bpath, const NRMatrix *transform, const SPStyle *s unsigned int Print::image (unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - const NRMatrix *transform, const SPStyle *style) + const NR::Matrix *transform, const SPStyle *style) { return imp->image (this, px, w, h, rs, transform, style); } diff --git a/src/extension/print.h b/src/extension/print.h index d7cc146c6..070f928e3 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -41,18 +41,18 @@ public: unsigned int finish (void); /* Rendering methods */ - unsigned int bind (NRMatrix const *transform, + unsigned int bind (NR::Matrix const *transform, float opacity); unsigned int release (void); unsigned int comment (const char * comment); unsigned int fill (NRBPath const *bpath, - NRMatrix const *ctm, + NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); unsigned int stroke (NRBPath const *bpath, - NRMatrix const *transform, + NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, @@ -61,7 +61,7 @@ public: unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *transform, + NR::Matrix const *transform, SPStyle const *style); unsigned int text (char const *text, NR::Point p, diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index b9ff1287b..46dbfe0f5 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -26,6 +26,7 @@ #include "sp-filter-reference.h" #include "sp-gaussian-blur.h" #include "svg/css-ostringstream.h" +#include "libnr/nr-matrix-fns.h" #include "xml/repr.h" @@ -331,7 +332,7 @@ new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mod NR::Matrix i2d = sp_item_i2d_affine (item); - return (new_filter_blend_gaussian_blur (document, mode, radius, i2d.expansion(), i2d.expansionX(), i2d.expansionY(), width, height)); + return (new_filter_blend_gaussian_blur (document, mode, radius, NR::expansion(i2d), NR::expansionX(i2d), NR::expansionY(i2d), width, height)); } /** @@ -367,7 +368,7 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, // Determine the required standard deviation value NR::Matrix i2d = sp_item_i2d_affine (item); - double expansion = i2d.expansion(); + double expansion = NR::expansion(i2d); double stdDeviation = radius; if (expansion != 0) stdDeviation /= expansion; @@ -385,8 +386,8 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, // Set the filter effects area Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->getFilter()); - set_filter_area(repr, radius, expansion, i2d.expansionX(), - i2d.expansionY(), width, height); + set_filter_area(repr, radius, expansion, NR::expansionX(i2d), + NR::expansionY(i2d), width, height); // Search for gaussian blur primitives. If found, set the stdDeviation // of the first one and return. diff --git a/src/flood-context.cpp b/src/flood-context.cpp index d263d2ffb..c6335cb0f 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -806,7 +806,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); - nr_matrix_set_identity(&gc.transform); + gc.transform.set_identity(); NRRectL final_bbox; final_bbox.x0 = 0; diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 70bc835bc..057877daf 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -367,7 +367,7 @@ sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar const *prop * transformation from bounding box space to user space. */ NR::Matrix skew = bbox2user; - double exp = skew.expansion(); + double exp = NR::expansion(skew); skew[0] /= exp; skew[1] /= exp; skew[2] /= exp; @@ -398,7 +398,7 @@ sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar const *prop // converted points in userspace coords NR::Point c_u = c_b * point_convert; NR::Point f_u = f_b * point_convert; - double r_u = r_b * point_convert.expansion(); + double r_u = r_b * NR::expansion(point_convert); sp_repr_set_svg_double(repr, "cx", c_u[NR::X]); sp_repr_set_svg_double(repr, "cy", c_u[NR::Y]); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index f44a514a1..5c1a5748a 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -125,7 +125,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); - nr_matrix_set_identity(&gc.transform); + gc.transform.set_identity(); // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 6156f60e6..69848e9a6 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -230,7 +230,7 @@ sp_export_get_rows(guchar const **rows, int row, int num_rows, void *data) bbox.y1 = row + num_rows; /* Update to renderable state */ NRGC gc(NULL); - nr_matrix_set_identity(&gc.transform); + gc.transform.set_identity(); nr_arena_item_invoke_update(ebp->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); diff --git a/src/interface.cpp b/src/interface.cpp index fbd57cdab..2e1fda1e5 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1192,7 +1192,7 @@ sp_ui_drag_data_received(GtkWidget *widget, ( !SP_OBJECT_STYLE(item)->stroke.isNone() ? desktop->current_zoom() * SP_OBJECT_STYLE (item)->stroke_width.computed * - sp_item_i2d_affine (item).expansion() * 0.5 + NR::expansion(sp_item_i2d_affine(item)) * 0.5 : 0.0) + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); diff --git a/src/libnr/nr-forward.h b/src/libnr/nr-forward.h index cbc4d8eec..b12d141df 100644 --- a/src/libnr/nr-forward.h +++ b/src/libnr/nr-forward.h @@ -22,8 +22,6 @@ class translate; class NArtBpath; struct NRBPath; struct NRPixBlock; -struct NRMatrix; -struct NRPoint; struct NRRect; struct NRRectL; diff --git a/src/libnr/nr-gradient.cpp b/src/libnr/nr-gradient.cpp index 2d52767bf..57ba651f4 100644 --- a/src/libnr/nr-gradient.cpp +++ b/src/libnr/nr-gradient.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -299,31 +300,31 @@ NRRenderer * nr_lgradient_renderer_setup (NRLGradientRenderer *lgr, const unsigned char *cv, unsigned int spread, - const NRMatrix *gs2px, + const NR::Matrix *gs2px, float x0, float y0, float x1, float y1) { - NRMatrix n2gs, n2px, px2n; + NR::Matrix n2gs, n2px, px2n; lgr->render = &render; lgr->vector = cv; lgr->spread = spread; - n2gs.c[0] = x1 - x0; - n2gs.c[1] = y1 - y0; - n2gs.c[2] = y1 - y0; - n2gs.c[3] = x0 - x1; - n2gs.c[4] = x0; - n2gs.c[5] = y0; + n2gs[0] = x1 - x0; + n2gs[1] = y1 - y0; + n2gs[2] = y1 - y0; + n2gs[3] = x0 - x1; + n2gs[4] = x0; + n2gs[5] = y0; - nr_matrix_multiply (&n2px, &n2gs, gs2px); - nr_matrix_invert (&px2n, &n2px); + n2px = n2gs * (*gs2px); + px2n = n2px.inverse(); - lgr->x0 = n2px.c[4] - 0.5; - lgr->y0 = n2px.c[5] - 0.5; - lgr->dx = px2n.c[0] * NR_GRADIENT_VECTOR_LENGTH; - lgr->dy = px2n.c[2] * NR_GRADIENT_VECTOR_LENGTH; + lgr->x0 = n2px[4] - 0.5; + lgr->y0 = n2px[5] - 0.5; + lgr->dx = px2n[0] * NR_GRADIENT_VECTOR_LENGTH; + lgr->dy = px2n[2] * NR_GRADIENT_VECTOR_LENGTH; return (NRRenderer *) lgr; } @@ -362,8 +363,8 @@ static void render(NRGradientRenderer *gr, NRPixBlock *pb) { NRRGradientRenderer *rgr = static_cast(gr); - NR::Coord const dx = rgr->px2gs.c[0]; - NR::Coord const dy = rgr->px2gs.c[1]; + NR::Coord const dx = rgr->px2gs[0]; + NR::Coord const dy = rgr->px2gs[1]; NRPixBlock spb; nr_pixblock_setup_extern(&spb, NR_PIXBLOCK_MODE_R8G8B8A8N, @@ -374,8 +375,8 @@ static void render(NRGradientRenderer *gr, NRPixBlock *pb) for (int y = pb->area.y0; y < pb->area.y1; y++) { unsigned char *d = NR_PIXBLOCK_PX(pb) + (y - pb->area.y0) * pb->rs; - NR::Coord gx = rgr->px2gs.c[0] * pb->area.x0 + rgr->px2gs.c[2] * y + rgr->px2gs.c[4]; - NR::Coord gy = rgr->px2gs.c[1] * pb->area.x0 + rgr->px2gs.c[3] * y + rgr->px2gs.c[5]; + NR::Coord gx = rgr->px2gs[0] * pb->area.x0 + rgr->px2gs[2] * y + rgr->px2gs[4]; + NR::Coord gy = rgr->px2gs[1] * pb->area.x0 + rgr->px2gs[3] * y + rgr->px2gs[5]; for (int x = pb->area.x0; x < pb->area.x1; x++) { NR::Coord const pos = sqrt(((gx*gx) + (gy*gy))); unsigned char const *s=spread::color_at(pos, rgr->vector); @@ -410,10 +411,10 @@ static void render(NRGradientRenderer *gr, NRPixBlock *pb) for (int y = y0; y < y1; y++) { unsigned char *d = NR_PIXBLOCK_PX(pb) + (y - y0) * rs; - NR::Coord gx = rgr->px2gs.c[0] * x0 + rgr->px2gs.c[2] * y + rgr->px2gs.c[4]; - NR::Coord gy = rgr->px2gs.c[1] * x0 + rgr->px2gs.c[3] * y + rgr->px2gs.c[5]; - NR::Coord const dx = rgr->px2gs.c[0]; - NR::Coord const dy = rgr->px2gs.c[1]; + NR::Coord gx = rgr->px2gs[0] * x0 + rgr->px2gs[2] * y + rgr->px2gs[4]; + NR::Coord gy = rgr->px2gs[1] * x0 + rgr->px2gs[3] * y + rgr->px2gs[5]; + NR::Coord const dx = rgr->px2gs[0]; + NR::Coord const dy = rgr->px2gs[1]; for (int x = x0; x < x1; x++) { NR::Coord const gx2 = gx * gx; NR::Coord const gxy2 = gx2 + gy * gy; @@ -452,7 +453,7 @@ NRRenderer * nr_rgradient_renderer_setup(NRRGradientRenderer *rgr, unsigned char const *cv, unsigned spread, - NRMatrix const *gs2px, + NR::Matrix const *gs2px, float cx, float cy, float fx, float fy, float r) @@ -466,15 +467,15 @@ nr_rgradient_renderer_setup(NRRGradientRenderer *rgr, NR_DF_TEST_CLOSE(cy, fy, NR_EPSILON)) { rgr->render = render; - nr_matrix_invert(&rgr->px2gs, gs2px); - rgr->px2gs.c[0] *= (NR_GRADIENT_VECTOR_LENGTH / r); - rgr->px2gs.c[1] *= (NR_GRADIENT_VECTOR_LENGTH / r); - rgr->px2gs.c[2] *= (NR_GRADIENT_VECTOR_LENGTH / r); - rgr->px2gs.c[3] *= (NR_GRADIENT_VECTOR_LENGTH / r); - rgr->px2gs.c[4] -= cx; - rgr->px2gs.c[5] -= cy; - rgr->px2gs.c[4] *= (NR_GRADIENT_VECTOR_LENGTH / r); - rgr->px2gs.c[5] *= (NR_GRADIENT_VECTOR_LENGTH / r); + rgr->px2gs = gs2px->inverse(); + rgr->px2gs[0] *= (NR_GRADIENT_VECTOR_LENGTH / r); + rgr->px2gs[1] *= (NR_GRADIENT_VECTOR_LENGTH / r); + rgr->px2gs[2] *= (NR_GRADIENT_VECTOR_LENGTH / r); + rgr->px2gs[3] *= (NR_GRADIENT_VECTOR_LENGTH / r); + rgr->px2gs[4] -= cx; + rgr->px2gs[5] -= cy; + rgr->px2gs[4] *= (NR_GRADIENT_VECTOR_LENGTH / r); + rgr->px2gs[5] *= (NR_GRADIENT_VECTOR_LENGTH / r); rgr->cx = 0.0; rgr->cy = 0.0; @@ -490,17 +491,17 @@ nr_rgradient_renderer_setup(NRRGradientRenderer *rgr, fy = cy + (fy - cy ) * r / (float) df; } - NRMatrix n2gs; - n2gs.c[0] = cx - fx; - n2gs.c[1] = cy - fy; - n2gs.c[2] = cy - fy; - n2gs.c[3] = fx - cx; - n2gs.c[4] = fx; - n2gs.c[5] = fy; - - NRMatrix n2px; - nr_matrix_multiply(&n2px, &n2gs, gs2px); - nr_matrix_invert(&rgr->px2gs, &n2px); + NR::Matrix n2gs; + n2gs[0] = cx - fx; + n2gs[1] = cy - fy; + n2gs[2] = cy - fy; + n2gs[3] = fx - cx; + n2gs[4] = fx; + n2gs[5] = fy; + + NR::Matrix n2px; + n2px = n2gs * (*gs2px); + rgr->px2gs = n2px.inverse(); rgr->cx = 1.0; rgr->cy = 0.0; diff --git a/src/libnr/nr-gradient.h b/src/libnr/nr-gradient.h index 092ed1e22..1073f36ae 100644 --- a/src/libnr/nr-gradient.h +++ b/src/libnr/nr-gradient.h @@ -44,14 +44,14 @@ struct NRLGradientRenderer : public NRGradientRenderer { NRRenderer *nr_lgradient_renderer_setup (NRLGradientRenderer *lgr, const unsigned char *cv, unsigned int spread, - const NRMatrix *gs2px, + const NR::Matrix *gs2px, float x0, float y0, float x1, float y1); /* Radial */ struct NRRGradientRenderer : public NRGradientRenderer { - NRMatrix px2gs; + NR::Matrix px2gs; float cx, cy; float fx, fy; float r; @@ -61,7 +61,7 @@ struct NRRGradientRenderer : public NRGradientRenderer { NRRenderer *nr_rgradient_renderer_setup (NRRGradientRenderer *rgr, const unsigned char *cv, unsigned int spread, - const NRMatrix *gs2px, + const NR::Matrix *gs2px, float cx, float cy, float fx, float fy, float r); diff --git a/src/libnr/nr-macros.h b/src/libnr/nr-macros.h index 0ccad30c4..e0d3dabfb 100644 --- a/src/libnr/nr-macros.h +++ b/src/libnr/nr-macros.h @@ -47,22 +47,12 @@ #define NR_DF_TEST_CLOSE(a,b,e) (fabs ((a) - (b)) <= (e)) // Todo: move these into nr-matrix.h -#define NR_MATRIX_DF_TEST_TRANSFORM_CLOSE(a,b,e) (NR_DF_TEST_CLOSE ((*(a))[0], (*(b))[0], e) && \ - NR_DF_TEST_CLOSE ((*(a))[1], (*(b))[1], e) && \ - NR_DF_TEST_CLOSE ((*(a))[2], (*(b))[2], e) && \ - NR_DF_TEST_CLOSE ((*(a))[3], (*(b))[3], e)) -#define NR_MATRIX_DF_TEST_TRANSLATE_CLOSE(a,b,e) (NR_DF_TEST_CLOSE ((*(a))[4], (*(b))[4], e) && \ - NR_DF_TEST_CLOSE ((*(a))[5], (*(b))[5], e)) -#define NR_MATRIX_DF_TEST_CLOSE(a,b,e) (NR_MATRIX_DF_TEST_TRANSLATE_CLOSE (a, b, e) && \ - NR_MATRIX_DF_TEST_TRANSFORM_CLOSE (a, b, e)) - #define NR_RECT_DFLS_TEST_EMPTY(a) (((a)->x0 >= (a)->x1) || ((a)->y0 >= (a)->y1)) #define NR_RECT_DFLS_TEST_INTERSECT(a,b) (((a)->x0 < (b)->x1) && ((a)->x1 > (b)->x0) && ((a)->y0 < (b)->y1) && ((a)->y1 > (b)->y0)) #define NR_RECT_DF_POINT_DF_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1)) #define NR_RECT_LS_POINT_LS_TEST_INSIDE(r,p) (((p)->x >= (r)->x0) && ((p)->x < (r)->x1) && ((p)->y >= (r)->y0) && ((p)->y < (r)->y1)) #define NR_RECT_LS_TEST_INSIDE(r,x,y) ((x >= (r)->x0) && (x < (r)->x1) && (y >= (r)->y0) && (y < (r)->y1)) -#define NR_MATRIX_D_TO_DOUBLE(m) ((m)->c) -#define NR_MATRIX_D_FROM_DOUBLE(d) ((NRMatrix *) &(d)[0]) +#define NR_MATRIX_D_FROM_DOUBLE(d) ((NR::Matrix *) &(d)[0]) #endif diff --git a/src/libnr/nr-matrix-fns.h b/src/libnr/nr-matrix-fns.h index 208366746..a46aca909 100644 --- a/src/libnr/nr-matrix-fns.h +++ b/src/libnr/nr-matrix-fns.h @@ -2,6 +2,7 @@ #define SEEN_NR_MATRIX_FNS_H #include "nr-matrix.h" +#include namespace NR { @@ -24,6 +25,8 @@ Matrix from_basis(const Point x_basis, const Point y_basis, const Point offset=P Matrix identity(); double expansion(Matrix const &m); +inline double expansionX(Matrix const &m) { return hypot(m[0], m[1]); } +inline double expansionY(Matrix const &m) { return hypot(m[2], m[3]); } bool transform_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon); bool translate_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon); diff --git a/src/libnr/nr-matrix-ops.h b/src/libnr/nr-matrix-ops.h index 02fb28d0c..e534f9cf6 100644 --- a/src/libnr/nr-matrix-ops.h +++ b/src/libnr/nr-matrix-ops.h @@ -23,14 +23,10 @@ inline bool operator!=(Matrix const &a, Matrix const &b) Matrix operator*(Matrix const &a, Matrix const &b); -inline Matrix operator*(Matrix const &a, NRMatrix const &b) -{ - return a * NR::Matrix(b); -} +inline Matrix &operator*=(Matrix &a, Matrix const &b) { a = a * b; return a; } } /* namespace NR */ - #endif /* !SEEN_NR_MATRIX_OPS_H */ /* diff --git a/src/libnr/nr-matrix-scale-ops.cpp b/src/libnr/nr-matrix-scale-ops.cpp deleted file mode 100644 index 0079d3f76..000000000 --- a/src/libnr/nr-matrix-scale-ops.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "libnr/nr-matrix-ops.h" - -NR::Matrix -operator/(NR::Matrix const &m, NR::scale const &s) -{ - using NR::X; using NR::Y; - NR::Matrix ret(m); - ret[0] /= s[X]; ret[1] /= s[Y]; - ret[2] /= s[X]; ret[3] /= s[Y]; - ret[4] /= s[X]; ret[5] /= s[Y]; - return ret; -} - -NR::Matrix -operator*(NR::Matrix const &m, NR::scale const &s) -{ - using NR::X; using NR::Y; - NR::Matrix ret(m); - ret[0] *= s[X]; ret[1] *= s[Y]; - ret[2] *= s[X]; ret[3] *= s[Y]; - ret[4] *= s[X]; ret[5] *= s[Y]; - return ret; -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-matrix-scale-ops.h b/src/libnr/nr-matrix-scale-ops.h index dee275182..d030bb66c 100644 --- a/src/libnr/nr-matrix-scale-ops.h +++ b/src/libnr/nr-matrix-scale-ops.h @@ -6,9 +6,26 @@ #include "libnr/nr-forward.h" -NR::Matrix operator/(NR::Matrix const &m, NR::scale const &s); +namespace NR { -NR::Matrix operator*(NR::Matrix const &m, NR::scale const &s); +inline Matrix &operator/=(Matrix &m, scale const &s) { + m[0] /= s[X]; m[1] /= s[Y]; + m[2] /= s[X]; m[3] /= s[Y]; + m[4] /= s[X]; m[5] /= s[Y]; + return m; +} +inline Matrix &operator*=(Matrix &m, scale const &s) { + m[0] *= s[X]; m[1] *= s[Y]; + m[2] *= s[X]; m[3] *= s[Y]; + m[4] *= s[X]; m[5] *= s[Y]; + return m; +} + +inline Matrix operator/(Matrix const &m, scale const &s) { Matrix ret(m); ret /= s; return ret; } + +inline Matrix operator*(Matrix const &m, scale const &s) { Matrix ret(m); ret *= s; return ret; } + +} #endif /* !SEEN_LIBNR_NR_MATRIX_SCALE_OPS_H */ diff --git a/src/libnr/nr-matrix-test.cpp b/src/libnr/nr-matrix-test.cpp index b7f064e48..d0bf25310 100644 --- a/src/libnr/nr-matrix-test.cpp +++ b/src/libnr/nr-matrix-test.cpp @@ -100,14 +100,14 @@ int main(int argc, char *argv[]) } UTEST_TEST("nr_matrix_invert") { - NRMatrix const nr_m_id(m_id); + NR::Matrix const nr_m_id(m_id); Matrix const m_s2(NR::scale(-4.0, 2.0)); - NRMatrix const nr_s2(m_s2); + NR::Matrix const nr_s2(m_s2); Matrix const m_sp5(NR::scale(-.25, .5)); - NRMatrix const nr_sp5(m_sp5); + NR::Matrix const nr_sp5(m_sp5); Matrix const m_t23(t23); - NRMatrix const nr_t23(m_t23); - NRMatrix inv; + NR::Matrix const nr_t23(m_t23); + NR::Matrix inv; nr_matrix_invert(&inv, &nr_m_id); UTEST_ASSERT( Matrix(inv) == m_id ); nr_matrix_invert(&inv, &nr_t23); diff --git a/src/libnr/nr-matrix-test.h b/src/libnr/nr-matrix-test.h index 476852890..ee60d8f9b 100644 --- a/src/libnr/nr-matrix-test.h +++ b/src/libnr/nr-matrix-test.h @@ -127,14 +127,14 @@ public: void testNrMatrixInvert(void) { - NRMatrix const nr_m_id(m_id); + NR::Matrix const nr_m_id(m_id); Matrix const m_s2(NR::scale(-4.0, 2.0)); - NRMatrix const nr_s2(m_s2); + NR::Matrix const nr_s2(m_s2); Matrix const m_sp5(NR::scale(-.25, .5)); - NRMatrix const nr_sp5(m_sp5); + NR::Matrix const nr_sp5(m_sp5); Matrix const m_t23(t23); - NRMatrix const nr_t23(m_t23); - NRMatrix inv; + NR::Matrix const nr_t23(m_t23); + NR::Matrix inv; nr_matrix_invert(&inv, &nr_m_id); TS_ASSERT_EQUALS( Matrix(inv), m_id ); nr_matrix_invert(&inv, &nr_t23); diff --git a/src/libnr/nr-matrix-translate-ops.cpp b/src/libnr/nr-matrix-translate-ops.cpp deleted file mode 100644 index 554b5790a..000000000 --- a/src/libnr/nr-matrix-translate-ops.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "libnr/nr-matrix-ops.h" - -namespace NR { - -Matrix -operator*(Matrix const &m, translate const &t) -{ - Matrix ret(m); - ret[4] += t[X]; - ret[5] += t[Y]; - return ret; -} - -} // namespace NR - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/libnr/nr-matrix-translate-ops.h b/src/libnr/nr-matrix-translate-ops.h index f51bccaa1..6e5607759 100644 --- a/src/libnr/nr-matrix-translate-ops.h +++ b/src/libnr/nr-matrix-translate-ops.h @@ -9,18 +9,19 @@ #include "libnr/nr-matrix.h" #include "libnr/nr-translate.h" -//NR::Matrix operator*(NR::Matrix const &m, NR::translate const &t); - namespace NR { -Matrix operator*(Matrix const &m, translate const &t); -} -inline NR::Matrix -operator/(NR::Matrix const &numer, NR::translate const &denom) -{ - return numer * NR::translate(-denom.offset); +inline Matrix &operator*=(Matrix &m, translate const &t) { + m[4] += t[X]; + m[5] += t[Y]; + return m; } +inline Matrix operator*(Matrix const &m, translate const &t) { Matrix ret(m); ret *= t; return ret; } + +inline Matrix operator/(Matrix const &numer, translate const &denom) { return numer * translate(-denom.offset); } + +} #endif /* !SEEN_LIBNR_NR_MATRIX_TRANSLATE_OPS_H */ diff --git a/src/libnr/nr-matrix.cpp b/src/libnr/nr-matrix.cpp index ed482f46f..eb1f21d47 100644 --- a/src/libnr/nr-matrix.cpp +++ b/src/libnr/nr-matrix.cpp @@ -13,156 +13,7 @@ #include #include "nr-matrix.h" - - - -/** - * Multiply two NRMatrices together, storing the result in d. - */ -NRMatrix * -nr_matrix_multiply(NRMatrix *d, NRMatrix const *m0, NRMatrix const *m1) -{ - if (m0) { - if (m1) { - NR::Coord d0 = m0->c[0] * m1->c[0] + m0->c[1] * m1->c[2]; - NR::Coord d1 = m0->c[0] * m1->c[1] + m0->c[1] * m1->c[3]; - NR::Coord d2 = m0->c[2] * m1->c[0] + m0->c[3] * m1->c[2]; - NR::Coord d3 = m0->c[2] * m1->c[1] + m0->c[3] * m1->c[3]; - NR::Coord d4 = m0->c[4] * m1->c[0] + m0->c[5] * m1->c[2] + m1->c[4]; - NR::Coord d5 = m0->c[4] * m1->c[1] + m0->c[5] * m1->c[3] + m1->c[5]; - - NR::Coord *dest = d->c; - *dest++ = d0; - *dest++ = d1; - *dest++ = d2; - *dest++ = d3; - *dest++ = d4; - *dest = d5; - } else { - *d = *m0; - } - } else { - if (m1) { - *d = *m1; - } else { - nr_matrix_set_identity(d); - } - } - - return d; -} - - - - -/** - * Store the inverted value of Matrix m in d - */ -NRMatrix * -nr_matrix_invert(NRMatrix *d, NRMatrix const *m) -{ - if (m) { - NR::Coord const det = m->c[0] * m->c[3] - m->c[1] * m->c[2]; - if (!NR_DF_TEST_CLOSE(det, 0.0, NR_EPSILON)) { - - NR::Coord const idet = 1.0 / det; - NR::Coord *dest = d->c; - - /* Cache m->c[0] and m->c[4] in case d == m. */ - NR::Coord const m_c0(m->c[0]); - NR::Coord const m_c4(m->c[4]); - - /*0*/ *dest++ = m->c[3] * idet; - /*1*/ *dest++ = -m->c[1] * idet; - /*2*/ *dest++ = -m->c[2] * idet; - /*3*/ *dest++ = m_c0 * idet; - /*4*/ *dest++ = -m_c4 * d->c[0] - m->c[5] * d->c[2]; - /*5*/ *dest = -m_c4 * d->c[1] - m->c[5] * d->c[3]; - - } else { - nr_matrix_set_identity(d); - } - } else { - nr_matrix_set_identity(d); - } - - return d; -} - - - - - -/** - * Set this matrix to a translation of x and y - */ -NRMatrix * -nr_matrix_set_translate(NRMatrix *m, NR::Coord const x, NR::Coord const y) -{ - NR::Coord *dest = m->c; - - *dest++ = 1.0; //0 - *dest++ = 0.0; //1 - *dest++ = 0.0; //2 - *dest++ = 1.0; //3 - *dest++ = x; //4 - *dest = y; //5 - - return m; -} - - - - - -/** - * Set this matrix to a scaling transform in sx and sy - */ -NRMatrix * -nr_matrix_set_scale(NRMatrix *m, NR::Coord const sx, NR::Coord const sy) -{ - NR::Coord *dest = m->c; - - *dest++ = sx; //0 - *dest++ = 0.0; //1 - *dest++ = 0.0; //2 - *dest++ = sy; //3 - *dest++ = 0.0; //4 - *dest = 0.0; //5 - - return m; -} - - - - - -/** - * Set this matrix to a rotating transform of angle 'theta' radians - */ -NRMatrix * -nr_matrix_set_rotate(NRMatrix *m, NR::Coord const theta) -{ - NR::Coord const s = sin(theta); - NR::Coord const c = cos(theta); - - NR::Coord *dest = m->c; - - *dest++ = c; //0 - *dest++ = s; //1 - *dest++ = -s; //2 - *dest++ = c; //3 - *dest++ = 0.0; //4 - *dest = 0.0; //5 - - return m; -} - - - - - - +#include "nr-matrix-fns.h" @@ -175,22 +26,6 @@ namespace NR { -/** - * Constructor. Assign to nr if not null, else identity - */ -Matrix::Matrix(NRMatrix const *nr) -{ - if (nr) { - assign(nr->c); - } else { - set_identity(); - } -} - - - - - /** * Multiply two matrices together */ @@ -212,54 +47,6 @@ Matrix operator*(Matrix const &m0, Matrix const &m1) -/** - * Multiply a matrix by another - */ -Matrix &Matrix::operator*=(Matrix const &o) -{ - *this = *this * o; - return *this; -} - - - - - -/** - * Multiply by a scaling matrix - */ -Matrix &Matrix::operator*=(scale const &other) -{ - /* This loop is massive overkill. Let's unroll. - * o _c[] goes from 0..5 - * o other[] alternates between 0 and 1 - */ - /* - * for (unsigned i = 0; i < 3; ++i) { - * for (unsigned j = 0; j < 2; ++j) { - * this->_c[i * 2 + j] *= other[j]; - * } - * } - */ - - NR::Coord const xscale = other[0]; - NR::Coord const yscale = other[1]; - NR::Coord *dest = _c; - - /*i=0 j=0*/ *dest++ *= xscale; - /*i=0 j=1*/ *dest++ *= yscale; - /*i=1 j=0*/ *dest++ *= xscale; - /*i=1 j=1*/ *dest++ *= yscale; - /*i=2 j=0*/ *dest++ *= xscale; - /*i=2 j=1*/ *dest *= yscale; - - return *this; -} - - - - - /** * Return the inverse of this matrix. If an inverse is not defined, * then return the identity matrix. @@ -397,121 +184,6 @@ NR::Coord Matrix::descrim() const -/** - * Assign a matrix to a given coordinate array - */ -Matrix &Matrix::assign(Coord const *array) -{ - assert(array != NULL); - - Coord const *src = array; - Coord *dest = _c; - - *dest++ = *src++; //0 - *dest++ = *src++; //1 - *dest++ = *src++; //2 - *dest++ = *src++; //3 - *dest++ = *src++; //4 - *dest = *src ; //5 - - return *this; -} - - - - - -/** - * Copy this matrix's value to a NRMatrix - */ -NRMatrix *Matrix::copyto(NRMatrix *nrm) const { - - assert(nrm != NULL); - - Coord const *src = _c; - Coord *dest = nrm->c; - - *dest++ = *src++; //0 - *dest++ = *src++; //1 - *dest++ = *src++; //2 - *dest++ = *src++; //3 - *dest++ = *src++; //4 - *dest = *src ; //5 - - return nrm; -} - - - - -/** - * Copy this matrix's values to an array - */ -NR::Coord *Matrix::copyto(NR::Coord *array) const { - - assert(array != NULL); - - Coord const *src = _c; - Coord *dest = array; - - *dest++ = *src++; //0 - *dest++ = *src++; //1 - *dest++ = *src++; //2 - *dest++ = *src++; //3 - *dest++ = *src++; //4 - *dest = *src ; //5 - - return array; -} - - - - - -/** - * - */ -double expansion(Matrix const &m) { - return sqrt(fabs(m.det())); -} - - - - - -/** - * - */ -double Matrix::expansion() const { - return sqrt(fabs(det())); -} - - - - - -/** - * - */ -double Matrix::expansionX() const { - return sqrt(_c[0] * _c[0] + _c[1] * _c[1]); -} - - - - - -/** - * - */ -double Matrix::expansionY() const { - return sqrt(_c[2] * _c[2] + _c[3] * _c[3]); -} - - - - - /** * */ @@ -550,7 +222,18 @@ bool Matrix::is_rotation(Coord const eps) const { * */ bool Matrix::test_identity() const { - return NR_MATRIX_DF_TEST_CLOSE(this, &NR_MATRIX_IDENTITY, NR_EPSILON); + return matrix_equalp(*this, NR_MATRIX_IDENTITY, NR_EPSILON); +} + + + + + +/** + * + */ +double expansion(Matrix const &m) { + return sqrt(fabs(m.det())); } @@ -561,7 +244,11 @@ bool Matrix::test_identity() const { * */ bool transform_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) { - return NR_MATRIX_DF_TEST_TRANSFORM_CLOSE(&m0, &m1, epsilon); + return + NR_DF_TEST_CLOSE(m0[0], m1[0], epsilon) && + NR_DF_TEST_CLOSE(m0[1], m1[1], epsilon) && + NR_DF_TEST_CLOSE(m0[2], m1[2], epsilon) && + NR_DF_TEST_CLOSE(m0[3], m1[3], epsilon); } @@ -572,7 +259,7 @@ bool transform_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilo * */ bool translate_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) { - return NR_MATRIX_DF_TEST_TRANSLATE_CLOSE(&m0, &m1, epsilon); + return NR_DF_TEST_CLOSE(m0[4], m1[4], epsilon) && NR_DF_TEST_CLOSE(m0[5], m1[5], epsilon); } @@ -582,10 +269,8 @@ bool translate_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilo /** * */ -bool matrix_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) -{ - return ( NR_MATRIX_DF_TEST_TRANSFORM_CLOSE(&m0, &m1, epsilon) && - NR_MATRIX_DF_TEST_TRANSLATE_CLOSE(&m0, &m1, epsilon) ); +bool matrix_equalp(Matrix const &m0, Matrix const &m1, NR::Coord const epsilon) { + return transform_equalp(m0, m1, epsilon) && translate_equalp(m0, m1, epsilon); } diff --git a/src/libnr/nr-matrix.h b/src/libnr/nr-matrix.h index a8af553b6..f626377e5 100644 --- a/src/libnr/nr-matrix.h +++ b/src/libnr/nr-matrix.h @@ -2,7 +2,7 @@ #define __NR_MATRIX_H__ /** \file - * Definition of NRMatrix and NR::Matrix types. + * Definition of NR::Matrix type. * * \note Operator functions (e.g. Matrix * Matrix etc.) are mostly in * libnr/nr-matrix-ops.h. See end of file for discussion. @@ -26,41 +26,6 @@ #include #include -/// NRMatrix is the obsolete form of NR::Matrix. -/// It consists of six NR::Coord values. -struct NRMatrix { - NR::Coord c[6]; - - NR::Coord &operator[](int i) { return c[i]; } - NR::Coord operator[](int i) const { return c[i]; } -}; - -#define nr_matrix_set_identity(m) (*(m) = NR_MATRIX_IDENTITY) - -#define nr_matrix_test_identity(m,e) (!(m) || NR_MATRIX_DF_TEST_CLOSE(m, &NR_MATRIX_IDENTITY, e)) - -#define nr_matrix_test_equal(m0,m1,e) ((!(m0) && !(m1)) || ((m0) && (m1) && NR_MATRIX_DF_TEST_CLOSE(m0, m1, e))) -#define nr_matrix_test_transform_equal(m0,m1,e) ((!(m0) && !(m1)) || ((m0) && (m1) && NR_MATRIX_DF_TEST_TRANSFORM_CLOSE(m0, m1, e))) -#define nr_matrix_test_translate_equal(m0,m1,e) ((!(m0) && !(m1)) || ((m0) && (m1) && NR_MATRIX_DF_TEST_TRANSLATE_CLOSE(m0, m1, e))) - -NRMatrix *nr_matrix_invert(NRMatrix *d, NRMatrix const *m); - -/* d,m0,m1 needn't be distinct in any of these multiply routines. */ - -NRMatrix *nr_matrix_multiply(NRMatrix *d, NRMatrix const *m0, NRMatrix const *m1); - -NRMatrix *nr_matrix_set_translate(NRMatrix *m, NR::Coord const x, NR::Coord const y); - -NRMatrix *nr_matrix_set_scale(NRMatrix *m, NR::Coord const sx, NR::Coord const sy); - -NRMatrix *nr_matrix_set_rotate(NRMatrix *m, NR::Coord const theta); - -#define NR_MATRIX_DF_TRANSFORM_X(m,x,y) ((*(m))[0] * (x) + (*(m))[2] * (y) + (*(m))[4]) -#define NR_MATRIX_DF_TRANSFORM_Y(m,x,y) ((*(m))[1] * (x) + (*(m))[3] * (y) + (*(m))[5]) - -#define NR_MATRIX_DF_EXPANSION2(m) (fabs((*(m))[0] * (*(m))[3] - (*(m))[1] * (*(m))[2])) -#define NR_MATRIX_DF_EXPANSION(m) (sqrt(NR_MATRIX_DF_EXPANSION2(m))) - namespace NR { /** @@ -113,27 +78,6 @@ class Matrix { - - /** - * - */ - Matrix(NRMatrix const &m) { - - NR::Coord const *src = m.c; - NR::Coord *dest = _c; - - *dest++ = *src++; //0 - *dest++ = *src++; //1 - *dest++ = *src++; //2 - *dest++ = *src++; //3 - *dest++ = *src++; //4 - *dest = *src ; //5 - - } - - - - /** * */ @@ -231,13 +175,6 @@ class Matrix { } - - /** - * - */ - Matrix(NRMatrix const *nr); - - /** * */ @@ -266,29 +203,6 @@ class Matrix { Matrix inverse() const; - /** - * - */ - Matrix &operator*=(Matrix const &other); - - - /** - * - */ - Matrix &operator*=(scale const &other); - - - - /** - * - */ - Matrix &operator*=(translate const &other) { - _c[4] += other[X]; - _c[5] += other[Y]; - return *this; - } - - /** * @@ -330,83 +244,6 @@ class Matrix { Coord descrim() const; - /** - * - */ - double expansion() const; - - - /** - * - */ - double expansionX() const; - - - /** - * - */ - double expansionY() const; - - // legacy - - - /** - * - */ - Matrix &assign(Coord const *array); - - - /** - * - */ - NRMatrix *copyto(NRMatrix* nrm) const; - - - /** - * - */ - Coord *copyto(Coord *array) const; - - - - /** - * - */ - operator NRMatrix&() { - g_assert(sizeof(_c) == sizeof(NRMatrix)); - return *reinterpret_cast(_c); - } - - - - /** - * - */ - operator NRMatrix const&() const { - g_assert(sizeof(_c) == sizeof(NRMatrix)); - return *reinterpret_cast(_c); - } - - - - /** - * - */ - operator NRMatrix*() { - g_assert(sizeof(_c) == sizeof(NRMatrix)); - return reinterpret_cast(_c); - } - - - /** - * - */ - operator NRMatrix const*() const { - g_assert(sizeof(_c) == sizeof(NRMatrix)); - return reinterpret_cast(_c); - } - - private: diff --git a/src/libnr/nr-path.cpp b/src/libnr/nr-path.cpp index a0011c9dc..713cfe43d 100644 --- a/src/libnr/nr-path.cpp +++ b/src/libnr/nr-path.cpp @@ -20,7 +20,7 @@ static void nr_curve_bbox(NR::Point const p000, NR::Point const p001, NR::Point const p011, NR::Point const p111, NRRect *bbox); -NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NRMatrix const *transform) +NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NR::Matrix const *transform) { int i; @@ -38,13 +38,10 @@ NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NRMatrix const *tra while (s->path[i].code != NR_END) { d->path[i].code = s->path[i].code; if (s->path[i].code == NR_CURVETO) { - d->path[i].x1 = NR_MATRIX_DF_TRANSFORM_X (transform, s->path[i].x1, s->path[i].y1); - d->path[i].y1 = NR_MATRIX_DF_TRANSFORM_Y (transform, s->path[i].x1, s->path[i].y1); - d->path[i].x2 = NR_MATRIX_DF_TRANSFORM_X (transform, s->path[i].x2, s->path[i].y2); - d->path[i].y2 = NR_MATRIX_DF_TRANSFORM_Y (transform, s->path[i].x2, s->path[i].y2); + d->path[i].setC(1, s->path[i].c(1) * (*transform)); + d->path[i].setC(2, s->path[i].c(2) * (*transform)); } - d->path[i].x3 = NR_MATRIX_DF_TRANSFORM_X (transform, s->path[i].x3, s->path[i].y3); - d->path[i].y3 = NR_MATRIX_DF_TRANSFORM_Y (transform, s->path[i].x3, s->path[i].y3); + d->path[i].setC(3, s->path[i].c(3) * (*transform)); i += 1; } d->path[i].code = NR_END; @@ -53,7 +50,7 @@ NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NRMatrix const *tra } NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NR::Matrix const transform) { - NRMatrix tr = transform; + NR::Matrix tr = transform; return nr_path_duplicate_transform(d, s, &tr); } diff --git a/src/libnr/nr-path.h b/src/libnr/nr-path.h index 6fdc85694..bf7369be4 100644 --- a/src/libnr/nr-path.h +++ b/src/libnr/nr-path.h @@ -36,7 +36,7 @@ struct NRBPath { NArtBpath *path; }; -NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NRMatrix const *transform); +NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NR::Matrix const *transform); NRBPath *nr_path_duplicate_transform(NRBPath *d, NRBPath *s, NR::Matrix const transform); diff --git a/src/libnr/nr-point.h b/src/libnr/nr-point.h index 60c5586b0..c1ec3adc9 100644 --- a/src/libnr/nr-point.h +++ b/src/libnr/nr-point.h @@ -18,13 +18,6 @@ #include <2geom/point.h> -/// A NRPoint consists of x and y coodinates. -/// \todo -/// This class appears to be obsoleted out in favour of NR::Point. -struct NRPoint { - NR::Coord x, y; -}; - namespace NR { class Matrix; @@ -40,11 +33,6 @@ public: _pt[Y] = y; } - inline Point(NRPoint const &p) { - _pt[X] = p.x; - _pt[Y] = p.y; - } - inline Point(Point const &p) { for (unsigned i = 0; i < 2; ++i) { _pt[i] = p._pt[i]; diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp index f3036eff1..a1c8c93b2 100644 --- a/src/libnr/nr-rect.cpp +++ b/src/libnr/nr-rect.cpp @@ -224,7 +224,7 @@ nr_rect_d_matrix_transform(NRRect *d, NRRect const *const s, NR::Matrix const &m } NRRect * -nr_rect_d_matrix_transform(NRRect *d, NRRect const *s, NRMatrix const *m) +nr_rect_d_matrix_transform(NRRect *d, NRRect const *s, NR::Matrix const *m) { return nr_rect_d_matrix_transform(d, s, *m); } diff --git a/src/libnr/nr-rect.h b/src/libnr/nr-rect.h index 5d897c695..c61083b4b 100644 --- a/src/libnr/nr-rect.h +++ b/src/libnr/nr-rect.h @@ -24,9 +24,9 @@ #include #include #include +#include namespace NR { - struct Matrix; /** A rectangle is always aligned to the X and Y axis. This means it * can be defined using only 4 coordinates, and determining @@ -247,8 +247,6 @@ inline std::ostream /* legacy rect stuff */ -struct NRMatrix; - /* NULL rect is infinite */ struct NRRect { @@ -302,7 +300,7 @@ NRRect *nr_rect_d_union_xy(NRRect *d, NR::Coord x, NR::Coord y); NRRectL *nr_rect_l_union_xy(NRRectL *d, NR::ICoord x, NR::ICoord y); NRRect *nr_rect_d_matrix_transform(NRRect *d, NRRect const *s, NR::Matrix const &m); -NRRect *nr_rect_d_matrix_transform(NRRect *d, NRRect const *s, NRMatrix const *m); +NRRect *nr_rect_d_matrix_transform(NRRect *d, NRRect const *s, NR::Matrix const *m); NRRectL *nr_rect_l_enlarge(NRRectL *d, int amount); diff --git a/src/libnr/nr-svp-render.cpp b/src/libnr/nr-svp-render.cpp index 3ad1c2ca5..4e53cd5de 100644 --- a/src/libnr/nr-svp-render.cpp +++ b/src/libnr/nr-svp-render.cpp @@ -9,8 +9,8 @@ * This code is in public domain */ -#define NR_SVPSEG_Y0(s,i) ((s)->points[(s)->segments[i].start].y) -#define NR_SVPSEG_Y1(s,i) ((s)->points[(s)->segments[i].start + (s)->segments[i].length - 1].y) +#define NR_SVPSEG_Y0(s,i) ((s)->points[(s)->segments[i].start][NR::Y]) +#define NR_SVPSEG_Y1(s,i) ((s)->points[(s)->segments[i].start + (s)->segments[i].length - 1][NR::Y]) #define noNR_VERBOSE @@ -75,7 +75,7 @@ static NRRun *nr_run_insort (NRRun *start, NRRun *run); struct NRSlice { NRSlice *next; int wind; - NRPoint *points; + NR::Point *points; unsigned int current; unsigned int last; NR::Coord x; @@ -83,7 +83,7 @@ struct NRSlice { NR::Coord stepx; }; -static NRSlice *nr_slice_new (int wind, NRPoint *points, unsigned int length, NR::Coord y); +static NRSlice *nr_slice_new (int wind, NR::Point *points, unsigned int length, NR::Coord y); static NRSlice *nr_slice_free_one (NRSlice *s); static void nr_slice_free_list (NRSlice *s); static NRSlice *nr_slice_insort (NRSlice *start, NRSlice *slice); @@ -189,7 +189,7 @@ nr_svp_render (NRSVP *svp, unsigned char *px, unsigned int bpp, unsigned int rs, NRRun * newrun; rx0 = cs->x; ry0 = cs->y; - if (cs->points[cs->current + 1].y > dy1) { + if (cs->points[cs->current + 1][NR::Y] > dy1) { /* The same slice continues */ rx1 = rx0 + (dy1 - ry0) * cs->stepx; ry1 = dy1; @@ -198,12 +198,12 @@ nr_svp_render (NRSVP *svp, unsigned char *px, unsigned int bpp, unsigned int rs, } else { /* Subpixel height run */ cs->current += 1; - rx1 = cs->points[cs->current].x; - ry1 = cs->points[cs->current].y; + rx1 = cs->points[cs->current][NR::X]; + ry1 = cs->points[cs->current][NR::Y]; cs->x = rx1; cs->y = ry1; if (cs->current < cs->last) { - cs->stepx = (cs->points[cs->current + 1].x - rx1) / (cs->points[cs->current + 1].y - ry1); + cs->stepx = (cs->points[cs->current + 1][NR::X] - rx1) / (cs->points[cs->current + 1][NR::Y] - ry1); } } newrun = nr_run_new (rx0, ry0, rx1, ry1, cs->wind); @@ -355,10 +355,10 @@ nr_svp_render (NRSVP *svp, unsigned char *px, unsigned int bpp, unsigned int rs, static NRSlice *ffslice = NULL; static NRSlice * -nr_slice_new (int wind, NRPoint *points, unsigned int length, NR::Coord y) +nr_slice_new (int wind, NR::Point *points, unsigned int length, NR::Coord y) { NRSlice *s; - NRPoint *p; + NR::Point *p; /* g_assert (svl); */ /* g_assert (svl->vertex); */ @@ -386,16 +386,16 @@ nr_slice_new (int wind, NRPoint *points, unsigned int length, NR::Coord y) s->current = 0; s->last = length - 1; - while ((s->current < s->last) && (s->points[s->current + 1].y <= y)) s->current += 1; + while ((s->current < s->last) && (s->points[s->current + 1][NR::Y] <= y)) s->current += 1; p = s->points + s->current; - if (s->points[s->current].y == y) { - s->x = p[0].x; + if (s->points[s->current][NR::Y] == y) { + s->x = p[0][NR::X]; } else { - s->x = p[0].x + (p[1].x - p[0].x) * (y - p[0].y) / (p[1].y - p[0].y); + s->x = p[0][NR::X] + (p[1][NR::X] - p[0][NR::X]) * (y - p[0][NR::Y]) / (p[1][NR::Y] - p[0][NR::Y]); } s->y = y; - s->stepx = (p[1].x - p[0].x) / (p[1].y - p[0].y); + s->stepx = (p[1][NR::X] - p[0][NR::X]) / (p[1][NR::Y] - p[0][NR::Y]); return s; } @@ -462,44 +462,44 @@ nr_slice_compare (NRSlice *l, NRSlice *r) if (l->stepx > r->stepx) return 1; } else if (l->y > r->y) { unsigned int pidx; - NRPoint *p; + NR::Point *p; NR::Coord x, ldx, rdx; /* This is bitch - we have to determine r values at l->y */ pidx = 0; - while ((pidx < r->last) && (r->points[pidx + 1].y <= l->y)) pidx += 1; + while ((pidx < r->last) && (r->points[pidx + 1][NR::Y] <= l->y)) pidx += 1; /* If v is last vertex, r ends before l starts */ if (pidx >= r->last) return 1; p = r->points + pidx; - if (p[0].y == l->y) { - x = p[0].x; + if (p[0][NR::Y] == l->y) { + x = p[0][NR::X]; } else { - x = p[0].x + (p[1].x - p[0].x) * (l->y - p[0].y) / (p[1].y - p[0].y); + x = p[0][NR::X] + (p[1][NR::X] - p[0][NR::X]) * (l->y - p[0][NR::Y]) / (p[1][NR::Y] - p[0][NR::Y]); } if (l->x < x) return -1; if (l->x > x) return 1; - ldx = l->stepx * (p[1].y - p[0].y); - rdx = p[1].x - p[0].x; + ldx = l->stepx * (p[1][NR::Y] - p[0][NR::Y]); + rdx = p[1][NR::X] - p[0][NR::X]; if (ldx < rdx) return -1; if (ldx > rdx) return 1; } else { unsigned int pidx; - NRPoint *p; + NR::Point *p; NR::Coord x, ldx, rdx; /* This is bitch - we have to determine l value at r->y */ pidx = 0; - while ((pidx < l->last) && (l->points[pidx + 1].y <= r->y)) pidx += 1; + while ((pidx < l->last) && (l->points[pidx + 1][NR::Y] <= r->y)) pidx += 1; /* If v is last vertex, l ends before r starts */ if (pidx >= l->last) return 1; p = l->points + pidx; - if (p[0].y == r->y) { - x = p[0].x; + if (p[0][NR::Y] == r->y) { + x = p[0][NR::X]; } else { - x = p[0].x + (p[1].x - p[0].x) * (r->y - p[0].y) / (p[1].y - p[0].y); + x = p[0][NR::X] + (p[1][NR::X] - p[0][NR::X]) * (r->y - p[0][NR::Y]) / (p[1][NR::Y] - p[0][NR::Y]); } if (x < r->x) return -1; if (x > r->x) return 1; - ldx = l->stepx * (p[1].y - p[0].y); - rdx = p[1].x - p[0].x; + ldx = l->stepx * (p[1][NR::Y] - p[0][NR::Y]); + rdx = p[1][NR::X] - p[0][NR::X]; if (ldx < rdx) return -1; if (ldx > rdx) return 1; } diff --git a/src/libnr/nr-svp.cpp b/src/libnr/nr-svp.cpp index 7fa2cfd36..e9581e969 100644 --- a/src/libnr/nr-svp.cpp +++ b/src/libnr/nr-svp.cpp @@ -48,9 +48,9 @@ nr_svp_bbox (NRSVP *svp, NRRect *bbox, unsigned int clear) seg = svp->segments + sidx; if (seg->length) { x0 = MIN (x0, seg->x0); - y0 = MIN (y0, svp->points[seg->start].y); + y0 = MIN (y0, svp->points[seg->start][NR::Y]); x1 = MAX (x1, seg->x1); - y1 = MAX (y1, svp->points[seg->start + seg->length - 1].y); + y1 = MAX (y1, svp->points[seg->start + seg->length - 1][NR::Y]); } } diff --git a/src/libnr/nr-svp.h b/src/libnr/nr-svp.h index ca1521f29..122238db6 100644 --- a/src/libnr/nr-svp.h +++ b/src/libnr/nr-svp.h @@ -14,8 +14,7 @@ #include #include - -struct NRPoint; +#include struct NRSVPSegment { gint16 wind; @@ -33,7 +32,7 @@ struct NRSVPFlat { struct NRSVP { unsigned int length; - NRPoint *points; + NR::Point *points; NRSVPSegment segments[1]; }; diff --git a/src/libnr/nr-values.cpp b/src/libnr/nr-values.cpp index 846a16bb8..f828c1396 100644 --- a/src/libnr/nr-values.cpp +++ b/src/libnr/nr-values.cpp @@ -1,14 +1,14 @@ #define __NR_VALUES_C__ #include +#include /* The following predefined objects are for reference and comparison. */ -NRMatrix NR_MATRIX_IDENTITY = - {{1.0, 0.0, 0.0, 1.0, 0.0, 0.0}}; +NR::Matrix NR_MATRIX_IDENTITY = NR::identity(); NRRect NR_RECT_EMPTY(NR_HUGE, NR_HUGE, -NR_HUGE, -NR_HUGE); NRRectL NR_RECT_L_EMPTY = {NR_HUGE_L, NR_HUGE_L, -NR_HUGE_L, -NR_HUGE_L}; diff --git a/src/libnr/nr-values.h b/src/libnr/nr-values.h index 7fa00d809..fb3c574a6 100644 --- a/src/libnr/nr-values.h +++ b/src/libnr/nr-values.h @@ -22,7 +22,7 @@ The following predefined objects are for reference and comparison. They are defined in nr-values.cpp */ -extern NRMatrix NR_MATRIX_IDENTITY; +extern NR::Matrix NR_MATRIX_IDENTITY; extern NRRect NR_RECT_EMPTY; extern NRRectL NR_RECT_L_EMPTY; extern NRRectL NR_RECT_S_EMPTY; diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index d689fbe30..9ff953c47 100755 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -15,6 +15,7 @@ #include "print.h" #include "extension/print.h" #include "livarot/Path.h" +#include "libnr/nr-matrix-fns.h" #include "libnr/nr-scale-matrix-ops.h" #include "font-instance.h" #include "svg/svg-length.h" @@ -55,7 +56,7 @@ void Layout::LineHeight::max(LineHeight const &other) if (other.leading > leading) leading = other.leading; } -void Layout::_getGlyphTransformMatrix(int glyph_index, NRMatrix *matrix) const +void Layout::_getGlyphTransformMatrix(int glyph_index, NR::Matrix *matrix) const { Span const &span = _glyphs[glyph_index].span(this); double sin_rotation = sin(_glyphs[glyph_index].rotation); @@ -86,7 +87,7 @@ void Layout::show(NRArenaGroup *in_arena, NRRect const *paintbox) const nr_arena_glyphs_group_set_style(nr_group, text_source->style); while (glyph_index < (int)_glyphs.size() && _characters[_glyphs[glyph_index].in_character].in_span == span_index) { if (_characters[_glyphs[glyph_index].in_character].in_glyph != -1) { - NRMatrix glyph_matrix; + NR::Matrix glyph_matrix; _getGlyphTransformMatrix(glyph_index, &glyph_matrix); nr_arena_glyphs_group_add_component(nr_group, _spans[span_index].font, _glyphs[glyph_index].glyph, &glyph_matrix); } @@ -108,7 +109,7 @@ void Layout::getBoundingBox(NRRect *bounding_box, NR::Matrix const &transform, i if ((int) _glyphs[glyph_index].in_character > start + length) continue; } // this could be faster - NRMatrix glyph_matrix; + NR::Matrix glyph_matrix; _getGlyphTransformMatrix(glyph_index, &glyph_matrix); NR::Matrix total_transform = glyph_matrix; total_transform *= transform; @@ -133,7 +134,7 @@ void Layout::getBoundingBox(NRRect *bounding_box, NR::Matrix const &transform, i void Layout::print(SPPrintContext *ctx, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, - NRMatrix const &ctm) const + NR::Matrix const &ctm) const { if (_input_stream.empty()) return; @@ -147,7 +148,7 @@ void Layout::print(SPPrintContext *ctx, glyph_index++; continue; } - NRMatrix glyph_matrix; + NR::Matrix glyph_matrix; Span const &span = _spans[_characters[_glyphs[glyph_index].in_character].in_span]; InputStreamTextSource const *text_source = static_cast(_input_stream[span.in_input_stream_item]); if (text_to_path || _path_fitted) { @@ -168,12 +169,12 @@ void Layout::print(SPPrintContext *ctx, NR::Point g_pos(0,0); // all strings are output at (0,0) because we do the translation using the matrix glyph_matrix = NR::Matrix(NR::scale(1.0, -1.0) * NR::Matrix(NR::rotate(_glyphs[glyph_index].rotation))); if (block_progression == LEFT_TO_RIGHT || block_progression == RIGHT_TO_LEFT) { - glyph_matrix.c[4] = span.line(this).baseline_y + span.baseline_shift; + glyph_matrix[4] = span.line(this).baseline_y + span.baseline_shift; // since we're outputting character codes, not glyphs, we want the character x - glyph_matrix.c[5] = span.chunk(this).left_x + span.x_start + _characters[_glyphs[glyph_index].in_character].x; + glyph_matrix[5] = span.chunk(this).left_x + span.x_start + _characters[_glyphs[glyph_index].in_character].x; } else { - glyph_matrix.c[4] = span.chunk(this).left_x + span.x_start + _characters[_glyphs[glyph_index].in_character].x; - glyph_matrix.c[5] = span.line(this).baseline_y + span.baseline_shift; + glyph_matrix[4] = span.chunk(this).left_x + span.x_start + _characters[_glyphs[glyph_index].in_character].x; + glyph_matrix[5] = span.line(this).baseline_y + span.baseline_shift; } Glib::ustring::const_iterator span_iter = span.input_stream_first_character; unsigned char_index = _glyphs[glyph_index].in_character; @@ -226,7 +227,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const Span const &span = _spans[_characters[_glyphs[glyph_index].in_character].in_span]; InputStreamTextSource const *text_source = static_cast(_input_stream[span.in_input_stream_item]); - NRMatrix glyph_matrix; + NR::Matrix glyph_matrix; _getGlyphTransformMatrix(glyph_index, &glyph_matrix); if (clip_mode) { NArtBpath *bpath = (NArtBpath*)span.font->ArtBPath(_glyphs[glyph_index].glyph); @@ -242,13 +243,13 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const continue; } - NRMatrix font_matrix; + NR::Matrix font_matrix; if (_path_fitted == NULL) { font_matrix = glyph_matrix; font_matrix[4] = 0; font_matrix[5] = 0; } else { - nr_matrix_set_identity(&font_matrix); + font_matrix.set_identity(); } Glib::ustring::const_iterator span_iter = span.input_stream_first_character; @@ -276,8 +277,8 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const CairoGlyphInfo info; info.index = _glyphs[glyph_index].glyph; if (_path_fitted == NULL) { - info.x = glyph_matrix.c[4]; - info.y = glyph_matrix.c[5]; + info.x = glyph_matrix[4]; + info.y = glyph_matrix[5]; } else { info.x = 0; info.y = 0; @@ -288,7 +289,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const } } while (glyph_index < _glyphs.size() && _path_fitted == NULL - && nr_matrix_test_transform_equal(&font_matrix, &glyph_matrix, NR_EPSILON) + && NR::transform_equalp(font_matrix, glyph_matrix, NR_EPSILON) && _characters[_glyphs[glyph_index].in_character].in_span == this_span_index); // remove vertical flip @@ -543,7 +544,7 @@ SPCurve *Layout::convertToCurves(iterator const &from_glyph, iterator const &to_ GSList *cc = NULL; for (int glyph_index = from_glyph._glyph_index ; glyph_index < to_glyph._glyph_index ; glyph_index++) { - NRMatrix glyph_matrix; + NR::Matrix glyph_matrix; Span const &span = _glyphs[glyph_index].span(this); _getGlyphTransformMatrix(glyph_index, &glyph_matrix); diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index 63a48e562..ec12ddff5 100755 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -337,7 +337,7 @@ public: \param bbox parameters \param ctm do yet */ - void print(SPPrintContext *ctx, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, NRMatrix const &ctm) const; + void print(SPPrintContext *ctx, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, NR::Matrix const &ctm) const; #ifdef HAVE_CAIRO_PDF /** Renders all the glyphs to the given Cairo rendering context. @@ -733,7 +733,7 @@ private: /** gets the overall matrix that transforms the given glyph from local space to world space. */ - void _getGlyphTransformMatrix(int glyph_index, NRMatrix *matrix) const; + void _getGlyphTransformMatrix(int glyph_index, NR::Matrix *matrix) const; // loads of functions to drill down the object tree, all of them // annoyingly similar and all of them requiring predicate functors. diff --git a/src/libnrtype/RasterFont.cpp b/src/libnrtype/RasterFont.cpp index c9af6621f..61ef1720b 100644 --- a/src/libnrtype/RasterFont.cpp +++ b/src/libnrtype/RasterFont.cpp @@ -26,7 +26,7 @@ void font_style::Apply(Path* src,Shape* dest) { if ( stroke_width > 0 ) { if ( nbDash > 0 ) { double dlen = 0.0; - const float scale = 1/*NR_MATRIX_DF_EXPANSION (&transform)*/; + const float scale = 1/*NR::expansion(transform)*/; for (int i = 0; i < nbDash; i++) dlen += dashes[i] * scale; if (dlen >= 0.01) { float sc_offset = dash_offset * scale; diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index 2b398ef7c..7000bb115 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -7,6 +7,7 @@ */ #include "livarot/Shape.h" +#include #include #include "livarot/Path.h" #include "livarot/path-description.h" @@ -634,7 +635,7 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, if (this_power != 0) done_something = true; - double scaler = 1 / (*i2doc).expansion(); + double scaler = 1 / NR::expansion(*i2doc); NR::Point this_vec(0,0); if (mode == tweak_mode_push) { diff --git a/src/marker.cpp b/src/marker.cpp index 08f1b5fad..aacbee875 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -20,7 +20,9 @@ #include "libnr/nr-matrix-fns.h" #include "libnr/nr-matrix-ops.h" +#include "libnr/nr-matrix-translate-ops.h" #include "libnr/nr-scale-matrix-ops.h" +#include "libnr/nr-translate-matrix-ops.h" #include "libnr/nr-rotate-fns.h" #include "svg/svg.h" #include "display/nr-arena-group.h" @@ -116,7 +118,7 @@ sp_marker_init (SPMarker *marker) { marker->viewBox_set = FALSE; - nr_matrix_set_identity (&marker->c2p); + marker->c2p.set_identity(); } /** @@ -353,7 +355,6 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) SPItemCtx rctx; NRRect *vb; double x, y, width, height; - NRMatrix q; SPMarkerView *v; item = SP_ITEM (object); @@ -373,7 +374,7 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) rctx.vp.y1 = marker->markerHeight.computed; /* Start with identity transform */ - nr_matrix_set_identity (&marker->c2p); + marker->c2p.set_identity(); /* Viewbox is always present, either implicitly or explicitly */ if (marker->viewBox_set) { @@ -440,21 +441,23 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) break; } } - /* Compose additional transformation from scale and position */ - q.c[0] = width / (vb->x1 - vb->x0); - q.c[1] = 0.0; - q.c[2] = 0.0; - q.c[3] = height / (vb->y1 - vb->y0); - q.c[4] = -vb->x0 * q.c[0] + x; - q.c[5] = -vb->y0 * q.c[3] + y; - /* Append viewbox transformation */ - nr_matrix_multiply (&marker->c2p, &q, &marker->c2p); + { + NR::Matrix q; + /* Compose additional transformation from scale and position */ + q[0] = width / (vb->x1 - vb->x0); + q[1] = 0.0; + q[2] = 0.0; + q[3] = height / (vb->y1 - vb->y0); + q[4] = -vb->x0 * q[0] + x; + q[5] = -vb->y0 * q[3] + y; + /* Append viewbox transformation */ + marker->c2p = q * marker->c2p; + } /* Append reference translation */ /* fixme: lala (Lauris) */ - nr_matrix_set_translate (&q, -marker->refX.computed, -marker->refY.computed); - nr_matrix_multiply (&marker->c2p, &q, &marker->c2p); + marker->c2p = NR::translate(-marker->refX.computed, -marker->refY.computed) * marker->c2p; rctx.i2doc = marker->c2p * rctx.i2doc; diff --git a/src/marker.h b/src/marker.h index ef8fcd583..9686b8213 100644 --- a/src/marker.h +++ b/src/marker.h @@ -61,7 +61,7 @@ struct SPMarker : public SPGroup { unsigned int aspect_clip : 1; /* Child to parent additional transform */ - NRMatrix c2p; + NR::Matrix c2p; /* Private views */ SPMarkerView *views; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index b9a084ec1..2a6c84bc7 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -38,6 +38,7 @@ #include "display/sodipodi-ctrl.h" #include #include "libnr/n-art-bpath.h" +#include "libnr/nr-point-ops.h" #include "helper/units.h" #include "macros.h" #include "context-fns.h" @@ -864,7 +865,7 @@ pen_lastpoint_tocurve (SPPenContext *const pc) if (bpath && bpath->code == NR_CURVETO) { pc->p[1] = pc->p[0] + (NR::Point(bpath->x3, bpath->y3) - NR::Point(bpath->x2, bpath->y2)); } else { - pc->p[1] = pc->p[0] + (pc->p[3] - pc->p[0])*(1/3); + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); } pen_redraw_all(pc); diff --git a/src/print.cpp b/src/print.cpp index cc5d8c0a1..b557298ef 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -29,12 +29,12 @@ unsigned int sp_print_bind(SPPrintContext *ctx, NR::Matrix const &transform, float opacity) { - NRMatrix const ntransform(transform); + NR::Matrix const ntransform(transform); return sp_print_bind(ctx, &ntransform, opacity); } unsigned int -sp_print_bind(SPPrintContext *ctx, NRMatrix const *transform, float opacity) +sp_print_bind(SPPrintContext *ctx, NR::Matrix const *transform, float opacity) { return ctx->module->bind(transform, opacity); } @@ -52,14 +52,14 @@ sp_print_comment(SPPrintContext *ctx, char const *comment) } unsigned int -sp_print_fill(SPPrintContext *ctx, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *style, +sp_print_fill(SPPrintContext *ctx, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { return ctx->module->fill(bpath, ctm, style, pbox, dbox, bbox); } unsigned int -sp_print_stroke(SPPrintContext *ctx, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *style, +sp_print_stroke(SPPrintContext *ctx, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) { return ctx->module->stroke(bpath, ctm, style, pbox, dbox, bbox); @@ -68,7 +68,7 @@ sp_print_stroke(SPPrintContext *ctx, NRBPath const *bpath, NRMatrix const *ctm, unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *transform, SPStyle const *style) + NR::Matrix const *transform, SPStyle const *style) { return ctx->module->image(px, w, h, rs, transform, style); } diff --git a/src/print.h b/src/print.h index 3109b4947..dd5c1fa73 100644 --- a/src/print.h +++ b/src/print.h @@ -21,17 +21,17 @@ struct SPPrintContext { }; unsigned int sp_print_bind(SPPrintContext *ctx, NR::Matrix const &transform, float opacity); -unsigned int sp_print_bind(SPPrintContext *ctx, NRMatrix const *transform, float opacity); +unsigned int sp_print_bind(SPPrintContext *ctx, NR::Matrix const *transform, float opacity); unsigned int sp_print_release(SPPrintContext *ctx); unsigned int sp_print_comment(SPPrintContext *ctx, char const *comment); -unsigned int sp_print_fill(SPPrintContext *ctx, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *style, +unsigned int sp_print_fill(SPPrintContext *ctx, NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); -unsigned int sp_print_stroke(SPPrintContext *ctx, NRBPath const *bpath, NRMatrix const *transform, SPStyle const *style, +unsigned int sp_print_stroke(SPPrintContext *ctx, NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox); unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, guchar *px, unsigned int w, unsigned int h, unsigned int rs, - NRMatrix const *transform, SPStyle const *style); + NR::Matrix const *transform, SPStyle const *style); unsigned int sp_print_text(SPPrintContext *ctx, char const *text, NR::Point p, SPStyle const *style); diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 70d7b7721..a25b39961 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -419,7 +419,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent SPItem *item = selection->singleItem(); if (item && SP_IS_RECT (item)) { g_print ("Scaling transformation matrix\n"); - SP_RECT (item)->transform = nr_matrix_set_scale(SP_RECT (item)->transform, 1.25, 1.5); + SP_RECT (item)->transform = NR::Matrix(NR::scale(1.25, 1.5)); SP_OBJECT (item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } ret = TRUE; diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index dd8e1124e..d73e99e7c 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -305,9 +305,9 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) { (( !SP_OBJECT_STYLE(item)->stroke.isNone() ? desktop->current_zoom() * SP_OBJECT_STYLE (item)->stroke_width.computed * 0.5 * - sp_item_i2d_affine (item).expansion() + NR::expansion(sp_item_i2d_affine(item)) : 0.0) - + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /sp_item_i2d_affine (item).expansion(); + + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(sp_item_i2d_affine(item)); bool close = (NR::L2 (delta) < stroke_tolerance); if (remember && close) { diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 881605a13..7a0d3ed5b 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -205,10 +205,9 @@ sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags) SPClipPath *cp = SP_CLIPPATH(object); for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - NRMatrix t; - nr_matrix_set_scale(&t, v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0); - t.c[4] = v->bbox.x0; - t.c[5] = v->bbox.y0; + NR::Matrix t(NR::scale(v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0)); + t[4] = v->bbox.x0; + t[5] = v->bbox.y0; nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), &t); } else { nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), NULL); @@ -279,10 +278,9 @@ sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key) } if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - NRMatrix t; - nr_matrix_set_scale(&t, cp->display->bbox.x1 - cp->display->bbox.x0, cp->display->bbox.y1 - cp->display->bbox.y0); - t.c[4] = cp->display->bbox.x0; - t.c[5] = cp->display->bbox.y0; + NR::Matrix t(NR::scale(cp->display->bbox.x1 - cp->display->bbox.x0, cp->display->bbox.y1 - cp->display->bbox.y0)); + t[4] = cp->display->bbox.x0; + t[5] = cp->display->bbox.y0; nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), &t); } diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 02544d0b1..b9ed10cbc 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1518,10 +1518,7 @@ sp_lineargradient_painter_new(SPPaintServer *ps, } - NRMatrix v2px; - color2px.copyto(&v2px); - - nr_lgradient_renderer_setup(&lgp->lgr, gr->color, sp_gradient_get_spread(gr), &v2px, + nr_lgradient_renderer_setup(&lgp->lgr, gr->color, sp_gradient_get_spread(gr), &color2px, lg->x1.computed, lg->y1.computed, lg->x2.computed, lg->y2.computed); @@ -1797,11 +1794,8 @@ sp_radialgradient_painter_new(SPPaintServer *ps, gs2px = gr->gradientTransform * full_transform; } - NRMatrix gs2px_nr; - gs2px.copyto(&gs2px_nr); - nr_rgradient_renderer_setup(&rgp->rgr, gr->color, sp_gradient_get_spread(gr), - &gs2px_nr, + &gs2px, rg->cx.computed, rg->cy.computed, rg->fx.computed, rg->fy.computed, rg->r.computed); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 8c9df56b4..95e104b76 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include //#define GDK_PIXBUF_ENABLE_BACKEND 1 //#include #include "display/nr-arena-image.h" @@ -996,7 +999,6 @@ static void sp_image_print (SPItem *item, SPPrintContext *ctx) { SPImage *image; - NRMatrix tp, ti, s, t; guchar *px; int w, h, rs, pixskip; @@ -1011,20 +1013,22 @@ sp_image_print (SPItem *item, SPPrintContext *ctx) rs = gdk_pixbuf_get_rowstride (image->pixbuf); pixskip = gdk_pixbuf_get_n_channels (image->pixbuf) * gdk_pixbuf_get_bits_per_sample (image->pixbuf) / 8; + NR::Matrix t; if (image->aspect_align == SP_ASPECT_NONE) { /* fixme: (Lauris) */ - nr_matrix_set_translate (&tp, image->x.computed, image->y.computed); - nr_matrix_set_scale (&s, image->width.computed, -image->height.computed); - nr_matrix_set_translate (&ti, 0.0, -1.0); + NR::translate tp = NR::translate(image->x.computed, image->y.computed); + NR::scale s = NR::scale(image->width.computed, -image->height.computed); + NR::translate ti = NR::translate(0.0, -1.0); + t = s * tp; + t = ti * t; } else { // preserveAspectRatio - nr_matrix_set_translate (&tp, image->viewx, image->viewy); - nr_matrix_set_scale (&s, image->viewwidth, -image->viewheight); - nr_matrix_set_translate (&ti, 0.0, -1.0); + NR::translate tp = NR::translate(image->viewx, image->viewy); + NR::scale s = NR::scale(image->viewwidth, -image->viewheight); + NR::translate ti = NR::translate(0.0, -1.0); + t = s * tp; + t = ti * t; } - nr_matrix_multiply (&t, &s, &tp); - nr_matrix_multiply (&t, &ti, &t); - if (image->aspect_align == SP_ASPECT_NONE) sp_print_image_R8G8B8A8_N (ctx, px, w, h, rs, &t, SP_OBJECT_STYLE (item)); else // preserveAspectRatio diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 65d8b997c..4b5ddb373 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1248,16 +1248,16 @@ sp_item_adjust_livepatheffect (SPItem *item, NR::Matrix const &postmul, bool set } /** - * A temporary wrapper for the next function accepting the NRMatrix + * A temporary wrapper for the next function accepting the NR::Matrix * instead of NR::Matrix */ void -sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NRMatrix const *transform, NR::Matrix const *adv) +sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const *transform, NR::Matrix const *adv) { if (transform == NULL) sp_item_write_transform(item, repr, NR::identity(), adv); else - sp_item_write_transform(item, repr, NR::Matrix (transform), adv); + sp_item_write_transform(item, repr, *transform, adv); } /** diff --git a/src/sp-item.h b/src/sp-item.h index 18a3c2df7..96981aa1d 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -235,7 +235,7 @@ void sp_item_adjust_stroke_width_recursive(SPItem *item, gdouble ex); void sp_item_adjust_paint_recursive(SPItem *item, NR::Matrix advertized_transform, NR::Matrix t_ancestors, bool is_pattern); void sp_item_adjust_livepatheffect(SPItem *item, NR::Matrix const &postmul, bool set = false); -void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NRMatrix const *transform, NR::Matrix const *adv = NULL); +void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const *transform, NR::Matrix const *adv = NULL); void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const &transform, NR::Matrix const *adv = NULL, bool compensate = true); void sp_item_set_item_transform(SPItem *item, NR::Matrix const &transform); diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 0019b598e..4bdf1d40e 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -16,6 +16,7 @@ #include "display/nr-arena.h" #include "display/nr-arena-group.h" +#include "libnr/nr-matrix-ops.h" #include #include "enums.h" @@ -219,10 +220,9 @@ sp_mask_update (SPObject *object, SPCtx *ctx, guint flags) SPMask *mask = SP_MASK (object); for (SPMaskView *v = mask->display; v != NULL; v = v->next) { if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - NRMatrix t; - nr_matrix_set_scale (&t, v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0); - t.c[4] = v->bbox.x0; - t.c[5] = v->bbox.y0; + NR::Matrix t(NR::scale(v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0)); + t[4] = v->bbox.x0; + t[5] = v->bbox.y0; nr_arena_group_set_child_transform (NR_ARENA_GROUP (v->arenaitem), &t); } else { nr_arena_group_set_child_transform (NR_ARENA_GROUP (v->arenaitem), NULL); @@ -325,10 +325,9 @@ sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key) } if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - NRMatrix t; - nr_matrix_set_scale (&t, mask->display->bbox.x1 - mask->display->bbox.x0, mask->display->bbox.y1 - mask->display->bbox.y0); - t.c[4] = mask->display->bbox.x0; - t.c[5] = mask->display->bbox.y0; + NR::Matrix t(NR::scale(mask->display->bbox.x1 - mask->display->bbox.x0, mask->display->bbox.y1 - mask->display->bbox.y0)); + t[4] = mask->display->bbox.x0; + t[5] = mask->display->bbox.y0; nr_arena_group_set_child_transform (NR_ARENA_GROUP (ai), &t); } diff --git a/src/sp-path.cpp b/src/sp-path.cpp index e401d0a20..7dbe51c26 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -377,24 +377,18 @@ sp_path_set_transform(SPItem *item, NR::Matrix const &xform) return NR::identity(); } - if (path->original_curve) { /* Transform the original-d path */ - NRBPath dorigpath, sorigpath; - sorigpath.path = SP_CURVE_BPATH(path->original_curve); - nr_path_duplicate_transform(&dorigpath, &sorigpath, xform); - SPCurve *origcurve = sp_curve_new_from_bpath(dorigpath.path); - if (origcurve) { - sp_path_set_original_curve(path, origcurve, TRUE, true); - sp_curve_unref(origcurve); - } - } else { /* Transform the path */ - NRBPath dpath, spath; - spath.path = SP_CURVE_BPATH(shape->curve); - nr_path_duplicate_transform(&dpath, &spath, xform); - SPCurve *curve = sp_curve_new_from_bpath(dpath.path); - if (curve) { - sp_shape_set_curve(shape, curve, TRUE); - sp_curve_unref(curve); + // Transform the original-d path or the (ordinary) path + bool original_path = (bool)path->original_curve; + SPCurve *srccurve = original_path ? path->original_curve : shape->curve; + SPCurve *dstcurve = sp_curve_copy(srccurve); + if (dstcurve) { + sp_curve_transform(dstcurve, xform); + if (original_path) { + sp_path_set_original_curve(path, dstcurve, TRUE, true); + } else { + sp_shape_set_curve(shape, dstcurve, TRUE); } + sp_curve_unref(dstcurve); } // Adjust stroke diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index c3d35de72..dcf09fdbf 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -44,17 +44,17 @@ struct SPPatPainter { SPPainter painter; SPPattern *pat; - NRMatrix ps2px; - NRMatrix px2ps; - NRMatrix pcs2px; + NR::Matrix ps2px; + NR::Matrix px2ps; + NR::Matrix pcs2px; NRArena *arena; unsigned int dkey; NRArenaItem *root; bool use_cached_tile; - NRMatrix ca2pa; - NRMatrix pa2ca; + NR::Matrix ca2pa; + NR::Matrix pa2ca; NRRectL cached_bbox; NRPixBlock cached_tile; }; @@ -655,10 +655,7 @@ sp_pattern_painter_new (SPPaintServer *ps, NR::Matrix const &full_transform, NR: NR::Matrix const ps2user(pattern_patternTransform(pat) * bbox2user); // see (*) comment below - NR::Matrix ps2px = ps2user * full_transform; - - ps2px.copyto (&pp->ps2px); - + pp->ps2px = ps2user * full_transform; } else { /* Problem: What to do, if we have mixed lengths and percentages? */ /* Currently we do ignore percentages at all, but that is not good (lauris) */ @@ -675,13 +672,11 @@ sp_pattern_painter_new (SPPaintServer *ps, NR::Matrix const &full_transform, NR: // So here I comply with the majority opinion, but leave my interpretation commented out below. // (To get item_transform, I subtract parent from full.) - //NR::Matrix ps2px = (full_transform / parent_transform) * pattern_patternTransform(pat) * parent_transform; - NR::Matrix ps2px = pattern_patternTransform(pat) * full_transform; - - ps2px.copyto (&pp->ps2px); + //pp->ps2px = (full_transform / parent_transform) * pattern_patternTransform(pat) * parent_transform; + pp->ps2px = pattern_patternTransform(pat) * full_transform; } - nr_matrix_invert (&pp->px2ps, &pp->ps2px); + pp->px2ps = pp->ps2px.inverse(); if (pat->viewBox_set) { gdouble tmp_x = (pattern_viewBox(pat)->x1 - pattern_viewBox(pat)->x0) / pattern_width (pat); @@ -693,12 +688,8 @@ sp_pattern_painter_new (SPPaintServer *ps, NR::Matrix const &full_transform, NR: NR::Matrix vb2us = vb2ps * pattern_patternTransform(pat); // see (*) - NR::Matrix pcs2px = vb2us * full_transform; - - pcs2px.copyto (&pp->pcs2px); + pp->pcs2px = vb2us * full_transform; } else { - NR::Matrix pcs2px; - /* No viewbox, have to parse units */ if (pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { /* BBox to user coordinate system */ @@ -707,16 +698,14 @@ sp_pattern_painter_new (SPPaintServer *ps, NR::Matrix const &full_transform, NR: NR::Matrix pcs2user = pattern_patternTransform(pat) * bbox2user; // see (*) - pcs2px = pcs2user * full_transform; + pp->pcs2px = pcs2user * full_transform; } else { // see (*) //pcs2px = (full_transform / parent_transform) * pattern_patternTransform(pat) * parent_transform; - pcs2px = pattern_patternTransform(pat) * full_transform; + pp->pcs2px = pattern_patternTransform(pat) * full_transform; } - pcs2px = NR::translate (pattern_x (pat), pattern_y (pat)) * pcs2px; - - pcs2px.copyto (&pp->pcs2px); + pp->pcs2px = NR::translate (pattern_x (pat), pattern_y (pat)) * pp->pcs2px; } /* Create arena */ @@ -764,18 +753,18 @@ sp_pattern_painter_new (SPPaintServer *ps, NR::Matrix const &full_transform, NR: nr_pixblock_setup (&pp->cached_tile,NR_PIXBLOCK_MODE_R8G8B8A8N, pp->cached_bbox.x0, pp->cached_bbox.y0, pp->cached_bbox.x1, pp->cached_bbox.y1,TRUE); } - pp->pa2ca.c[0]=((double)tr_width)/(one_tile.x1-one_tile.x0); - pp->pa2ca.c[1]=0; - pp->pa2ca.c[2]=0; - pp->pa2ca.c[3]=((double)tr_height)/(one_tile.y1-one_tile.y0); - pp->pa2ca.c[4]=-one_tile.x0*pp->pa2ca.c[0]; - pp->pa2ca.c[5]=-one_tile.y0*pp->pa2ca.c[1]; - pp->ca2pa.c[0]=(one_tile.x1-one_tile.x0)/((double)tr_width); - pp->ca2pa.c[1]=0; - pp->ca2pa.c[2]=0; - pp->ca2pa.c[3]=(one_tile.y1-one_tile.y0)/((double)tr_height); - pp->ca2pa.c[4]=one_tile.x0; - pp->ca2pa.c[5]=one_tile.y0; + pp->pa2ca[0]=((double)tr_width)/(one_tile.x1-one_tile.x0); + pp->pa2ca[1]=0; + pp->pa2ca[2]=0; + pp->pa2ca[3]=((double)tr_height)/(one_tile.y1-one_tile.y0); + pp->pa2ca[4]=-one_tile.x0*pp->pa2ca[0]; + pp->pa2ca[5]=-one_tile.y0*pp->pa2ca[1]; + pp->ca2pa[0]=(one_tile.x1-one_tile.x0)/((double)tr_width); + pp->ca2pa[1]=0; + pp->ca2pa[2]=0; + pp->ca2pa[3]=(one_tile.y1-one_tile.y0)/((double)tr_height); + pp->ca2pa[4]=one_tile.x0; + pp->ca2pa[5]=one_tile.y0; // } else { // pp->use_cached_tile=false; // } @@ -890,15 +879,15 @@ sp_pat_fill (SPPainter *painter, NRPixBlock *pb) unsigned char* cpx=lpx; double px_x = pb->area.x0; - double ps_x=pp->px2ps.c[0]*px_x+pp->px2ps.c[2]*px_y+pp->px2ps.c[4]; - double ps_y=pp->px2ps.c[1]*px_x+pp->px2ps.c[3]*px_y+pp->px2ps.c[5]; + double ps_x=pp->px2ps[0]*px_x+pp->px2ps[2]*px_y+pp->px2ps[4]; + double ps_y=pp->px2ps[1]*px_x+pp->px2ps[3]*px_y+pp->px2ps[5]; for (int i=pb->area.x0;iarea.x1;i++) { while ( ps_x > pat_w ) ps_x-=pat_w; while ( ps_x < 0 ) ps_x+=pat_w; while ( ps_y > pat_h ) ps_y-=pat_h; while ( ps_y < 0 ) ps_y+=pat_h; - double ca_x=pp->pa2ca.c[0]*ps_x+pp->pa2ca.c[2]*ps_y+pp->pa2ca.c[4]; - double ca_y=pp->pa2ca.c[1]*ps_x+pp->pa2ca.c[3]*ps_y+pp->pa2ca.c[5]; + double ca_x=pp->pa2ca[0]*ps_x+pp->pa2ca[2]*ps_y+pp->pa2ca[4]; + double ca_y=pp->pa2ca[1]*ps_x+pp->pa2ca[3]*ps_y+pp->pa2ca[5]; unsigned char n_a,n_r,n_g,n_b; get_cached_tile_pixel(pp,ca_x,ca_y,n_r,n_g,n_b,n_a); cpx[0]=n_r; @@ -907,8 +896,8 @@ sp_pat_fill (SPPainter *painter, NRPixBlock *pb) cpx[3]=n_a; px_x+=1.0; - ps_x+=pp->px2ps.c[0]; - ps_y+=pp->px2ps.c[1]; + ps_x+=pp->px2ps[0]; + ps_y+=pp->px2ps[1]; cpx+=4; } px_y+=1.0; @@ -921,15 +910,15 @@ sp_pat_fill (SPPainter *painter, NRPixBlock *pb) unsigned char* cpx=lpx; double px_x = pb->area.x0; - double ps_x=pp->px2ps.c[0]*px_x+pp->px2ps.c[2]*px_y+pp->px2ps.c[4]; - double ps_y=pp->px2ps.c[1]*px_x+pp->px2ps.c[3]*px_y+pp->px2ps.c[5]; + double ps_x=pp->px2ps[0]*px_x+pp->px2ps[2]*px_y+pp->px2ps[4]; + double ps_y=pp->px2ps[1]*px_x+pp->px2ps[3]*px_y+pp->px2ps[5]; for (int i=pb->area.x0;iarea.x1;i++) { while ( ps_x > pat_w ) ps_x-=pat_w; while ( ps_x < 0 ) ps_x+=pat_w; while ( ps_y > pat_h ) ps_y-=pat_h; while ( ps_y < 0 ) ps_y+=pat_h; - double ca_x=pp->pa2ca.c[0]*ps_x+pp->pa2ca.c[2]*ps_y+pp->pa2ca.c[4]; - double ca_y=pp->pa2ca.c[1]*ps_x+pp->pa2ca.c[3]*ps_y+pp->pa2ca.c[5]; + double ca_x=pp->pa2ca[0]*ps_x+pp->pa2ca[2]*ps_y+pp->pa2ca[4]; + double ca_y=pp->pa2ca[1]*ps_x+pp->pa2ca[3]*ps_y+pp->pa2ca[5]; unsigned char n_a,n_r,n_g,n_b; get_cached_tile_pixel(pp,ca_x,ca_y,n_r,n_g,n_b,n_a); cpx[0]=n_r; @@ -937,8 +926,8 @@ sp_pat_fill (SPPainter *painter, NRPixBlock *pb) cpx[2]=n_b; px_x+=1.0; - ps_x+=pp->px2ps.c[0]; - ps_y+=pp->px2ps.c[1]; + ps_x+=pp->px2ps[0]; + ps_y+=pp->px2ps[1]; cpx+=4; } px_y+=1.0; @@ -955,10 +944,10 @@ sp_pat_fill (SPPainter *painter, NRPixBlock *pb) // Bail out if the transformation matrix has extreme values. If we bail out // however, then something (which was meaningless anyway) won't be rendered, // which is better than getting stuck in a virtually infinite loop - if (fabs(pp->px2ps.c[0]) < 1e6 && - fabs(pp->px2ps.c[3]) < 1e6 && - fabs(pp->px2ps.c[4]) < 1e6 && - fabs(pp->px2ps.c[5]) < 1e6) + if (fabs(pp->px2ps[0]) < 1e6 && + fabs(pp->px2ps[3]) < 1e6 && + fabs(pp->px2ps[4]) < 1e6 && + fabs(pp->px2ps[5]) < 1e6) { nr_rect_d_matrix_transform (&psa, &ba, &pp->px2ps); @@ -980,8 +969,8 @@ sp_pat_fill (SPPainter *painter, NRPixBlock *pb) psx = x * pattern_width (pp->pat); psy = y * pattern_height (pp->pat); - area.x0 = (gint32)(pb->area.x0 - (pp->ps2px.c[0] * psx + pp->ps2px.c[2] * psy)); - area.y0 = (gint32)(pb->area.y0 - (pp->ps2px.c[1] * psx + pp->ps2px.c[3] * psy)); + area.x0 = (gint32)(pb->area.x0 - (pp->ps2px[0] * psx + pp->ps2px[2] * psy)); + area.y0 = (gint32)(pb->area.y0 - (pp->ps2px[1] * psx + pp->ps2px[3] * psy)); area.x1 = area.x0 + pb->area.x1 - pb->area.x0; area.y1 = area.y0 + pb->area.y1 - pb->area.y0; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 6ad5ff638..c3fdeb24b 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -128,7 +128,7 @@ sp_root_init(SPRoot *root) root->width.unset(SVGLength::PERCENT, 1.0, 1.0); root->height.unset(SVGLength::PERCENT, 1.0, 1.0); - /* nr_matrix_set_identity(&root->viewbox); */ + /* root->viewbox.set_identity(); */ root->viewBox_set = FALSE; root->c2p.set_identity(); diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index e990fdf8e..12929e89c 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -799,13 +799,13 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) if (!style->fill.isNone()) { NRBPath bp; bp.path = SP_CURVE_BPATH(shape->curve); - sp_print_fill (ctx, &bp, i2d, style, &pbox, &dbox, &bbox); + sp_print_fill (ctx, &bp, &i2d, style, &pbox, &dbox, &bbox); } if (!style->stroke.isNone()) { NRBPath bp; bp.path = SP_CURVE_BPATH(shape->curve); - sp_print_stroke (ctx, &bp, i2d, style, &pbox, &dbox, &bbox); + sp_print_stroke (ctx, &bp, &i2d, style, &pbox, &dbox, &bbox); } for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 0a7fca4d2..943257c8b 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -97,7 +97,7 @@ sp_symbol_init (SPSymbol *symbol) { symbol->viewBox_set = FALSE; - nr_matrix_set_identity (&symbol->c2p); + symbol->c2p.set_identity(); } static void @@ -269,11 +269,11 @@ sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags) /* Calculate child to parent transformation */ /* Apply parent translation (set up as vewport) */ - nr_matrix_set_translate (&symbol->c2p, rctx.vp.x0, rctx.vp.y0); + symbol->c2p = NR::Matrix(NR::translate(rctx.vp.x0, rctx.vp.y0)); if (symbol->viewBox_set) { double x, y, width, height; - NRMatrix q; + NR::Matrix q; /* Determine actual viewbox in viewport coordinates */ if (symbol->aspect_align == SP_ASPECT_NONE) { x = 0.0; @@ -333,14 +333,14 @@ sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags) } } /* Compose additional transformation from scale and position */ - q.c[0] = width / (symbol->viewBox.x1 - symbol->viewBox.x0); - q.c[1] = 0.0; - q.c[2] = 0.0; - q.c[3] = height / (symbol->viewBox.y1 - symbol->viewBox.y0); - q.c[4] = -symbol->viewBox.x0 * q.c[0] + x; - q.c[5] = -symbol->viewBox.y0 * q.c[3] + y; + q[0] = width / (symbol->viewBox.x1 - symbol->viewBox.x0); + q[1] = 0.0; + q[2] = 0.0; + q[3] = height / (symbol->viewBox.y1 - symbol->viewBox.y0); + q[4] = -symbol->viewBox.x0 * q[0] + x; + q[5] = -symbol->viewBox.y0 * q[3] + y; /* Append viewbox transformation */ - nr_matrix_multiply (&symbol->c2p, &q, &symbol->c2p); + symbol->c2p = q * symbol->c2p; } rctx.i2doc = symbol->c2p * rctx.i2doc; diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 626c1d2ca..672710fd0 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -41,7 +41,7 @@ struct SPSymbol : public SPGroup { unsigned int aspect_clip : 1; /* Child to parent additional transform */ - NRMatrix c2p; + NR::Matrix c2p; }; struct SPSymbolClass { diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 590103d36..bc64c5ebc 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -288,12 +288,11 @@ static void sp_use_print(SPItem *item, SPPrintContext *ctx) { bool translated = false; - NRMatrix tp; SPUse *use = SP_USE(item); if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { - nr_matrix_set_translate(&tp, use->x.computed, use->y.computed); - sp_print_bind(ctx, &tp, 1.0); + NR::Matrix tp(NR::translate(use->x.computed, use->y.computed)); + sp_print_bind(ctx, tp, 1.0); translated = true; } @@ -618,9 +617,8 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) /* As last step set additional transform of arena group */ for (SPItemView *v = item->display; v != NULL; v = v->next) { - NRMatrix t; - nr_matrix_set_translate(&t, use->x.computed, use->y.computed); - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), &t); + NR::Matrix t(NR::translate(use->x.computed, use->y.computed)); + nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), t); } } @@ -721,9 +719,8 @@ sp_use_unlink(SPUse *use) // Set the accummulated transform. { NR::Matrix nomove(NR::identity()); - NRMatrix ctrans = t.operator const NRMatrix&(); // Advertise ourselves as not moving. - sp_item_write_transform(item, SP_OBJECT_REPR(item), &ctrans, &nomove); + sp_item_write_transform(item, SP_OBJECT_REPR(item), t, &nomove); } return item; } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 72f059bdc..b2da4e9f6 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -454,7 +454,7 @@ sp_selected_path_boolop(bool_op bop, const unsigned int verb, const Glib::ustrin // to get a correct style attribute for the new path SPItem* item_source = SP_ITEM(source); NR::Matrix i2root = sp_item_i2root_affine(item_source); - sp_item_adjust_stroke(item_source, i2root.expansion()); + sp_item_adjust_stroke(item_source, NR::expansion(i2root)); sp_item_adjust_pattern(item_source, i2root); sp_item_adjust_gradient(item_source, i2root); sp_item_adjust_livepatheffect(item_source, i2root); @@ -661,7 +661,7 @@ sp_selected_path_outline() } NR::Matrix const transform(item->transform); - float const scale = transform.expansion(); + float const scale = NR::expansion(transform); gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style")); SPStyle *i_style = SP_OBJECT(item)->style; gchar const *mask = SP_OBJECT_REPR(item)->attribute("mask"); diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp index 98a6cbf3b..d33947447 100644 --- a/src/svg/svg-affine.cpp +++ b/src/svg/svg-affine.cpp @@ -108,7 +108,7 @@ sp_svg_transform_read(gchar const *str, NR::Matrix *transform) /* ok, have parsed keyword and args, now modify the transform */ if (!strcmp (keyword, "matrix")) { if (n_args != 6) return false; - a = NR_MATRIX_D_FROM_DOUBLE(args) * a; + a = (*NR_MATRIX_D_FROM_DOUBLE(args)) * a; } else if (!strcmp (keyword, "translate")) { if (n_args == 1) { args[1] = 0; @@ -164,12 +164,12 @@ sp_svg_transform_read(gchar const *str, NR::Matrix *transform) gchar * sp_svg_transform_write(NR::Matrix const &transform) { - NRMatrix const t(transform); + NR::Matrix const t(transform); return sp_svg_transform_write(&t); } gchar * -sp_svg_transform_write(NRMatrix const *transform) +sp_svg_transform_write(NR::Matrix const *transform) { double e; @@ -177,14 +177,14 @@ sp_svg_transform_write(NRMatrix const *transform) return NULL; } - e = 0.000001 * NR_MATRIX_DF_EXPANSION (transform); + e = 0.000001 * NR::expansion(*transform); int prec = prefs_get_int_attribute("options.svgoutput", "numericprecision", 8); int min_exp = prefs_get_int_attribute("options.svgoutput", "minimumexponent", -8); /* fixme: We could use t1 * t1 + t2 * t2 here instead */ - if (NR_DF_TEST_CLOSE (transform->c[1], 0.0, e) && NR_DF_TEST_CLOSE (transform->c[2], 0.0, e)) { - if (NR_DF_TEST_CLOSE (transform->c[4], 0.0, e) && NR_DF_TEST_CLOSE (transform->c[5], 0.0, e)) { - if (NR_DF_TEST_CLOSE (transform->c[0], 1.0, e) && NR_DF_TEST_CLOSE (transform->c[3], 1.0, e)) { + if (NR_DF_TEST_CLOSE ((*transform)[1], 0.0, e) && NR_DF_TEST_CLOSE ((*transform)[2], 0.0, e)) { + if (NR_DF_TEST_CLOSE ((*transform)[4], 0.0, e) && NR_DF_TEST_CLOSE ((*transform)[5], 0.0, e)) { + if (NR_DF_TEST_CLOSE ((*transform)[0], 1.0, e) && NR_DF_TEST_CLOSE ((*transform)[3], 1.0, e)) { /* We are more or less identity */ return NULL; } else { @@ -193,24 +193,24 @@ sp_svg_transform_write(NRMatrix const *transform) unsigned p = 0; strcpy (c + p, "scale("); p += 6; - p += sp_svg_number_write_de (c + p, transform->c[0], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[0], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[3], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[3], prec, min_exp, FALSE); c[p++] = ')'; c[p] = '\000'; g_assert( p <= sizeof(c) ); return g_strdup(c); } } else { - if (NR_DF_TEST_CLOSE (transform->c[0], 1.0, e) && NR_DF_TEST_CLOSE (transform->c[3], 1.0, e)) { + if (NR_DF_TEST_CLOSE ((*transform)[0], 1.0, e) && NR_DF_TEST_CLOSE ((*transform)[3], 1.0, e)) { /* We are more or less translate */ gchar c[256]; unsigned p = 0; strcpy (c + p, "translate("); p += 10; - p += sp_svg_number_write_de (c + p, transform->c[4], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[4], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[5], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[5], prec, min_exp, FALSE); c[p++] = ')'; c[p] = '\000'; g_assert( p <= sizeof(c) ); @@ -220,17 +220,17 @@ sp_svg_transform_write(NRMatrix const *transform) unsigned p = 0; strcpy (c + p, "matrix("); p += 7; - p += sp_svg_number_write_de (c + p, transform->c[0], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[0], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[1], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[1], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[2], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[2], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[3], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[3], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[4], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[4], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[5], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[5], prec, min_exp, FALSE); c[p++] = ')'; c[p] = '\000'; g_assert( p <= sizeof(c) ); @@ -242,17 +242,17 @@ sp_svg_transform_write(NRMatrix const *transform) unsigned p = 0; strcpy (c + p, "matrix("); p += 7; - p += sp_svg_number_write_de (c + p, transform->c[0], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[0], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[1], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[1], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[2], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[2], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[3], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[3], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[4], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[4], prec, min_exp, FALSE); c[p++] = ','; - p += sp_svg_number_write_de (c + p, transform->c[5], prec, min_exp, FALSE); + p += sp_svg_number_write_de (c + p, (*transform)[5], prec, min_exp, FALSE); c[p++] = ')'; c[p] = '\000'; g_assert( p <= sizeof(c) ); diff --git a/src/svg/svg.h b/src/svg/svg.h index 4adacef7a..4b2dea994 100644 --- a/src/svg/svg.h +++ b/src/svg/svg.h @@ -17,12 +17,7 @@ #include #include "svg/svg-length.h" - -struct NArtBpath; -struct NRMatrix; -namespace NR { - class Matrix; -} +#include "libnr/nr-forward.h" /* Generic */ @@ -61,7 +56,7 @@ std::string sp_svg_length_write_with_units(SVGLength const &length); bool sp_svg_transform_read(gchar const *str, NR::Matrix *transform); gchar *sp_svg_transform_write(NR::Matrix const &transform); -gchar *sp_svg_transform_write(NRMatrix const *transform); +gchar *sp_svg_transform_write(NR::Matrix const *transform); double sp_svg_read_percentage (const char * str, double def); diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 5833db4fd..95c144e28 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -281,7 +283,7 @@ Tracer::sioxProcessImage(SPImage *img, //Get absolute X,Y position double xpos = ((double)aImg->bbox.x0) + iwscale * (double)col; NR::Point point(xpos, ypos); - point *= aImg->transform; + point *= *aImg->transform; //point *= imgMat; //point = desktop->doc2dt(point); //g_message("x:%f y:%f\n", point[0], point[1]); @@ -499,19 +501,17 @@ void Tracer::traceThread() if (sp_repr_get_double(imgRepr, "height", &dval)) height = dval; - NR::Matrix trans(NR::translate(x, y)); - double iwidth = (double)pixbuf->get_width(); double iheight = (double)pixbuf->get_height(); double iwscale = width / iwidth; double ihscale = height / iheight; - NR::Matrix scal(NR::scale(iwscale, ihscale)); + NR::translate trans(x, y); + NR::scale scal(iwscale, ihscale); //# Convolve scale, translation, and the original transform - NR::Matrix tf(scal); - tf *= trans; + NR::Matrix tf(scal * trans); tf *= img->transform; diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index a70ae49d3..d2ec3d3c0 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -392,7 +392,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi Shape *theRes = new Shape; NR::Matrix i2doc(sp_item_i2doc_affine(item)); - orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.expansion()); // default 0.059 + orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / NR::expansion(i2doc)); // default 0.059 orig->Fill(theShape, 0); SPCSSAttr *css = sp_repr_css_attr(SP_OBJECT_REPR(item), "style"); @@ -447,7 +447,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi res->Reset(); theRes->ConvertToForme(res); - double th_max = (0.6 - 0.59*sqrt(fidelity)) / i2doc.expansion(); + double th_max = (0.6 - 0.59*sqrt(fidelity)) / NR::expansion(i2doc); double threshold = MAX(th_max, th_max*force); res->ConvertEvenLines(threshold); res->Simplify(threshold / (SP_ACTIVE_DESKTOP->current_zoom())); diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index c00e58f5e..a930cfc99 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -34,12 +34,11 @@ GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const NR::Rect& dbox, unsigned psize) { NRGC gc(NULL); - NRMatrix t; - nr_matrix_set_scale(&t, scale_factor, scale_factor); - nr_arena_item_set_transform(root, &t); + NR::Matrix t(NR::scale(scale_factor, scale_factor)); + nr_arena_item_set_transform(root, t); - nr_matrix_set_identity(&gc.transform); + gc.transform.set_identity(); nr_arena_item_invoke_update( root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 280fc52a6..361df293f 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -873,7 +873,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() arena, key, SP_ITEM_SHOW_DISPLAY); NRGC gc(NULL); - nr_matrix_set_scale(&gc.transform, scaleFactor, scaleFactor); + gc.transform = NR::Matrix(NR::scale(scaleFactor, scaleFactor)); nr_arena_item_invoke_update (root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 6745fcc59..c6d23eee2 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -615,7 +615,7 @@ static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event) font_instance *tface = fprev->rfont->daddy; - double theSize = NR_MATRIX_DF_EXPANSION (&fprev->rfont->style.transform); + double theSize = NR::expansion(fprev->rfont->style.transform); gchar const *p; if (fprev->phrase) { @@ -794,8 +794,7 @@ void sp_font_preview_set_font(SPFontPreview *fprev, font_instance *font, SPFontS if (fprev->font) { - NRMatrix flip; - nr_matrix_set_scale (&flip, fsel->fontsize, -fsel->fontsize); + NR::Matrix flip(NR::scale(fsel->fontsize, -fsel->fontsize)); fprev->rfont = fprev->font->RasterFont(flip, 0); } diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 8c582da83..498a24998 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -623,10 +623,8 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, NRGC gc(NULL); /* Update to renderable state */ double sf = 1.0; - NRMatrix t; - nr_matrix_set_scale(&t, sf, sf); - nr_arena_item_set_transform(root, &t); - nr_matrix_set_identity(&gc.transform); + nr_arena_item_set_transform(root, NR::Matrix(NR::scale(sf, sf))); + gc.transform.set_identity(); nr_arena_item_invoke_update( root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); @@ -657,9 +655,8 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, } sf = (double)psize / (double)block; - nr_matrix_set_scale(&t, sf, sf); - nr_arena_item_set_transform(root, &t); - nr_matrix_set_identity(&gc.transform); + nr_arena_item_set_transform(root, NR::Matrix(NR::scale(sf, sf))); + gc.transform.set_identity(); nr_arena_item_invoke_update( root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE );