From f51227a487f3d80e096c04470a969f5efa911a98 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 21:49:36 +0100 Subject: Turned all functions concerning SPRect into member functions. (bzr r11608.1.60) --- src/extension/internal/latex-text-renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/extension') diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index ecc201733..9b707d355 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -405,7 +405,7 @@ Flowing in rectangle is possible, not in arb shape. } SPRect *frame = SP_RECT(frame_item); - Geom::Rect framebox = sp_rect_get_rect(frame) * transform(); + Geom::Rect framebox = frame->getRect() * transform(); // get position and alignment // Align on topleft corner. -- cgit v1.2.3 From db53a4b489fbcf45eee9f54a0b1231e6092374dc Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 1 Aug 2013 14:35:39 +0200 Subject: Fixed more mismatched-tags; replaced GObject-properties in SPGuide (bzr r11608.1.115) --- src/extension/internal/latex-text-renderer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/extension') diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h index 0fa94c9e6..e51c2d245 100644 --- a/src/extension/internal/latex-text-renderer.h +++ b/src/extension/internal/latex-text-renderer.h @@ -22,7 +22,7 @@ #include class SPItem; -struct SPRoot; +class SPRoot; namespace Inkscape { namespace Extension { -- cgit v1.2.3 From 5488905e7f4659c0fed7c1841b768cbaf26e3cb1 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 2 Aug 2013 22:25:14 +0200 Subject: reordered SPDesktop::set_event_context2; fixed last mismatched-tags (bzr r11608.1.116) --- src/extension/internal/cairo-render-context.h | 2 +- src/extension/internal/cairo-renderer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index 8829940c6..9ea4559a0 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -29,7 +29,7 @@ #include class SPClipPath; -struct SPMask; +class SPMask; namespace Inkscape { namespace Extension { diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h index c1482d82e..db3068fed 100644 --- a/src/extension/internal/cairo-renderer.h +++ b/src/extension/internal/cairo-renderer.h @@ -28,7 +28,7 @@ #include class SPClipPath; -struct SPMask; +class SPMask; namespace Inkscape { namespace Extension { -- cgit v1.2.3 From bf4a1d2d49850170b936c30cfe2b30e798716406 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 3 Aug 2013 03:03:43 +0200 Subject: Cleaned up. (bzr r11608.1.117) --- src/extension/internal/odf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/extension') diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 9f745cdea..a7c14387f 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -1484,7 +1484,7 @@ bool OdfOutput::processGradient(SPItem *item, for (SPStop *stop = grvec->getFirstStop(); stop ; stop = stop->getNextStop()) { - unsigned long rgba = sp_stop_get_rgba32(stop); + unsigned long rgba = stop->get_rgba32(); unsigned long rgb = (rgba >> 8) & 0xffffff; double opacity = (static_cast(rgba & 0xff)) / 256.0; GradientStop gs(rgb, opacity); -- cgit v1.2.3 From 083367b313247a4cf0c082fff25e993892dc38d1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 19 Sep 2013 02:57:10 +0200 Subject: Encapsulate the shared memory hack for Cairo and GdkPixbuf in a class called Inkscape::Pixbuf. Replace usage in the code as appropriate. (bzr r12531) --- src/extension/internal/cairo-render-context.cpp | 8 ++++---- src/extension/internal/cairo-render-context.h | 6 ++++-- src/extension/internal/cairo-renderer.cpp | 26 ++++++++++--------------- src/extension/internal/emf-print.cpp | 9 +++++---- src/extension/internal/gdkpixbuf-input.cpp | 20 ++++++------------- src/extension/internal/metafile-print.cpp | 2 +- src/extension/internal/metafile-print.h | 4 +++- src/extension/internal/wmf-print.cpp | 13 +++++++------ 8 files changed, 40 insertions(+), 48 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index a950fa177..4f9273cbb 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1436,7 +1436,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con return true; } -bool CairoRenderContext::renderImage(GdkPixbuf *pb, +bool CairoRenderContext::renderImage(Inkscape::Pixbuf *pb, Geom::Affine const &image_transform, SPStyle const * /*style*/) { g_assert( _is_valid ); @@ -1447,13 +1447,13 @@ bool CairoRenderContext::renderImage(GdkPixbuf *pb, _prepareRenderGraphic(); - int w = gdk_pixbuf_get_width (pb); - int h = gdk_pixbuf_get_height (pb); + int w = pb->width(); + int h = pb->height(); // TODO: reenable merge_opacity if useful float opacity = _state->opacity; - cairo_surface_t *image_surface = ink_cairo_surface_get_for_pixbuf(pb); + cairo_surface_t *image_surface = pb->getSurfaceRaw(); if (cairo_surface_status(image_surface)) { TRACE(("Image surface creation failed:\n%s\n", cairo_status_to_string(cairo_surface_status(image_surface)))); return false; diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index f8426aebe..6fccc71b7 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -6,7 +6,7 @@ */ /* * Authors: - * Miklos Erdelyi + * Miklos Erdelyi * * Copyright (C) 2006 Miklos Erdelyi * @@ -32,6 +32,8 @@ class SPClipPath; struct SPMask; namespace Inkscape { +class Pixbuf; + namespace Extension { namespace Internal { @@ -144,7 +146,7 @@ public: /* Rendering methods */ bool renderPathVector(Geom::PathVector const &pathv, SPStyle const *style, Geom::OptRect const &pbox); - bool renderImage(GdkPixbuf *pb, + bool renderImage(Inkscape::Pixbuf *pb, Geom::Affine const &image_transform, SPStyle const *style); bool renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix, std::vector const &glyphtext, SPStyle const *style); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 3463925b6..eb16a38e1 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -27,6 +27,7 @@ #include #include +#include #include "libnrtype/Layout-TNG.h" #include <2geom/transforms.h> @@ -347,8 +348,8 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx) if (!image->pixbuf) return; if ((image->width.computed <= 0.0) || (image->height.computed <= 0.0)) return; - w = gdk_pixbuf_get_width (image->pixbuf); - h = gdk_pixbuf_get_height (image->pixbuf); + w = image->pixbuf->width(); + h = image->pixbuf->height(); double x = image->x.computed; double y = image->y.computed; @@ -497,22 +498,15 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) GSList *items = NULL; items = g_slist_append(items, item); - GdkPixbuf *pb = sp_generate_internal_bitmap(document, NULL, - bbox->min()[Geom::X], bbox->min()[Geom::Y], bbox->max()[Geom::X], bbox->max()[Geom::Y], - width, height, res, res, (guint32) 0xffffff00, items ); + boost::scoped_ptr pb( + sp_generate_internal_bitmap(document, NULL, + bbox->min()[Geom::X], bbox->min()[Geom::Y], bbox->max()[Geom::X], bbox->max()[Geom::Y], + width, height, res, res, (guint32) 0xffffff00, items )); if (pb) { - TEST(gdk_pixbuf_save( pb, "bitmap.png", "png", NULL, NULL )); - - /* TODO: find a way to avoid a duplicate conversion between - * Cairo and GdkPixbuf pixel formats here. - * Internally, generate_internal_bitmap creates a Cairo surface, - * but then converts it to pixbuf format. In turn, renderImage() - * below converts back to Cairo format. - */ - ctx->renderImage(pb, t, item->style); - g_object_unref(pb); - pb = 0; + //TEST(gdk_pixbuf_save( pb, "bitmap.png", "png", NULL, NULL )); + + ctx->renderImage(pb.get(), t, item->style); } g_slist_free (items); } diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 826a52ade..770257978 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -53,6 +53,7 @@ #include "sp-gradient.h" #include "sp-radial-gradient.h" #include "sp-linear-gradient.h" +#include "display/cairo-utils.h" #include "splivarot.h" // pieces for union on shapes #include "2geom/svg-path-parser.h" // to get from SVG text to Geom::Path @@ -333,7 +334,7 @@ int PrintEmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) U_LOGBRUSH lb; uint32_t brush, fmode; MFDrawMode fill_mode; - GdkPixbuf *pixbuf; + Inkscape::Pixbuf *pixbuf; uint32_t brushStyle; int hatchType; U_COLORREF hatchColor; @@ -462,7 +463,7 @@ int PrintEmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) int numCt; U_BITMAPINFOHEADER Bmih; PU_BITMAPINFO Bmi; - rgba_px = (char *) gdk_pixbuf_get_pixels(pixbuf); // Do NOT free this!!! + rgba_px = (char *) pixbuf->pixels(); // Do NOT free this!!! colortype = U_BCBM_COLOR32; (void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, rgba_px, width, height, width * 4, colortype, 0, 1); // Not sure why the next swap is needed because the preceding does it, and the code is identical @@ -528,7 +529,7 @@ int PrintEmf::create_pen(SPStyle const *style, const Geom::Affine &transform) int linejoin = 0; uint32_t pen; uint32_t brushStyle; - GdkPixbuf *pixbuf; + Inkscape::Pixbuf *pixbuf; int hatchType; U_COLORREF hatchColor; U_COLORREF bkColor; @@ -565,7 +566,7 @@ int PrintEmf::create_pen(SPStyle const *style, const Geom::Affine &transform) brush_classify(pat, 0, &pixbuf, &hatchType, &hatchColor, &bkColor); if (pixbuf) { brushStyle = U_BS_DIBPATTERN; - rgba_px = (char *) gdk_pixbuf_get_pixels(pixbuf); // Do NOT free this!!! + rgba_px = (char *) pixbuf->pixels(); // Do NOT free this!!! colortype = U_BCBM_COLOR32; (void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, rgba_px, width, height, width * 4, colortype, 0, 1); // Not sure why the next swap is needed because the preceding does it, and the code is identical diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index 117c2fe39..87cf8a9cc 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -1,6 +1,7 @@ #ifdef HAVE_CONFIG_H # include #endif +#include #include #include #include "document-private.h" @@ -14,15 +15,11 @@ #include "document-undo.h" #include "util/units.h" #include "image-resolution.h" +#include "display/cairo-utils.h" #include namespace Inkscape { -namespace IO { -// this is defined in sp-image.cpp -GdkPixbuf* pixbuf_new_from_file(char const *filename, time_t &modTime, gchar*& pixPath); -} - namespace Extension { namespace Internal { @@ -47,9 +44,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) } SPDocument *doc = NULL; - gchar *pixpath = NULL; - time_t dummy; - GdkPixbuf *pb = Inkscape::IO::pixbuf_new_from_file(uri, dummy, pixpath); + boost::scoped_ptr pb(Inkscape::Pixbuf::create_from_file(uri)); // TODO: the pixbuf is created again from the base64-encoded attribute in SPImage. // Find a way to create the pixbuf only once. @@ -59,8 +54,8 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) bool saved = DocumentUndo::getUndoSensitive(doc); DocumentUndo::setUndoSensitive(doc, false); // no need to undo in this temporary document - double width = gdk_pixbuf_get_width(pb); - double height = gdk_pixbuf_get_height(pb); + double width = pb->width(); + double height = pb->height(); double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", Inkscape::Util::Quantity::convert(1, "in", "px")); bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi"); ImageResolution *ir = 0; @@ -91,7 +86,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) sp_repr_set_svg_double(image_node, "height", height); if (embed) { - sp_embed_image(image_node, pb); + sp_embed_image(image_node, pb.get()); } else { // convert filename to uri gchar* _uri = g_filename_to_uri(uri, NULL, NULL); @@ -103,9 +98,6 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) } } - g_object_set_data(G_OBJECT(pb), "cairo_surface", NULL); - g_object_unref(pb); - // Add it to the current layer doc->getRoot()->appendChildRepr(image_node); Inkscape::GC::release(image_node); diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp index 9d080bd96..1e7735410 100644 --- a/src/extension/internal/metafile-print.cpp +++ b/src/extension/internal/metafile-print.cpp @@ -266,7 +266,7 @@ void PrintMetafile::hatch_classify(char *name, int *hatchType, U_COLORREF *hatch // otherwise hatchType is set to -1 and hatchColor is not defined. // -void PrintMetafile::brush_classify(SPObject *parent, int depth, GdkPixbuf **epixbuf, int *hatchType, U_COLORREF *hatchColor, U_COLORREF *bkColor) +void PrintMetafile::brush_classify(SPObject *parent, int depth, Inkscape::Pixbuf **epixbuf, int *hatchType, U_COLORREF *hatchColor, U_COLORREF *bkColor) { if (depth == 0) { *epixbuf = NULL; diff --git a/src/extension/internal/metafile-print.h b/src/extension/internal/metafile-print.h index e64ba92f3..cba4d564d 100644 --- a/src/extension/internal/metafile-print.h +++ b/src/extension/internal/metafile-print.h @@ -30,6 +30,8 @@ struct SPGradient; struct SPObject; namespace Inkscape { +class Pixbuf; + namespace Extension { namespace Internal { @@ -93,7 +95,7 @@ protected: U_COLORREF weight_colors(U_COLORREF c1, U_COLORREF c2, double t); void hatch_classify(char *name, int *hatchType, U_COLORREF *hatchColor, U_COLORREF *bkColor); - void brush_classify(SPObject *parent, int depth, GdkPixbuf **epixbuf, int *hatchType, U_COLORREF *hatchColor, U_COLORREF *bkColor); + void brush_classify(SPObject *parent, int depth, Inkscape::Pixbuf **epixbuf, int *hatchType, U_COLORREF *hatchColor, U_COLORREF *bkColor); static void swapRBinRGBA(char *px, int pixels); int hold_gradient(void *gr, int mode); diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index e5816073e..99262b109 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -56,6 +56,7 @@ #include "sp-gradient.h" #include "sp-radial-gradient.h" #include "sp-linear-gradient.h" +#include "display/cairo-utils.h" #include "splivarot.h" // pieces for union on shapes #include "2geom/svg-path-parser.h" // to get from SVG text to Geom::Path @@ -336,7 +337,7 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) U_WLOGBRUSH lb; uint32_t brush, fmode; MFDrawMode fill_mode; - GdkPixbuf *pixbuf; + Inkscape::Pixbuf *pixbuf; uint32_t brushStyle; int hatchType; U_COLORREF hatchColor; @@ -464,7 +465,7 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) int numCt; U_BITMAPINFOHEADER Bmih; PU_BITMAPINFO Bmi; - rgba_px = (char *) gdk_pixbuf_get_pixels(pixbuf); // Do NOT free this!!! + rgba_px = (char *) pixbuf->pixels(); // Do NOT free this!!! colortype = U_BCBM_COLOR32; (void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, rgba_px, width, height, width * 4, colortype, 0, 1); // Not sure why the next swap is needed because the preceding does it, and the code is identical @@ -1112,10 +1113,10 @@ unsigned int PrintWmf::image( g_error("Fatal programming error in PrintWmf::image at EMRHEADER"); } - x1 = atof(style->object->getAttribute("x")); - y1 = atof(style->object->getAttribute("y")); - dw = atof(style->object->getAttribute("width")); - dh = atof(style->object->getAttribute("height")); + x1 = g_ascii_strtod(style->object->getAttribute("x"), NULL); + y1 = g_ascii_strtod(style->object->getAttribute("y"), NULL); + dw = g_ascii_strtod(style->object->getAttribute("width"), NULL); + dh = g_ascii_strtod(style->object->getAttribute("height"), NULL); Geom::Point pLL(x1, y1); Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates -- cgit v1.2.3 From f74229c8bc1a97f5f30ea658c178fde50834eb73 Mon Sep 17 00:00:00 2001 From: Adrian Johnson <> Date: Thu, 19 Sep 2013 19:03:35 +0200 Subject: Do not require a new layer for clipping paths in the Cairo renderer. Fixes LP #523285. Fixed bugs: - https://launchpad.net/bugs/523285 (bzr r12544) --- src/extension/internal/cairo-renderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index eb16a38e1..cace251cf 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -580,9 +580,9 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) setStateForItem(ctx, item); CairoRenderState *state = ctx->getCurrentState(); - state->need_layer = ( state->mask || state->clip_path || state->opacity != 1.0 ); + state->need_layer = ( state->mask || state->opacity != 1.0 ); - // Draw item on a temporary surface so a mask, clip path, or opacity can be applied to it. + // Draw item on a temporary surface so a mask or opacity can be applied to it. if (state->need_layer) { state->merge_opacity = FALSE; ctx->pushLayer(); -- cgit v1.2.3