summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cd54e98)
raw | patch | inline | side by side (parent: cd54e98)
author | jaspervdg <jaspervdg@users.sourceforge.net> | |
Fri, 21 Mar 2008 19:53:10 +0000 (19:53 +0000) | ||
committer | jaspervdg <jaspervdg@users.sourceforge.net> | |
Fri, 21 Mar 2008 19:53:10 +0000 (19:53 +0000) |
99 files changed:
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 48dc594002c7cf69a9e54ea3f9df57d38610d344..3504dcf4070ffc0284816547751a8dda5e1c8a2c 100644 (file)
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
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)
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 1435eea6fc02da5528bf4bb5615be7a4a876cedc..52bb91c76e7a31781dcceabd08bfffe99c39302b 100644 (file)
--- a/src/desktop.h
+++ b/src/desktop.h
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();
index 899b7b5ca78b43475b6ab5451847119ab87806b1..64583b9f2acc0befc36b10dff2feb9f85e44464b 100644 (file)
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 );
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:
// 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);
}
index ca4e781a97ec9d1331989ae2d625fdaf4e3f66da..9456e8a7e635d57c193bd130618dc1dd2ddc2d41 100644 (file)
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;
}
}
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;
index a2dda988b5b59fa58b1f3b23615661a6d63f7563..0c01211609cbef81157b6790046140c3f6f18667 100644 (file)
struct NRArenaGlyphs : public NRArenaItem {
/* Glyphs data */
SPStyle *style;
- NRMatrix g_transform;
+ NR::Matrix g_transform;
font_instance *font;
gint glyph;
raster_font *sfont;
float x, y;
-// NRMatrix cached_tr;
+// NR::Matrix cached_tr;
// Shape *cached_shp;
// bool cached_shp_dirty;
// bool cached_style_dirty;
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 */
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);
index fcce681a87f5643dcd0bef856c9c1023d1087b97..51f1c6b2f1821179135d9734003614b94fcdbb69 100644 (file)
#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);
group->children = NULL;
group->last = NULL;
group->style = NULL;
- nr_matrix_set_identity (&group->child_transform);
+ group->child_transform.set_identity();
}
static NRArenaItem *
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);
index 1b699fd04f8c25ae2d2d453b29fe2b9e620215fc..ff3ec02dd64a0faf624203e50ed21922ee402728 100644 (file)
unsigned int transparent : 1;
NRArenaItem *children;
NRArenaItem *last;
- NRMatrix child_transform;
+ NR::Matrix child_transform;
SPStyle *style;
static NRArenaGroup *create(NRArena *arena) {
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
index c0c53f0ee42b86501177580ea0da50d59110c817..a2050f75cfa3cf4ccab1aa17d78a4fd2a9de9750 100644 (file)
image->width = 256.0;
image->height = 256.0;
- nr_matrix_set_identity (&image->grid2px);
+ image->grid2px.set_identity();
image->style = 0;
}
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);
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;
index 95b0c0eae69328aea84ec3d15d79cf7258142005..f04146f2065b5acf3775fd1834118091bb47e32d 100644 (file)
#include <libnr/nr-blit.h>
#include <libnr/nr-pixops.h>
+#include <libnr/nr-matrix-ops.h>
+#include <libnr/nr-matrix-fns.h>
#include "nr-arena.h"
#include "nr-arena-item.h"
#include "gc-core.h"
/* 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;
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));
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);
index 6ca1564a171a718e9e78553fa43d86fd43740939..c62c9a6ca5403d8b27f411f026e17c5558ece442 100644 (file)
struct NRGC {
NRGC(NRGC const *p) : parent(p) {}
NRGC const *parent;
- NRMatrix transform;
+ NR::Matrix transform;
};
struct NRArenaItem : public NRObject {
* specified in SVG standard. Required by filters. */
NR::Maybe<NR::Rect> item_bbox;
/* Our affine */
- NRMatrix *transform;
+ NR::Matrix *transform;
/* Clip item */
NRArenaItem *clip;
/* Mask 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);
index 9150b419f73b1f6e2d820657437c92c83a8a8bc7..8e53e7262abfc0fad20ac31fa51382d251d63a5e 100644 (file)
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;
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;
{
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 ecf0e8defc6358d69649450ee2b50e3c598fb9f1..886ee118e12f7cc0ef9c1c80493cdede17752342 100644 (file)
#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 {
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++){
index b4d1fb00dd3fd69ddf811f9fac0391fe379b3a23..5ef43039475e1570cb7c745693270805e98d3d79 100644 (file)
#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"
// 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
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);
index 42b78fa16ad2ec4e244d59b973a17cc14d933b89..1eeb3e8c60343a022a299cf29e742c59670b4eed 100644 (file)
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 );
index 5b7bcdd4eaa4c6cabbb8447b36a1ec96304b1ad8..6836e39af8771ccac3d7ef729f00f58732d9aa47 100644 (file)
#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"
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();
index 6027b5f27e4bf187b54b0c9d73c1ceda9789d524..7423bb7f3de5656f2e3ec43b371eb8bc40d28eec 100644 (file)
return 1;
}
- Matrix trans = *item->ctm;
+ Matrix trans = item->ctm;
FilterSlot slot(_slot_count, item);
Rect item_bbox;
index e948058310edb9889f576257192142267d42552d..a3c7839c765d2092c543a605301e3a21ddf5c6e9 100644 (file)
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));
}
}
index d7863bf19a0bf719d3699142dbed7e46cde6e77c..3c83388d85a7d2ae5a7d4bcf79b24db46f269342 100644 (file)
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{};
index 5c11aa50c5a554b0c3cfc118214bd5e6641b8ae9..66e8a40fbc79acb572dbdf10ecdd5d2814d282b7 100644 (file)
--- 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 0c7cdb92e23f51ed8014e903f3bcc6b73689c750..5fdb47835a4dca9861be89b8a76e4264a06ba4b5 100644 (file)
/* 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 f2855a168076946201774d067eaf101a9b6a0095..caa4a89bd17b4ab5c5d656869dc6f045c81adca6 100644 (file)
/* ----- 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,
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 d7fbbc1aa90aac4939567c01612c4ace0a13290b..a040d5c099c387a9f0bce9ccc2d59abc1f52675c 100644 (file)
#include <libnr/n-art-bpath.h>
#include <libnr/nr-matrix-ops.h>
#include <libnr/nr-matrix-fns.h>
+#include <libnr/nr-matrix-scale-ops.h>
#include <libnr/nr-matrix-translate-ops.h>
#include <libnr/nr-scale-matrix-ops.h>
}
void
-CairoRenderContext::transform(NRMatrix const *transform)
+CairoRenderContext::transform(NR::Matrix const *transform)
{
g_assert( _is_valid );
}
void
-CairoRenderContext::setTransform(NRMatrix const *transform)
+CairoRenderContext::setTransform(NR::Matrix const *transform)
{
g_assert( _is_valid );
}
void
-CairoRenderContext::getTransform(NRMatrix *copy) const
+CairoRenderContext::getTransform(NR::Matrix *copy) const
{
g_assert( _is_valid );
}
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<CairoG
}
bool
-CairoRenderContext::renderGlyphtext(PangoFont *font, NRMatrix const *font_matrix,
+CairoRenderContext::renderGlyphtext(PangoFont *font, NR::Matrix const *font_matrix,
std::vector<CairoGlyphInfo> 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 5950434675903749433ec83e2b120da6e3f3c3f9..948efc438a87dc7516d028867e3892132adaf8d1 100644 (file)
SPClipPath *clip_path;
SPMask* mask;
- NRMatrix transform; // the CTM
+ NR::Matrix transform; // the CTM
};
class CairoRenderContext {
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);
/* 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<CairoGlyphInfo> const &glyphtext, SPStyle const *style);
/* More general rendering methods will have to be added (like fill, stroke) */
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);
};
index 1d103fed27cadb980ebbdd3c54c41b8a066c153b..f13e26abb04a1a7c146dfc5132f456f5a51358b3 100644 (file)
// 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;
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;
static void sp_image_render(SPItem *item, CairoRenderContext *ctx)
{
SPImage *image;
- NRMatrix tp, s, t;
guchar *px;
int w, h, rs;
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));
}
// 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;
&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];
ctx->pushState();
renderer->setStateForItem(ctx, item);
- ctx->transform(root->c2p);
+ ctx->transform(&root->c2p);
sp_group_render(item, ctx);
ctx->popState();
}
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));
/*
state->merge_opacity = FALSE;
ctx->pushLayer();
}
- ctx->transform(item->transform);
+ ctx->transform(&item->transform);
sp_item_invoke_render(item, ctx);
if (state->need_layer)
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);
}
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 6b2fd912c455098c4ce6b8ac97614d21c13e0bc5..d486a78035ca75320a572f7b8fd1dd461bbf8188 100644 (file)
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];
}
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;
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;
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;
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;
index 26ffc1807bf145d63cfc5d614a1da38e7c08037c..fdf0cd490b8ea59eb70f68bc1678c4df713a6729 100644 (file)
@@ -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);
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,
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();
index 116cccb3be45a30d1e9dee8fd2fa551499074aae..1baa06991dcfd9ae020fc0098212ea463542c6e6 100644 (file)
}
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;
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.
}
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;
index 0e15006306f74b6989ca8a9a608fc399e9cce31c..c418eaf5bca9db655e5f9d1e0e534ee7de262736 100644 (file)
std::stack<NR::Matrix> 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);
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);
index f189d6b6b95b62af1978306e7929b477b6934db0..019a8f710cdbc63c39c502078bc5448e211127ee 100644 (file)
}
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);
}
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);
index f18a15d86da37482b3b9bf7b5e097ec67b408aa7..185f86727dc369d58ab8a9febeaec86c4a100863 100644 (file)
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);
index 6cc27988dc4e9deff00b50d1d2cf7204a16ff0c2..e6086aa81c3e9d0525a2c451f7f116847a6a5227 100644 (file)
#include <errno.h>
#include <libnr/n-art-bpath.h>
+#include <libnr/nr-matrix-fns.h>
#include <glib/gmem.h>
#include <glib/gstrfuncs.h>
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);
/* 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*) */
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);
}
}
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";
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.
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;
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";
index 673cde82c4722e470546b3f31da17f112c3c40b8..1397063daddb89193d1e5aee8ca835892f5870e1 100644 (file)
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 */
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);
index 74635b2a609b4e25e71f3818f3bef7c615505cda..b66308c9f1d6d382875722759bdc97a930aef81d 100644 (file)
float scalex, scaley;
int x0, y0, x1, y1;
int width, height;
- NRMatrix affine;
+ NR::Matrix affine;
unsigned char *px;
int sheight, row;
BITMAPINFO bmInfo = {
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);
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);
index d46b5b2fbab0441d238d2a95e2a7963daba4b0ac..6eb634f47c005d88026bb12d9f21809de5675c8e 100644 (file)
/* 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);
*/
};
index 6aed4da25737228c93a38f6bd4aff063f9182992..6f8c1afd2219a939a61942b48e7728a5f2ed71c8 100644 (file)
--- a/src/extension/print.cpp
+++ b/src/extension/print.cpp
}
unsigned int
-Print::bind (const NRMatrix *transform, float opacity)
+Print::bind (const NR::Matrix *transform, float opacity)
{
return imp->bind (this, transform, opacity);
}
}
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);
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 d7cc146c68d7b4574f7194c0ca8944600d61635a..070f928e3724bcb80f79498d9561b30c39e564fa 100644 (file)
--- a/src/extension/print.h
+++ b/src/extension/print.h
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,
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,
index b9ff1287b9bdbc4bc08497b413ec180fdf56f206..46dbfe0f50c8ee58ff11d9811269fdbe1733ba59 100644 (file)
--- a/src/filter-chemistry.cpp
+++ b/src/filter-chemistry.cpp
#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));
}
/**
// 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;
// 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 d263d2ffb273fb17fa615e9a4e225e9805227cef..c6335cb0f90a2912b95fb0a87b1dcdefbd987d01 100644 (file)
--- 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;
index 70bc835bc6420f993b45fdf93b28626361f24495..057877daf61ee76272b084c79443f22fb84d63b8 100644 (file)
@@ -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]);
index f44a514a1e4b69ffe89a88f1be04d468c3e92364..5c1a5748a2ceea0eaab651da4aa6b738bad6ffd9 100644 (file)
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
index 6156f60e6c130e33b62ec17250ff174b85e25ca5..69848e9a6995350c909a1989977df0709a07e13a 100644 (file)
--- a/src/helper/png-write.cpp
+++ b/src/helper/png-write.cpp
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 fbd57cdab908ec5835dc309f20f868f47b19d88d..2e1fda1e5527a250220d4215e4314a75521f364c 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
( !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 cbc4d8eecad4911a33dcdd84ba3eb36b550037f9..b12d141df78528fdfd152e0d540c57bf796f7eef 100644 (file)
--- a/src/libnr/nr-forward.h
+++ b/src/libnr/nr-forward.h
class NArtBpath;
struct NRBPath;
struct NRPixBlock;
-struct NRMatrix;
-struct NRPoint;
struct NRRect;
struct NRRectL;
index 2d52767bf2c189e56bf73de5679bc92f9b366e7f..57ba651f42c745c48eb489093d2c65a226c2dd8c 100644 (file)
#include <libnr/nr-pixblock-pixel.h>
#include <libnr/nr-blit.h>
#include <libnr/nr-gradient.h>
+#include <libnr/nr-matrix-ops.h>
#include <glib/gtypes.h>
#include <stdio.h>
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<Linear>;
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;
}
{
NRRGradientRenderer *rgr = static_cast<NRRGradientRenderer *>(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,
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);
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;
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)
NR_DF_TEST_CLOSE(cy, fy, NR_EPSILON)) {
rgr->render = render<SymmetricRadial>;
- 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;
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;
index 092ed1e22801360d11ea86a7cb9a6f3f66d7845b..1073f36ae18faeace48043584dbcd93aa0cf90b6 100644 (file)
--- a/src/libnr/nr-gradient.h
+++ b/src/libnr/nr-gradient.h
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;
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 0ccad30c4a48b5d0846fba6dcc0ccaae4335e9c4..e0d3dabfbbec3143d56fdef9f2efc78f342da407 100644 (file)
--- a/src/libnr/nr-macros.h
+++ b/src/libnr/nr-macros.h
#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
index 20836674669d8aa50a6d929d2a2b5698a5196f1d..a46aca9095900fadf04c6416e88d5aecd4c67615 100644 (file)
#define SEEN_NR_MATRIX_FNS_H
#include "nr-matrix.h"
+#include <math.h>
namespace NR {
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);
index 02fb28d0c66d6eade19f9d655e25d122b35633cb..e534f9cf62007fa39225f4d61afdd20c833d4041 100644 (file)
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
+++ /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 :
index dee275182da5986f424b31d32a4e00e537198f23..d030bb66cc6d533ddaf9e897855b109eb240ce6c 100644 (file)
#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 */
index b7f064e48521ba3433776263d5f8126c46e30f9a..d0bf25310ffa1e935f05c862cd8a8a6fd1171bee 100644 (file)
}
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);
index 476852890560a4099f5c1cdc0693976d8bd8007e..ee60d8f9b3b11b535ce8a29cf06c891e26acd92d 100644 (file)
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
+++ /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 :
index f51bccaa1d17834d397fe51fd70d47edf9109495..6e5607759f7c760973e60b33a990a5bc4e6422a9 100644 (file)
#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 */
index ed482f46f17ea1253fb9ef763038f0965e28a964..eb1f21d4793ff9c1528802bda0f76e578d154181 100644 (file)
--- a/src/libnr/nr-matrix.cpp
+++ b/src/libnr/nr-matrix.cpp
#include <cstdlib>
#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"
-/**
- * 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
*/
-/**
- * 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.
-/**
- * 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]);
-}
-
-
-
-
-
/**
*
*/
*
*/
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()));
}
*
*/
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 a8af553b6239fef01ac437e087db90dc30bcbad6..f626377e50a2e2f9e0c6f15b24ef5117210e8e83 100644 (file)
--- a/src/libnr/nr-matrix.h
+++ b/src/libnr/nr-matrix.h
#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.
#include <libnr/nr-scale.h>
#include <libnr/nr-translate.h>
-/// 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 {
/**
-
- /**
- *
- */
- 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
-
- }
-
-
-
-
/**
*
*/
}
-
- /**
- *
- */
- Matrix(NRMatrix const *nr);
-
-
/**
*
*/
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;
- }
-
-
/**
*
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<NRMatrix *>(_c);
- }
-
-
-
- /**
- *
- */
- operator NRMatrix const&() const {
- g_assert(sizeof(_c) == sizeof(NRMatrix));
- return *reinterpret_cast<const NRMatrix *>(_c);
- }
-
-
-
- /**
- *
- */
- operator NRMatrix*() {
- g_assert(sizeof(_c) == sizeof(NRMatrix));
- return reinterpret_cast<NRMatrix *>(_c);
- }
-
-
- /**
- *
- */
- operator NRMatrix const*() const {
- g_assert(sizeof(_c) == sizeof(NRMatrix));
- return reinterpret_cast<NRMatrix const *>(_c);
- }
-
-
private:
diff --git a/src/libnr/nr-path.cpp b/src/libnr/nr-path.cpp
index a0011c9dcf9cc474fbbf19307fedbdfc27496836..713cfe43dabc69981509d19951121cb9fcfd2f2c 100644 (file)
--- a/src/libnr/nr-path.cpp
+++ b/src/libnr/nr-path.cpp
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;
}
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 6fdc856941440bbc47193e78b47f61f67f595bff..bf7369be4290883a44ba81467816b86c50153de4 100644 (file)
--- a/src/libnr/nr-path.h
+++ b/src/libnr/nr-path.h
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 60c5586b0526ee8468be7b5440fb710b5fb58fcc..c1ec3adc9230fa534cb73db2dce412c7b5a11187 100644 (file)
--- a/src/libnr/nr-point.h
+++ b/src/libnr/nr-point.h
#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;
_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 f3036eff10be3004c73c7a6d93a9e44b1318ef94..a1c8c93b204fb375b833456ab019cc82dfe73f4d 100644 (file)
--- 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 5d897c6959e7e1b1ccee10fcf40cab6b5651fb83..c61083b4b975eb1b98242534211995ee16aa60b1 100644 (file)
--- a/src/libnr/nr-rect.h
+++ b/src/libnr/nr-rect.h
#include <libnr/nr-point.h>
#include <libnr/nr-maybe.h>
#include <libnr/nr-point-matrix-ops.h>
+#include <libnr/nr-forward.h>
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
/* legacy rect stuff */
-struct NRMatrix;
-
/* NULL rect is infinite */
struct NRRect {
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);
index 3ad1c2ca58132ef1bcf24ae7afa32e9d3ca70ac6..4e53cd5de8380a8685e4f9f13933d32ec1a845d4 100644 (file)
* 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
struct NRSlice {
NRSlice *next;
int wind;
- NRPoint *points;
+ NR::Point *points;
unsigned int current;
unsigned int last;
NR::Coord x;
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); */
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;
}
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 7fa2cfd3690b16884681f0847cde0ae5fb2d4a00..e9581e9693eab45f3c982ef1625c763e3f4fdd7b 100644 (file)
--- a/src/libnr/nr-svp.cpp
+++ b/src/libnr/nr-svp.cpp
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 ca1521f29a535326307f87dde3a54e6a79786380..122238db66ab9225cd03f02b1e1dd623022d490b 100644 (file)
--- a/src/libnr/nr-svp.h
+++ b/src/libnr/nr-svp.h
#include <glib/gtypes.h>
#include <libnr/nr-coord.h>
-
-struct NRPoint;
+#include <libnr/nr-forward.h>
struct NRSVPSegment {
gint16 wind;
struct NRSVP {
unsigned int length;
- NRPoint *points;
+ NR::Point *points;
NRSVPSegment segments[1];
};
index 846a16bb8a439abf83f7b1c51855fe653f765da3..f828c13962b31bc98b7f38591b07d352da62d19b 100644 (file)
--- a/src/libnr/nr-values.cpp
+++ b/src/libnr/nr-values.cpp
#define __NR_VALUES_C__
#include <libnr/nr-rect-l.h>
+#include <libnr/nr-matrix-fns.h>
/*
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 7fa00d80914f0812cb434c7456dd70cb37f9abea..fb3c574a61ef9be9f352df9443c965eed14d8c23 100644 (file)
--- a/src/libnr/nr-values.h
+++ b/src/libnr/nr-values.h
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;
index d689fbe30c8f9066b9e9a1bfe7b9ae8a92e03a4b..9ff953c47ba6ee0bf97b3cb44a117b9eca1aac77 100755 (executable)
#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"
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);
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;
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<InputStreamTextSource const *>(_input_stream[span.in_input_stream_item]);
if (text_to_path || _path_fitted) {
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;
Span const &span = _spans[_characters[_glyphs[glyph_index].in_character].in_span];
InputStreamTextSource const *text_source = static_cast<InputStreamTextSource const *>(_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);
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;
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;
}
} 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);
index 63a48e562e121b1652e17acaec56204e20972ee3..ec12ddff59e12051b8340082428cb7329b9895e3 100755 (executable)
\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.
/** 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.
index c9af6621f36f8d83be4438be543569d87ebb4186..61ef1720b4056dd05d89114228b0fc582b73cc13 100644 (file)
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;
index 2b398ef7c34b4621a221be5fe35bbd5a445004f0..7000bb115618530c49ff728bbff8d60281fdd8ea 100644 (file)
*/
#include "livarot/Shape.h"
+#include <libnr/nr-matrix-fns.h>
#include <libnr/nr-point-fns.h>
#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 08f1b5fad1cdf66ce030b44b6bffe8f6f54fa69b..aacbee87531af918f955c9392d2ae67de25af2bb 100644 (file)
--- a/src/marker.cpp
+++ b/src/marker.cpp
#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"
{
marker->viewBox_set = FALSE;
- nr_matrix_set_identity (&marker->c2p);
+ marker->c2p.set_identity();
}
/**
SPItemCtx rctx;
NRRect *vb;
double x, y, width, height;
- NRMatrix q;
SPMarkerView *v;
item = SP_ITEM (object);
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) {
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 ef8fcd583c9a0f7b9c9eed2f2b09af563394579d..9686b8213514803519e738dc64bf4af51f13885e 100644 (file)
--- a/src/marker.h
+++ b/src/marker.h
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 b9a084ec1f79e1d975b7cccbf2fe6e8047a6f5b7..2a6c84bc7ba02260a285b4573e3b7f77132b5825 100644 (file)
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
#include "display/sodipodi-ctrl.h"
#include <glibmm/i18n.h>
#include "libnr/n-art-bpath.h"
+#include "libnr/nr-point-ops.h"
#include "helper/units.h"
#include "macros.h"
#include "context-fns.h"
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 cc5d8c0a1fad582db858425eea2d24b4a0a33404..b557298ef7d5e0f282bfa0591a6ebd61de5124c1 100644 (file)
--- a/src/print.cpp
+++ b/src/print.cpp
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);
}
}
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);
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 3109b4947e2adf47d37a413882976ce7f8ab4e1c..dd5c1fa7354344f8066803cb38b05caccdaa56cd 100644 (file)
--- a/src/print.h
+++ b/src/print.h
};
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 70d7b7721aff64baecde4972ce3fffd463e844de..a25b39961dd406bc0b1b72e0b07b7e08c08e426f 100644 (file)
--- 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 dd8e1124e675a0c5847e74eeb39738d0c662798d..d73e99e7c8905ca484200ee6e3fead5d6a33e361 100644 (file)
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
(( !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 881605a13c3dfc7cdc16fd4cddc9135ad7f2fa03..7a0d3ed5b9fc95b266ea7e716ace8319251f98a9 100644 (file)
--- a/src/sp-clippath.cpp
+++ b/src/sp-clippath.cpp
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);
}
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 02544d0b1ff805ac409a3b06a98954130dcc3c2a..b9ed10cbc00f9a03de9e270df0e5e103fd690a3c 100644 (file)
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
}
- 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);
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 8c9df56b491d9dee8b2dda4e809aedb5a1e95eef..95e104b7652774de37739cd4266a38ea20e179d1 100644 (file)
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
#include <cstring>
#include <string>
#include <libnr/nr-matrix-fns.h>
+#include <libnr/nr-matrix-ops.h>
+#include <libnr/nr-translate-matrix-ops.h>
+#include <libnr/nr-scale-translate-ops.h>
//#define GDK_PIXBUF_ENABLE_BACKEND 1
//#include <gdk-pixbuf/gdk-pixbuf-io.h>
#include "display/nr-arena-image.h"
sp_image_print (SPItem *item, SPPrintContext *ctx)
{
SPImage *image;
- NRMatrix tp, ti, s, t;
guchar *px;
int w, h, rs, pixskip;
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 65d8b997c729130a31a37a8b2130f05e51052a29..4b5ddb37394aabe43909ae6ebd4444af6b711f76 100644 (file)
--- 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 18a3c2df74f144107fc140114aa9578f4932b884..96981aa1d7b1bd5cedc1655902488ddd53971265 100644 (file)
--- a/src/sp-item.h
+++ b/src/sp-item.h
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 0019b598e87047fc71ea7a902a32fd4d3cf0a686..4bdf1d40ea17caba2fb2fc615e27ab6c92aea6f9 100644 (file)
--- a/src/sp-mask.cpp
+++ b/src/sp-mask.cpp
#include "display/nr-arena.h"
#include "display/nr-arena-group.h"
+#include "libnr/nr-matrix-ops.h"
#include <xml/repr.h>
#include "enums.h"
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);
}
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 e401d0a2085414b05af36d077bb21937149df29c..7dbe51c265c954703bfadc54ccb9fac64df29d9b 100644 (file)
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
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 c3d35de7230c579bc29b6a5161764f58551f4ff6..dcf09fdbf566378e0362f4c9bd519aad49a9c553 100644 (file)
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
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;
// }
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;i<pb->area.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;
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;
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;i<pb->area.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;
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;
// 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);
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 6ad5ff6385798398609a62eb89c2c6b993c5ba15..c3fdeb24bb4bd4792a1464bd33527f49e8456728 100644 (file)
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
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 e990fdf8e9fca402524ca1f4daac39b6b9d00956..12929e89cd74d65980c70ea5c02a578e3819176f 100644 (file)
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
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 0a7fca4d212dad84bd385221196fd46537e7e20a..943257c8bbc4cad39efa298bae9c281c98cf2d48 100644 (file)
--- a/src/sp-symbol.cpp
+++ b/src/sp-symbol.cpp
{
symbol->viewBox_set = FALSE;
- nr_matrix_set_identity (&symbol->c2p);
+ symbol->c2p.set_identity();
}
static void
/* Calculate child to parent transformation */
/* Apply parent <use> 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;
}
}
/* 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 626c1d2ca04d7a78743ccaf278f5ceb0a7ff0e22..672710fd0833e852cc4effab7c3ad7ca7b2141d1 100644 (file)
--- a/src/sp-symbol.h
+++ b/src/sp-symbol.h
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 590103d36b023bd8e72c2c7c481b4331e5a0dcbf..bc64c5ebc87db9fc097264f86418f3f12c2e78fb 100644 (file)
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
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;
}
/* 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);
}
}
// 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 72f059bdcdbb314b4e90ec2e03e9f5e732bc5ba9..b2da4e9f661f98f102911646356c81ec55b70126 100644 (file)
--- 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);
}
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 98a6cbf3b996d4fe13c923bc3ac3238831fcf13a..d339474475251b252222b7ec86eb29179cd0ac9a 100644 (file)
--- a/src/svg/svg-affine.cpp
+++ b/src/svg/svg-affine.cpp
/* 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;
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;
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 {
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) );
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) );
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 4adacef7ab8b282ba1386a5ccc9ee510f9003dce..4b2dea9940e975a3474f2cc4b6a32fcf5efff838 100644 (file)
--- a/src/svg/svg.h
+++ b/src/svg/svg.h
#include <string>
#include "svg/svg-length.h"
-
-struct NArtBpath;
-struct NRMatrix;
-namespace NR {
- class Matrix;
-}
+#include "libnr/nr-forward.h"
/* Generic */
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 5833db4fd7b1a55db98152d9cab183ef285c97af..95c144e28b18b831023685a779ee699601fb8c18 100644 (file)
--- a/src/trace/trace.cpp
+++ b/src/trace/trace.cpp
#include <sp-item.h>
#include <sp-shape.h>
#include <sp-image.h>
+#include <libnr/nr-matrix-ops.h>
+#include <libnr/nr-scale-translate-ops.h>
#include <display/nr-arena.h>
#include <display/nr-arena-shape.h>
//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]);
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 a70ae49d325701a3170a173dafbd550e5a8e80d8..d2ec3d3c0f4c80e23c2b78be9a78c0ab94c92b1c 100644 (file)
--- 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()));
index c00e58f5e1fb85e26921c2dfc54a8684c31e4806..a930cfc991727fdd892334daacf6eab71cdd0ea4 100644 (file)
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 );
index 280fc52a6e1f3a0cb8507ef0d5d817a38e0e15b8..361df293f90c300794f4746138aaf8d2c3332fe5 100644 (file)
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);
index 6745fcc59c996e9402ecf19230835b0c14ac2678..c6d23eee2e264bea83ef66f1a4ad33f9fdd10ee4 100644 (file)
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 8c582da83ca4ef1e4befdcf8547d60ab4accb7db..498a2499807a3f65628f1266a26f08062fe049df 100644 (file)
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
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 );
}
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 );