diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-08-28 22:53:56 +0000 |
|---|---|---|
| committer | Krzysztof Kosinski <tweenk.pl@gmail.com> | 2011-08-28 22:53:56 +0000 |
| commit | f4b79d4a8edc870f099fb9194c8493ec04012ad1 (patch) | |
| tree | 2951d5171168abc288c00d09d04f5e5737e779d5 /src/extension/internal | |
| parent | Tie the snapping of rectangle corners and quadrant points of ellipses to the ... (diff) | |
| parent | Completely remove libnr (diff) | |
| download | inkscape-f4b79d4a8edc870f099fb9194c8493ec04012ad1.tar.gz inkscape-f4b79d4a8edc870f099fb9194c8493ec04012ad1.zip | |
Completely remove libnr
(bzr r10589)
Diffstat (limited to 'src/extension/internal')
| -rw-r--r-- | src/extension/internal/bitmap/crop.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/cairo-render-context.cpp | 124 | ||||
| -rw-r--r-- | src/extension/internal/cairo-render-context.h | 26 | ||||
| -rw-r--r-- | src/extension/internal/cairo-renderer.cpp | 123 | ||||
| -rw-r--r-- | src/extension/internal/emf-win32-print.cpp | 39 | ||||
| -rw-r--r-- | src/extension/internal/emf-win32-print.h | 18 | ||||
| -rw-r--r-- | src/extension/internal/grid.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/latex-pstricks.cpp | 28 | ||||
| -rw-r--r-- | src/extension/internal/latex-pstricks.h | 16 | ||||
| -rw-r--r-- | src/extension/internal/latex-text-renderer.cpp | 26 | ||||
| -rw-r--r-- | src/extension/internal/odf.cpp | 15 | ||||
| -rw-r--r-- | src/extension/internal/pdfinput/svg-builder.cpp | 1 |
12 files changed, 202 insertions, 218 deletions
diff --git a/src/extension/internal/bitmap/crop.cpp b/src/extension/internal/bitmap/crop.cpp index 23e31b510..2ad75a0dc 100644 --- a/src/extension/internal/bitmap/crop.cpp +++ b/src/extension/internal/bitmap/crop.cpp @@ -38,7 +38,7 @@ Crop::postEffect(Magick::Image *image, SPItem *item) { sp_item_scale_rel (item, scale); // Translate proportionaly to the image/bbox ratio - Geom::OptRect bbox(item->getBboxDesktop()); + Geom::OptRect bbox(item->desktopGeometricBounds()); //g_warning("bbox. W:%f, H:%f, X:%f, Y:%f", bbox->dimensions()[Geom::X], bbox->dimensions()[Geom::Y], bbox->min()[Geom::X], bbox->min()[Geom::Y]); Geom::Translate translate (0,0); diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index c3a8a790b..9bafa9432 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -87,19 +87,19 @@ #define TEST(_args) // FIXME: expose these from sp-clippath/mask.cpp -struct SPClipPathView { +/*struct SPClipPathView { SPClipPathView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; + Geom::OptRect bbox; }; struct SPMaskView { SPMaskView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; -}; + Geom::OptRect bbox; +};*/ namespace Inkscape { namespace Extension { @@ -682,12 +682,12 @@ CairoRenderContext::popLayer(void) // copy the correct CTM to mask context /* if (_state->parent_has_userspace) - mask_ctx->setTransform(&getParentState()->transform); + mask_ctx->setTransform(getParentState()->transform); else - mask_ctx->setTransform(&_state->transform); + mask_ctx->setTransform(_state->transform); */ // This is probably not correct... but it seems to do the trick. - mask_ctx->setTransform(&_state->item_transform); + mask_ctx->setTransform(_state->item_transform); // render mask contents to mask_ctx _renderer->applyMask(mask_ctx, mask); @@ -915,7 +915,7 @@ CairoRenderContext::finish(void) } void -CairoRenderContext::transform(Geom::Affine const *transform) +CairoRenderContext::transform(Geom::Affine const &transform) { g_assert( _is_valid ); @@ -924,42 +924,44 @@ CairoRenderContext::transform(Geom::Affine const *transform) cairo_transform(_cr, &matrix); // store new CTM - getTransform(&_state->transform); + _state->transform = getTransform(); } void -CairoRenderContext::setTransform(Geom::Affine const *transform) +CairoRenderContext::setTransform(Geom::Affine const &transform) { g_assert( _is_valid ); cairo_matrix_t matrix; _initCairoMatrix(&matrix, transform); cairo_set_matrix(_cr, &matrix); - _state->transform = *transform; + _state->transform = transform; } -void -CairoRenderContext::getTransform(Geom::Affine *copy) const +Geom::Affine +CairoRenderContext::getTransform() const { g_assert( _is_valid ); cairo_matrix_t ctm; cairo_get_matrix(_cr, &ctm); - (*copy)[0] = ctm.xx; - (*copy)[1] = ctm.yx; - (*copy)[2] = ctm.xy; - (*copy)[3] = ctm.yy; - (*copy)[4] = ctm.x0; - (*copy)[5] = ctm.y0; + Geom::Affine ret; + ret[0] = ctm.xx; + ret[1] = ctm.yx; + ret[2] = ctm.xy; + ret[3] = ctm.yy; + ret[4] = ctm.x0; + ret[5] = ctm.y0; + return ret; } -void -CairoRenderContext::getParentTransform(Geom::Affine *copy) const +Geom::Affine +CairoRenderContext::getParentTransform() const { g_assert( _is_valid ); CairoRenderState *parent_state = getParentState(); - memcpy(copy, &parent_state->transform, sizeof(Geom::Affine)); + return parent_state->transform; } void @@ -1002,7 +1004,7 @@ static bool pattern_hasItemChildren(SPPattern *pat) } cairo_pattern_t* -CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox) +CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox) { g_assert( SP_IS_PATTERN(paintserver) ); @@ -1023,10 +1025,10 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver if (pbox && pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { //Geom::Affine bbox2user (pbox->x1 - pbox->x0, 0.0, 0.0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); - bbox_width_scaler = pbox->x1 - pbox->x0; - bbox_height_scaler = pbox->y1 - pbox->y0; - ps2user[4] = x * bbox_width_scaler + pbox->x0; - ps2user[5] = y * bbox_height_scaler + pbox->y0; + bbox_width_scaler = pbox->width(); + bbox_height_scaler = pbox->height(); + ps2user[4] = x * bbox_width_scaler + pbox->left(); + ps2user[5] = y * bbox_height_scaler + pbox->top(); } else { bbox_width_scaler = 1.0; bbox_height_scaler = 1.0; @@ -1041,27 +1043,22 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // create pattern contents coordinate system if (pat->viewBox_set) { - NRRect *view_box = pattern_viewBox(pat); + Geom::Rect view_box = *pattern_viewBox(pat); double x, y, w, h; - double view_width, view_height; x = 0; y = 0; w = width * bbox_width_scaler; h = height * bbox_height_scaler; - view_width = view_box->x1 - view_box->x0; - view_height = view_box->y1 - view_box->y0; - //calculatePreserveAspectRatio(pat->aspect_align, pat->aspect_clip, view_width, view_height, &x, &y, &w, &h); - pcs2dev[0] = w / view_width; - pcs2dev[3] = h / view_height; - pcs2dev[4] = x - view_box->x0 * pcs2dev[0]; - pcs2dev[5] = y - view_box->y0 * pcs2dev[3]; + pcs2dev[0] = w / view_box.width(); + pcs2dev[3] = h / view_box.height(); + pcs2dev[4] = x - view_box.left() * pcs2dev[0]; + pcs2dev[5] = y - view_box.top() * pcs2dev[3]; } else if (pbox && pattern_patternContentUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { - pcs2dev[0] = pbox->x1 - pbox->x0; - pcs2dev[3] = pbox->y1 - pbox->y0; - + pcs2dev[0] = pbox->width(); + pcs2dev[3] = pbox->height(); } // Calculate the size of the surface which has to be created @@ -1089,7 +1086,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver ps2user[4] = ori[Geom::X]; ps2user[5] = ori[Geom::Y]; - pattern_ctx->setTransform(&pcs2dev); + pattern_ctx->setTransform(pcs2dev); pattern_ctx->pushState(); // create drawing and group @@ -1119,7 +1116,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // set pattern transformation cairo_matrix_t pattern_matrix; - _initCairoMatrix(&pattern_matrix, &ps2user); + _initCairoMatrix(&pattern_matrix, ps2user); cairo_matrix_invert(&pattern_matrix); cairo_pattern_set_matrix(result, &pattern_matrix); @@ -1142,7 +1139,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver cairo_pattern_t* CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const paintserver, - NRRect const *pbox, float alpha) + Geom::OptRect const &pbox, float alpha) { cairo_pattern_t *pattern = NULL; bool apply_bbox2user = FALSE; @@ -1157,7 +1154,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain Geom::Point p2 (lg->x2.computed, lg->y2.computed); if (pbox && SP_GRADIENT(lg)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { // convert to userspace - Geom::Affine bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); + Geom::Affine bbox2user(pbox->width(), 0, 0, pbox->height(), pbox->left(), pbox->top()); p1 *= bbox2user; p2 *= bbox2user; } @@ -1237,7 +1234,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain if (apply_bbox2user) { // convert to userspace cairo_matrix_t bbox2user; - cairo_matrix_init (&bbox2user, pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0); + cairo_matrix_init (&bbox2user, pbox->width(), 0, 0, pbox->height(), pbox->left(), pbox->top()); cairo_matrix_multiply (&pattern_matrix, &bbox2user, &pattern_matrix); } cairo_matrix_invert(&pattern_matrix); // because Cairo expects a userspace->patternspace matrix @@ -1248,7 +1245,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain } void -CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox) +CairoRenderContext::_setFillStyle(SPStyle const *const style, Geom::OptRect const &pbox) { g_return_if_fail( !style->fill.set || style->fill.isColor() @@ -1284,7 +1281,7 @@ CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox } void -CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox) +CairoRenderContext::_setStrokeStyle(SPStyle const *style, Geom::OptRect const &pbox) { float alpha = SP_SCALE24_TO_FLOAT(style->stroke_opacity.value); if (_state->merge_opacity) @@ -1351,7 +1348,7 @@ CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox) } bool -CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox) +CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox) { g_assert( _is_valid ); @@ -1419,7 +1416,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con } bool CairoRenderContext::renderImage(GdkPixbuf *pb, - Geom::Affine const *image_transform, SPStyle const * /*style*/) + Geom::Affine const &image_transform, SPStyle const * /*style*/) { g_assert( _is_valid ); @@ -1442,8 +1439,7 @@ bool CairoRenderContext::renderImage(GdkPixbuf *pb, cairo_save(_cr); // scaling by width & height is not needed because it will be done by Cairo - if (image_transform) - transform(image_transform); + transform(image_transform); cairo_set_source_surface(_cr, image_surface, 0.0, 0.0); @@ -1507,7 +1503,7 @@ unsigned int CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont * /*font*/, } bool -CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_matrix, +CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix, std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style) { // create a cairo_font_face from PangoFont @@ -1575,7 +1571,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma stroke = true; } if (fill) { - _setFillStyle(style, NULL); + _setFillStyle(style, Geom::OptRect()); if (_is_texttopath) { _showGlyphs(_cr, font, glyphtext, true); have_path = true; @@ -1586,7 +1582,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma } } if (stroke) { - _setStrokeStyle(style, NULL); + _setStrokeStyle(style, Geom::OptRect()); if (!have_path) _showGlyphs(_cr, font, glyphtext, true); cairo_stroke(_cr); } @@ -1625,22 +1621,22 @@ CairoRenderContext::_concatTransform(cairo_t *cr, double xx, double yx, double x } void -CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const *transform) +CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const &transform) { - matrix->xx = (*transform)[0]; - matrix->yx = (*transform)[1]; - matrix->xy = (*transform)[2]; - matrix->yy = (*transform)[3]; - matrix->x0 = (*transform)[4]; - matrix->y0 = (*transform)[5]; + matrix->xx = transform[0]; + matrix->yx = transform[1]; + matrix->xy = transform[2]; + matrix->yy = transform[3]; + matrix->x0 = transform[4]; + matrix->y0 = transform[5]; } void -CairoRenderContext::_concatTransform(cairo_t *cr, Geom::Affine const *transform) +CairoRenderContext::_concatTransform(cairo_t *cr, Geom::Affine const &transform) { - _concatTransform(cr, (*transform)[0], (*transform)[1], - (*transform)[2], (*transform)[3], - (*transform)[4], (*transform)[5]); + _concatTransform(cr, transform[0], transform[1], + transform[2], transform[3], + transform[4], transform[5]); } static cairo_status_t diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index d4117ff7e..94c7bb294 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -128,20 +128,20 @@ public: CairoRenderState *getParentState(void) const; void setStateForStyle(SPStyle const *style); - void transform(Geom::Affine const *transform); - void setTransform(Geom::Affine const *transform); - void getTransform(Geom::Affine *copy) const; - void getParentTransform(Geom::Affine *copy) const; + void transform(Geom::Affine const &transform); + void setTransform(Geom::Affine const &transform); + Geom::Affine getTransform() const; + Geom::Affine getParentTransform() const; /* Clipping methods */ void addClipPath(Geom::PathVector const &pv, SPIEnum const *fill_rule); void addClippingRect(double x, double y, double width, double height); /* Rendering methods */ - bool renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox); + bool renderPathVector(Geom::PathVector const &pathv, SPStyle const *style, Geom::OptRect const &pbox); bool renderImage(GdkPixbuf *pb, - Geom::Affine const *image_transform, SPStyle const *style); - bool renderGlyphtext(PangoFont *font, Geom::Affine const *font_matrix, + Geom::Affine const &image_transform, SPStyle const *style); + bool renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix, std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style); /* More general rendering methods will have to be added (like fill, stroke) */ @@ -183,18 +183,18 @@ protected: CairoClipMode _clip_mode; cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver, - NRRect const *pbox, float alpha); - cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox); + Geom::OptRect const &pbox, float alpha); + cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox); unsigned int _showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoGlyphInfo> const &glyphtext, bool is_stroke); bool _finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t *ctm = NULL); - void _setFillStyle(SPStyle const *style, NRRect const *pbox); - void _setStrokeStyle(SPStyle const *style, NRRect const *pbox); + void _setFillStyle(SPStyle const *style, Geom::OptRect const &pbox); + void _setStrokeStyle(SPStyle const *style, Geom::OptRect const &pbox); - void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const *transform); + void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const &transform); void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0); - void _concatTransform(cairo_t *cr, Geom::Affine const *transform); + void _concatTransform(cairo_t *cr, Geom::Affine const &transform); GHashTable *font_table; static void font_data_free(gpointer data); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 5e7fb991a..3b6c26113 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -28,7 +28,6 @@ #include <signal.h> #include <errno.h> -#include "libnr/nr-rect.h" #include "libnrtype/Layout-TNG.h" #include <2geom/transforms.h> #include <2geom/pathvector.h> @@ -87,14 +86,14 @@ struct SPClipPathView { SPClipPathView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; + Geom::OptRect bbox; }; struct SPMaskView { SPMaskView *next; unsigned int key; Inkscape::DrawingItem *arenaitem; - NRRect bbox; + Geom::OptRect bbox; }; namespace Inkscape { @@ -181,15 +180,13 @@ static void sp_shape_render_invoke_marker_rendering(SPMarker* marker, Geom::Affi static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) { - NRRect pbox; - SPShape *shape = SP_SHAPE(item); if (!shape->curve) { return; } - item->invoke_bbox( &pbox, Geom::identity(), TRUE); + Geom::OptRect pbox = item->geometricBounds(); SPStyle* style = item->style; @@ -198,7 +195,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) return; } - ctx->renderPathVector(pathv, style, &pbox); + ctx->renderPathVector(pathv, style, pbox); // START marker for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START @@ -316,7 +313,7 @@ static void sp_use_render(SPItem *item, CairoRenderContext *ctx) if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { Geom::Affine tp(Geom::Translate(use->x.computed, use->y.computed)); ctx->pushState(); - ctx->transform(&tp); + ctx->transform(tp); translated = true; } @@ -372,7 +369,7 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx) Geom::Scale s(width / (double)w, height / (double)h); Geom::Affine t(s * tp); - ctx->renderImage (image->pixbuf, &t, item->style); + ctx->renderImage (image->pixbuf, t, item->style); } static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) @@ -384,7 +381,7 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) /* Cloned <symbol> is actually renderable */ ctx->pushState(); - ctx->transform(&symbol->c2p); + ctx->transform(symbol->c2p); // apply viewbox if set if (0 /*symbol->viewBox_set*/) { @@ -396,8 +393,8 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) width = 1.0; height = 1.0; - view_width = symbol->viewBox.x1 - symbol->viewBox.x0; - view_height = symbol->viewBox.y1 - symbol->viewBox.y0; + view_width = symbol->viewBox.width(); + view_height = symbol->viewBox.height(); calculatePreserveAspectRatio(symbol->aspect_align, symbol->aspect_clip, view_width, view_height, &x, &y,&width, &height); @@ -406,10 +403,10 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) vb2user = Geom::identity(); vb2user[0] = width / view_width; vb2user[3] = height / view_height; - vb2user[4] = x - symbol->viewBox.x0 * vb2user[0]; - vb2user[5] = y - symbol->viewBox.y0 * vb2user[3]; + vb2user[4] = x - symbol->viewBox.left() * vb2user[0]; + vb2user[5] = y - symbol->viewBox.top() * vb2user[3]; - ctx->transform(&vb2user); + ctx->transform(vb2user); } sp_group_render(item, ctx); @@ -425,8 +422,7 @@ static void sp_root_render(SPRoot *root, CairoRenderContext *ctx) ctx->pushState(); renderer->setStateForItem(ctx, root); - Geom::Affine tempmat (root->c2p); - ctx->transform(&tempmat); + ctx->transform(root->c2p); sp_group_render(root, ctx); ctx->popState(); } @@ -450,9 +446,8 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } TRACE(("sp_asbitmap_render: resolution: %f\n", res )); - // Get the bounding box of the selection in document coordinates. - Geom::OptRect bbox = - item->getBounds(item->i2dt_affine(), SPItem::RENDERING_BBOX); + // Get the bounding box of the selection in desktop coordinates. + Geom::OptRect bbox = item->desktopVisualBounds(); // no bbox, e.g. empty group if (!bbox) { @@ -460,12 +455,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } Geom::Rect docrect(Geom::Rect(Geom::Point(0, 0), item->document->getDimensions())); - Geom::Rect bboxrect(Geom::Rect(Geom::Point(bbox->min()[Geom::X], bbox->min()[Geom::Y]), Geom::Point(bbox->max()[Geom::X], bbox->max()[Geom::Y]))); - - Geom::OptRect _bbox = Geom::intersect(docrect, bboxrect); - - // assign the object dimension clipped on the document, no need to draw on area not on canvas - bbox = _bbox; + bbox &= docrect; // no bbox, e.g. empty group if (!bbox) { @@ -473,14 +463,14 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } // The width and height of the bitmap in pixels - unsigned width = ceil((bbox->max()[Geom::X] - bbox->min()[Geom::X]) * (res / PX_PER_IN)); - unsigned height = ceil((bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) * (res / PX_PER_IN)); + unsigned width = ceil(bbox->width() * (res / PX_PER_IN)); + unsigned height = ceil(bbox->height() * (res / PX_PER_IN)); if (width == 0 || height == 0) return; // Scale to exactly fit integer bitmap inside bounding box - double scale_x = (bbox->max()[Geom::X] - bbox->min()[Geom::X]) / width; - double scale_y = (bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) / height; + double scale_x = bbox->width() / width; + double scale_y = bbox->height() / height; // Location of bounding box in document coordinates. double shift_x = bbox->min()[Geom::X]; @@ -516,7 +506,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) TEST(gdk_pixbuf_save( pb, "bitmap.png", "png", NULL, NULL )); // TODO this is stupid - we just converted to pixbuf format when generating the bitmap! convert_pixbuf_normal_to_argb32(pb); - ctx->renderImage(pb, &t, item->style); + ctx->renderImage(pb, t, item->style); gdk_pixbuf_unref(pb); pb = 0; } @@ -604,8 +594,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) state->merge_opacity = FALSE; ctx->pushLayer(); } - Geom::Affine tempmat (item->transform); - ctx->transform(&tempmat); + ctx->transform(item->transform); sp_item_invoke_render(item, ctx); if (state->need_layer) @@ -625,25 +614,25 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page base = doc->getRoot(); } - NRRect d; + Geom::Rect d; if (pageBoundingBox) { - d.x0 = d.y0 = 0; - d.x1 = doc->getWidth(); - d.y1 = doc->getHeight(); + d = Geom::Rect::from_xywh(Geom::Point(0,0), doc->getDimensions()); } else { - base->invoke_bbox( &d, base->i2dt_affine(), TRUE, SPItem::RENDERING_BBOX); + Geom::OptRect bbox = base->desktopVisualBounds(); + if (!bbox) { + g_message("CairoRenderer: empty bounding box."); + return false; + } + d = *bbox; } if (ctx->_vector_based_target) { // convert from px to pt - d.x0 *= PT_PER_PX; - d.x1 *= PT_PER_PX; - d.y0 *= PT_PER_PX; - d.y1 *= PT_PER_PX; + d *= Geom::Scale(PT_PER_PX); } - ctx->_width = d.x1-d.x0; - ctx->_height = d.y1-d.y0; + ctx->_width = d.width(); + ctx->_height = d.height(); TRACE(("setupDocument: %f x %f\n", ctx->_width, ctx->_height)); @@ -655,11 +644,12 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page if (ctx->_vector_based_target) high *= PT_PER_PX; - Geom::Affine tp(Geom::Translate(-d.x0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0), - (d.y1 - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); - ctx->transform(&tp); + /// @fixme hardcoded dt2doc transform? + Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0), + (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); + ctx->transform(tp); } - + return ret; } @@ -677,16 +667,17 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) CairoRenderContext::CairoRenderMode saved_mode = ctx->getRenderMode(); ctx->setRenderMode(CairoRenderContext::RENDER_MODE_CLIP); + // FIXME: the access to the first clippath view to obtain the bbox is completely bogus Geom::Affine saved_ctm; - if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { + if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && cp->display->bbox) { //SP_PRINT_DRECT("clipd", cp->display->bbox); - NRRect clip_bbox(cp->display->bbox); - Geom::Affine t(Geom::Scale(clip_bbox.x1 - clip_bbox.x0, clip_bbox.y1 - clip_bbox.y0)); - t[4] = clip_bbox.x0; - t[5] = clip_bbox.y0; + Geom::Rect clip_bbox = *cp->display->bbox; + Geom::Affine t(Geom::Scale(clip_bbox.dimensions())); + t[4] = clip_bbox.left(); + t[5] = clip_bbox.top(); t *= ctx->getCurrentState()->transform; - ctx->getTransform(&saved_ctm); - ctx->setTransform(&t); + saved_ctm = ctx->getTransform(); + ctx->setTransform(t); } TRACE(("BEGIN clip\n")); @@ -696,12 +687,11 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) SPItem const *item = SP_ITEM(child); // combine transform of the item in clippath and the item using clippath: - Geom::Affine tempmat (item->transform); - tempmat = tempmat * (ctx->getCurrentState()->item_transform); + Geom::Affine tempmat = item->transform * ctx->getCurrentState()->item_transform; // render this item in clippath ctx->pushState(); - ctx->transform(&tempmat); + ctx->transform(tempmat); setStateForItem(ctx, item); // TODO fix this call to accept const items sp_item_invoke_render(const_cast<SPItem *>(item), ctx); @@ -716,7 +706,7 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) cairo_clip(ctx->_cr); if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) - ctx->setTransform(&saved_ctm); + ctx->setTransform(saved_ctm); ctx->setRenderMode(saved_mode); } @@ -730,15 +720,16 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) if (mask == NULL) return; - //SP_PRINT_DRECT("maskd", &mask->display->bbox); - NRRect mask_bbox(mask->display->bbox); + // FIXME: the access to the first mask view to obtain the bbox is completely bogus // TODO: should the bbox be transformed if maskUnits != userSpaceOnUse ? - if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Affine t(Geom::Scale(mask_bbox.x1 - mask_bbox.x0, mask_bbox.y1 - mask_bbox.y0)); - t[4] = mask_bbox.x0; - t[5] = mask_bbox.y0; + if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && mask->display->bbox) { + //SP_PRINT_DRECT("maskd", &mask->display->bbox); + Geom::Rect mask_bbox = *mask->display->bbox; + Geom::Affine t(Geom::Scale(mask_bbox.dimensions())); + t[4] = mask_bbox.left(); + t[5] = mask_bbox.top(); t *= ctx->getCurrentState()->transform; - ctx->setTransform(&t); + ctx->setTransform(t); } // Clip mask contents... but... diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 7ed0f6fcf..d08304a00 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -135,25 +135,22 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) _width = doc->getWidth(); _height = doc->getHeight(); - NRRect d; bool pageBoundingBox; pageBoundingBox = mod->get_param_bool("pageBoundingBox"); + + Geom::Rect d; if (pageBoundingBox) { - d.x0 = d.y0 = 0; - d.x1 = _width; - d.y1 = _height; + d = Geom::Rect::from_xywh(0, 0, _width, _height); } else { SPItem* doc_item = doc->getRoot(); - doc_item->invoke_bbox(&d, doc_item->i2dt_affine(), TRUE); + Geom::OptRect bbox = doc_item->desktopVisualBounds(); + if (bbox) d = *bbox; } - d.x0 *= IN_PER_PX; - d.y0 *= IN_PER_PX; - d.x1 *= IN_PER_PX; - d.y1 *= IN_PER_PX; + d *= IN_PER_PX; - float dwInchesX = (d.x1 - d.x0); - float dwInchesY = (d.y1 - d.y0); + float dwInchesX = d.width(); + float dwInchesY = d.height(); // dwInchesX x dwInchesY in .01mm units SetRect( &rc, 0, 0, (int) ceil(dwInchesX*2540), (int) ceil(dwInchesY*2540) ); @@ -451,15 +448,13 @@ PrintEmfWin32::flush_fill() } unsigned int -PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const *transform, float /*opacity*/) -{ - Geom::Affine tr = *transform; - +PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &transform, float /*opacity*/) +{ if (m_tr_stack.size()) { Geom::Affine tr_top = m_tr_stack.top(); - m_tr_stack.push(tr * tr_top); + m_tr_stack.push(transform * tr_top); } else { - m_tr_stack.push(tr); + m_tr_stack.push(transform); } return 1; @@ -474,8 +469,8 @@ PrintEmfWin32::release(Inkscape::Extension::Print * /*mod*/) unsigned int PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/, - Geom::PathVector const &pathv, Geom::Affine const * /*transform*/, SPStyle const *style, - NRRect const * /*pbox*/, NRRect const * /*dbox*/, NRRect const * /*bbox*/) + Geom::PathVector const &pathv, Geom::Affine const & /*transform*/, SPStyle const *style, + Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/) { if (!hdc) return 0; @@ -503,8 +498,8 @@ PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/, unsigned int PrintEmfWin32::stroke (Inkscape::Extension::Print * /*mod*/, - Geom::PathVector const &pathv, const Geom::Affine * /*transform*/, const SPStyle *style, - const NRRect * /*pbox*/, const NRRect * /*dbox*/, const NRRect * /*bbox*/) + Geom::PathVector const &pathv, const Geom::Affine &/*transform*/, const SPStyle *style, + Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/) { if (!hdc) return 0; @@ -849,7 +844,7 @@ PrintEmfWin32::textToPath(Inkscape::Extension::Print * ext) } unsigned int -PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point p, +PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point const &p, SPStyle const *const style) { if (!hdc) return 0; diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h index 44327d35e..71ce5d6d0 100644 --- a/src/extension/internal/emf-win32-print.h +++ b/src/extension/internal/emf-win32-print.h @@ -62,17 +62,21 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const &transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); - virtual unsigned int fill (Inkscape::Extension::Print * module, - Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); + virtual unsigned int fill (Inkscape::Extension::Print *module, + Geom::PathVector const &pathv, + Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, + Geom::OptRect const &bbox); virtual unsigned int stroke (Inkscape::Extension::Print * module, - Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); + Geom::PathVector const &pathv, + Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, + Geom::OptRect const &bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); virtual unsigned int text(Inkscape::Extension::Print *module, char const *text, - Geom::Point p, SPStyle const *style); + Geom::Point const &p, SPStyle const *style); bool textToPath (Inkscape::Extension::Print * ext); static void init (void); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 6436624fd..da5ea6d9e 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -90,7 +90,7 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc bounding_area = Geom::Rect( Geom::Point(0,0), Geom::Point(doc->getWidth(), doc->getHeight()) ); } else { - Geom::OptRect bounds = selection->bounds(); + Geom::OptRect bounds = selection->visualBounds(); if (bounds) { bounding_area = *bounds; } diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 18950295c..49304de96 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -164,15 +164,14 @@ PrintLatex::finish (Inkscape::Extension::Print *mod) } unsigned int -PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const *transform, float opacity) +PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const &transform, float opacity) { - Geom::Affine tr = *transform; - - if(m_tr_stack.size()){ + if (m_tr_stack.size()) { Geom::Affine tr_top = m_tr_stack.top(); - m_tr_stack.push(tr * tr_top); - }else - m_tr_stack.push(tr); + m_tr_stack.push(transform * tr_top); + } else { + m_tr_stack.push(transform); + } return 1; } @@ -194,8 +193,8 @@ unsigned int PrintLatex::comment (Inkscape::Extension::Print * module, unsigned int PrintLatex::fill(Inkscape::Extension::Print *mod, - Geom::PathVector const &pathv, Geom::Affine const *transform, SPStyle const *style, - NRRect const *pbox, NRRect const *dbox, NRRect const *bbox) + Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -227,8 +226,9 @@ PrintLatex::fill(Inkscape::Extension::Print *mod, } unsigned int -PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox) +PrintLatex::stroke (Inkscape::Extension::Print *mod, + Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned. @@ -277,12 +277,12 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pat // FIXME: why is 'transform' argument not used? void -PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine * /*transform*/) +PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine & /*transform*/) { if (pathv_in.empty()) return; -// Geom::Affine tf=*transform; // why was this here? +// Geom::Affine tf=transform; // why was this here? Geom::Affine tf_stack=m_tr_stack.top(); // and why is transform argument not used? Geom::PathVector pathv = pathv_in * tf_stack; // generates new path, which is a bit slow, but this doesn't have to be performance optimized @@ -304,7 +304,7 @@ PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv } void -PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c ) +PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const &c) { using Geom::X; using Geom::Y; diff --git a/src/extension/internal/latex-pstricks.h b/src/extension/internal/latex-pstricks.h index 64b0de474..5bc6eeb22 100644 --- a/src/extension/internal/latex-pstricks.h +++ b/src/extension/internal/latex-pstricks.h @@ -33,7 +33,7 @@ class PrintLatex : public Inkscape::Extension::Implementation::Implementation { std::stack<Geom::Affine> m_tr_stack; - void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine * /*transform*/); + void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine & /*transform*/); void print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c ); public: @@ -47,13 +47,17 @@ public: virtual unsigned int finish (Inkscape::Extension::Print * module); /* Rendering methods */ - virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const *transform, float opacity); + virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const &transform, float opacity); virtual unsigned int release(Inkscape::Extension::Print *module); - virtual unsigned int fill (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); - virtual unsigned int stroke (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style, - const NRRect *pbox, const NRRect *dbox, const NRRect *bbox); + virtual unsigned int fill (Inkscape::Extension::Print *module, Geom::PathVector const &pathv, + Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, + Geom::OptRect const &bbox); + virtual unsigned int stroke (Inkscape::Extension::Print *module, Geom::PathVector const &pathv, + Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, + Geom::OptRect const &bbox); virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment); bool textToPath (Inkscape::Extension::Print * ext); diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 02f0823d9..0da048a17 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -588,27 +588,27 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * base = doc->getRoot(); } - Geom::OptRect d; + Geom::Rect d; if (pageBoundingBox) { - d = Geom::Rect( Geom::Point(0,0), - Geom::Point(doc->getWidth(), doc->getHeight()) ); + d = Geom::Rect::from_xywh(Geom::Point(0,0), doc->getDimensions()); } else { - base->invoke_bbox( d, base->i2dt_affine(), TRUE, SPItem::RENDERING_BBOX); - } - if (!d) { - g_message("LaTeXTextRenderer: could not retrieve boundingbox."); - return false; + Geom::OptRect bbox = base->desktopVisualBounds(); + if (!bbox) { + g_message("CairoRenderer: empty bounding box."); + return false; + } + d = *bbox; } // scale all coordinates, such that the width of the image is 1, this is convenient for scaling the image in LaTeX - double scale = 1/(d->width()); - double _width = d->width() * scale; - double _height = d->height() * scale; + double scale = 1/(d.width()); + double _width = d.width() * scale; + double _height = d.height() * scale; push_transform( Geom::Scale(scale, scale) ); if (!pageBoundingBox) { - push_transform( Geom::Translate( - d->min() ) ); + push_transform( Geom::Translate( -d.min() ) ); } // flip y-axis @@ -621,7 +621,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * // scaling of the image when including it in LaTeX os << " \\ifx\\svgwidth\\undefined%\n"; - os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384 + os << " \\setlength{\\unitlength}{" << d.width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384 os << " \\ifx\\svgscale\\undefined%\n"; os << " \\relax%\n"; os << " \\else%\n"; diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 568c804a0..735c57798 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -573,7 +573,7 @@ void SingularValueDecomposition::calculate() //double eps = pow(2.0,-52.0); //double tiny = pow(2.0,-966.0); //let's just calculate these now - //a double can be e ± 308.25, so this is safe + //a double can be e ± 308.25, so this is safe double eps = 2.22e-16; double tiny = 1.6e-291; while (p > 0) { @@ -965,15 +965,10 @@ static Geom::Affine getODFTransform(const SPItem *item) */ static Geom::OptRect getODFBoundingBox(const SPItem *item) { - Geom::OptRect bbox_temp = ((SPItem *)item)->getBboxDesktop(); - Geom::OptRect bbox; - if (bbox_temp) { - bbox = *bbox_temp; - double doc_height = SP_ACTIVE_DOCUMENT->getHeight(); - Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0)); - doc2dt_tf = doc2dt_tf * Geom::Affine(Geom::Translate(0, doc_height)); - bbox = *bbox * doc2dt_tf; - bbox = *bbox * Geom::Affine(Geom::Scale(pxToCm)); + // TODO: geometric or visual? + Geom::OptRect bbox = ((SPItem *)item)->documentVisualBounds(); + if (bbox) { + *bbox *= Geom::Affine(Geom::Scale(pxToCm)); } return bbox; } diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index dc995b7aa..fe383b920 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -37,7 +37,6 @@ #include "io/stringstream.h" #include "io/base64stream.h" #include "display/nr-filter-utils.h" -#include "libnr/nr-macros.h" #include "libnrtype/font-instance.h" #include "Function.h" |
