summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-09-19 17:32:15 +0000
committerMarkus Engel <markus.engel@tum.de>2013-09-19 17:32:15 +0000
commit658a60b2ffdb7ed361b3c3b57d62efd419f7ba47 (patch)
tree7f0f76347c27e59a784b4a3af990af7b247c5b41 /src/extension
parentAdded gpl notice (diff)
parentDo not require a new layer for clipping paths in the Cairo renderer. (diff)
downloadinkscape-658a60b2ffdb7ed361b3c3b57d62efd419f7ba47.tar.gz
inkscape-658a60b2ffdb7ed361b3c3b57d62efd419f7ba47.zip
Merged from trunk (r12544).
(bzr r11608.1.126)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/internal/cairo-ps-out.cpp2
-rw-r--r--src/extension/internal/cairo-render-context.cpp8
-rw-r--r--src/extension/internal/cairo-render-context.h6
-rw-r--r--src/extension/internal/cairo-renderer.cpp30
-rw-r--r--src/extension/internal/emf-print.cpp9
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp20
-rw-r--r--src/extension/internal/metafile-print.cpp2
-rw-r--r--src/extension/internal/metafile-print.h4
-rw-r--r--src/extension/internal/wmf-print.cpp13
9 files changed, 43 insertions, 51 deletions
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index e06c9f30d..5f535dc64 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -340,7 +340,7 @@ CairoPsOutput::init (void)
"<_option value=\"page\">" N_("Use document's page size") "</_option>"
"<_option value=\"drawing\">" N_("Use exported object's size") "</_option>"
"</param>"
- "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm)") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n"
+ "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm):") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n"
"<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
"<output>\n"
"<extension>.ps</extension>\n"
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 91e1cdf7d..8d3e63775 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -6,7 +6,7 @@
*/
/*
* Authors:
- * Miklos Erdelyi <erdelyim@gmail.com>
+ * Miklos Erdelyi <erdelyim@gmail.com>
*
* Copyright (C) 2006 Miklos Erdelyi
*
@@ -32,6 +32,8 @@ class SPClipPath;
class 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<CairoGlyphInfo> const &glyphtext, SPStyle const *style);
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 3463925b6..cace251cf 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -27,6 +27,7 @@
#include <signal.h>
#include <errno.h>
+#include <boost/scoped_ptr.hpp>
#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<Inkscape::Pixbuf> 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);
}
@@ -586,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();
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 <config.h>
#endif
+#include <boost/scoped_ptr.hpp>
#include <glib/gprintf.h>
#include <glibmm/i18n.h>
#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 <set>
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<Inkscape::Pixbuf> 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